异常封装之序列号信息后台修改
This commit is contained in:
@@ -26,16 +26,16 @@ public class SerialNumberComponent implements ICommonQuery {
|
|||||||
private SerialNumberService serialNumberService;
|
private SerialNumberService serialNumberService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object selectOne(String condition) {
|
public Object selectOne(String condition)throws Exception {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<?> select(Map<String, String> map) {
|
public List<?> select(Map<String, String> map)throws Exception {
|
||||||
return getSerialNumberList(map);
|
return getSerialNumberList(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<?> getSerialNumberList(Map<String, String> map) {
|
private List<?> getSerialNumberList(Map<String, String> map) throws Exception{
|
||||||
String search = map.get(Constants.SEARCH);
|
String search = map.get(Constants.SEARCH);
|
||||||
String serialNumber = StringUtil.getInfo(search, "serialNumber");
|
String serialNumber = StringUtil.getInfo(search, "serialNumber");
|
||||||
String materialName = StringUtil.getInfo(search, "materialName");
|
String materialName = StringUtil.getInfo(search, "materialName");
|
||||||
@@ -43,7 +43,7 @@ public class SerialNumberComponent implements ICommonQuery {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long counts(Map<String, String> map) {
|
public Long counts(Map<String, String> map)throws Exception {
|
||||||
String search = map.get(Constants.SEARCH);
|
String search = map.get(Constants.SEARCH);
|
||||||
String serialNumber = StringUtil.getInfo(search, "serialNumber");
|
String serialNumber = StringUtil.getInfo(search, "serialNumber");
|
||||||
String materialName = StringUtil.getInfo(search, "materialName");
|
String materialName = StringUtil.getInfo(search, "materialName");
|
||||||
@@ -56,22 +56,22 @@ public class SerialNumberComponent implements ICommonQuery {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int update(String beanJson, Long id) {
|
public int update(String beanJson, Long id)throws Exception {
|
||||||
return serialNumberService.updateSerialNumber(beanJson, id);
|
return serialNumberService.updateSerialNumber(beanJson, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int delete(Long id) {
|
public int delete(Long id)throws Exception {
|
||||||
return serialNumberService.deleteSerialNumber(id);
|
return serialNumberService.deleteSerialNumber(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int batchDelete(String ids) {
|
public int batchDelete(String ids)throws Exception {
|
||||||
return serialNumberService.batchDeleteSerialNumber(ids);
|
return serialNumberService.batchDeleteSerialNumber(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int checkIsNameExist(Long id, String serialNumber) {
|
public int checkIsNameExist(Long id, String serialNumber) throws Exception{
|
||||||
return serialNumberService.checkIsNameExist(id, serialNumber);
|
return serialNumberService.checkIsNameExist(id, serialNumber);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class SerialNumberService {
|
public class SerialNumberService {
|
||||||
private Logger logger = LoggerFactory.getLogger(MaterialService.class);
|
private Logger logger = LoggerFactory.getLogger(SerialNumberService.class);
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private SerialNumberMapper serialNumberMapper;
|
private SerialNumberMapper serialNumberMapper;
|
||||||
@@ -48,84 +48,190 @@ public class SerialNumberService {
|
|||||||
private LogService logService;
|
private LogService logService;
|
||||||
|
|
||||||
|
|
||||||
public SerialNumber getSerialNumber(long id) {
|
public SerialNumber getSerialNumber(long id)throws Exception {
|
||||||
return serialNumberMapper.selectByPrimaryKey(id);
|
SerialNumber result=null;
|
||||||
|
try{
|
||||||
|
result=serialNumberMapper.selectByPrimaryKey(id);
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("异常码[{}],异常提示[{}],异常[{}]",
|
||||||
|
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
|
||||||
|
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
|
||||||
|
ExceptionConstants.DATA_READ_FAIL_MSG);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<SerialNumber> getSerialNumber() {
|
public List<SerialNumber> getSerialNumber()throws Exception {
|
||||||
SerialNumberExample example = new SerialNumberExample();
|
SerialNumberExample example = new SerialNumberExample();
|
||||||
return serialNumberMapper.selectByExample(example);
|
List<SerialNumber> list=null;
|
||||||
|
try{
|
||||||
|
list=serialNumberMapper.selectByExample(example);
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("异常码[{}],异常提示[{}],异常[{}]",
|
||||||
|
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
|
||||||
|
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
|
||||||
|
ExceptionConstants.DATA_READ_FAIL_MSG);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<SerialNumberEx> select(String serialNumber, String materialName, Integer offset, Integer rows) {
|
public List<SerialNumberEx> select(String serialNumber, String materialName, Integer offset, Integer rows)throws Exception {
|
||||||
return serialNumberMapperEx.selectByConditionSerialNumber(serialNumber, materialName,offset, rows);
|
List<SerialNumberEx> list=null;
|
||||||
|
try{
|
||||||
|
list=serialNumberMapperEx.selectByConditionSerialNumber(serialNumber, materialName,offset, rows);
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("异常码[{}],异常提示[{}],异常[{}]",
|
||||||
|
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
|
||||||
|
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
|
||||||
|
ExceptionConstants.DATA_READ_FAIL_MSG);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long countSerialNumber(String serialNumber,String materialName) {
|
public Long countSerialNumber(String serialNumber,String materialName)throws Exception {
|
||||||
return serialNumberMapperEx.countSerialNumber(serialNumber, materialName);
|
Long result=null;
|
||||||
|
try{
|
||||||
|
result=serialNumberMapperEx.countSerialNumber(serialNumber, materialName);
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("异常码[{}],异常提示[{}],异常[{}]",
|
||||||
|
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
|
||||||
|
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
|
||||||
|
ExceptionConstants.DATA_READ_FAIL_MSG);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||||
public int insertSerialNumber(String beanJson, HttpServletRequest request)throws Exception {
|
public int insertSerialNumber(String beanJson, HttpServletRequest request)throws Exception {
|
||||||
SerialNumber serialNumber = JSONObject.parseObject(beanJson, SerialNumber.class);
|
SerialNumber serialNumber = JSONObject.parseObject(beanJson, SerialNumber.class);
|
||||||
logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_SERIAL_NUMBER, BusinessConstants.LOG_OPERATION_TYPE_ADD, request);
|
logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_SERIAL_NUMBER, BusinessConstants.LOG_OPERATION_TYPE_ADD, request);
|
||||||
return serialNumberMapper.insertSelective(serialNumber);
|
int result=0;
|
||||||
|
try{
|
||||||
|
result=serialNumberMapper.insertSelective(serialNumber);
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("异常码[{}],异常提示[{}],异常[{}]",
|
||||||
|
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
|
||||||
|
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
|
||||||
|
ExceptionConstants.DATA_WRITE_FAIL_MSG);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||||
public int updateSerialNumber(String beanJson, Long id) {
|
public int updateSerialNumber(String beanJson, Long id) throws Exception{
|
||||||
SerialNumber serialNumber = JSONObject.parseObject(beanJson, SerialNumber.class);
|
SerialNumber serialNumber = JSONObject.parseObject(beanJson, SerialNumber.class);
|
||||||
serialNumber.setId(id);
|
serialNumber.setId(id);
|
||||||
int res = serialNumberMapper.updateByPrimaryKeySelective(serialNumber);
|
int result=0;
|
||||||
return res;
|
try{
|
||||||
|
result=serialNumberMapper.updateByPrimaryKeySelective(serialNumber);
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("异常码[{}],异常提示[{}],异常[{}]",
|
||||||
|
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
|
||||||
|
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
|
||||||
|
ExceptionConstants.DATA_WRITE_FAIL_MSG);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||||
public int deleteSerialNumber(Long id) {
|
public int deleteSerialNumber(Long id)throws Exception {
|
||||||
return serialNumberMapper.deleteByPrimaryKey(id);
|
int result=0;
|
||||||
|
try{
|
||||||
|
result=serialNumberMapper.deleteByPrimaryKey(id);
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("异常码[{}],异常提示[{}],异常[{}]",
|
||||||
|
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
|
||||||
|
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
|
||||||
|
ExceptionConstants.DATA_WRITE_FAIL_MSG);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||||
public int batchDeleteSerialNumber(String ids) {
|
public int batchDeleteSerialNumber(String ids)throws Exception {
|
||||||
List<Long> idList = StringUtil.strToLongList(ids);
|
List<Long> idList = StringUtil.strToLongList(ids);
|
||||||
SerialNumberExample example = new SerialNumberExample();
|
SerialNumberExample example = new SerialNumberExample();
|
||||||
example.createCriteria().andIdIn(idList);
|
example.createCriteria().andIdIn(idList);
|
||||||
return serialNumberMapper.deleteByExample(example);
|
int result=0;
|
||||||
|
try{
|
||||||
|
result=serialNumberMapper.deleteByExample(example);
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("异常码[{}],异常提示[{}],异常[{}]",
|
||||||
|
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
|
||||||
|
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
|
||||||
|
ExceptionConstants.DATA_WRITE_FAIL_MSG);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int checkIsNameExist(Long id, String serialNumber) {
|
public int checkIsNameExist(Long id, String serialNumber)throws Exception {
|
||||||
SerialNumberExample example = new SerialNumberExample();
|
SerialNumberExample example = new SerialNumberExample();
|
||||||
example.createCriteria().andIdNotEqualTo(id).andSerialNumberEqualTo(serialNumber).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
|
example.createCriteria().andIdNotEqualTo(id).andSerialNumberEqualTo(serialNumber).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
|
||||||
List<SerialNumber> list = serialNumberMapper.selectByExample(example);
|
List<SerialNumber> list=null;
|
||||||
return list.size();
|
try{
|
||||||
|
list=serialNumberMapper.selectByExample(example);
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("异常码[{}],异常提示[{}],异常[{}]",
|
||||||
|
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
|
||||||
|
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
|
||||||
|
ExceptionConstants.DATA_READ_FAIL_MSG);
|
||||||
|
}
|
||||||
|
return list==null?0:list.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||||
public int batchSetEnable(Boolean enabled, String materialIDs) {
|
public int batchSetEnable(Boolean enabled, String materialIDs)throws Exception{
|
||||||
List<Long> ids = StringUtil.strToLongList(materialIDs);
|
List<Long> ids = StringUtil.strToLongList(materialIDs);
|
||||||
SerialNumber serialNumber = new SerialNumber();
|
SerialNumber serialNumber = new SerialNumber();
|
||||||
SerialNumberExample example = new SerialNumberExample();
|
SerialNumberExample example = new SerialNumberExample();
|
||||||
example.createCriteria().andIdIn(ids);
|
example.createCriteria().andIdIn(ids);
|
||||||
return serialNumberMapper.updateByExampleSelective(serialNumber, example);
|
int result=0;
|
||||||
|
try{
|
||||||
|
result=serialNumberMapper.updateByExampleSelective(serialNumber, example);
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("异常码[{}],异常提示[{}],异常[{}]",
|
||||||
|
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
|
||||||
|
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
|
||||||
|
ExceptionConstants.DATA_WRITE_FAIL_MSG);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<SerialNumberEx> findById(Long id){
|
public List<SerialNumberEx> findById(Long id)throws Exception{
|
||||||
return serialNumberMapperEx.findById(id);
|
List<SerialNumberEx> list=null;
|
||||||
|
try{
|
||||||
|
list=serialNumberMapperEx.findById(id);
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("异常码[{}],异常提示[{}],异常[{}]",
|
||||||
|
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
|
||||||
|
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
|
||||||
|
ExceptionConstants.DATA_READ_FAIL_MSG);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void checkIsExist(Long id, String materialName, String serialNumber) {
|
public void checkIsExist(Long id, String materialName, String serialNumber) throws Exception{
|
||||||
/**
|
/**
|
||||||
* 商品名称不为空时,检查商品名称是否存在
|
* 商品名称不为空时,检查商品名称是否存在
|
||||||
* */
|
* */
|
||||||
if(StringUtil.isNotEmpty(materialName)){
|
if(StringUtil.isNotEmpty(materialName)){
|
||||||
List<Material> mlist = materialMapperEx.findByMaterialName(materialName);
|
List<Material> mlist=null;
|
||||||
|
try{
|
||||||
|
mlist = materialMapperEx.findByMaterialName(materialName);
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("异常码[{}],异常提示[{}],异常[{}]",
|
||||||
|
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
|
||||||
|
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
|
||||||
|
ExceptionConstants.DATA_READ_FAIL_MSG);
|
||||||
|
}
|
||||||
|
|
||||||
if(mlist==null||mlist.size()<1){
|
if(mlist==null||mlist.size()<1){
|
||||||
//商品名称不存在
|
//商品名称不存在
|
||||||
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_NOT_EXISTS_CODE,
|
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_NOT_EXISTS_CODE,
|
||||||
@@ -140,7 +246,15 @@ public class SerialNumberService {
|
|||||||
/***
|
/***
|
||||||
* 判断序列号是否已存在
|
* 判断序列号是否已存在
|
||||||
* */
|
* */
|
||||||
List <SerialNumberEx> list = serialNumberMapperEx.findBySerialNumber(serialNumber);
|
List <SerialNumberEx> list=null;
|
||||||
|
try{
|
||||||
|
list = serialNumberMapperEx.findBySerialNumber(serialNumber);
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("异常码[{}],异常提示[{}],异常[{}]",
|
||||||
|
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
|
||||||
|
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
|
||||||
|
ExceptionConstants.DATA_READ_FAIL_MSG);
|
||||||
|
}
|
||||||
if(list!=null&&list.size()>0){
|
if(list!=null&&list.size()>0){
|
||||||
if(list.size()>1){
|
if(list.size()>1){
|
||||||
//存在多个同名序列号
|
//存在多个同名序列号
|
||||||
@@ -187,8 +301,16 @@ public class SerialNumberService {
|
|||||||
User userInfo=userService.getCurrentUser();
|
User userInfo=userService.getCurrentUser();
|
||||||
serialNumberEx.setCreator(userInfo==null?null:userInfo.getId());
|
serialNumberEx.setCreator(userInfo==null?null:userInfo.getId());
|
||||||
serialNumberEx.setUpdater(userInfo==null?null:userInfo.getId());
|
serialNumberEx.setUpdater(userInfo==null?null:userInfo.getId());
|
||||||
int result=serialNumberMapperEx.addSerialNumber(serialNumberEx);
|
int result=0;
|
||||||
if(result==1){
|
try{
|
||||||
|
result = serialNumberMapperEx.addSerialNumber(serialNumberEx);
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("异常码[{}],异常提示[{}],异常[{}]",
|
||||||
|
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
|
||||||
|
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
|
||||||
|
ExceptionConstants.DATA_WRITE_FAIL_MSG);
|
||||||
|
}
|
||||||
|
if(result>0){
|
||||||
return serialNumberEx;
|
return serialNumberEx;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@@ -207,8 +329,16 @@ public class SerialNumberService {
|
|||||||
serialNumberEx.setUpdateTime(date);
|
serialNumberEx.setUpdateTime(date);
|
||||||
User userInfo=userService.getCurrentUser();
|
User userInfo=userService.getCurrentUser();
|
||||||
serialNumberEx.setUpdater(userInfo==null?null:userInfo.getId());
|
serialNumberEx.setUpdater(userInfo==null?null:userInfo.getId());
|
||||||
int result = serialNumberMapperEx.updateSerialNumber(serialNumberEx);
|
int result=0;
|
||||||
if(result==1){
|
try{
|
||||||
|
result = serialNumberMapperEx.updateSerialNumber(serialNumberEx);
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("异常码[{}],异常提示[{}],异常[{}]",
|
||||||
|
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
|
||||||
|
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
|
||||||
|
ExceptionConstants.DATA_WRITE_FAIL_MSG);
|
||||||
|
}
|
||||||
|
if(result>0){
|
||||||
return serialNumberEx;
|
return serialNumberEx;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@@ -221,9 +351,17 @@ public class SerialNumberService {
|
|||||||
* @Param: materialName
|
* @Param: materialName
|
||||||
* @return Long 满足使用条件的商品的id
|
* @return Long 满足使用条件的商品的id
|
||||||
*/
|
*/
|
||||||
public Long checkMaterialName(String materialName){
|
public Long checkMaterialName(String materialName)throws Exception{
|
||||||
if(StringUtil.isNotEmpty(materialName)) {
|
if(StringUtil.isNotEmpty(materialName)) {
|
||||||
List<Material> mlist = materialMapperEx.findByMaterialName(materialName);
|
List<Material> mlist=null;
|
||||||
|
try{
|
||||||
|
mlist = materialMapperEx.findByMaterialName(materialName);
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("异常码[{}],异常提示[{}],异常[{}]",
|
||||||
|
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
|
||||||
|
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
|
||||||
|
ExceptionConstants.DATA_READ_FAIL_MSG);
|
||||||
|
}
|
||||||
if (mlist == null || mlist.size() < 1) {
|
if (mlist == null || mlist.size() < 1) {
|
||||||
//商品名称不存在
|
//商品名称不存在
|
||||||
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_NOT_EXISTS_CODE,
|
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_NOT_EXISTS_CODE,
|
||||||
@@ -258,7 +396,7 @@ public class SerialNumberService {
|
|||||||
* @Param: materialName
|
* @Param: materialName
|
||||||
* @return Long 满足使用条件的商品的id
|
* @return Long 满足使用条件的商品的id
|
||||||
*/
|
*/
|
||||||
public Long getSerialNumberMaterialIdByMaterialName(String materialName){
|
public Long getSerialNumberMaterialIdByMaterialName(String materialName)throws Exception{
|
||||||
if(StringUtil.isNotEmpty(materialName)){
|
if(StringUtil.isNotEmpty(materialName)){
|
||||||
//计算商品库存和目前占用的可用序列号数量关系
|
//计算商品库存和目前占用的可用序列号数量关系
|
||||||
//库存=入库-出库
|
//库存=入库-出库
|
||||||
@@ -290,14 +428,22 @@ public class SerialNumberService {
|
|||||||
public void checkAndUpdateSerialNumber(DepotItem depotItem,User userInfo) throws Exception{
|
public void checkAndUpdateSerialNumber(DepotItem depotItem,User userInfo) throws Exception{
|
||||||
if(depotItem!=null){
|
if(depotItem!=null){
|
||||||
//查询商品下已分配的可用序列号数量
|
//查询商品下已分配的可用序列号数量
|
||||||
int SerialNumberSum= serialNumberMapperEx.countSerialNumberByMaterialIdAndDepotheadId(depotItem.getMaterialid(),null,BusinessConstants.IS_SELL_HOLD);
|
try{
|
||||||
//BasicNumber=OperNumber*ratio
|
int SerialNumberSum= serialNumberMapperEx.countSerialNumberByMaterialIdAndDepotheadId(depotItem.getMaterialid(),null,BusinessConstants.IS_SELL_HOLD);
|
||||||
if((depotItem.getBasicnumber()==null?0:depotItem.getBasicnumber()).intValue()>SerialNumberSum){
|
//BasicNumber=OperNumber*ratio
|
||||||
//获取商品名称
|
if((depotItem.getBasicnumber()==null?0:depotItem.getBasicnumber()).intValue()>SerialNumberSum){
|
||||||
Material material= materialMapper.selectByPrimaryKey(depotItem.getMaterialid());
|
//获取商品名称
|
||||||
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_SERIAL_NUMBERE_NOT_ENOUGH_CODE,
|
Material material= materialMapper.selectByPrimaryKey(depotItem.getMaterialid());
|
||||||
String.format(ExceptionConstants.MATERIAL_SERIAL_NUMBERE_NOT_ENOUGH_MSG,material==null?"":material.getName()));
|
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_SERIAL_NUMBERE_NOT_ENOUGH_CODE,
|
||||||
|
String.format(ExceptionConstants.MATERIAL_SERIAL_NUMBERE_NOT_ENOUGH_MSG,material==null?"":material.getName()));
|
||||||
|
}
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("异常码[{}],异常提示[{}],异常[{}]",
|
||||||
|
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
|
||||||
|
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
|
||||||
|
ExceptionConstants.DATA_READ_FAIL_MSG);
|
||||||
}
|
}
|
||||||
|
|
||||||
//商品下序列号充足,分配序列号
|
//商品下序列号充足,分配序列号
|
||||||
sellSerialNumber(depotItem.getMaterialid(),depotItem.getHeaderid(),(depotItem.getBasicnumber()==null?0:depotItem.getBasicnumber()).intValue(),userInfo);
|
sellSerialNumber(depotItem.getMaterialid(),depotItem.getHeaderid(),(depotItem.getBasicnumber()==null?0:depotItem.getBasicnumber()).intValue(),userInfo);
|
||||||
}
|
}
|
||||||
@@ -320,7 +466,16 @@ public class SerialNumberService {
|
|||||||
*/
|
*/
|
||||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||||
public int sellSerialNumber(Long materialId, Long depotheadId,int count,User user) throws Exception{
|
public int sellSerialNumber(Long materialId, Long depotheadId,int count,User user) throws Exception{
|
||||||
return serialNumberMapperEx.sellSerialNumber(materialId,depotheadId,count,new Date(),user==null?null:user.getId());
|
int result=0;
|
||||||
|
try{
|
||||||
|
result = serialNumberMapperEx.sellSerialNumber(materialId,depotheadId,count,new Date(),user==null?null:user.getId());
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("异常码[{}],异常提示[{}],异常[{}]",
|
||||||
|
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
|
||||||
|
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
|
||||||
|
ExceptionConstants.DATA_WRITE_FAIL_MSG);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -336,7 +491,16 @@ public class SerialNumberService {
|
|||||||
*/
|
*/
|
||||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||||
public int cancelSerialNumber(Long materialId, Long depotheadId,int count,User user) throws Exception{
|
public int cancelSerialNumber(Long materialId, Long depotheadId,int count,User user) throws Exception{
|
||||||
return serialNumberMapperEx.cancelSerialNumber(materialId,depotheadId,count,new Date(),user==null?null:user.getId());
|
int result=0;
|
||||||
|
try{
|
||||||
|
result = serialNumberMapperEx.cancelSerialNumber(materialId,depotheadId,count,new Date(),user==null?null:user.getId());
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("异常码[{}],异常提示[{}],异常[{}]",
|
||||||
|
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
|
||||||
|
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
|
||||||
|
ExceptionConstants.DATA_WRITE_FAIL_MSG);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -386,6 +550,15 @@ public class SerialNumberService {
|
|||||||
each.setSerialNumber(new StringBuffer(prefixBuf.toString()).append(insertNum).toString());
|
each.setSerialNumber(new StringBuffer(prefixBuf.toString()).append(insertNum).toString());
|
||||||
list.add(each);
|
list.add(each);
|
||||||
}
|
}
|
||||||
|
int result=0;
|
||||||
|
try{
|
||||||
|
result = serialNumberMapperEx.batAddSerialNumber(list);
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("异常码[{}],异常提示[{}],异常[{}]",
|
||||||
|
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
|
||||||
|
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
|
||||||
|
ExceptionConstants.DATA_WRITE_FAIL_MSG);
|
||||||
|
}
|
||||||
serialNumberMapperEx.batAddSerialNumber(list);
|
serialNumberMapperEx.batAddSerialNumber(list);
|
||||||
batAddTotal -= BusinessConstants.BATCH_INSERT_MAX_NUMBER;
|
batAddTotal -= BusinessConstants.BATCH_INSERT_MAX_NUMBER;
|
||||||
}while(batAddTotal>0);
|
}while(batAddTotal>0);
|
||||||
@@ -407,7 +580,16 @@ public class SerialNumberService {
|
|||||||
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
|
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
|
||||||
User userInfo=userService.getCurrentUser();
|
User userInfo=userService.getCurrentUser();
|
||||||
String [] idArray=ids.split(",");
|
String [] idArray=ids.split(",");
|
||||||
return serialNumberMapperEx.batchDeleteSerialNumberByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray);
|
int result=0;
|
||||||
|
try{
|
||||||
|
result = serialNumberMapperEx.batchDeleteSerialNumberByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray);
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("异常码[{}],异常提示[{}],异常[{}]",
|
||||||
|
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
|
||||||
|
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
|
||||||
|
ExceptionConstants.DATA_WRITE_FAIL_MSG);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user