diff --git a/src/main/java/com/jsh/erp/controller/SupplierController.java b/src/main/java/com/jsh/erp/controller/SupplierController.java index 3ae785c0..8c0976f3 100644 --- a/src/main/java/com/jsh/erp/controller/SupplierController.java +++ b/src/main/java/com/jsh/erp/controller/SupplierController.java @@ -73,7 +73,7 @@ public class SupplierController { * @return */ @PostMapping(value = "/findBySelect_cus") - public JSONArray findBySelectCus(HttpServletRequest request) { + public JSONArray findBySelectCus(HttpServletRequest request)throws Exception { JSONArray arr = new JSONArray(); try { List supplierList = supplierService.findBySelectCus(); @@ -108,7 +108,7 @@ public class SupplierController { * @return */ @PostMapping(value = "/findBySelect_sup") - public JSONArray findBySelectSup(HttpServletRequest request) { + public JSONArray findBySelectSup(HttpServletRequest request) throws Exception{ JSONArray arr = new JSONArray(); try { List supplierList = supplierService.findBySelectSup(); @@ -135,7 +135,7 @@ public class SupplierController { * @return */ @PostMapping(value = "/findBySelect_retail") - public JSONArray findBySelectRetail(HttpServletRequest request) { + public JSONArray findBySelectRetail(HttpServletRequest request)throws Exception { JSONArray arr = new JSONArray(); try { List supplierList = supplierService.findBySelectRetail(); @@ -165,7 +165,7 @@ public class SupplierController { */ @GetMapping(value = "/findById") public BaseResponseInfo findById(@RequestParam("supplierId") Long supplierId, - HttpServletRequest request) { + HttpServletRequest request)throws Exception { BaseResponseInfo res = new BaseResponseInfo(); try { JSONArray dataArray = new JSONArray(); @@ -240,7 +240,7 @@ public class SupplierController { */ @PostMapping(value = "/findUserCustomer") public JSONArray findUserCustomer(@RequestParam("UBType") String type, @RequestParam("UBKeyId") String keyId, - HttpServletRequest request) { + HttpServletRequest request) throws Exception{ JSONArray arr = new JSONArray(); try { List dataList = supplierService.findUserCustomer(); @@ -295,7 +295,7 @@ public class SupplierController { @RequestParam("phonenum") String phonenum, @RequestParam("telephone") String telephone, @RequestParam("description") String description, - HttpServletRequest request, HttpServletResponse response) { + HttpServletRequest request, HttpServletResponse response)throws Exception { BaseResponseInfo res = new BaseResponseInfo(); Map map = new HashMap(); String message = "成功"; @@ -382,7 +382,7 @@ public class SupplierController { importFun(supplierFile); response.sendRedirect("../pages/manage/member.html"); } - public String importFun(MultipartFile supplierFile){ + public String importFun(MultipartFile supplierFile)throws Exception{ BaseResponseInfo info = new BaseResponseInfo(); Map data = new HashMap(); @@ -436,7 +436,7 @@ public class SupplierController { return null; } - public BigDecimal parseBigDecimalEx(String str){ + public BigDecimal parseBigDecimalEx(String str)throws Exception{ if(!StringUtil.isEmpty(str)) { return new BigDecimal(str); } else { diff --git a/src/main/java/com/jsh/erp/service/supplier/SupplierComponent.java b/src/main/java/com/jsh/erp/service/supplier/SupplierComponent.java index ec881237..c018e2ac 100644 --- a/src/main/java/com/jsh/erp/service/supplier/SupplierComponent.java +++ b/src/main/java/com/jsh/erp/service/supplier/SupplierComponent.java @@ -21,16 +21,16 @@ public class SupplierComponent implements ICommonQuery { private SupplierService supplierService; @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 getSupplierList(map); } - private List getSupplierList(Map map) { + private List getSupplierList(Map map)throws Exception { String search = map.get(Constants.SEARCH); String supplier = StringUtil.getInfo(search, "supplier"); String type = StringUtil.getInfo(search, "type"); @@ -42,7 +42,7 @@ public class SupplierComponent implements ICommonQuery { } @Override - public Long counts(Map map) { + public Long counts(Map map)throws Exception { String search = map.get(Constants.SEARCH); String supplier = StringUtil.getInfo(search, "supplier"); String type = StringUtil.getInfo(search, "type"); @@ -53,27 +53,27 @@ public class SupplierComponent implements ICommonQuery { } @Override - public int insert(String beanJson, HttpServletRequest request) { + public int insert(String beanJson, HttpServletRequest request)throws Exception { return supplierService.insertSupplier(beanJson, request); } @Override - public int update(String beanJson, Long id) { + public int update(String beanJson, Long id)throws Exception { return supplierService.updateSupplier(beanJson, id); } @Override - public int delete(Long id) { + public int delete(Long id)throws Exception { return supplierService.deleteSupplier(id); } @Override - public int batchDelete(String ids) { + public int batchDelete(String ids)throws Exception { return supplierService.batchDeleteSupplier(ids); } @Override - public int checkIsNameExist(Long id, String name) { + public int checkIsNameExist(Long id, String name)throws Exception { return supplierService.checkIsNameExist(id, name); } diff --git a/src/main/java/com/jsh/erp/service/supplier/SupplierService.java b/src/main/java/com/jsh/erp/service/supplier/SupplierService.java index ceb25c30..e40d496f 100644 --- a/src/main/java/com/jsh/erp/service/supplier/SupplierService.java +++ b/src/main/java/com/jsh/erp/service/supplier/SupplierService.java @@ -47,55 +47,136 @@ public class SupplierService { @Resource private DepotHeadMapperEx depotHeadMapperEx; - public Supplier getSupplier(long id) { - return supplierMapper.selectByPrimaryKey(id); + public Supplier getSupplier(long id)throws Exception { + Supplier result=null; + try{ + result=supplierMapper.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 getSupplier() { + public List getSupplier()throws Exception { SupplierExample example = new SupplierExample(); example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); - return supplierMapper.selectByExample(example); + List list=null; + try{ + list=supplierMapper.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 supplier, String type, String phonenum, String telephone, String description, int offset, int rows) { - return supplierMapperEx.selectByConditionSupplier(supplier, type, phonenum, telephone, description, offset, rows); + public List select(String supplier, String type, String phonenum, + String telephone, String description, int offset, int rows) throws Exception{ + List list=null; + try{ + list=supplierMapperEx.selectByConditionSupplier(supplier, type, phonenum, telephone, description, 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 countSupplier(String supplier, String type, String phonenum, String telephone, String description) { - return supplierMapperEx.countsBySupplier(supplier, type, phonenum, telephone, description); + public Long countSupplier(String supplier, String type, String phonenum, String telephone, String description) throws Exception{ + Long result=null; + try{ + result=supplierMapperEx.countsBySupplier(supplier, type, phonenum, telephone, description); + }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 insertSupplier(String beanJson, HttpServletRequest request) { + public int insertSupplier(String beanJson, HttpServletRequest request)throws Exception { Supplier supplier = JSONObject.parseObject(beanJson, Supplier.class); - return supplierMapper.insertSelective(supplier); + int result=0; + try{ + result=supplierMapper.insertSelective(supplier); + }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 updateSupplier(String beanJson, Long id) { + public int updateSupplier(String beanJson, Long id)throws Exception { Supplier supplier = JSONObject.parseObject(beanJson, Supplier.class); supplier.setId(id); - return supplierMapper.updateByPrimaryKeySelective(supplier); + int result=0; + try{ + result=supplierMapper.updateByPrimaryKeySelective(supplier); + }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 deleteSupplier(Long id) { + public int deleteSupplier(Long id)throws Exception { + int result=0; + try{ + result=supplierMapper.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 supplierMapper.deleteByPrimaryKey(id); } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int batchDeleteSupplier(String ids) { + public int batchDeleteSupplier(String ids) throws Exception{ List idList = StringUtil.strToLongList(ids); SupplierExample example = new SupplierExample(); example.createCriteria().andIdIn(idList); - return supplierMapper.deleteByExample(example); + int result=0; + try{ + result=supplierMapper.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 { SupplierExample example = new SupplierExample(); example.createCriteria().andIdNotEqualTo(id).andSupplierEqualTo(name).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); - List list = supplierMapper.selectByExample(example); - return list.size(); + List list=null; + try{ + list= supplierMapper.selectByExample(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 list==null?0:list.size(); } @Transactional(value = "transactionManager", rollbackFor = Exception.class) @@ -103,45 +184,95 @@ public class SupplierService { logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_SUPPLIER, new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(supplierId).toString(), ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); - Supplier supplier = supplierMapper.selectByPrimaryKey(supplierId); - if(supplier!=null){ - supplier.setAdvancein(supplier.getAdvancein().add(advanceIn)); //增加预收款的金额,可能增加的是负值 - return supplierMapper.updateByPrimaryKeySelective(supplier); - }else{ - return 0; + Supplier supplier=null; + try{ + supplier = supplierMapper.selectByPrimaryKey(supplierId); + }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); } - + int result=0; + try{ + if(supplier!=null){ + supplier.setAdvancein(supplier.getAdvancein().add(advanceIn)); //增加预收款的金额,可能增加的是负值 + result=supplierMapper.updateByPrimaryKeySelective(supplier); + } + }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 findBySelectCus() { + public List findBySelectCus()throws Exception { SupplierExample example = new SupplierExample(); example.createCriteria().andTypeLike("客户").andEnabledEqualTo(true).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.setOrderByClause("id desc"); - return supplierMapper.selectByExample(example); + List list=null; + try{ + list = supplierMapper.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 findBySelectSup() { + public List findBySelectSup()throws Exception { SupplierExample example = new SupplierExample(); example.createCriteria().andTypeLike("供应商").andEnabledEqualTo(true) .andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.setOrderByClause("id desc"); - return supplierMapper.selectByExample(example); + List list=null; + try{ + list = supplierMapper.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 findBySelectRetail() { + public List findBySelectRetail()throws Exception { SupplierExample example = new SupplierExample(); example.createCriteria().andTypeLike("会员").andEnabledEqualTo(true) .andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.setOrderByClause("id desc"); - return supplierMapper.selectByExample(example); + List list=null; + try{ + list = supplierMapper.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 findById(Long supplierId) { + public List findById(Long supplierId)throws Exception { SupplierExample example = new SupplierExample(); example.createCriteria().andIdEqualTo(supplierId) .andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.setOrderByClause("id desc"); - return supplierMapper.selectByExample(example); + List list=null; + try{ + list = supplierMapper.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; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) @@ -154,20 +285,47 @@ public class SupplierService { supplier.setEnabled(enabled); SupplierExample example = new SupplierExample(); example.createCriteria().andIdIn(ids); - return supplierMapper.updateByExampleSelective(supplier, example); + int result=0; + try{ + result = supplierMapper.updateByExampleSelective(supplier, 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 findUserCustomer(){ + public List findUserCustomer()throws Exception{ SupplierExample example = new SupplierExample(); example.createCriteria().andTypeEqualTo("客户") .andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.setOrderByClause("id desc"); - List list = supplierMapper.selectByExample(example); + List list=null; + try{ + list = supplierMapper.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 findByAll(String supplier, String type, String phonenum, String telephone, String description) { - return supplierMapperEx.findByAll(supplier, type, phonenum, telephone, description); + public List findByAll(String supplier, String type, String phonenum, + String telephone, String description) throws Exception{ + List list=null; + try{ + list = supplierMapperEx.findByAll(supplier, type, phonenum, telephone, description); + }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 BaseResponseInfo importExcel(List mList) throws Exception { @@ -183,6 +341,8 @@ public class SupplierService { info.code = 200; data.put("message", "成功"); } catch (Exception e) { + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); e.printStackTrace(); info.code = 500; data.put("message", e.getMessage()); @@ -197,7 +357,16 @@ public class SupplierService { ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); User userInfo=userService.getCurrentUser(); String [] idArray=ids.split(","); - return supplierMapperEx.batchDeleteSupplierByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); + int result=0; + try{ + result = supplierMapperEx.batchDeleteSupplierByIds(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 @@ -224,7 +393,15 @@ public class SupplierService { /** * 校验财务主表 jsh_accounthead * */ - List accountHeadList=accountHeadMapperEx.getAccountHeadListByOrganIds(idArray); + List accountHeadList=null; + try{ + accountHeadList = accountHeadMapperEx.getAccountHeadListByOrganIds(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(accountHeadList!=null&&accountHeadList.size()>0){ logger.error("异常码[{}],异常提示[{}],参数,OrganIds[{}]", ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids); @@ -234,7 +411,15 @@ public class SupplierService { /** * 校验单据主表 jsh_depothead * */ - List depotHeadList=depotHeadMapperEx.getDepotHeadListByOrganIds(idArray); + List depotHeadList=null; + try{ + depotHeadList = depotHeadMapperEx.getDepotHeadListByOrganIds(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("异常码[{}],异常提示[{}],参数,OrganIds[{}]", ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids);