From 94c64dd9055410bad980c08687bbbab22692fc39 Mon Sep 17 00:00:00 2001 From: qiankunpingtai Date: Thu, 18 Apr 2019 18:16:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=82=E5=B8=B8=E5=B0=81=E8=A3=85=E4=B9=8B?= =?UTF-8?q?=E6=94=B6=E6=94=AF=E9=A1=B9=E7=9B=AE=E4=BF=A1=E6=81=AF=E5=90=8E?= =?UTF-8?q?=E5=8F=B0=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../erp/controller/InOutItemController.java | 2 +- .../service/inOutItem/InOutItemComponent.java | 18 +- .../service/inOutItem/InOutItemService.java | 160 +++++++++++++++--- 3 files changed, 142 insertions(+), 38 deletions(-) diff --git a/src/main/java/com/jsh/erp/controller/InOutItemController.java b/src/main/java/com/jsh/erp/controller/InOutItemController.java index fc920907..62f76885 100644 --- a/src/main/java/com/jsh/erp/controller/InOutItemController.java +++ b/src/main/java/com/jsh/erp/controller/InOutItemController.java @@ -35,7 +35,7 @@ public class InOutItemController { * @return */ @GetMapping(value = "/findBySelect") - public String findBySelect(@RequestParam("type") String type, HttpServletRequest request) { + public String findBySelect(@RequestParam("type") String type, HttpServletRequest request) throws Exception{ String res = null; try { List dataList = inOutItemService.findBySelect(type); diff --git a/src/main/java/com/jsh/erp/service/inOutItem/InOutItemComponent.java b/src/main/java/com/jsh/erp/service/inOutItem/InOutItemComponent.java index f5f41b97..9cce46bc 100644 --- a/src/main/java/com/jsh/erp/service/inOutItem/InOutItemComponent.java +++ b/src/main/java/com/jsh/erp/service/inOutItem/InOutItemComponent.java @@ -19,16 +19,16 @@ public class InOutItemComponent implements ICommonQuery { private InOutItemService inOutItemService; @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 getFunctionsList(map); } - private List getFunctionsList(Map map) { + private List getFunctionsList(Map map)throws Exception { String search = map.get(Constants.SEARCH); String name = StringUtil.getInfo(search, "name"); String type = StringUtil.getInfo(search, "type"); @@ -38,7 +38,7 @@ public class InOutItemComponent 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"); String type = StringUtil.getInfo(search, "type"); @@ -47,27 +47,27 @@ public class InOutItemComponent implements ICommonQuery { } @Override - public int insert(String beanJson, HttpServletRequest request) { + public int insert(String beanJson, HttpServletRequest request)throws Exception { return inOutItemService.insertInOutItem(beanJson, request); } @Override - public int update(String beanJson, Long id) { + public int update(String beanJson, Long id)throws Exception { return inOutItemService.updateInOutItem(beanJson, id); } @Override - public int delete(Long id) { + public int delete(Long id)throws Exception { return inOutItemService.deleteInOutItem(id); } @Override - public int batchDelete(String ids) { + public int batchDelete(String ids)throws Exception { return inOutItemService.batchDeleteInOutItem(ids); } @Override - public int checkIsNameExist(Long id, String name) { + public int checkIsNameExist(Long id, String name)throws Exception { return inOutItemService.checkIsNameExist(id, name); } diff --git a/src/main/java/com/jsh/erp/service/inOutItem/InOutItemService.java b/src/main/java/com/jsh/erp/service/inOutItem/InOutItemService.java index a3797a36..18446237 100644 --- a/src/main/java/com/jsh/erp/service/inOutItem/InOutItemService.java +++ b/src/main/java/com/jsh/erp/service/inOutItem/InOutItemService.java @@ -4,10 +4,7 @@ import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.jsh.erp.constants.BusinessConstants; import com.jsh.erp.constants.ExceptionConstants; -import com.jsh.erp.datasource.entities.AccountItem; -import com.jsh.erp.datasource.entities.InOutItem; -import com.jsh.erp.datasource.entities.InOutItemExample; -import com.jsh.erp.datasource.entities.User; +import com.jsh.erp.datasource.entities.*; import com.jsh.erp.datasource.mappers.AccountItemMapperEx; import com.jsh.erp.datasource.mappers.InOutItemMapper; import com.jsh.erp.datasource.mappers.InOutItemMapperEx; @@ -43,58 +40,139 @@ public class InOutItemService { @Resource private AccountItemMapperEx accountItemMapperEx; - public InOutItem getInOutItem(long id) { - return inOutItemMapper.selectByPrimaryKey(id); + public InOutItem getInOutItem(long id)throws Exception { + InOutItem result=null; + try{ + result=inOutItemMapper.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 getInOutItem() { + public List getInOutItem()throws Exception { InOutItemExample example = new InOutItemExample(); example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); - return inOutItemMapper.selectByExample(example); + List list=null; + try{ + list=inOutItemMapper.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, String type, String remark, int offset, int rows) { - return inOutItemMapperEx.selectByConditionInOutItem(name, type, remark, offset, rows); + public List select(String name, String type, String remark, int offset, int rows)throws Exception { + List list=null; + try{ + list=inOutItemMapperEx.selectByConditionInOutItem(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 countInOutItem(String name, String type, String remark) { - return inOutItemMapperEx.countsByInOutItem(name, type, remark); + public Long countInOutItem(String name, String type, String remark)throws Exception { + Long result=null; + try{ + result=inOutItemMapperEx.countsByInOutItem(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 insertInOutItem(String beanJson, HttpServletRequest request) { + public int insertInOutItem(String beanJson, HttpServletRequest request)throws Exception { InOutItem depot = JSONObject.parseObject(beanJson, InOutItem.class); - return inOutItemMapper.insertSelective(depot); + int result=0; + try{ + result=inOutItemMapper.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 updateInOutItem(String beanJson, Long id) { + public int updateInOutItem(String beanJson, Long id)throws Exception { InOutItem depot = JSONObject.parseObject(beanJson, InOutItem.class); depot.setId(id); - return inOutItemMapper.updateByPrimaryKeySelective(depot); + int result=0; + try{ + result=inOutItemMapper.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 deleteInOutItem(Long id) { - return inOutItemMapper.deleteByPrimaryKey(id); + public int deleteInOutItem(Long id)throws Exception { + int result=0; + try{ + result=inOutItemMapper.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 batchDeleteInOutItem(String ids) { + public int batchDeleteInOutItem(String ids)throws Exception { List idList = StringUtil.strToLongList(ids); InOutItemExample example = new InOutItemExample(); example.createCriteria().andIdIn(idList); - return inOutItemMapper.deleteByExample(example); + int result=0; + try{ + result=inOutItemMapper.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 { InOutItemExample example = new InOutItemExample(); example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); - List list = inOutItemMapper.selectByExample(example); - return list.size(); + List list = null; + try{ + list=inOutItemMapper.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 findBySelect(String type) { + public List findBySelect(String type)throws Exception { InOutItemExample example = new InOutItemExample(); if (type.equals("in")) { example.createCriteria().andTypeEqualTo("收入").andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); @@ -102,16 +180,34 @@ public class InOutItemService { example.createCriteria().andTypeEqualTo("支出").andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); } example.setOrderByClause("id desc"); - return inOutItemMapper.selectByExample(example); + List list = null; + try{ + list=inOutItemMapper.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) - public int batchDeleteInOutItemByIds(String ids) { + public int batchDeleteInOutItemByIds(String ids)throws Exception { logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_IN_OUT_ITEM, new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(), ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); User userInfo=userService.getCurrentUser(); String [] idArray=ids.split(","); - return inOutItemMapperEx.batchDeleteInOutItemByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); + int result = 0; + try{ + result=inOutItemMapperEx.batchDeleteInOutItemByIds(new Date(),userInfo==null?null:userInfo.getId(),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); + } + return result; } /** * create by: qiankunpingtai @@ -137,7 +233,15 @@ public class InOutItemService { /** * 校验财务子表 jsh_accountitem * */ - List accountItemList=accountItemMapperEx.getAccountItemListByInOutItemIds(idArray); + List accountItemList=null; + try{ + accountItemList=accountItemMapperEx.getAccountItemListByInOutItemIds(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("异常码[{}],异常提示[{}],参数,InOutItemIds[{}]", ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids);