异常封装之经手人信息后台修改

This commit is contained in:
qiankunpingtai
2019-04-19 10:31:34 +08:00
parent 1686ebb56f
commit f1ced5a839
3 changed files with 164 additions and 39 deletions

View File

@@ -30,7 +30,7 @@ public class PersonController {
private PersonService personService; private PersonService personService;
@GetMapping(value = "/getAllList") @GetMapping(value = "/getAllList")
public BaseResponseInfo getAllList(HttpServletRequest request) { public BaseResponseInfo getAllList(HttpServletRequest request)throws Exception {
BaseResponseInfo res = new BaseResponseInfo(); BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<String, Object>();
try { try {
@@ -53,7 +53,8 @@ public class PersonController {
* @return * @return
*/ */
@GetMapping(value = "/getPersonByIds") @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(); BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<String, Object>();
try { try {
@@ -76,7 +77,8 @@ public class PersonController {
* @return * @return
*/ */
@GetMapping(value = "/getPersonByType") @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(); BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<String, Object>();
try { try {
@@ -99,7 +101,8 @@ public class PersonController {
* @return * @return
*/ */
@PostMapping(value = "/getPersonByNumType") @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(); JSONArray dataArray = new JSONArray();
try { try {
String type = ""; String type = "";

View File

@@ -21,16 +21,16 @@ public class PersonComponent implements ICommonQuery {
private PersonService personService; private PersonService personService;
@Override @Override
public Object selectOne(String condition) { public Object selectOne(String condition)throws Exception {
return null; return null;
} }
@Override @Override
public List<?> select(Map<String, String> map) { public List<?> select(Map<String, String> map)throws Exception {
return getPersonList(map); return getPersonList(map);
} }
private List<?> getPersonList(Map<String, String> map) { private List<?> getPersonList(Map<String, String> map) throws Exception{
String search = map.get(Constants.SEARCH); String search = map.get(Constants.SEARCH);
String name = StringUtil.getInfo(search, "name"); String name = StringUtil.getInfo(search, "name");
String type = StringUtil.getInfo(search, "type"); String type = StringUtil.getInfo(search, "type");
@@ -39,7 +39,7 @@ public class PersonComponent implements ICommonQuery {
} }
@Override @Override
public Long counts(Map<String, String> map) { public Long counts(Map<String, String> map) throws Exception{
String search = map.get(Constants.SEARCH); String search = map.get(Constants.SEARCH);
String name = StringUtil.getInfo(search, "name"); String name = StringUtil.getInfo(search, "name");
String type = StringUtil.getInfo(search, "type"); String type = StringUtil.getInfo(search, "type");
@@ -47,27 +47,27 @@ public class PersonComponent implements ICommonQuery {
} }
@Override @Override
public int insert(String beanJson, HttpServletRequest request) { public int insert(String beanJson, HttpServletRequest request)throws Exception {
return personService.insertPerson(beanJson, request); return personService.insertPerson(beanJson, request);
} }
@Override @Override
public int update(String beanJson, Long id) { public int update(String beanJson, Long id)throws Exception {
return personService.updatePerson(beanJson, id); return personService.updatePerson(beanJson, id);
} }
@Override @Override
public int delete(Long id) { public int delete(Long id)throws Exception {
return personService.deletePerson(id); return personService.deletePerson(id);
} }
@Override @Override
public int batchDelete(String ids) { public int batchDelete(String ids)throws Exception {
return personService.batchDeletePerson(ids); return personService.batchDeletePerson(ids);
} }
@Override @Override
public int checkIsNameExist(Long id, String name) { public int checkIsNameExist(Long id, String name)throws Exception {
return personService.checkIsNameExist(id, name); return personService.checkIsNameExist(id, name);
} }

View File

@@ -43,63 +43,151 @@ public class PersonService {
@Resource @Resource
private DepotHeadMapperEx depotHeadMapperEx; private DepotHeadMapperEx depotHeadMapperEx;
public Person getPerson(long id) { public Person getPerson(long id)throws Exception {
return personMapper.selectByPrimaryKey(id); 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<Person> getPerson() { public List<Person> getPerson()throws Exception {
PersonExample example = new PersonExample(); PersonExample example = new PersonExample();
example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
return personMapper.selectByExample(example); List<Person> 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<Person> select(String name, String type, int offset, int rows) { public List<Person> select(String name, String type, int offset, int rows)throws Exception {
return personMapperEx.selectByConditionPerson(name, type, offset, rows); List<Person> 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) { public Long countPerson(String name, String type)throws Exception {
return personMapperEx.countsByPerson(name, type); 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) @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); 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) @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 person = JSONObject.parseObject(beanJson, Person.class);
person.setId(id); 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) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deletePerson(Long id) { public int deletePerson(Long id)throws Exception {
return personMapper.deleteByPrimaryKey(id); 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) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeletePerson(String ids) { public int batchDeletePerson(String ids) throws Exception{
List<Long> idList = StringUtil.strToLongList(ids); List<Long> idList = StringUtil.strToLongList(ids);
PersonExample example = new PersonExample(); PersonExample example = new PersonExample();
example.createCriteria().andIdIn(idList); 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(); PersonExample example = new PersonExample();
example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
List<Person> list = personMapper.selectByExample(example); List<Person> list =null;
return list.size(); 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<Long> ids = StringUtil.strToLongList(personIDs); List<Long> ids = StringUtil.strToLongList(personIDs);
PersonExample example = new PersonExample(); PersonExample example = new PersonExample();
example.createCriteria().andIdIn(ids).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.createCriteria().andIdIn(ids).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
example.setOrderByClause("Id asc"); example.setOrderByClause("Id asc");
List<Person> list = personMapper.selectByExample(example); List<Person> 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(); StringBuffer sb = new StringBuffer();
if (null != list) { if (null != list) {
for (Person person : list) { for (Person person : list) {
@@ -109,11 +197,20 @@ public class PersonService {
return sb.toString(); return sb.toString();
} }
public List<Person> getPersonByType(String type) { public List<Person> getPersonByType(String type)throws Exception {
PersonExample example = new PersonExample(); PersonExample example = new PersonExample();
example.createCriteria().andTypeEqualTo(type).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.createCriteria().andTypeEqualTo(type).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
example.setOrderByClause("Id asc"); example.setOrderByClause("Id asc");
return personMapper.selectByExample(example); List<Person> 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) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
@@ -123,7 +220,16 @@ public class PersonService {
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
User userInfo=userService.getCurrentUser(); User userInfo=userService.getCurrentUser();
String [] idArray=ids.split(","); 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 * create by: qiankunpingtai
@@ -150,7 +256,15 @@ public class PersonService {
/** /**
* 校验财务主表 jsh_accounthead * 校验财务主表 jsh_accounthead
* */ * */
List<AccountHead> accountHeadList=accountHeadMapperEx.getAccountHeadListByHandsPersonIds(idArray); List<AccountHead> 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){ if(accountHeadList!=null&&accountHeadList.size()>0){
logger.error("异常码[{}],异常提示[{}],参数,HandsPersonIds[{}]", logger.error("异常码[{}],异常提示[{}],参数,HandsPersonIds[{}]",
ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids); ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids);
@@ -160,7 +274,15 @@ public class PersonService {
/** /**
* 校验单据主表 jsh_depothead * 校验单据主表 jsh_depothead
* */ * */
List<DepotHead> depotHeadList=depotHeadMapperEx.getDepotHeadListByHandsPersonIds(idArray); List<DepotHead> 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){ if(depotHeadList!=null&&depotHeadList.size()>0){
logger.error("异常码[{}],异常提示[{}],参数,HandsPersonIds[{}]", logger.error("异常码[{}],异常提示[{}],参数,HandsPersonIds[{}]",
ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids); ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids);