异常封装之财务明细信息后台修改

This commit is contained in:
qiankunpingtai
2019-04-17 09:42:46 +08:00
parent edfb696f92
commit afcf2edb4c
3 changed files with 157 additions and 38 deletions

View File

@@ -55,7 +55,7 @@ public class AccountItemController {
@RequestParam("updated") String updated, @RequestParam("updated") String updated,
@RequestParam("headerId") Long headerId, @RequestParam("headerId") Long headerId,
@RequestParam("listType") String listType, @RequestParam("listType") String listType,
HttpServletRequest request) { HttpServletRequest request) throws Exception{
Map<String, Object> objectMap = new HashMap<String, Object>(); Map<String, Object> objectMap = new HashMap<String, Object>();
try { try {
@@ -70,7 +70,7 @@ public class AccountItemController {
@GetMapping(value = "/getDetailList") @GetMapping(value = "/getDetailList")
public BaseResponseInfo getDetailList(@RequestParam("headerId") Long headerId, public BaseResponseInfo getDetailList(@RequestParam("headerId") Long headerId,
HttpServletRequest request) { 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 {

View File

@@ -19,16 +19,16 @@ public class AccountItemComponent implements ICommonQuery {
private AccountItemService accountItemService; private AccountItemService accountItemService;
@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 getAccountItemList(map); return getAccountItemList(map);
} }
private List<?> getAccountItemList(Map<String, String> map) { private List<?> getAccountItemList(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");
Integer type = StringUtil.parseInteger(StringUtil.getInfo(search, "type")); Integer type = StringUtil.parseInteger(StringUtil.getInfo(search, "type"));
@@ -38,7 +38,7 @@ public class AccountItemComponent 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");
Integer type = StringUtil.parseInteger(StringUtil.getInfo(search, "type")); Integer type = StringUtil.parseInteger(StringUtil.getInfo(search, "type"));
@@ -47,27 +47,27 @@ public class AccountItemComponent implements ICommonQuery {
} }
@Override @Override
public int insert(String beanJson, HttpServletRequest request) { public int insert(String beanJson, HttpServletRequest request) throws Exception{
return accountItemService.insertAccountItem(beanJson, request); return accountItemService.insertAccountItem(beanJson, request);
} }
@Override @Override
public int update(String beanJson, Long id) { public int update(String beanJson, Long id)throws Exception {
return accountItemService.updateAccountItem(beanJson, id); return accountItemService.updateAccountItem(beanJson, id);
} }
@Override @Override
public int delete(Long id) { public int delete(Long id)throws Exception {
return accountItemService.deleteAccountItem(id); return accountItemService.deleteAccountItem(id);
} }
@Override @Override
public int batchDelete(String ids) { public int batchDelete(String ids)throws Exception {
return accountItemService.batchDeleteAccountItem(ids); return accountItemService.batchDeleteAccountItem(ids);
} }
@Override @Override
public int checkIsNameExist(Long id, String name) { public int checkIsNameExist(Long id, String name)throws Exception {
return accountItemService.checkIsNameExist(id, name); return accountItemService.checkIsNameExist(id, name);
} }

View File

@@ -3,12 +3,15 @@ package com.jsh.erp.service.accountItem;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.constants.BusinessConstants; import com.jsh.erp.constants.BusinessConstants;
import com.jsh.erp.constants.ExceptionConstants;
import com.jsh.erp.datasource.entities.AccountHead;
import com.jsh.erp.datasource.entities.AccountItem; import com.jsh.erp.datasource.entities.AccountItem;
import com.jsh.erp.datasource.entities.AccountItemExample; import com.jsh.erp.datasource.entities.AccountItemExample;
import com.jsh.erp.datasource.entities.User; import com.jsh.erp.datasource.entities.User;
import com.jsh.erp.datasource.mappers.AccountItemMapper; import com.jsh.erp.datasource.mappers.AccountItemMapper;
import com.jsh.erp.datasource.mappers.AccountItemMapperEx; import com.jsh.erp.datasource.mappers.AccountItemMapperEx;
import com.jsh.erp.datasource.vo.AccountItemVo4List; import com.jsh.erp.datasource.vo.AccountItemVo4List;
import com.jsh.erp.exception.BusinessRunTimeException;
import com.jsh.erp.service.log.LogService; import com.jsh.erp.service.log.LogService;
import com.jsh.erp.service.user.UserService; import com.jsh.erp.service.user.UserService;
import com.jsh.erp.utils.ErpInfo; import com.jsh.erp.utils.ErpInfo;
@@ -43,72 +46,179 @@ public class AccountItemService {
@Resource @Resource
private UserService userService; private UserService userService;
public AccountItem getAccountItem(long id) { public AccountItem getAccountItem(long id)throws Exception {
return accountItemMapper.selectByPrimaryKey(id); AccountItem result=null;
try{
result=accountItemMapper.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<AccountItem> getAccountItem() { public List<AccountItem> getAccountItem()throws Exception {
AccountItemExample example = new AccountItemExample(); AccountItemExample example = new AccountItemExample();
example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
return accountItemMapper.selectByExample(example); List<AccountItem> list=null;
try{
list=accountItemMapper.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<AccountItem> select(String name, Integer type, String remark, int offset, int rows) { public List<AccountItem> select(String name, Integer type, String remark, int offset, int rows)throws Exception {
return accountItemMapperEx.selectByConditionAccountItem(name, type, remark, offset, rows); List<AccountItem> list=null;
try{
list = accountItemMapperEx.selectByConditionAccountItem(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 countAccountItem(String name, Integer type, String remark) { public Long countAccountItem(String name, Integer type, String remark)throws Exception {
return accountItemMapperEx.countsByAccountItem(name, type, remark); Long result=null;
try{
result = accountItemMapperEx.countsByAccountItem(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) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertAccountItem(String beanJson, HttpServletRequest request) { public int insertAccountItem(String beanJson, HttpServletRequest request) throws Exception{
AccountItem accountItem = JSONObject.parseObject(beanJson, AccountItem.class); AccountItem accountItem = JSONObject.parseObject(beanJson, AccountItem.class);
return accountItemMapper.insertSelective(accountItem); int result=0;
try{
result = accountItemMapper.insertSelective(accountItem);
}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 updateAccountItem(String beanJson, Long id) { public int updateAccountItem(String beanJson, Long id)throws Exception {
AccountItem accountItem = JSONObject.parseObject(beanJson, AccountItem.class); AccountItem accountItem = JSONObject.parseObject(beanJson, AccountItem.class);
accountItem.setId(id); accountItem.setId(id);
return accountItemMapper.updateByPrimaryKeySelective(accountItem); int result=0;
try{
result = accountItemMapper.updateByPrimaryKeySelective(accountItem);
}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 deleteAccountItem(Long id) { public int deleteAccountItem(Long id)throws Exception {
return accountItemMapper.deleteByPrimaryKey(id); int result=0;
try{
result = accountItemMapper.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 batchDeleteAccountItem(String ids) { public int batchDeleteAccountItem(String ids)throws Exception {
List<Long> idList = StringUtil.strToLongList(ids); List<Long> idList = StringUtil.strToLongList(ids);
AccountItemExample example = new AccountItemExample(); AccountItemExample example = new AccountItemExample();
example.createCriteria().andIdIn(idList); example.createCriteria().andIdIn(idList);
return accountItemMapper.deleteByExample(example); int result=0;
try{
result = accountItemMapper.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 {
AccountItemExample example = new AccountItemExample(); AccountItemExample example = new AccountItemExample();
example.createCriteria().andIdNotEqualTo(id).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.createCriteria().andIdNotEqualTo(id).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
List<AccountItem> list = accountItemMapper.selectByExample(example); List<AccountItem> list = null;
return list.size(); try{
list = accountItemMapper.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();
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertAccountItemWithObj(AccountItem accountItem) { public int insertAccountItemWithObj(AccountItem accountItem)throws Exception {
return accountItemMapper.insertSelective(accountItem); int result=0;
try{
result = accountItemMapper.insertSelective(accountItem);
}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 updateAccountItemWithObj(AccountItem accountItem) { public int updateAccountItemWithObj(AccountItem accountItem)throws Exception {
return accountItemMapper.updateByPrimaryKeySelective(accountItem); int result=0;
try{
result = accountItemMapper.updateByPrimaryKeySelective(accountItem);
}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 List<AccountItemVo4List> getDetailList(Long headerId) { public List<AccountItemVo4List> getDetailList(Long headerId) {
return accountItemMapperEx.getDetailList(headerId); List<AccountItemVo4List> list=null;
try{
list = accountItemMapperEx.getDetailList(headerId);
}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)
public String saveDetials(String inserted, String deleted, String updated, Long headerId, String listType) throws DataAccessException { public String saveDetials(String inserted, String deleted, String updated, Long headerId, String listType) throws Exception {
logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_ACCOUNT_ITEM, logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_ACCOUNT_ITEM,
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(",headerId:").append(headerId).toString(), new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(",headerId:").append(headerId).toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
@@ -181,12 +291,21 @@ public class AccountItemService {
return null; return null;
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteAccountItemByIds(String ids) { public int batchDeleteAccountItemByIds(String ids) throws Exception{
logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_ACCOUNT_ITEM, logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_ACCOUNT_ITEM,
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(), new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(),
((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 accountItemMapperEx.batchDeleteAccountItemByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); int result=0;
try{
result = accountItemMapperEx.batchDeleteAccountItemByIds(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;
} }
} }