feat: freeze and propagate first-leg pallet labels

This commit is contained in:
2026-09-09 17:27:00 +08:00
parent 83e95d764e
commit de1f7e8ddd
24 changed files with 560 additions and 21 deletions
@@ -44,6 +44,7 @@ public class LoadingCompletedConsumer {
@Resource private DropshipOrderService dropshipOrders;
@Resource private InventoryCommandService inventory;
@Resource private ContainerShippingGateMapper shippingGates;
@Resource private LastlegSourcePalletMapper sourcePallets;
@Transactional(isolation = Isolation.READ_COMMITTED)
public int consume(EventEnvelope envelope) {
@@ -273,6 +274,21 @@ public class LoadingCompletedConsumer {
}
createInboundOrderSnapshot(event, payload, source, order, orderHash);
if ("FIRST_LEG".equals(orderType) && event.eventVersion() >= 2) {
List<FirstLegLoadingPlanCompletedV1.PalletSnapshot> pallets = source.pallets() == null ? List.of() : source.pallets();
Set<String> palletNos = new HashSet<>();
for (int palletIndex = 0; palletIndex < pallets.size(); palletIndex++) {
String palletNo = pallets.get(palletIndex).palletNo();
if (palletNo == null || palletNo.isBlank() || palletNo.length() > 128 || !palletNos.add(palletNo)) {
throw new IllegalArgumentException("散货来源托盘码为空、重复或过长");
}
sourcePallets.insert(IdWorker.getId(), customerId, order.getId(), palletNo.trim(), palletIndex + 1, event.eventId());
}
if (!pallets.isEmpty() && order.getPalletCount() > 0 && pallets.size() != order.getPalletCount()) {
throw new IllegalArgumentException("散货来源托盘码数量与托盘数不一致");
}
}
for(var item:source.items()) {
LastlegOrderDetail detail=new LastlegOrderDetail();
detail.setCustomerId(customerId);