diff --git a/src/main/java/com/jsh/erp/controller/PersonController.java b/src/main/java/com/jsh/erp/controller/PersonController.java index 6460f737..f80fe964 100644 --- a/src/main/java/com/jsh/erp/controller/PersonController.java +++ b/src/main/java/com/jsh/erp/controller/PersonController.java @@ -30,7 +30,7 @@ public class PersonController { private PersonService personService; @GetMapping(value = "/getAllList") - public BaseResponseInfo getAllList(HttpServletRequest request) { + public BaseResponseInfo getAllList(HttpServletRequest request)throws Exception { BaseResponseInfo res = new BaseResponseInfo(); Map map = new HashMap(); try { @@ -53,7 +53,8 @@ public class PersonController { * @return */ @GetMapping(value = "/getPersonByIds") - public BaseResponseInfo getPersonByIds(@RequestParam("personIDs") String personIDs, HttpServletRequest request) { + public BaseResponseInfo getPersonByIds(@RequestParam("personIDs") String personIDs, + HttpServletRequest request)throws Exception { BaseResponseInfo res = new BaseResponseInfo(); Map map = new HashMap(); try { @@ -76,7 +77,8 @@ public class PersonController { * @return */ @GetMapping(value = "/getPersonByType") - public BaseResponseInfo getPersonByType(@RequestParam("type") String type, HttpServletRequest request) { + public BaseResponseInfo getPersonByType(@RequestParam("type") String type, + HttpServletRequest request)throws Exception { BaseResponseInfo res = new BaseResponseInfo(); Map map = new HashMap(); try { @@ -99,7 +101,8 @@ public class PersonController { * @return */ @PostMapping(value = "/getPersonByNumType") - public JSONArray getPersonByNumType(@RequestParam("type") String typeNum, HttpServletRequest request) { + public JSONArray getPersonByNumType(@RequestParam("type") String typeNum, + HttpServletRequest request)throws Exception { JSONArray dataArray = new JSONArray(); try { String type = ""; diff --git a/src/main/java/com/jsh/erp/service/person/PersonComponent.java b/src/main/java/com/jsh/erp/service/person/PersonComponent.java index 7e9a6e44..b7b6a6cc 100644 --- a/src/main/java/com/jsh/erp/service/person/PersonComponent.java +++ b/src/main/java/com/jsh/erp/service/person/PersonComponent.java @@ -21,16 +21,16 @@ public class PersonComponent implements ICommonQuery { private PersonService personService; @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 getPersonList(map); } - private List getPersonList(Map map) { + private List getPersonList(Map map) throws Exception{ String search = map.get(Constants.SEARCH); String name = StringUtil.getInfo(search, "name"); String type = StringUtil.getInfo(search, "type"); @@ -39,7 +39,7 @@ public class PersonComponent 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 PersonComponent implements ICommonQuery { } @Override - public int insert(String beanJson, HttpServletRequest request) { + public int insert(String beanJson, HttpServletRequest request)throws Exception { return personService.insertPerson(beanJson, request); } @Override - public int update(String beanJson, Long id) { + public int update(String beanJson, Long id)throws Exception { return personService.updatePerson(beanJson, id); } @Override - public int delete(Long id) { + public int delete(Long id)throws Exception { return personService.deletePerson(id); } @Override - public int batchDelete(String ids) { + public int batchDelete(String ids)throws Exception { return personService.batchDeletePerson(ids); } @Override - public int checkIsNameExist(Long id, String name) { + public int checkIsNameExist(Long id, String name)throws Exception { return personService.checkIsNameExist(id, name); } diff --git a/src/main/java/com/jsh/erp/service/person/PersonService.java b/src/main/java/com/jsh/erp/service/person/PersonService.java index 3bd13e4f..3dea10df 100644 --- a/src/main/java/com/jsh/erp/service/person/PersonService.java +++ b/src/main/java/com/jsh/erp/service/person/PersonService.java @@ -43,63 +43,151 @@ public class PersonService { @Resource private DepotHeadMapperEx depotHeadMapperEx; - public Person getPerson(long id) { - return personMapper.selectByPrimaryKey(id); + public Person getPerson(long id)throws Exception { + Person result=null; + try{ + result=personMapper.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 getPerson() { + public List getPerson()throws Exception { PersonExample example = new PersonExample(); example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); - return personMapper.selectByExample(example); + List list=null; + try{ + list=personMapper.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, int offset, int rows) { - return personMapperEx.selectByConditionPerson(name, type, offset, rows); + public List select(String name, String type, int offset, int rows)throws Exception { + List list=null; + try{ + list=personMapperEx.selectByConditionPerson(name, type, 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 countPerson(String name, String type) { - return personMapperEx.countsByPerson(name, type); + public Long countPerson(String name, String type)throws Exception { + Long result=null; + try{ + result=personMapperEx.countsByPerson(name, type); + }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 insertPerson(String beanJson, HttpServletRequest request) { + public int insertPerson(String beanJson, HttpServletRequest request)throws Exception { Person person = JSONObject.parseObject(beanJson, Person.class); - return personMapper.insertSelective(person); + int result=0; + try{ + result=personMapper.insertSelective(person); + }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 updatePerson(String beanJson, Long id) { + public int updatePerson(String beanJson, Long id)throws Exception { Person person = JSONObject.parseObject(beanJson, Person.class); person.setId(id); - return personMapper.updateByPrimaryKeySelective(person); + int result=0; + try{ + result=personMapper.updateByPrimaryKeySelective(person); + }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 deletePerson(Long id) { - return personMapper.deleteByPrimaryKey(id); + public int deletePerson(Long id)throws Exception { + int result=0; + try{ + result=personMapper.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 batchDeletePerson(String ids) { + public int batchDeletePerson(String ids) throws Exception{ List idList = StringUtil.strToLongList(ids); PersonExample example = new PersonExample(); example.createCriteria().andIdIn(idList); - return personMapper.deleteByExample(example); + int result=0; + try{ + result=personMapper.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{ PersonExample example = new PersonExample(); example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); - List list = personMapper.selectByExample(example); - return list.size(); + List list =null; + try{ + list=personMapper.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 String getPersonByIds(String personIDs) { + public String getPersonByIds(String personIDs)throws Exception { List ids = StringUtil.strToLongList(personIDs); PersonExample example = new PersonExample(); example.createCriteria().andIdIn(ids).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.setOrderByClause("Id asc"); - List list = personMapper.selectByExample(example); + List list =null; + try{ + list=personMapper.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); + } StringBuffer sb = new StringBuffer(); if (null != list) { for (Person person : list) { @@ -109,11 +197,20 @@ public class PersonService { return sb.toString(); } - public List getPersonByType(String type) { + public List getPersonByType(String type)throws Exception { PersonExample example = new PersonExample(); example.createCriteria().andTypeEqualTo(type).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.setOrderByClause("Id asc"); - return personMapper.selectByExample(example); + List list =null; + try{ + list=personMapper.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) @@ -123,7 +220,16 @@ public class PersonService { ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); User userInfo=userService.getCurrentUser(); String [] idArray=ids.split(","); - return personMapperEx.batchDeletePersonByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); + int result =0; + try{ + result=personMapperEx.batchDeletePersonByIds(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 @@ -150,7 +256,15 @@ public class PersonService { /** * 校验财务主表 jsh_accounthead * */ - List accountHeadList=accountHeadMapperEx.getAccountHeadListByHandsPersonIds(idArray); + List accountHeadList =null; + try{ + accountHeadList=accountHeadMapperEx.getAccountHeadListByHandsPersonIds(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("异常码[{}],异常提示[{}],参数,HandsPersonIds[{}]", ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids); @@ -160,7 +274,15 @@ public class PersonService { /** * 校验单据主表 jsh_depothead * */ - List depotHeadList=depotHeadMapperEx.getDepotHeadListByHandsPersonIds(idArray); + List depotHeadList =null; + try{ + depotHeadList=depotHeadMapperEx.getDepotHeadListByHandsPersonIds(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("异常码[{}],异常提示[{}],参数,HandsPersonIds[{}]", ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids);