fix(lastleg): complete generated pallet receiving flow

This commit is contained in:
2026-09-09 02:54:09 +08:00
parent 86646ccd69
commit c5862db98d
20 changed files with 367 additions and 225 deletions
@@ -23,6 +23,9 @@ public record InboundPlanListResponse(
Integer pickedPackageCount,
BigDecimal volumeCbm,
Integer palletCount,
boolean assigned,
boolean mergeAllowed,
boolean urgent,
String status,
String appointmentNo,
String appointmentStatus,
@@ -44,7 +44,8 @@ public interface InboundPlanQueryMapper {
"o.customer_name customerName,l.required_package_count packageCount," +
"COALESCE((SELECT SUM(pa.picked_package_count) FROM ll_inbound_plan_pallet_allocation pa WHERE pa.line_id=l.id),0) pickedPackageCount," +
"l.volume_cbm volumeCbm," +
"l.planned_pallet_count palletCount,p.status status,a.appointment_no appointmentNo," +
"l.planned_pallet_count palletCount,p.assigned_flag assigned,p.merge_required mergeAllowed," +
"p.urgent_flag urgent,p.status status,a.appointment_no appointmentNo," +
"a.appointment_status appointmentStatus,a.appointment_at appointmentAt," +
"a.expected_loading_at expectedLoadingAt," +
"CASE WHEN EXISTS (SELECT 1 FROM ll_dispatch_item di WHERE " +
@@ -55,7 +55,8 @@ public final class ReceivingContainerResponses {
String destinationWarehouseCode, String destinationWarehouseName,
String fbaWarehouseCode, int plannedPalletCount, int totalPackages,
int receivedPackages, int pendingPackages,
boolean palletMergeRequired, String palletMergeHint) { }
boolean assigned, boolean mergeAllowed, boolean urgent,
String mergeHint) { }
public record CartonResolved(String cartonMark, String inboundCode,
String destinationType, String overseasWarehouseId,
@@ -63,7 +64,8 @@ public final class ReceivingContainerResponses {
String destinationWarehouseCode, String destinationWarehouseName,
String fbaWarehouseCode, int plannedPalletCount, int totalPackages,
int receivedPackages, int pendingPackages,
boolean palletMergeRequired, String palletMergeHint) {
boolean assigned, boolean mergeAllowed, boolean urgent,
String mergeHint) {
public CartonResolved(String cartonMark, String inboundCode, String destinationType,
String overseasWarehouseId, String overseasWarehouseName,
String destinationWarehouseId, String destinationWarehouseCode,
@@ -73,7 +75,7 @@ public final class ReceivingContainerResponses {
this(cartonMark, inboundCode, destinationType, overseasWarehouseId, overseasWarehouseName,
destinationWarehouseId, destinationWarehouseCode, destinationWarehouseName,
fbaWarehouseCode, plannedPalletCount, totalPackages, receivedPackages,
pendingPackages, false, null);
pendingPackages, false, false, false, null);
}
}
@@ -84,12 +86,13 @@ public final class ReceivingContainerResponses {
public record Receipt(String result, String containerNo, String inboundCode,
String destinationType, String palletCode, int acceptedPackages,
int receivedPackages, int pendingPackages, String sessionStatus,
boolean palletMergeRequired, String palletMergeHint) {
boolean assigned, boolean mergeAllowed, boolean urgent,
String mergeHint) {
public Receipt(String result, String containerNo, String inboundCode,
String destinationType, String palletCode, int acceptedPackages,
int receivedPackages, int pendingPackages, String sessionStatus) {
this(result, containerNo, inboundCode, destinationType, palletCode, acceptedPackages,
receivedPackages, pendingPackages, sessionStatus, false, null);
receivedPackages, pendingPackages, sessionStatus, false, false, false, null);
}
}
@@ -117,6 +117,12 @@ public class HttpWarehouseResourceGateway implements WarehouseResourceGateway {
@Override
public WarehousePalletReference resolvePallet(String palletCode) {
WarehousePalletResponse response = lookupPallet(palletCode);
return reference(response.data());
}
@Override
public WarehousePalletReference resolveAvailablePallet(String palletCode) {
WarehousePalletResponse response = lookupPallet(palletCode);
requireReservable(response.data());
return reference(response.data());
@@ -153,7 +159,6 @@ public class HttpWarehouseResourceGateway implements WarehouseResourceGateway {
.body(WarehousePalletResponse.class);
if (response == null || response.data() == null) throw new ResponseStatusException(HttpStatus.SERVICE_UNAVAILABLE,
"Warehouse pallet service returned no usable response");
requireReservable(response.data());
return new WarehousePalletReference(response.data().id(), response.data().palletCode(), response.data().warehouseId(),
response.data().locationId(), response.data().status(), response.data().fbaWarehouseCode(),
response.data().unitPrice(), response.data().version());
@@ -11,6 +11,9 @@ public interface WarehouseResourceGateway {
void scrapPallet(String customerId, long palletId);
WarehousePalletReference resolvePallet(String palletCode);
WarehousePalletReference resolvePallet(long palletId);
default WarehousePalletReference resolveAvailablePallet(String palletCode) {
return resolvePallet(palletCode);
}
default WarehousePalletReference resolveReservedPallet(String palletCode, String customerId, long warehouseId,
long palletId, long locationId, long resourceLockId) {
throw new UnsupportedOperationException("Reserved warehouse pallet resolution is not configured");
@@ -61,7 +61,8 @@ import java.util.stream.Collectors;
public class ReceivingContainerService {
private static final String PHOTO_DOWNLOAD_PATH =
"/api/pda/v1/last-leg/receiving-containers/current/unload-photos/files/{fileId}/download";
private static final String PALLET_MERGE_HINT = "该入仓单已标记合托,请按合托要求拣货";
private static final String PALLET_MERGE_HINT =
"该入库计划可选择合托:合托时扫描同目的仓已使用的托盘码,独立收货时扫描新托盘码;不强制合托";
@Resource private InboundPlanMapper plans;
@Resource private InboundPlanLineMapper lines;
@@ -266,7 +267,7 @@ public class ReceivingContainerService {
inbound.overseasWarehouseName(), inbound.destinationWarehouseId(),
inbound.destinationWarehouseCode(), inbound.destinationWarehouseName(), inbound.fbaWarehouseCode(),
inbound.plannedPalletCount(), inbound.totalPackages(), inbound.receivedPackages(), inbound.pendingPackages(),
inbound.palletMergeRequired(), inbound.palletMergeHint());
inbound.assigned(), inbound.mergeAllowed(), inbound.urgent(), inbound.mergeHint());
}
public ReceivingContainerResponses.PalletResolved resolvePallet(String operatorKey,
@@ -311,8 +312,8 @@ public class ReceivingContainerService {
int total = fbaPlanRefs.stream().mapToInt(refValue -> value(refValue.line().getRequiredPackageCount())).sum();
ReceivingContainerResponses.Receipt result = new ReceivingContainerResponses.Receipt("RECEIVED",
session.getContainerNo(), ref.line().getInboundCode(), "FBA", resource.palletNo(), accepted,
received, Math.max(0, total - received), session.getStatus(), palletMergeRequired(ref.order()),
palletMergeHint(ref.order()));
received, Math.max(0, total - received), session.getStatus(), assigned(ref.plan()),
mergeAllowed(ref.plan()), urgent(ref.plan()), mergeHint(ref.plan()));
save(session, "BULK_RECEIVE", request.idempotencyKey(), request, result);
return result;
} catch (RuntimeException failure) {
@@ -351,7 +352,7 @@ public class ReceivingContainerService {
ReceivingContainerResponses.Receipt result = new ReceivingContainerResponses.Receipt("RECEIVED",
session.getContainerNo(), inbound.inboundCode(), inbound.destinationType(), resource.palletNo(), 1,
inbound.receivedPackages(), inbound.pendingPackages(), session.getStatus(),
inbound.palletMergeRequired(), inbound.palletMergeHint());
inbound.assigned(), inbound.mergeAllowed(), inbound.urgent(), inbound.mergeHint());
save(session, "CARTON_RECEIVE", request.idempotencyKey(), request, result);
return result;
} catch (RuntimeException failure) {
@@ -654,7 +655,7 @@ public class ReceivingContainerService {
pallet.getWarehousePalletId(), pallet.getWarehouseLocationId(), pallet.getWarehouseResourceLockId());
} else {
try {
resource = warehouse.resolvePallet(palletCode.trim());
resource = warehouse.resolveAvailablePallet(palletCode.trim());
} catch (IllegalArgumentException exception) {
throw notFound("Pallet was not found");
}
@@ -728,16 +729,23 @@ public class ReceivingContainerService {
ref.line().getDestinationWarehouseId(), ref.line().getDestinationWarehouseCode(),
ref.line().getDestinationWarehouseName(), ref.line().getFbaWarehouseCode(),
value(ref.line().getPlannedPalletCount()), total, received, Math.max(0, total - received),
palletMergeRequired(ref.order()), palletMergeHint(ref.order()));
assigned(ref.plan()), mergeAllowed(ref.plan()), urgent(ref.plan()), mergeHint(ref.plan()));
}
private boolean palletMergeRequired(LastlegOrder order) {
return order != null && ("REQUIRED".equals(order.getPalletMergeFlag())
|| "MERGED".equals(order.getPalletMergeFlag()));
private boolean assigned(InboundPlan plan) {
return plan != null && Boolean.TRUE.equals(plan.getAssignedFlag());
}
private String palletMergeHint(LastlegOrder order) {
return palletMergeRequired(order) ? PALLET_MERGE_HINT : null;
private boolean mergeAllowed(InboundPlan plan) {
return plan != null && Boolean.TRUE.equals(plan.getMergeRequired());
}
private boolean urgent(InboundPlan plan) {
return plan != null && Boolean.TRUE.equals(plan.getUrgentFlag());
}
private String mergeHint(InboundPlan plan) {
return mergeAllowed(plan) ? PALLET_MERGE_HINT : null;
}
private Totals totals(List<InboundPlan> containerPlans) {