From 128608c85a39cc38c1f0bcfe7735d16953d84ed4 Mon Sep 17 00:00:00 2001 From: aike <17730485278@139.com> Date: Mon, 11 Aug 2025 18:29:26 +0800 Subject: [PATCH] =?UTF-8?q?demand:=20TMS=E7=B3=BB=E7=BB=9F=20-=20=E8=BF=90?= =?UTF-8?q?=E8=BE=93=E7=AE=A1=E7=90=86=20-=20=E8=B4=A7=E7=89=A9=E7=BB=84?= =?UTF-8?q?=E6=89=B9=E6=AC=A1=E6=96=B0=E5=A2=9E-=E5=90=8C=E4=B8=80?= =?UTF-8?q?=E8=B5=B7=E5=A7=8B=E7=BD=91=E7=82=B9=E3=80=81=E4=B8=8B=E4=B8=80?= =?UTF-8?q?=E7=BD=91=E7=82=B9=E5=AF=B9=E5=BA=94=E5=A4=9A=E4=B8=AA=E4=BE=9B?= =?UTF-8?q?=E5=BA=94=E5=95=86=E6=97=A0=E6=B3=95=E5=BD=95=E5=85=A5=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E4=BF=AE=E5=A4=8D=20committer:=20heyu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/EmisTmsSiteBatchServiceImpl.java | 40 +++++++++++++------ 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisTmsSiteBatchServiceImpl.java b/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisTmsSiteBatchServiceImpl.java index 61d36f978..549999c88 100644 --- a/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisTmsSiteBatchServiceImpl.java +++ b/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisTmsSiteBatchServiceImpl.java @@ -249,6 +249,7 @@ public class EmisTmsSiteBatchServiceImpl extends EmisBaseService implements IEmi EmisTmsSiteBatch currentBatch = new EmisTmsSiteBatch(); currentBatch.setStartSiteCode(oldSiteBatch.getStartSiteCode()); currentBatch.setNextSiteCode(oldSiteBatch.getNextSiteCode()); + currentBatch.setSupplierCode(oldSiteBatch.getSupplierCode()); currentBatch.setTotalWeight(itemDtl.getBatchWeight()); currentBatch.setTotalParcelQty(itemDtl.getBatchParcelQty()); currentBatch.setTotalVolume(itemDtl.getBatchVolume()); @@ -280,21 +281,34 @@ public class EmisTmsSiteBatchServiceImpl extends EmisBaseService implements IEmi // 如果有匹配的批次组,进行处理 if (!matchedBatchGroups.isEmpty()) { - // 将多个list合一去重生成listALL - List listALL = matchedBatchGroups.stream() - .flatMap(List::stream) - .distinct() - .collect(Collectors.toList()); - - // 从countBatches中去除包含在listALL中的元素 - countBatches.removeAll(listALL); - - // 将每个list中留一个元素插入countBatches中 for (List batchGroup : matchedBatchGroups) { - if (!batchGroup.isEmpty()) { - countBatches.add(batchGroup.get(0)); - } + + // 根据起始网点、下一网点、批次重量、件数、体积去重 + List deduplicatedGroup = batchGroup.stream() + .collect(Collectors.toMap( + batch -> batch.getStartSiteCode() + "_" + batch.getNextSiteCode() + "_" + + (batch.getTotalWeight() != null + ? batch.getTotalWeight().stripTrailingZeros().toPlainString() + : "0") + + "_" + + batch.getTotalParcelQty() + "_" + + (batch.getTotalVolume() != null + ? batch.getTotalVolume().stripTrailingZeros().toPlainString() + : "0"), + batch -> batch, + (existing, replacement) -> existing // 如果有重复,保留第一个 + )) + .values() + .stream() + .collect(Collectors.toList()); + + // 将batchGroup比deduplicatedGroup多的EmisTmsSiteBatch从countBatches中移除 + List toRemove = new ArrayList<>(batchGroup); + toRemove.removeAll(deduplicatedGroup); + countBatches.removeAll(toRemove); + } + } // 计算去重后的批次总重量、总件数、总体积