diff --git a/src/main/java/com/jsh/erp/controller/AccountHeadController.java b/src/main/java/com/jsh/erp/controller/AccountHeadController.java index 1abbce8f..ae350955 100644 --- a/src/main/java/com/jsh/erp/controller/AccountHeadController.java +++ b/src/main/java/com/jsh/erp/controller/AccountHeadController.java @@ -40,7 +40,7 @@ public class AccountHeadController { * @return */ @GetMapping(value = "/getMaxId") - public BaseResponseInfo getMaxId(HttpServletRequest request) { + public BaseResponseInfo getMaxId(HttpServletRequest request)throws Exception { BaseResponseInfo res = new BaseResponseInfo(); Map map = new HashMap(); try { @@ -68,7 +68,7 @@ public class AccountHeadController { public BaseResponseInfo findTotalPay(@RequestParam("supplierId") Integer supplierId, @RequestParam("endTime") String endTime, @RequestParam("supType") String supType, - HttpServletRequest request) { + HttpServletRequest request)throws Exception { BaseResponseInfo res = new BaseResponseInfo(); Map map = new HashMap(); try { @@ -106,7 +106,7 @@ public class AccountHeadController { */ @GetMapping(value = "/getDetailByNumber") public BaseResponseInfo getDetailByNumber(@RequestParam("billNo") String billNo, - HttpServletRequest request) { + HttpServletRequest request)throws Exception { BaseResponseInfo res = new BaseResponseInfo(); AccountHeadVo4ListEx ahl = new AccountHeadVo4ListEx(); try { @@ -132,7 +132,7 @@ public class AccountHeadController { * @param endTime * @return */ - public BigDecimal allMoney(String getS, String type, String mode, String endTime) { + public BigDecimal allMoney(String getS, String type, String mode, String endTime)throws Exception { BigDecimal allMoney = BigDecimal.ZERO; try { Integer supplierId = Integer.valueOf(getS); diff --git a/src/main/java/com/jsh/erp/service/accountHead/AccountHeadComponent.java b/src/main/java/com/jsh/erp/service/accountHead/AccountHeadComponent.java index d07e3e27..a9b67219 100644 --- a/src/main/java/com/jsh/erp/service/accountHead/AccountHeadComponent.java +++ b/src/main/java/com/jsh/erp/service/accountHead/AccountHeadComponent.java @@ -19,16 +19,16 @@ public class AccountHeadComponent implements ICommonQuery { private AccountHeadService accountHeadService; @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 getAccountHeadList(map); } - private List getAccountHeadList(Map map) { + private List getAccountHeadList(Map map)throws Exception { String search = map.get(Constants.SEARCH); String type = StringUtil.getInfo(search, "type"); String billNo = StringUtil.getInfo(search, "billNo"); @@ -39,7 +39,7 @@ public class AccountHeadComponent implements ICommonQuery { } @Override - public Long counts(Map map) { + public Long counts(Map map)throws Exception { String search = map.get(Constants.SEARCH); String type = StringUtil.getInfo(search, "type"); String billNo = StringUtil.getInfo(search, "billNo"); @@ -49,27 +49,27 @@ public class AccountHeadComponent implements ICommonQuery { } @Override - public int insert(String beanJson, HttpServletRequest request) { + public int insert(String beanJson, HttpServletRequest request) throws Exception{ return accountHeadService.insertAccountHead(beanJson, request); } @Override - public int update(String beanJson, Long id) { + public int update(String beanJson, Long id)throws Exception { return accountHeadService.updateAccountHead(beanJson, id); } @Override - public int delete(Long id) { + public int delete(Long id)throws Exception { return accountHeadService.deleteAccountHead(id); } @Override - public int batchDelete(String ids) { + public int batchDelete(String ids)throws Exception { return accountHeadService.batchDeleteAccountHead(ids); } @Override - public int checkIsNameExist(Long id, String name) { + public int checkIsNameExist(Long id, String name)throws Exception { return accountHeadService.checkIsNameExist(id, name); } diff --git a/src/main/java/com/jsh/erp/service/accountHead/AccountHeadService.java b/src/main/java/com/jsh/erp/service/accountHead/AccountHeadService.java index bfc72f33..45cd02a7 100644 --- a/src/main/java/com/jsh/erp/service/accountHead/AccountHeadService.java +++ b/src/main/java/com/jsh/erp/service/accountHead/AccountHeadService.java @@ -42,18 +42,44 @@ public class AccountHeadService { @Resource private AccountItemMapperEx accountItemMapperEx; - public AccountHead getAccountHead(long id) { - return accountHeadMapper.selectByPrimaryKey(id); + public AccountHead getAccountHead(long id) throws Exception { + AccountHead result=null; + try{ + result=accountHeadMapper.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 getAccountHead() { + public List getAccountHead() throws Exception{ AccountHeadExample example = new AccountHeadExample(); - return accountHeadMapper.selectByExample(example); + List list=null; + try{ + list=accountHeadMapper.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 type, String billNo, String beginTime, String endTime, int offset, int rows) { + public List select(String type, String billNo, String beginTime, String endTime, int offset, int rows) throws Exception{ List resList = new ArrayList(); - List list = accountHeadMapperEx.selectByConditionAccountHead(type, billNo, beginTime, endTime, offset, rows); + List list=null; + try{ + list = accountHeadMapperEx.selectByConditionAccountHead(type, billNo, beginTime, endTime, 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); + } if (null != list) { for (AccountHeadVo4ListEx ah : list) { if(ah.getChangeamount() != null) { @@ -68,45 +94,107 @@ public class AccountHeadService { return resList; } - public Long countAccountHead(String type, String billNo, String beginTime, String endTime) { - return accountHeadMapperEx.countsByAccountHead(type, billNo, beginTime, endTime); + public Long countAccountHead(String type, String billNo, String beginTime, String endTime) throws Exception{ + Long result=null; + try{ + result = accountHeadMapperEx.countsByAccountHead(type, billNo, beginTime, endTime); + }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 insertAccountHead(String beanJson, HttpServletRequest request) { + public int insertAccountHead(String beanJson, HttpServletRequest request) throws Exception{ AccountHead accountHead = JSONObject.parseObject(beanJson, AccountHead.class); - return accountHeadMapper.insertSelective(accountHead); + int result=0; + try{ + result = accountHeadMapper.insertSelective(accountHead); + }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 updateAccountHead(String beanJson, Long id) { + public int updateAccountHead(String beanJson, Long id)throws Exception { AccountHead accountHead = JSONObject.parseObject(beanJson, AccountHead.class); accountHead.setId(id); - return accountHeadMapper.updateByPrimaryKeySelective(accountHead); + int result=0; + try{ + result = accountHeadMapper.updateByPrimaryKeySelective(accountHead); + }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 deleteAccountHead(Long id) { - return accountHeadMapper.deleteByPrimaryKey(id); + public int deleteAccountHead(Long id)throws Exception { + int result=0; + try{ + result = accountHeadMapper.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 batchDeleteAccountHead(String ids) { + public int batchDeleteAccountHead(String ids)throws Exception { List idList = StringUtil.strToLongList(ids); AccountHeadExample example = new AccountHeadExample(); example.createCriteria().andIdIn(idList); - return accountHeadMapper.deleteByExample(example); + int result=0; + try{ + result = accountHeadMapper.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 { AccountHeadExample example = new AccountHeadExample(); example.createCriteria().andIdNotEqualTo(id).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); - List list = accountHeadMapper.selectByExample(example); - return list.size(); + List list = null; + try{ + list = accountHeadMapper.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 Long getMaxId() { - return accountHeadMapperEx.getMaxId(); + public Long getMaxId()throws Exception { + Long result = null; + try{ + result = accountHeadMapperEx.getMaxId(); + }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 BigDecimal findAllMoney(Integer supplierId, String type, String mode, String endTime) { @@ -116,12 +204,29 @@ public class AccountHeadService { } else if (mode.equals("合计")) { modeName = "TotalPrice"; } - return accountHeadMapperEx.findAllMoney(supplierId, type, modeName, endTime); + BigDecimal result = null; + try{ + result = accountHeadMapperEx.findAllMoney(supplierId, type, modeName, endTime); + }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 getDetailByNumber(String billNo) { + public List getDetailByNumber(String billNo)throws Exception { List resList = new ArrayList(); - List list = accountHeadMapperEx.getDetailByNumber(billNo); + List list = null; + try{ + list = accountHeadMapperEx.getDetailByNumber(billNo); + }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 (null != list) { for (AccountHeadVo4ListEx ah : list) { if(ah.getChangeamount() != null) { @@ -136,13 +241,22 @@ public class AccountHeadService { return resList; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int batchDeleteAccountHeadByIds(String ids) { + public int batchDeleteAccountHeadByIds(String ids)throws Exception { logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_ACCOUNT_HEAD, new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(), ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); User userInfo=userService.getCurrentUser(); String [] idArray=ids.split(","); - return accountHeadMapperEx.batchDeleteAccountHeadByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); + int result = 0; + try{ + result = accountHeadMapperEx.batchDeleteAccountHeadByIds(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 @@ -168,7 +282,15 @@ public class AccountHeadService { /** * 校验财务子表 jsh_accountitem * */ - List accountItemList=accountItemMapperEx.getAccountItemListByHeaderIds(idArray); + List accountItemList = null; + try{ + accountItemList = accountItemMapperEx.getAccountItemListByHeaderIds(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(accountItemList!=null&&accountItemList.size()>0){ logger.error("异常码[{}],异常提示[{}],参数,HeaderIds[{}]", ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids);