diff --git a/jshERP-boot/src/main/java/com/jsh/erp/constants/BusinessConstants.java b/jshERP-boot/src/main/java/com/jsh/erp/constants/BusinessConstants.java index fb68641e..62910b04 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/constants/BusinessConstants.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/constants/BusinessConstants.java @@ -37,7 +37,7 @@ public class BusinessConstants { * 单据主表出入库类型 type 入库 出库 * depothead * */ - public static final String DEPOTHEAD_TYPE_STORAGE = "入库"; + public static final String DEPOTHEAD_TYPE_IN = "入库"; public static final String DEPOTHEAD_TYPE_OUT = "出库"; /** * 付款类型 payType //现付/预付款 diff --git a/jshERP-boot/src/main/java/com/jsh/erp/constants/ExceptionConstants.java b/jshERP-boot/src/main/java/com/jsh/erp/constants/ExceptionConstants.java index fb538e7e..f972df61 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/constants/ExceptionConstants.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/constants/ExceptionConstants.java @@ -330,6 +330,12 @@ public class ExceptionConstants { //单据删除-只有未审核的单据才能删除 public static final int DEPOT_HEAD_UN_AUDIT_DELETE_FAILED_CODE = 8500011; public static final String DEPOT_HEAD_UN_AUDIT_DELETE_FAILED_MSG = "抱歉,只有未审核的单据才能删除"; + //单据审核-只有未审核的单据才能审核 + public static final int DEPOT_HEAD_UN_AUDIT_TO_AUDIT_FAILED_CODE = 8500012; + public static final String DEPOT_HEAD_UN_AUDIT_TO_AUDIT_FAILED_MSG = "抱歉,只有未审核的单据才能审核"; + //单据反审核-只有已审核的单据才能反审核 + public static final int DEPOT_HEAD_AUDIT_TO_UN_AUDIT_FAILED_CODE = 8500013; + public static final String DEPOT_HEAD_AUDIT_TO_UN_AUDIT_FAILED_MSG = "抱歉,只有已审核的单据才能反审核"; /** * 单据明细信息 * type = 90 diff --git a/jshERP-boot/src/main/java/com/jsh/erp/service/depotHead/DepotHeadService.java b/jshERP-boot/src/main/java/com/jsh/erp/service/depotHead/DepotHeadService.java index e0e046f7..9c45b7cb 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/service/depotHead/DepotHeadService.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/service/depotHead/DepotHeadService.java @@ -284,15 +284,28 @@ public class DepotHeadService { } } } - /**删除单据子表数据*/ + //删除单据子表数据 depotItemMapperEx.batchDeleteDepotItemByDepotHeadIds(new Long[]{depotHead.getId()}); + //删除单据主表信息 + batchDeleteDepotHeadByIds(depotHead.getId().toString()); + //将关联的订单置为审核状态-针对采购入库和销售出库 + if(StringUtil.isNotEmpty(depotHead.getLinkNumber())){ + if((BusinessConstants.DEPOTHEAD_TYPE_IN.equals(depotHead.getType()) && + BusinessConstants.SUB_TYPE_PURCHASE.equals(depotHead.getSubType())) + || (BusinessConstants.DEPOTHEAD_TYPE_OUT.equals(depotHead.getType()) && + BusinessConstants.SUB_TYPE_SALES.equals(depotHead.getSubType()))) { + DepotHead dh = new DepotHead(); + dh.setStatus(BusinessConstants.BILLS_STATUS_AUDIT); + DepotHeadExample example = new DepotHeadExample(); + example.createCriteria().andNumberEqualTo(depotHead.getLinkNumber()); + depotHeadMapper.updateByExampleSelective(dh, example); + } + } //更新当前库存 List list = depotItemService.getListByHeaderId(depotHead.getId()); for (DepotItem depotItem : list) { depotItemService.updateCurrentStock(depotItem); } - /**删除单据主表信息*/ - batchDeleteDepotHeadByIds(depotHead.getId().toString()); } else { throw new BusinessRunTimeException(ExceptionConstants.DEPOT_HEAD_UN_AUDIT_DELETE_FAILED_CODE, String.format(ExceptionConstants.DEPOT_HEAD_UN_AUDIT_DELETE_FAILED_MSG)); @@ -350,32 +363,32 @@ public class DepotHeadService { @Transactional(value = "transactionManager", rollbackFor = Exception.class) public int batchSetStatus(String status, String depotHeadIDs)throws Exception { int result = 0; - try{ - List dhIds = new ArrayList<>(); - List ids = StringUtil.strToLongList(depotHeadIDs); - for(Long id: ids) { - DepotHead depotHead = getDepotHead(id); - if("0".equals(status)){ - if("1".equals(depotHead.getStatus())) { - dhIds.add(id); - } - } else if("1".equals(status)){ - if("0".equals(depotHead.getStatus())) { - dhIds.add(id); - } + List dhIds = new ArrayList<>(); + List ids = StringUtil.strToLongList(depotHeadIDs); + for(Long id: ids) { + DepotHead depotHead = getDepotHead(id); + if("0".equals(status)){ + if("1".equals(depotHead.getStatus())) { + dhIds.add(id); + } else { + throw new BusinessRunTimeException(ExceptionConstants.DEPOT_HEAD_AUDIT_TO_UN_AUDIT_FAILED_CODE, + String.format(ExceptionConstants.DEPOT_HEAD_AUDIT_TO_UN_AUDIT_FAILED_MSG)); + } + } else if("1".equals(status)){ + if("0".equals(depotHead.getStatus())) { + dhIds.add(id); + } else { + throw new BusinessRunTimeException(ExceptionConstants.DEPOT_HEAD_UN_AUDIT_TO_AUDIT_FAILED_CODE, + String.format(ExceptionConstants.DEPOT_HEAD_UN_AUDIT_TO_AUDIT_FAILED_MSG)); } } - if(dhIds.size()>0) { - DepotHead depotHead = new DepotHead(); - depotHead.setStatus(status); - DepotHeadExample example = new DepotHeadExample(); - example.createCriteria().andIdIn(dhIds); - result = depotHeadMapper.updateByExampleSelective(depotHead, example); - } else { - return 1; - } - }catch(Exception e){ - JshException.writeFail(logger, e); + } + if(dhIds.size()>0) { + DepotHead depotHead = new DepotHead(); + depotHead.setStatus(status); + DepotHeadExample example = new DepotHeadExample(); + example.createCriteria().andIdIn(dhIds); + result = depotHeadMapper.updateByExampleSelective(depotHead, example); } return result; }