From 174620b8a1c956b648df16caebc6346e29f50e3e Mon Sep 17 00:00:00 2001 From: aike <17730485278@139.com> Date: Wed, 2 Jul 2025 19:52:44 +0800 Subject: [PATCH] =?UTF-8?q?demand:=20=20=E7=BB=84=E6=A0=91=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=8D=97=E4=BA=AC=E5=88=86=E6=8B=A8=E4=B8=AD=E5=BF=83?= =?UTF-8?q?=E3=80=81=E6=9F=AF=E6=A1=A5=E5=88=86=E6=8B=A8=E4=B8=AD=E5=BF=83?= =?UTF-8?q?=20committer:=20heyu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../erp/emis/service/EmisBaseService.java | 156 +++++++++++------- .../mapper/EmisTmsSiteBatchMapper.xml | 21 ++- .../mapper/EmisTransPlanRuleMapper.xml | 4 +- .../resources/mapper/EmisWaybillMapper.xml | 11 +- 4 files changed, 123 insertions(+), 69 deletions(-) diff --git a/emis-biz/src/main/java/com/xdadan/erp/emis/service/EmisBaseService.java b/emis-biz/src/main/java/com/xdadan/erp/emis/service/EmisBaseService.java index 905c786bf..cb5e2d2f0 100644 --- a/emis-biz/src/main/java/com/xdadan/erp/emis/service/EmisBaseService.java +++ b/emis-biz/src/main/java/com/xdadan/erp/emis/service/EmisBaseService.java @@ -4030,7 +4030,8 @@ public class EmisBaseService { for (EmisTransPlanRule rule : lineRules) { if (rule.getProductType() != null) { String[] types = rule.getProductType().split(","); - String[] typeNames = rule.getProductTypeName() != null ? rule.getProductTypeName().split(",") : new String[0]; + String[] typeNames = rule.getProductTypeName() != null ? rule.getProductTypeName().split(",") + : new String[0]; for (int i = 0; i < types.length; i++) { String type = types[i].trim(); if (!type.isEmpty()) { @@ -4069,7 +4070,8 @@ public class EmisBaseService { Map> tempMap = new HashMap<>(); if (StringUtil.isNotBlank(emisTransPlanRule.getProductType())) { - Iterator>> iterator = groupByProductType.entrySet().iterator(); + Iterator>> iterator = groupByProductType.entrySet() + .iterator(); while (iterator.hasNext()) { Map.Entry> entry = iterator.next(); if (emisTransPlanRule.getProductType().equals(entry.getKey())) { @@ -4116,7 +4118,9 @@ public class EmisBaseService { String siteCode1 = child.getStartSiteCode() + "," + child.getNextSiteCode(); String siteCode2 = parent.getStartSiteCode() + "," + parent.getNextSiteCode(); if (!parent.getChildren().contains(child) && !compareSiteCodes(siteCode1, siteCode2)) { - parent.getChildren().add(child); + if (!wouldFormCycle(parent, child)) { + parent.getChildren().add(child); + } } } } @@ -4196,64 +4200,64 @@ public class EmisBaseService { } } - /** - * 深度复制节点及其子节点 - * - * @param source 源节点 - * @return 复制后的新节点 - */ - private EmisTransPlanRule deepCopyNode(EmisTransPlanRule source) { - return deepCopyNode(source, new HashSet<>(), new ArrayList<>()); - } + /** + * 深度复制节点及其子节点 + * + * @param source 源节点 + * @return 复制后的新节点 + */ + private EmisTransPlanRule deepCopyNode(EmisTransPlanRule source) { + return deepCopyNode(source, new HashSet<>(), new ArrayList<>()); + } - /** - * 深度复制节点及其子节点(带循环引用检测) - * - * @param source 源节点 - * @param visitedIds 已访问的节点ID集合 - * @param visitPath 访问路径,用于记录循环引用的路径 - * @return 复制后的新节点 - */ - private EmisTransPlanRule deepCopyNode(EmisTransPlanRule source, Set visitedIds, List visitPath) { - if (source == null) { - return null; - } + /** + * 深度复制节点及其子节点(带循环引用检测) + * + * @param source 源节点 + * @param visitedIds 已访问的节点ID集合 + * @param visitPath 访问路径,用于记录循环引用的路径 + * @return 复制后的新节点 + */ + private EmisTransPlanRule deepCopyNode(EmisTransPlanRule source, Set visitedIds, List visitPath) { + if (source == null) { + return null; + } - // 检查循环引用 - if (visitedIds.contains(source.getId())) { - // 找到循环引用的起始位置 - int cycleStartIndex = visitPath.indexOf(source.getId()); - if (cycleStartIndex != -1) { - // 构建循环路径 - List cyclePath = visitPath.subList(cycleStartIndex, visitPath.size()); - cyclePath.add(source.getId()); + // 检查循环引用 + if (visitedIds.contains(source.getId())) { + // 找到循环引用的起始位置 + int cycleStartIndex = visitPath.indexOf(source.getId()); + if (cycleStartIndex != -1) { + // 构建循环路径 + List cyclePath = visitPath.subList(cycleStartIndex, visitPath.size()); + cyclePath.add(source.getId()); // 构建详细的错误信息 - StringBuilder errorMsg = new StringBuilder(); - errorMsg.append("检测到循环引用!循环路径:"); - for (int i = 0; i < cyclePath.size(); i++) { - if (i > 0) { - errorMsg.append(" -> "); - } - Long id = cyclePath.get(i); - if (id == null) { - continue; - } - EmisTransPlanRule node = findNodeById(id); - if (node != null) { - errorMsg.append(node.getLineName()).append("-") - .append(node.getProductTypeName()).append("-") - .append(node.getStartSiteName()).append("-") - .append(node.getNextSiteName()).append("-") - .append(node.getSupplierName()); - } else { - errorMsg.append("节点ID:").append(id); - } - } -// errorMsg.append("\n循环引用发生在节点,详细信息见上"); - throw new RuntimeException(errorMsg.toString()); - } - } + StringBuilder errorMsg = new StringBuilder(); + errorMsg.append("检测到循环引用!循环路径:"); + for (int i = 0; i < cyclePath.size(); i++) { + if (i > 0) { + errorMsg.append(" -> "); + } + Long id = cyclePath.get(i); + if (id == null) { + continue; + } + EmisTransPlanRule node = findNodeById(id); + if (node != null) { + errorMsg.append(node.getLineName()).append("-") + .append(node.getProductTypeName()).append("-") + .append(node.getStartSiteName()).append("-") + .append(node.getNextSiteName()).append("-") + .append(node.getSupplierName()); + } else { + errorMsg.append("节点ID:").append(id); + } + } + // errorMsg.append("\n循环引用发生在节点,详细信息见上"); + throw new RuntimeException(errorMsg.toString()); + } + } // 添加到已访问集合和路径中 visitedIds.add(source.getId()); @@ -4285,6 +4289,22 @@ public class EmisBaseService { return emisTransPlanRuleMapper.selectEmisTransPlanRuleById(id); } + /** + * 判断添加child到parent后是否会形成环 + */ + private boolean wouldFormCycle(EmisTransPlanRule parent, EmisTransPlanRule child) { + if (child == null) + return false; + if (child.getId() != null && parent.getId() != null && child.getId().equals(parent.getId())) + return true; + if (child.getChildren() == null || child.getChildren().isEmpty()) + return false; + for (EmisTransPlanRule c : child.getChildren()) { + if (wouldFormCycle(parent, c)) + return true; + } + return false; + } /** * 检查月结客户首次签约日期,首次签约之前开的不允许修改 * @@ -4849,6 +4869,9 @@ public class EmisBaseService { if (currentLevelMatch) { hasCurrentLevelMatch = true; + if (CollectionUtil.isEmpty(currentLevelRule.getChildren())) { + return true; + } } // 收集当前级节点的所有子节点到下一级集合中 @@ -4943,6 +4966,13 @@ public class EmisBaseService { Objects.equals(filterRule.getNextSiteCode(), levelRule.getNextSiteCode()) && compareSupplierCodes(filterRule.getSupplierCode(), levelRule.getSupplierCode()))); if (!matched && !group.isEmpty()) { +// if (CollectionUtil.isNotEmpty(missRecords)) { +// List list = missRecords.stream().filter(i -> waybill.getBillCode().equals(i.getBillCode())).collect(Collectors.toList()); +// if (CollectionUtil.isNotEmpty(list) && list.size() > 10) { +// break; +// } +// } + // 聚合supplierCode、supplierName等 String supplierCodes = group.stream().map(EmisTransPlanRule::getSupplierCode) .filter(Objects::nonNull).distinct().collect(Collectors.joining(",")); @@ -5026,7 +5056,11 @@ public class EmisBaseService { } public void scanProblemInfo(EmisWaybill emisWaybillSave, EmisWaybill emisWaybillOld) { - if ("078".equals(emisWaybillSave.getTransLineType())) { + Set allowedTypes = new HashSet<>(); + allowedTypes.add("078"); + allowedTypes.add("012"); + allowedTypes.add("014"); + if (allowedTypes.contains(emisWaybillSave.getTransLineType())) { return; } String dispatchOrSendManCode = ""; @@ -5119,7 +5153,7 @@ public class EmisBaseService { long count = Arrays.stream(virtualRemark.split(",")) .filter(s -> s != null && !s.trim().isEmpty()) .count(); - if (count >= masterWaybill.getParcelQty()) { + if (("078".equals(emisWaybillSave.getTransLineType()) || "002".equals(emisWaybillSave.getTransLineType())) && count >= masterWaybill.getParcelQty()) { throw new EmisBizError(EmisBizErrorType.FAIL, emisWaybillSave.getMasterBillCode() + "最多只能绑定" + masterWaybill.getParcelQty() + "个虚拟单"); } @@ -5139,12 +5173,16 @@ public class EmisBaseService { } else { String masterBillCode = emisWaybillOld.getMasterBillCode(); if (StringUtil.isNotBlank(masterBillCode)) { + emisWaybillSave.setMasterBillCode(" "); String virtualBillCode = emisWaybillSave.getBillCode(); EmisWaybill masterWaybill = emisWaybillMapper .selectEmisWaybillByBillCode(masterBillCode); List filterVirtualRemark = Arrays.stream(masterWaybill.getVirtualRemark().split(",")) .filter(i -> !i.equals(virtualBillCode)).collect(Collectors.toList()); String virtualRemark = String.join(",", filterVirtualRemark); + if(StringUtil.isBlank(virtualRemark)) { + virtualRemark = " "; + } masterWaybill.setVirtualRemark(virtualRemark); emisWaybillMapper.updateEmisWaybill(masterWaybill); if (!"078".equals(emisWaybillSave.getTransLineType())) { diff --git a/emis-biz/src/main/resources/mapper/EmisTmsSiteBatchMapper.xml b/emis-biz/src/main/resources/mapper/EmisTmsSiteBatchMapper.xml index 9ef6c34f4..2bf859304 100644 --- a/emis-biz/src/main/resources/mapper/EmisTmsSiteBatchMapper.xml +++ b/emis-biz/src/main/resources/mapper/EmisTmsSiteBatchMapper.xml @@ -47,6 +47,23 @@ + + + + + + + + + + + + + + + + + @@ -493,8 +510,8 @@ - + select distinct b.id, b.batch_no, b.supplier_code, b.trans_line_type, b.product_type, b.trans_type, b.start_site_code, b.next_site_code, b.etd, d.bill_code from emis_tms_site_batch b inner join emis_tms_site_batch_dtl d on b.batch_no = d.batch_no where d.bill_code in diff --git a/emis-biz/src/main/resources/mapper/EmisTransPlanRuleMapper.xml b/emis-biz/src/main/resources/mapper/EmisTransPlanRuleMapper.xml index aea7d094d..2342aa629 100644 --- a/emis-biz/src/main/resources/mapper/EmisTransPlanRuleMapper.xml +++ b/emis-biz/src/main/resources/mapper/EmisTransPlanRuleMapper.xml @@ -385,7 +385,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and ( FIND_IN_SET(#{emisTransPlanRule.supplierCode},r.supplier_code) ) and r.start_date = #{emisTransPlanRule.startDate} and r.end_date = #{emisTransPlanRule.endDate} - and r.line_code not in ('014','012','077') +-- and r.line_code not in ('014','012','077') order by id desc limit #{offset}, #{pageSize} @@ -404,7 +404,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and ( FIND_IN_SET(#{supplierCode},r.supplier_code) ) and r.start_date = #{startDate} and r.end_date = #{endDate} - and r.line_code not in ('014','012','077') +-- and r.line_code not in ('014','012','077') diff --git a/emis-biz/src/main/resources/mapper/EmisWaybillMapper.xml b/emis-biz/src/main/resources/mapper/EmisWaybillMapper.xml index a5df9681a..ff3629398 100644 --- a/emis-biz/src/main/resources/mapper/EmisWaybillMapper.xml +++ b/emis-biz/src/main/resources/mapper/EmisWaybillMapper.xml @@ -3201,8 +3201,8 @@ bl_sensitive = #{blSensitive}, bl_over_long = #{blOverLong}, bl_virtual = #{blVirtual}, - master_bill_code= #{masterBillCode}, - virtual_remark= #{virtualRemark}, + master_bill_code= #{masterBillCode}, + virtual_remark= #{virtualRemark}, bl_bill = #{blBill}, bl_bill_text = #{blBillText}, bl_profit = #{blProfit}, @@ -3390,8 +3390,8 @@ bl_sensitive = #{blSensitive}, bl_over_long = #{blOverLong}, bl_virtual = #{blVirtual}, - master_bill_code= #{masterBillCode}, - virtual_remark= #{virtualRemark}, + master_bill_code= #{masterBillCode}, + virtual_remark= #{virtualRemark}, bl_bill = #{blBill}, bl_bill_text = #{blBillText}, bl_profit = #{blProfit}, @@ -3825,8 +3825,7 @@ from emis_waybill a where a.del_flag = '0' and a.problem_type in (173,170) - and (master_bill_code is null or master_bill_code='') --- and a.bill_code ='T708030039025903' + and (master_bill_code is null or master_bill_code='' or master_bill_code=' ') order by a.create_time desc limit #{offset}, #{pageSize}