From d188dcb216cfcf9d73638c8bed651deb3e55ffc3 Mon Sep 17 00:00:00 2001 From: qiankunpingtai Date: Fri, 19 Apr 2019 09:43:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=82=E5=B8=B8=E5=B0=81=E8=A3=85=E4=B9=8B?= =?UTF-8?q?=E5=95=86=E5=93=81=E7=B1=BB=E5=9E=8B=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 --- .../MaterialCategoryController.java | 4 +- .../MaterialCategoryComponent.java | 18 +- .../MaterialCategoryService.java | 209 +++++++++++++++--- 3 files changed, 190 insertions(+), 41 deletions(-) diff --git a/src/main/java/com/jsh/erp/controller/MaterialCategoryController.java b/src/main/java/com/jsh/erp/controller/MaterialCategoryController.java index 3b91415c..6e0de93f 100644 --- a/src/main/java/com/jsh/erp/controller/MaterialCategoryController.java +++ b/src/main/java/com/jsh/erp/controller/MaterialCategoryController.java @@ -35,7 +35,7 @@ public class MaterialCategoryController { private MaterialCategoryService materialCategoryService; @GetMapping(value = "/getAllList") - public BaseResponseInfo getAllList(@RequestParam("parentId") Long parentId, HttpServletRequest request) { + public BaseResponseInfo getAllList(@RequestParam("parentId") Long parentId, HttpServletRequest request) throws Exception{ BaseResponseInfo res = new BaseResponseInfo(); try { List materialCategoryList = materialCategoryService.getAllList(parentId); @@ -56,7 +56,7 @@ public class MaterialCategoryController { * @return */ @RequestMapping(value = "/findById") - public BaseResponseInfo findById(@RequestParam("id") Long id, HttpServletRequest request) { + public BaseResponseInfo findById(@RequestParam("id") Long id, HttpServletRequest request)throws Exception { BaseResponseInfo res = new BaseResponseInfo(); try { List dataList = materialCategoryService.findById(id); diff --git a/src/main/java/com/jsh/erp/service/materialCategory/MaterialCategoryComponent.java b/src/main/java/com/jsh/erp/service/materialCategory/MaterialCategoryComponent.java index 18395669..70598d69 100644 --- a/src/main/java/com/jsh/erp/service/materialCategory/MaterialCategoryComponent.java +++ b/src/main/java/com/jsh/erp/service/materialCategory/MaterialCategoryComponent.java @@ -21,16 +21,16 @@ public class MaterialCategoryComponent implements ICommonQuery { private MaterialCategoryService materialCategoryService; @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 getMaterialCategoryList(map); } - private List getMaterialCategoryList(Map map) { + private List getMaterialCategoryList(Map map) throws Exception{ String search = map.get(Constants.SEARCH); String name = StringUtil.getInfo(search, "name"); Integer parentId = StringUtil.parseInteger(StringUtil.getInfo(search, "parentId")); @@ -39,7 +39,7 @@ public class MaterialCategoryComponent 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 parentId = StringUtil.parseInteger(StringUtil.getInfo(search, "parentId")); @@ -47,27 +47,27 @@ public class MaterialCategoryComponent implements ICommonQuery { } @Override - public int insert(String beanJson, HttpServletRequest request) { + public int insert(String beanJson, HttpServletRequest request)throws Exception { return materialCategoryService.insertMaterialCategory(beanJson, request); } @Override - public int update(String beanJson, Long id) { + public int update(String beanJson, Long id)throws Exception { return materialCategoryService.updateMaterialCategory(beanJson, id); } @Override - public int delete(Long id) { + public int delete(Long id)throws Exception { return materialCategoryService.deleteMaterialCategory(id); } @Override - public int batchDelete(String ids) { + public int batchDelete(String ids)throws Exception { return materialCategoryService.batchDeleteMaterialCategory(ids); } @Override - public int checkIsNameExist(Long id, String name) { + public int checkIsNameExist(Long id, String name)throws Exception { return materialCategoryService.checkIsNameExist(id, name); } diff --git a/src/main/java/com/jsh/erp/service/materialCategory/MaterialCategoryService.java b/src/main/java/com/jsh/erp/service/materialCategory/MaterialCategoryService.java index e5b61afc..71c41bb3 100644 --- a/src/main/java/com/jsh/erp/service/materialCategory/MaterialCategoryService.java +++ b/src/main/java/com/jsh/erp/service/materialCategory/MaterialCategoryService.java @@ -40,64 +40,154 @@ public class MaterialCategoryService { @Resource private MaterialMapperEx materialMapperEx; - public MaterialCategory getMaterialCategory(long id) { - return materialCategoryMapper.selectByPrimaryKey(id); + public MaterialCategory getMaterialCategory(long id)throws Exception { + MaterialCategory result=null; + try{ + result=materialCategoryMapper.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 getMaterialCategory() { + public List getMaterialCategory()throws Exception { MaterialCategoryExample example = new MaterialCategoryExample(); - return materialCategoryMapper.selectByExample(example); + List list=null; + try{ + list=materialCategoryMapper.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(Long parentId) { + public List getAllList(Long parentId)throws Exception { MaterialCategoryExample example = new MaterialCategoryExample(); example.createCriteria().andParentidEqualTo(parentId).andIdNotEqualTo(1l); example.setOrderByClause("id"); - return materialCategoryMapper.selectByExample(example); + List list=null; + try{ + list=materialCategoryMapper.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 parentId, int offset, int rows) { - return materialCategoryMapperEx.selectByConditionMaterialCategory(name, parentId, offset, rows); + public List select(String name, Integer parentId, int offset, int rows) throws Exception{ + List list=null; + try{ + list=materialCategoryMapperEx.selectByConditionMaterialCategory(name, parentId, 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 countMaterialCategory(String name, Integer parentId) { - return materialCategoryMapperEx.countsByMaterialCategory(name, parentId); + public Long countMaterialCategory(String name, Integer parentId) throws Exception{ + Long result=null; + try{ + result=materialCategoryMapperEx.countsByMaterialCategory(name, parentId); + }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 insertMaterialCategory(String beanJson, HttpServletRequest request) { + public int insertMaterialCategory(String beanJson, HttpServletRequest request)throws Exception { MaterialCategory materialCategory = JSONObject.parseObject(beanJson, MaterialCategory.class); - return materialCategoryMapper.insertSelective(materialCategory); + int result=0; + try{ + result=materialCategoryMapper.insertSelective(materialCategory); + }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 updateMaterialCategory(String beanJson, Long id) { + public int updateMaterialCategory(String beanJson, Long id) throws Exception{ MaterialCategory materialCategory = JSONObject.parseObject(beanJson, MaterialCategory.class); materialCategory.setId(id); - return materialCategoryMapper.updateByPrimaryKeySelective(materialCategory); + int result=0; + try{ + result=materialCategoryMapper.updateByPrimaryKeySelective(materialCategory); + }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 deleteMaterialCategory(Long id) { - return materialCategoryMapper.deleteByPrimaryKey(id); + public int deleteMaterialCategory(Long id)throws Exception { + int result=0; + try{ + result=materialCategoryMapper.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 batchDeleteMaterialCategory(String ids) { + public int batchDeleteMaterialCategory(String ids)throws Exception { List idList = StringUtil.strToLongList(ids); MaterialCategoryExample example = new MaterialCategoryExample(); example.createCriteria().andIdIn(idList); - return materialCategoryMapper.deleteByExample(example); + int result=0; + try{ + result=materialCategoryMapper.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 { return 0; } - public List findById(Long id) { + public List findById(Long id)throws Exception { MaterialCategoryExample example = new MaterialCategoryExample(); example.createCriteria().andIdEqualTo(id); - return materialCategoryMapper.selectByExample(example); + List list=null; + try{ + list=materialCategoryMapper.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; } /** * create by: cjl @@ -108,7 +198,16 @@ public class MaterialCategoryService { * @return java.util.List */ public List getMaterialCategoryTree(Long id) throws Exception{ - return materialCategoryMapperEx.getNodeTree(id); + List list=null; + try{ + list=materialCategoryMapperEx.getNodeTree(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; } /** * create by: cjl @@ -144,7 +243,16 @@ public class MaterialCategoryService { mc.setUpdateTime(date); //更新人 mc.setUpdater(userInfo==null?null:userInfo.getId()); - return materialCategoryMapperEx.addMaterialCategory(mc); + int result=0; + try{ + result=materialCategoryMapperEx.addMaterialCategory(mc); + }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 batchDeleteMaterialCategoryByIds(String ids) throws Exception { @@ -160,8 +268,16 @@ public class MaterialCategoryService { if(strArray.length<1){ return 0; } - - return materialCategoryMapperEx.batchDeleteMaterialCategoryByIds(updateDate,updater,strArray); + int result=0; + try{ + result=materialCategoryMapperEx.batchDeleteMaterialCategoryByIds(updateDate,updater,strArray); + }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 editMaterialCategory(MaterialCategory mc) throws Exception{ @@ -180,12 +296,21 @@ public class MaterialCategoryService { //更新人 User userInfo=userService.getCurrentUser(); mc.setUpdater(userInfo==null?null:userInfo.getId()); - return materialCategoryMapperEx.editMaterialCategory(mc); + int result=0; + try{ + result= materialCategoryMapperEx.editMaterialCategory(mc); + }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 void checkMaterialCategorySerialNo(MaterialCategory mc) { + public void checkMaterialCategorySerialNo(MaterialCategory mc)throws Exception { if(mc==null){ return; } @@ -193,7 +318,15 @@ public class MaterialCategoryService { return; } //根据商品类别编号查询商品类别 - List mList=materialCategoryMapperEx.getMaterialCategoryBySerialNo(mc.getSerialNo()); + List mList=null; + try{ + mList= materialCategoryMapperEx.getMaterialCategoryBySerialNo(mc.getSerialNo()); + }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){ //未查询到对应数据,编号可用 return; @@ -243,7 +376,15 @@ public class MaterialCategoryService { /** * 校验产品表 jsh_material * */ - List materialList=materialMapperEx.getMaterialListByCategoryIds(idArray); + List materialList=null; + try{ + materialList= materialMapperEx.getMaterialListByCategoryIds(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(materialList!=null&&materialList.size()>0){ logger.error("异常码[{}],异常提示[{}],参数,CategoryIds[{}]", ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids); @@ -253,7 +394,15 @@ public class MaterialCategoryService { /** * 校验产品类型表 jsh_materialcategory * */ - List materialCategoryList=materialCategoryMapperEx.getMaterialCategoryListByCategoryIds(idArray); + List materialCategoryList=null; + try{ + materialCategoryList= materialCategoryMapperEx.getMaterialCategoryListByCategoryIds(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(materialCategoryList!=null&&materialCategoryList.size()>0){ logger.error("异常码[{}],异常提示[{}],参数,CategoryIds[{}]", ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids);