demand: TMS系统 - 运输管理 - 货物组批次新增-同一起始网点、下一网点对应多个供应商无法录入问题修复
committer: heyu
This commit is contained in:
parent
a4d4d82377
commit
128608c85a
@ -249,6 +249,7 @@ public class EmisTmsSiteBatchServiceImpl extends EmisBaseService implements IEmi
|
|||||||
EmisTmsSiteBatch currentBatch = new EmisTmsSiteBatch();
|
EmisTmsSiteBatch currentBatch = new EmisTmsSiteBatch();
|
||||||
currentBatch.setStartSiteCode(oldSiteBatch.getStartSiteCode());
|
currentBatch.setStartSiteCode(oldSiteBatch.getStartSiteCode());
|
||||||
currentBatch.setNextSiteCode(oldSiteBatch.getNextSiteCode());
|
currentBatch.setNextSiteCode(oldSiteBatch.getNextSiteCode());
|
||||||
|
currentBatch.setSupplierCode(oldSiteBatch.getSupplierCode());
|
||||||
currentBatch.setTotalWeight(itemDtl.getBatchWeight());
|
currentBatch.setTotalWeight(itemDtl.getBatchWeight());
|
||||||
currentBatch.setTotalParcelQty(itemDtl.getBatchParcelQty());
|
currentBatch.setTotalParcelQty(itemDtl.getBatchParcelQty());
|
||||||
currentBatch.setTotalVolume(itemDtl.getBatchVolume());
|
currentBatch.setTotalVolume(itemDtl.getBatchVolume());
|
||||||
@ -280,21 +281,34 @@ public class EmisTmsSiteBatchServiceImpl extends EmisBaseService implements IEmi
|
|||||||
|
|
||||||
// 如果有匹配的批次组,进行处理
|
// 如果有匹配的批次组,进行处理
|
||||||
if (!matchedBatchGroups.isEmpty()) {
|
if (!matchedBatchGroups.isEmpty()) {
|
||||||
// 将多个list合一去重生成listALL
|
for (List<EmisTmsSiteBatch> batchGroup : matchedBatchGroups) {
|
||||||
List<EmisTmsSiteBatch> listALL = matchedBatchGroups.stream()
|
|
||||||
.flatMap(List::stream)
|
// 根据起始网点、下一网点、批次重量、件数、体积去重
|
||||||
.distinct()
|
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());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
// 从countBatches中去除包含在listALL中的元素
|
// 将batchGroup比deduplicatedGroup多的EmisTmsSiteBatch从countBatches中移除
|
||||||
countBatches.removeAll(listALL);
|
List<EmisTmsSiteBatch> toRemove = new ArrayList<>(batchGroup);
|
||||||
|
toRemove.removeAll(deduplicatedGroup);
|
||||||
|
countBatches.removeAll(toRemove);
|
||||||
|
|
||||||
// 将每个list中留一个元素插入countBatches中
|
|
||||||
for (List<EmisTmsSiteBatch> batchGroup : matchedBatchGroups) {
|
|
||||||
if (!batchGroup.isEmpty()) {
|
|
||||||
countBatches.add(batchGroup.get(0));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 计算去重后的批次总重量、总件数、总体积
|
// 计算去重后的批次总重量、总件数、总体积
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user