demand: TMS系统 - 运输管理 - 货物组批次新增-同一起始网点、下一网点对应多个供应商无法录入问题修复

committer: heyu
This commit is contained in:
aike 2025-08-11 18:29:26 +08:00
parent a4d4d82377
commit 128608c85a

View File

@ -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<EmisTmsSiteBatch> listALL = matchedBatchGroups.stream()
.flatMap(List::stream)
.distinct()
.collect(Collectors.toList());
// 从countBatches中去除包含在listALL中的元素
countBatches.removeAll(listALL);
// 将每个list中留一个元素插入countBatches中
for (List<EmisTmsSiteBatch> batchGroup : matchedBatchGroups) {
if (!batchGroup.isEmpty()) {
countBatches.add(batchGroup.get(0));
}
// 根据起始网点、下一网点、批次重量、件数、体积去重
List<EmisTmsSiteBatch> 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<EmisTmsSiteBatch> toRemove = new ArrayList<>(batchGroup);
toRemove.removeAll(deduplicatedGroup);
countBatches.removeAll(toRemove);
}
}
// 计算去重后的批次总重量、总件数、总体积