异常封装之仓库信息后台修改

This commit is contained in:
qiankunpingtai
2019-04-17 10:47:36 +08:00
parent ae416e8fec
commit 8bfe0ba916
3 changed files with 183 additions and 44 deletions

View File

@@ -41,7 +41,7 @@ public class DepotController {
private UserBusinessService userBusinessService; private UserBusinessService userBusinessService;
@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();
try { try {
List<Depot> depotList = depotService.getAllList(); List<Depot> depotList = depotService.getAllList();
@@ -64,7 +64,7 @@ public class DepotController {
*/ */
@PostMapping(value = "/findUserDepot") @PostMapping(value = "/findUserDepot")
public JSONArray findUserDepot(@RequestParam("UBType") String type, @RequestParam("UBKeyId") String keyId, public JSONArray findUserDepot(@RequestParam("UBType") String type, @RequestParam("UBKeyId") String keyId,
HttpServletRequest request) { HttpServletRequest request) throws Exception{
JSONArray arr = new JSONArray(); JSONArray arr = new JSONArray();
try { try {
List<Depot> dataList = depotService.findUserDepot(); List<Depot> dataList = depotService.findUserDepot();
@@ -104,7 +104,7 @@ public class DepotController {
@RequestMapping(value = "/findDepotByUserId") @RequestMapping(value = "/findDepotByUserId")
public JSONArray findDepotByUserId(@RequestParam("UBType") String type, @RequestParam("UBKeyId") String keyId, public JSONArray findDepotByUserId(@RequestParam("UBType") String type, @RequestParam("UBKeyId") String keyId,
HttpServletRequest request) { HttpServletRequest request) throws Exception{
JSONArray arr = new JSONArray(); JSONArray arr = new JSONArray();
try { try {
List<Depot> dataList = depotService.findUserDepot(); List<Depot> dataList = depotService.findUserDepot();
@@ -145,7 +145,7 @@ public class DepotController {
public String getDepotList( public String getDepotList(
@RequestParam(value = Constants.PAGE_SIZE, required = false) Integer pageSize, @RequestParam(value = Constants.PAGE_SIZE, required = false) Integer pageSize,
@RequestParam(value = Constants.CURRENT_PAGE, required = false) Integer currentPage, @RequestParam(value = Constants.CURRENT_PAGE, required = false) Integer currentPage,
@RequestParam(value = Constants.SEARCH, required = false) String search) { @RequestParam(value = Constants.SEARCH, required = false) String search) throws Exception{
Map<String, Object> parameterMap = new HashMap<String, Object>(); Map<String, Object> parameterMap = new HashMap<String, Object>();
//查询参数 //查询参数
JSONObject obj=JSON.parseObject(search); JSONObject obj=JSON.parseObject(search);

View File

@@ -20,16 +20,16 @@ public class DepotComponent implements ICommonQuery {
private DepotService depotService; private DepotService depotService;
@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 getDepotList(map); return getDepotList(map);
} }
private List<?> getDepotList(Map<String, String> map) { private List<?> getDepotList(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"));
@@ -39,7 +39,7 @@ public class DepotComponent 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"));
@@ -48,27 +48,27 @@ public class DepotComponent implements ICommonQuery {
} }
@Override @Override
public int insert(String beanJson, HttpServletRequest request) { public int insert(String beanJson, HttpServletRequest request) throws Exception{
return depotService.insertDepot(beanJson, request); return depotService.insertDepot(beanJson, request);
} }
@Override @Override
public int update(String beanJson, Long id) { public int update(String beanJson, Long id)throws Exception {
return depotService.updateDepot(beanJson, id); return depotService.updateDepot(beanJson, id);
} }
@Override @Override
public int delete(Long id) { public int delete(Long id)throws Exception {
return depotService.deleteDepot(id); return depotService.deleteDepot(id);
} }
@Override @Override
public int batchDelete(String ids) { public int batchDelete(String ids)throws Exception {
return depotService.batchDeleteDepot(ids); return depotService.batchDeleteDepot(ids);
} }
@Override @Override
public int checkIsNameExist(Long id, String name) { public int checkIsNameExist(Long id, String name)throws Exception {
return depotService.checkIsNameExist(id, name); return depotService.checkIsNameExist(id, name);
} }

View File

@@ -41,91 +41,214 @@ public class DepotService {
@Resource @Resource
private DepotItemMapperEx depotItemMapperEx; private DepotItemMapperEx depotItemMapperEx;
public Depot getDepot(long id) { public Depot getDepot(long id)throws Exception {
return depotMapper.selectByPrimaryKey(id); Depot result=null;
try{
result=depotMapper.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<Depot> getDepot() { public List<Depot> getDepot()throws Exception {
DepotExample example = new DepotExample(); DepotExample example = new DepotExample();
example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
return depotMapper.selectByExample(example); List<Depot> list=null;
try{
list=depotMapper.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<Depot> getAllList() { public List<Depot> getAllList()throws Exception {
DepotExample example = new DepotExample(); DepotExample example = new DepotExample();
example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
example.setOrderByClause("sort"); example.setOrderByClause("sort");
return depotMapper.selectByExample(example); List<Depot> list=null;
try{
list=depotMapper.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<Depot> select(String name, Integer type, String remark, int offset, int rows) { public List<Depot> select(String name, Integer type, String remark, int offset, int rows)throws Exception {
return depotMapperEx.selectByConditionDepot(name, type, remark, offset, rows); List<Depot> list=null;
try{
list=depotMapperEx.selectByConditionDepot(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 countDepot(String name, Integer type, String remark) { public Long countDepot(String name, Integer type, String remark)throws Exception {
return depotMapperEx.countsByDepot(name, type, remark); Long result=null;
try{
result=depotMapperEx.countsByDepot(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 insertDepot(String beanJson, HttpServletRequest request) { public int insertDepot(String beanJson, HttpServletRequest request)throws Exception {
Depot depot = JSONObject.parseObject(beanJson, Depot.class); Depot depot = JSONObject.parseObject(beanJson, Depot.class);
return depotMapper.insertSelective(depot); int result=0;
try{
result=depotMapper.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) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateDepot(String beanJson, Long id) { public int updateDepot(String beanJson, Long id) throws Exception{
Depot depot = JSONObject.parseObject(beanJson, Depot.class); Depot depot = JSONObject.parseObject(beanJson, Depot.class);
depot.setId(id); depot.setId(id);
return depotMapper.updateByPrimaryKeySelective(depot); int result=0;
try{
result= depotMapper.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) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteDepot(Long id) { public int deleteDepot(Long id)throws Exception {
return depotMapper.deleteByPrimaryKey(id); int result=0;
try{
result= depotMapper.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 batchDeleteDepot(String ids) { public int batchDeleteDepot(String ids) throws Exception{
List<Long> idList = StringUtil.strToLongList(ids); List<Long> idList = StringUtil.strToLongList(ids);
DepotExample example = new DepotExample(); DepotExample example = new DepotExample();
example.createCriteria().andIdIn(idList); example.createCriteria().andIdIn(idList);
return depotMapper.deleteByExample(example); int result=0;
try{
result= depotMapper.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 {
DepotExample example = new DepotExample(); DepotExample example = new DepotExample();
example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
List<Depot> list = depotMapper.selectByExample(example); List<Depot> list=null;
return list.size(); try{
list= depotMapper.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<Depot> findUserDepot(){ public List<Depot> findUserDepot()throws Exception{
DepotExample example = new DepotExample(); DepotExample example = new DepotExample();
example.createCriteria().andTypeEqualTo(0).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.createCriteria().andTypeEqualTo(0).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
example.setOrderByClause("Sort"); example.setOrderByClause("Sort");
List<Depot> list = depotMapper.selectByExample(example); List<Depot> list=null;
try{
list= depotMapper.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; return list;
} }
public List<Depot> findGiftByType(Integer type){ public List<Depot> findGiftByType(Integer type)throws Exception{
DepotExample example = new DepotExample(); DepotExample example = new DepotExample();
example.createCriteria().andTypeEqualTo(type); example.createCriteria().andTypeEqualTo(type);
example.setOrderByClause("Sort"); example.setOrderByClause("Sort");
List<Depot> list = depotMapper.selectByExample(example); List<Depot> list=null;
try{
list= depotMapper.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; return list;
} }
public List<DepotEx> getDepotList(Map<String, Object> parameterMap) { public List<DepotEx> getDepotList(Map<String, Object> parameterMap)throws Exception {
return depotMapperEx.getDepotList(parameterMap); List<DepotEx> list=null;
try{
list= depotMapperEx.getDepotList(parameterMap);
}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 int batchDeleteDepotByIds(String ids) { public int batchDeleteDepotByIds(String ids)throws Exception {
logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_DEPOT, logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_DEPOT,
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 depotMapperEx.batchDeleteDepotByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); int result=0;
try{
result= depotMapperEx.batchDeleteDepotByIds(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
@@ -153,7 +276,15 @@ public class DepotService {
/** /**
* 校验单据主表 jsh_depothead * 校验单据主表 jsh_depothead
* */ * */
List<DepotHead> depotHeadList=depotHeadMapperEx.getDepotHeadListByDepotIds(idArray); List<DepotHead> depotHeadList=null;
try{
depotHeadList= depotHeadMapperEx.getDepotHeadListByDepotIds(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("异常码[{}],异常提示[{}],参数,DepotIds[{}]", logger.error("异常码[{}],异常提示[{}],参数,DepotIds[{}]",
ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids); ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids);
@@ -163,7 +294,15 @@ public class DepotService {
/** /**
* 校验单据子表 jsh_depotitem * 校验单据子表 jsh_depotitem
* */ * */
List<DepotItem> depotItemList=depotItemMapperEx.getDepotItemListListByDepotIds(idArray); List<DepotItem> depotItemList=null;
try{
depotItemList= depotItemMapperEx.getDepotItemListListByDepotIds(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(depotItemList!=null&&depotItemList.size()>0){ if(depotItemList!=null&&depotItemList.size()>0){
logger.error("异常码[{}],异常提示[{}],参数,DepotIds[{}]", logger.error("异常码[{}],异常提示[{}],参数,DepotIds[{}]",
ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids); ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids);