From ee04284ac16992c68070a029ad0c6e8ad8a85253 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A3=E5=9C=A3=E5=8D=8E?= <752718920@qq.com> Date: Sat, 18 Sep 2021 16:55:14 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=85=A5=E5=BA=93=E5=8D=95?= =?UTF-8?q?=E8=A2=AB=E5=88=A0=E4=B9=8B=E5=90=8E=EF=BC=8C=E5=85=B3=E8=81=94?= =?UTF-8?q?=E7=9A=84=E8=AE=A2=E5=8D=95=E7=8A=B6=E6=80=81=E4=B8=8D=E5=8F=98?= =?UTF-8?q?=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jsh/erp/constants/BusinessConstants.java | 2 +- .../jsh/erp/constants/ExceptionConstants.java | 6 ++ .../service/depotHead/DepotHeadService.java | 67 +++++++++++-------- 3 files changed, 47 insertions(+), 28 deletions(-) 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; }