fix(lastleg): resolve mixed-pallet return sources by dispatch snapshots
This commit is contained in:
+10
-5
@@ -485,12 +485,17 @@ public class ExceptionOrderService {
|
||||
for (DispatchPdaPickOrder attribution : attributions) {
|
||||
LastlegOrder tail = lastMileOrders.selectById(attribution.getOrderId());
|
||||
if (tail == null || !customerId.equals(tail.getCustomerId())) continue;
|
||||
OutboundPalletItem outboundItem = outboundItemById.values().stream()
|
||||
List<OutboundPalletItem> matchingItems = outboundItemById.values().stream()
|
||||
.filter(item -> Objects.equals(item.getWarehousePalletId(), dispatchItem.getWarehousePalletId()))
|
||||
.filter(item -> !StringUtils.hasText(item.getInboundCode())
|
||||
|| Objects.equals(item.getInboundCode(), tail.getInboundCode()))
|
||||
.findFirst().orElse(null);
|
||||
if (outboundItem == null) continue;
|
||||
.filter(item -> Objects.equals(item.getInboundCode(), dispatchItem.getInboundCode()))
|
||||
.filter(item -> Objects.equals(item.getDestinationWarehouseId(), dispatchItem.getDestinationWarehouseId()))
|
||||
.filter(item -> Objects.equals(item.getDestinationWarehouseCode(), dispatchItem.getDestinationWarehouseCode()))
|
||||
.filter(item -> Objects.equals(item.getDestinationWarehouseName(), dispatchItem.getDestinationWarehouseName()))
|
||||
.filter(item -> Objects.equals(item.getOrderRefs(), dispatchItem.getOrderRefs())).toList();
|
||||
if (matchingItems.size() > 1) throw conflict("排车明细对应的原出库托盘项不唯一,拒绝退回来源");
|
||||
if (matchingItems.isEmpty()) continue;
|
||||
OutboundPalletItem outboundItem = matchingItems.get(0);
|
||||
// A mixed pallet has one physical outbound item; each source is identified by the actual pick attribution.
|
||||
String key = outboundItem.getId() + ":" + pick.getInventoryPositionId() + ":" + tail.getInboundCode();
|
||||
long packages = Objects.requireNonNullElse(attribution.getPackages(), 0L);
|
||||
aggregated.merge(key, new Source(outboundItem.getId(), pick.getInventoryPositionId(),
|
||||
|
||||
Reference in New Issue
Block a user