From ca6c23f2a3237b043f323d58cf651ce0e00ea56c Mon Sep 17 00:00:00 2001 From: qiankunpingtai Date: Thu, 18 Apr 2019 10:21:50 +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=8D=95=E6=8D=AE=E4=BF=A1=E6=81=AF=E5=90=8E=E5=8F=B0=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../erp/controller/DepotHeadController.java | 2 +- .../service/depotHead/DepotHeadComponent.java | 18 +- .../service/depotHead/DepotHeadService.java | 372 +++++++++++++++--- 3 files changed, 326 insertions(+), 66 deletions(-) diff --git a/src/main/java/com/jsh/erp/controller/DepotHeadController.java b/src/main/java/com/jsh/erp/controller/DepotHeadController.java index 7b8f0aaa..78b6c628 100644 --- a/src/main/java/com/jsh/erp/controller/DepotHeadController.java +++ b/src/main/java/com/jsh/erp/controller/DepotHeadController.java @@ -55,7 +55,7 @@ public class DepotHeadController { @PostMapping(value = "/batchSetStatus") public String batchSetStatus(@RequestParam("status") String status, @RequestParam("depotHeadIDs") String depotHeadIDs, - HttpServletRequest request) { + HttpServletRequest request) throws Exception{ Map objectMap = new HashMap(); int res = depotHeadService.batchSetStatus(status, depotHeadIDs); if(res > 0) { diff --git a/src/main/java/com/jsh/erp/service/depotHead/DepotHeadComponent.java b/src/main/java/com/jsh/erp/service/depotHead/DepotHeadComponent.java index 5f91eb1c..ba817286 100644 --- a/src/main/java/com/jsh/erp/service/depotHead/DepotHeadComponent.java +++ b/src/main/java/com/jsh/erp/service/depotHead/DepotHeadComponent.java @@ -19,16 +19,16 @@ public class DepotHeadComponent implements ICommonQuery { private DepotHeadService depotHeadService; @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 getDepotHeadList(map); } - private List getDepotHeadList(Map map) { + private List getDepotHeadList(Map map)throws Exception { String search = map.get(Constants.SEARCH); String type = StringUtil.getInfo(search, "type"); String subType = StringUtil.getInfo(search, "subType"); @@ -41,7 +41,7 @@ public class DepotHeadComponent implements ICommonQuery { } @Override - public Long counts(Map map) { + public Long counts(Map map)throws Exception { String search = map.get(Constants.SEARCH); String type = StringUtil.getInfo(search, "type"); String subType = StringUtil.getInfo(search, "subType"); @@ -53,27 +53,27 @@ public class DepotHeadComponent implements ICommonQuery { } @Override - public int insert(String beanJson, HttpServletRequest request) { + public int insert(String beanJson, HttpServletRequest request) throws Exception{ return depotHeadService.insertDepotHead(beanJson, request); } @Override - public int update(String beanJson, Long id) { + public int update(String beanJson, Long id)throws Exception { return depotHeadService.updateDepotHead(beanJson, id); } @Override - public int delete(Long id) { + public int delete(Long id)throws Exception { return depotHeadService.deleteDepotHead(id); } @Override - public int batchDelete(String ids) { + public int batchDelete(String ids)throws Exception { return depotHeadService.batchDeleteDepotHead(ids); } @Override - public int checkIsNameExist(Long id, String name) { + public int checkIsNameExist(Long id, String name)throws Exception { return depotHeadService.checkIsNameExist(id, name); } diff --git a/src/main/java/com/jsh/erp/service/depotHead/DepotHeadService.java b/src/main/java/com/jsh/erp/service/depotHead/DepotHeadService.java index a78aba33..28df070a 100644 --- a/src/main/java/com/jsh/erp/service/depotHead/DepotHeadService.java +++ b/src/main/java/com/jsh/erp/service/depotHead/DepotHeadService.java @@ -2,6 +2,7 @@ package com.jsh.erp.service.depotHead; import com.alibaba.fastjson.JSONObject; import com.jsh.erp.constants.BusinessConstants; +import com.jsh.erp.constants.ExceptionConstants; import com.jsh.erp.datasource.entities.DepotHead; import com.jsh.erp.datasource.entities.DepotHeadExample; import com.jsh.erp.datasource.entities.DepotItem; @@ -13,6 +14,7 @@ import com.jsh.erp.datasource.vo.DepotHeadVo4InDetail; import com.jsh.erp.datasource.vo.DepotHeadVo4InOutMCount; import com.jsh.erp.datasource.vo.DepotHeadVo4List; import com.jsh.erp.datasource.vo.DepotHeadVo4StatementAccount; +import com.jsh.erp.exception.BusinessRunTimeException; import com.jsh.erp.service.depotItem.DepotItemService; import com.jsh.erp.service.log.LogService; import com.jsh.erp.service.serialNumber.SerialNumberService; @@ -58,19 +60,45 @@ public class DepotHeadService { private LogService logService; - public DepotHead getDepotHead(long id) { - return depotHeadMapper.selectByPrimaryKey(id); + public DepotHead getDepotHead(long id)throws Exception { + DepotHead result=null; + try{ + result=depotHeadMapper.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 getDepotHead() { + public List getDepotHead()throws Exception { DepotHeadExample example = new DepotHeadExample(); example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); - return depotHeadMapper.selectByExample(example); + List list=null; + try{ + list=depotHeadMapper.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 type, String subType, String number, String beginTime, String endTime, String dhIds, int offset, int rows) { + public List select(String type, String subType, String number, String beginTime, String endTime, String dhIds, int offset, int rows)throws Exception { List resList = new ArrayList(); - List list = depotHeadMapperEx.selectByConditionDepotHead(type, subType, number, beginTime, endTime, dhIds, offset, rows); + List list=null; + try{ + list=depotHeadMapperEx.selectByConditionDepotHead(type, subType, number, beginTime, endTime, dhIds, 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); + } if (null != list) { for (DepotHeadVo4List dh : list) { if(dh.getOthermoneylist() != null) { @@ -97,12 +125,21 @@ public class DepotHeadService { - public Long countDepotHead(String type, String subType, String number, String beginTime, String endTime, String dhIds) { - return depotHeadMapperEx.countsByDepotHead(type, subType, number, beginTime, endTime, dhIds); + public Long countDepotHead(String type, String subType, String number, String beginTime, String endTime, String dhIds) throws Exception{ + Long result=null; + try{ + result=depotHeadMapperEx.countsByDepotHead(type, subType, number, beginTime, endTime, dhIds); + }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 insertDepotHead(String beanJson, HttpServletRequest request) { + public int insertDepotHead(String beanJson, HttpServletRequest request)throws Exception { DepotHead depotHead = JSONObject.parseObject(beanJson, DepotHead.class); //判断用户是否已经登录过,登录过不再处理 Object userInfo = request.getSession().getAttribute("user"); @@ -113,42 +150,94 @@ public class DepotHeadService { } depotHead.setCreatetime(new Timestamp(System.currentTimeMillis())); depotHead.setStatus(BusinessConstants.BILLS_STATUS_UN_AUDIT); - return depotHeadMapper.insert(depotHead); + int result=0; + try{ + result=depotHeadMapper.insert(depotHead); + }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 updateDepotHead(String beanJson, Long id) { - DepotHead dh = depotHeadMapper.selectByPrimaryKey(id); + public int updateDepotHead(String beanJson, Long id) throws Exception{ + DepotHead dh=null; + try{ + dh = depotHeadMapper.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); + } DepotHead depotHead = JSONObject.parseObject(beanJson, DepotHead.class); depotHead.setId(id); depotHead.setStatus(dh.getStatus()); depotHead.setCreatetime(dh.getCreatetime()); depotHead.setOperpersonname(dh.getOperpersonname()); - return depotHeadMapper.updateByPrimaryKey(depotHead); + int result=0; + try{ + result = depotHeadMapper.updateByPrimaryKey(depotHead); + }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 deleteDepotHead(Long id) { - return depotHeadMapper.deleteByPrimaryKey(id); + public int deleteDepotHead(Long id)throws Exception { + int result=0; + try{ + result = depotHeadMapper.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 batchDeleteDepotHead(String ids) { + public int batchDeleteDepotHead(String ids)throws Exception { List idList = StringUtil.strToLongList(ids); DepotHeadExample example = new DepotHeadExample(); example.createCriteria().andIdIn(idList); - return depotHeadMapper.deleteByExample(example); + int result=0; + try{ + result = depotHeadMapper.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 { DepotHeadExample example = new DepotHeadExample(); example.createCriteria().andIdNotEqualTo(id).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); - List list = depotHeadMapper.selectByExample(example); - return list.size(); + List list = null; + try{ + list = depotHeadMapper.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) - public int batchSetStatus(String status, String depotHeadIDs) { + public int batchSetStatus(String status, String depotHeadIDs)throws Exception { logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_DEPOT_HEAD, new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(depotHeadIDs).toString(), ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); @@ -157,15 +246,32 @@ public class DepotHeadService { depotHead.setStatus(status); DepotHeadExample example = new DepotHeadExample(); example.createCriteria().andIdIn(ids); - return depotHeadMapper.updateByExampleSelective(depotHead, example); + int result = 0; + try{ + result = depotHeadMapper.updateByExampleSelective(depotHead, 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 String buildOnlyNumber(){ + public String buildOnlyNumber()throws Exception{ Long buildOnlyNumber=null; synchronized (this){ - buildOnlyNumber= depotHeadMapperEx.getBuildOnlyNumber(BusinessConstants.DEPOT_NUMBER_SEQ); + try{ + buildOnlyNumber= depotHeadMapperEx.getBuildOnlyNumber(BusinessConstants.DEPOT_NUMBER_SEQ); + }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); + } + } if(buildOnlyNumber findByMonth(String monthTime) { + public List findByMonth(String monthTime)throws Exception { DepotHeadExample example = new DepotHeadExample(); monthTime = monthTime + "-31 23:59:59"; Date month = StringUtil.getDateByString(monthTime, null); example.createCriteria().andOpertimeLessThanOrEqualTo(month).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); - return depotHeadMapper.selectByExample(example); + List list = null; + try{ + list = depotHeadMapper.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 getDepotHeadGiftOut(String projectId) { + public List getDepotHeadGiftOut(String projectId)throws Exception { DepotHeadExample example = new DepotHeadExample(); if (projectId != null) { example.createCriteria().andProjectidEqualTo(Long.parseLong(projectId)); } - return depotHeadMapper.selectByExample(example); + List list = null; + try{ + list =depotHeadMapper.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 findByAll(String beginTime, String endTime, String type, Integer pid, String dids, Integer oId, Integer offset, Integer rows) { - return depotHeadMapperEx.findByAll(beginTime, endTime, type, pid, dids, oId, offset, rows); + public List findByAll(String beginTime, String endTime, String type, Integer pid, String dids, Integer oId, Integer offset, Integer rows) throws Exception{ + List list = null; + try{ + list =depotHeadMapperEx.findByAll(beginTime, endTime, type, pid, dids, oId, 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 int findByAllCount(String beginTime, String endTime, String type, Integer pid, String dids, Integer oId) { - return depotHeadMapperEx.findByAllCount(beginTime, endTime, type, pid, dids, oId); + public int findByAllCount(String beginTime, String endTime, String type, Integer pid, String dids, Integer oId) throws Exception{ + int result = 0; + try{ + result =depotHeadMapperEx.findByAllCount(beginTime, endTime, type, pid, dids, oId); + }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 findInOutMaterialCount(String beginTime, String endTime, String type, Integer pid, String dids, Integer oId, Integer offset, Integer rows) { - return depotHeadMapperEx.findInOutMaterialCount(beginTime, endTime, type, pid, dids, oId, offset, rows); + public List findInOutMaterialCount(String beginTime, String endTime, String type, Integer pid, String dids, Integer oId, Integer offset, Integer rows)throws Exception { + List list = null; + try{ + list =depotHeadMapperEx.findInOutMaterialCount(beginTime, endTime, type, pid, dids, oId, 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 int findInOutMaterialCountTotal(String beginTime, String endTime, String type, Integer pid, String dids, Integer oId) { - return depotHeadMapperEx.findInOutMaterialCountTotal(beginTime, endTime, type, pid, dids, oId); + public int findInOutMaterialCountTotal(String beginTime, String endTime, String type, Integer pid, String dids, Integer oId)throws Exception { + int result = 0; + try{ + result =depotHeadMapperEx.findInOutMaterialCountTotal(beginTime, endTime, type, pid, dids, oId); + }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 findStatementAccount(String beginTime, String endTime, Integer organId, String supType, Integer offset, Integer rows) { - return depotHeadMapperEx.findStatementAccount(beginTime, endTime, organId, supType, offset, rows); + public List findStatementAccount(String beginTime, String endTime, Integer organId, String supType, Integer offset, Integer rows)throws Exception { + List list = null; + try{ + list =depotHeadMapperEx.findStatementAccount(beginTime, endTime, organId, supType, 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 int findStatementAccountCount(String beginTime, String endTime, Integer organId, String supType) { - return depotHeadMapperEx.findStatementAccountCount(beginTime, endTime, organId, supType); + public int findStatementAccountCount(String beginTime, String endTime, Integer organId, String supType) throws Exception{ + int result = 0; + try{ + result =depotHeadMapperEx.findStatementAccountCount(beginTime, endTime, organId, supType); + }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 BigDecimal findAllMoney(Integer supplierId, String type, String subType, String mode, String endTime) { + public BigDecimal findAllMoney(Integer supplierId, String type, String subType, String mode, String endTime)throws Exception { String modeName = ""; if (mode.equals("实际")) { modeName = "ChangeAmount"; } else if (mode.equals("合计")) { modeName = "DiscountLastMoney"; } - return depotHeadMapperEx.findAllMoney(supplierId, type, subType, modeName, endTime); + BigDecimal result = null; + try{ + result =depotHeadMapperEx.findAllMoney(supplierId, type, subType, modeName, endTime); + }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 getDetailByNumber(String number) { + public List getDetailByNumber(String number)throws Exception { List resList = new ArrayList(); - List list = depotHeadMapperEx.getDetailByNumber(number); + List list = null; + try{ + list = depotHeadMapperEx.getDetailByNumber(number); + }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 (null != list) { for (DepotHeadVo4List dh : list) { if(dh.getOthermoneylist() != null) { @@ -288,7 +500,15 @@ public class DepotHeadService { depotHead.setOperpersonname(userInfo==null?null:userInfo.getUsername()); depotHead.setCreatetime(new Timestamp(System.currentTimeMillis())); depotHead.setStatus(BusinessConstants.BILLS_STATUS_UN_AUDIT); - depotHeadMapperEx.adddepotHead(depotHead); + try{ + depotHeadMapperEx.adddepotHead(depotHead); + }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); + } + /**入库和出库处理预付款信息*/ if(BusinessConstants.PAY_TYPE_PREPAID.equals(depotHead.getPaytype())){ if(depotHead.getOrganid()!=null) { @@ -303,7 +523,14 @@ public class DepotHeadService { depotHeadOrders.setStatus(BusinessConstants.BILLS_STATUS_SKIP); DepotHeadExample example = new DepotHeadExample(); example.createCriteria().andNumberEqualTo(depotHead.getLinknumber()); - depotHeadMapper.updateByExampleSelective(depotHeadOrders, example); + try{ + depotHeadMapper.updateByExampleSelective(depotHeadOrders, 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); + } } } /** @@ -331,7 +558,14 @@ public class DepotHeadService { User userInfo=userService.getCurrentUser(); depotHead.setOperpersonname(userInfo==null?null:userInfo.getUsername()); depotHead.setOpertime(new Timestamp(System.currentTimeMillis())); - depotHeadMapperEx.updatedepotHead(depotHead); + try{ + depotHeadMapperEx.updatedepotHead(depotHead); + }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); + } /**入库和出库处理预付款信息*/ if(BusinessConstants.PAY_TYPE_PREPAID.equals(depotHead.getPaytype())){ if(depotHead.getOrganid()!=null){ @@ -362,7 +596,16 @@ public class DepotHeadService { if(BusinessConstants.DEPOTHEAD_TYPE_OUT.equals(depotHead.getType()) &&!BusinessConstants.SUB_TYPE_TRANSFER.equals(depotHead.getSubtype())){ //查询单据子表列表 - List depotItemList = depotItemMapperEx.findDepotItemListBydepotheadId(id,BusinessConstants.ENABLE_SERIAL_NUMBER_ENABLED); + List depotItemList=null; + try{ + depotItemList = depotItemMapperEx.findDepotItemListBydepotheadId(id,BusinessConstants.ENABLE_SERIAL_NUMBER_ENABLED); + }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){ for(DepotItem depotItem:depotItemList){ @@ -372,7 +615,15 @@ public class DepotHeadService { } } /**删除单据子表数据*/ - depotItemMapperEx.batchDeleteDepotItemByDepotHeadIds(new Long []{id}); + try{ + depotItemMapperEx.batchDeleteDepotItemByDepotHeadIds(new Long []{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); + } + /**删除单据主表信息*/ batchDeleteDepotHeadByIds(id.toString()); } @@ -397,12 +648,21 @@ public class DepotHeadService { } } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int batchDeleteDepotHeadByIds(String ids) { + public int batchDeleteDepotHeadByIds(String ids)throws Exception { logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_DEPOT_HEAD, new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(), ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); User userInfo=userService.getCurrentUser(); String [] idArray=ids.split(","); - return depotHeadMapperEx.batchDeleteDepotHeadByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); + int result=0; + try{ + result = depotHeadMapperEx.batchDeleteDepotHeadByIds(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; } }