diff --git a/src/main/java/com/jsh/erp/controller/DepotController.java b/src/main/java/com/jsh/erp/controller/DepotController.java index 6338420d..7a8b1db0 100644 --- a/src/main/java/com/jsh/erp/controller/DepotController.java +++ b/src/main/java/com/jsh/erp/controller/DepotController.java @@ -41,7 +41,7 @@ public class DepotController { private UserBusinessService userBusinessService; @GetMapping(value = "/getAllList") - public BaseResponseInfo getAllList(HttpServletRequest request) { + public BaseResponseInfo getAllList(HttpServletRequest request) throws Exception{ BaseResponseInfo res = new BaseResponseInfo(); try { List depotList = depotService.getAllList(); @@ -64,7 +64,7 @@ public class DepotController { */ @PostMapping(value = "/findUserDepot") public JSONArray findUserDepot(@RequestParam("UBType") String type, @RequestParam("UBKeyId") String keyId, - HttpServletRequest request) { + HttpServletRequest request) throws Exception{ JSONArray arr = new JSONArray(); try { List dataList = depotService.findUserDepot(); @@ -104,7 +104,7 @@ public class DepotController { @RequestMapping(value = "/findDepotByUserId") public JSONArray findDepotByUserId(@RequestParam("UBType") String type, @RequestParam("UBKeyId") String keyId, - HttpServletRequest request) { + HttpServletRequest request) throws Exception{ JSONArray arr = new JSONArray(); try { List dataList = depotService.findUserDepot(); @@ -145,7 +145,7 @@ public class DepotController { public String getDepotList( @RequestParam(value = Constants.PAGE_SIZE, required = false) Integer pageSize, @RequestParam(value = Constants.CURRENT_PAGE, required = false) Integer currentPage, - @RequestParam(value = Constants.SEARCH, required = false) String search) { + @RequestParam(value = Constants.SEARCH, required = false) String search) throws Exception{ Map parameterMap = new HashMap(); //查询参数 JSONObject obj=JSON.parseObject(search); diff --git a/src/main/java/com/jsh/erp/service/depot/DepotComponent.java b/src/main/java/com/jsh/erp/service/depot/DepotComponent.java index f267fe68..7dc0f06c 100644 --- a/src/main/java/com/jsh/erp/service/depot/DepotComponent.java +++ b/src/main/java/com/jsh/erp/service/depot/DepotComponent.java @@ -20,16 +20,16 @@ public class DepotComponent implements ICommonQuery { private DepotService depotService; @Override - public Object selectOne(String condition) { + public Object selectOne(String condition)throws Exception { return null; } @Override - public List select(Map map) { + public List select(Map map)throws Exception { return getDepotList(map); } - private List getDepotList(Map map) { + private List getDepotList(Map map)throws Exception { String search = map.get(Constants.SEARCH); String name = StringUtil.getInfo(search, "name"); Integer type = StringUtil.parseInteger(StringUtil.getInfo(search, "type")); @@ -39,7 +39,7 @@ public class DepotComponent implements ICommonQuery { } @Override - public Long counts(Map map) { + public Long counts(Map map)throws Exception { String search = map.get(Constants.SEARCH); String name = StringUtil.getInfo(search, "name"); Integer type = StringUtil.parseInteger(StringUtil.getInfo(search, "type")); @@ -48,27 +48,27 @@ public class DepotComponent implements ICommonQuery { } @Override - public int insert(String beanJson, HttpServletRequest request) { + public int insert(String beanJson, HttpServletRequest request) throws Exception{ return depotService.insertDepot(beanJson, request); } @Override - public int update(String beanJson, Long id) { + public int update(String beanJson, Long id)throws Exception { return depotService.updateDepot(beanJson, id); } @Override - public int delete(Long id) { + public int delete(Long id)throws Exception { return depotService.deleteDepot(id); } @Override - public int batchDelete(String ids) { + public int batchDelete(String ids)throws Exception { return depotService.batchDeleteDepot(ids); } @Override - public int checkIsNameExist(Long id, String name) { + public int checkIsNameExist(Long id, String name)throws Exception { return depotService.checkIsNameExist(id, name); } diff --git a/src/main/java/com/jsh/erp/service/depot/DepotService.java b/src/main/java/com/jsh/erp/service/depot/DepotService.java index 8b2edfbc..b1ba5c8a 100644 --- a/src/main/java/com/jsh/erp/service/depot/DepotService.java +++ b/src/main/java/com/jsh/erp/service/depot/DepotService.java @@ -41,91 +41,214 @@ public class DepotService { @Resource private DepotItemMapperEx depotItemMapperEx; - public Depot getDepot(long id) { - return depotMapper.selectByPrimaryKey(id); + public Depot getDepot(long id)throws Exception { + Depot result=null; + try{ + result=depotMapper.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 getDepot() { + public List getDepot()throws Exception { DepotExample example = new DepotExample(); example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); - return depotMapper.selectByExample(example); + List list=null; + try{ + list=depotMapper.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 getAllList() { + public List getAllList()throws Exception { DepotExample example = new DepotExample(); example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.setOrderByClause("sort"); - return depotMapper.selectByExample(example); + List list=null; + try{ + list=depotMapper.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 select(String name, Integer type, String remark, int offset, int rows) { - return depotMapperEx.selectByConditionDepot(name, type, remark, offset, rows); + public List select(String name, Integer type, String remark, int offset, int rows)throws Exception { + List list=null; + try{ + list=depotMapperEx.selectByConditionDepot(name, type, remark, 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 countDepot(String name, Integer type, String remark) { - return depotMapperEx.countsByDepot(name, type, remark); + public Long countDepot(String name, Integer type, String remark)throws Exception { + Long result=null; + try{ + result=depotMapperEx.countsByDepot(name, type, remark); + }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) - public int insertDepot(String beanJson, HttpServletRequest request) { + public int insertDepot(String beanJson, HttpServletRequest request)throws Exception { Depot depot = JSONObject.parseObject(beanJson, Depot.class); - return depotMapper.insertSelective(depot); + int result=0; + try{ + result=depotMapper.insertSelective(depot); + }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) - public int updateDepot(String beanJson, Long id) { + public int updateDepot(String beanJson, Long id) throws Exception{ Depot depot = JSONObject.parseObject(beanJson, Depot.class); depot.setId(id); - return depotMapper.updateByPrimaryKeySelective(depot); + int result=0; + try{ + result= depotMapper.updateByPrimaryKeySelective(depot); + }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) - public int deleteDepot(Long id) { - return depotMapper.deleteByPrimaryKey(id); + public int deleteDepot(Long id)throws Exception { + int result=0; + try{ + result= depotMapper.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) - public int batchDeleteDepot(String ids) { + public int batchDeleteDepot(String ids) throws Exception{ List idList = StringUtil.strToLongList(ids); DepotExample example = new DepotExample(); example.createCriteria().andIdIn(idList); - return depotMapper.deleteByExample(example); + int result=0; + try{ + result= depotMapper.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 name) { + public int checkIsNameExist(Long id, String name)throws Exception { DepotExample example = new DepotExample(); example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); - List list = depotMapper.selectByExample(example); - return list.size(); + List list=null; + try{ + list= depotMapper.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(); } - public List findUserDepot(){ + public List findUserDepot()throws Exception{ DepotExample example = new DepotExample(); example.createCriteria().andTypeEqualTo(0).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.setOrderByClause("Sort"); - List list = depotMapper.selectByExample(example); + List list=null; + try{ + list= depotMapper.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 findGiftByType(Integer type){ + public List findGiftByType(Integer type)throws Exception{ DepotExample example = new DepotExample(); example.createCriteria().andTypeEqualTo(type); example.setOrderByClause("Sort"); - List list = depotMapper.selectByExample(example); + List list=null; + try{ + list= depotMapper.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 getDepotList(Map parameterMap) { - return depotMapperEx.getDepotList(parameterMap); + public List getDepotList(Map parameterMap)throws Exception { + List list=null; + try{ + list= depotMapperEx.getDepotList(parameterMap); + }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; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int batchDeleteDepotByIds(String ids) { + public int batchDeleteDepotByIds(String ids)throws Exception { logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_DEPOT, new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(), ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); User userInfo=userService.getCurrentUser(); String [] idArray=ids.split(","); - return depotMapperEx.batchDeleteDepotByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); + int result=0; + try{ + result= depotMapperEx.batchDeleteDepotByIds(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; } /** * create by: qiankunpingtai @@ -153,7 +276,15 @@ public class DepotService { /** * 校验单据主表 jsh_depothead * */ - List depotHeadList=depotHeadMapperEx.getDepotHeadListByDepotIds(idArray); + List depotHeadList=null; + try{ + depotHeadList= depotHeadMapperEx.getDepotHeadListByDepotIds(idArray); + }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(depotHeadList!=null&&depotHeadList.size()>0){ logger.error("异常码[{}],异常提示[{}],参数,DepotIds[{}]", ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids); @@ -163,7 +294,15 @@ public class DepotService { /** * 校验单据子表 jsh_depotitem * */ - List depotItemList=depotItemMapperEx.getDepotItemListListByDepotIds(idArray); + List depotItemList=null; + try{ + depotItemList= depotItemMapperEx.getDepotItemListListByDepotIds(idArray); + }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(depotItemList!=null&&depotItemList.size()>0){ logger.error("异常码[{}],异常提示[{}],参数,DepotIds[{}]", ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids);