This commit is contained in:
2026-08-26 17:50:56 +08:00
parent aad8dd6344
commit 64047df5b3
10 changed files with 193 additions and 20 deletions
@@ -229,7 +229,7 @@ public class ReceivingContainerService {
CartonRef carton = requireCartonRef(customerId, session.getContainerNo(), request.cartonMark());
InboundRef ref = carton.ref();
ReceivingContainerResponses.Inbound inbound = inbound(ref);
return new ReceivingContainerResponses.CartonResolved(carton.carton().getCartonMark(),
return new ReceivingContainerResponses.CartonResolved(request.cartonMark().trim(),
inbound.inboundCode(), inbound.destinationType(), inbound.overseasWarehouseId(),
inbound.overseasWarehouseName(), inbound.destinationWarehouseId(),
inbound.destinationWarehouseCode(), inbound.destinationWarehouseName(), inbound.fbaWarehouseCode(),
@@ -423,13 +423,33 @@ public class ReceivingContainerService {
private CartonRef requireCartonRef(String customerId, String containerNo, String cartonMark) {
InboundPlanCarton carton = cartons.selectOne(new LambdaQueryWrapper<InboundPlanCarton>()
.eq(InboundPlanCarton::getCustomerId, customerId).eq(InboundPlanCarton::getCartonMark, cartonMark));
if (carton == null) throw notFound("Carton mark was not found");
if (carton == null) return resolveFbaCartonCodeWithoutManifest(customerId, containerNo, cartonMark);
List<InboundRef> matches = refs(customerId, containerNo).stream()
.filter(value -> carton.getLineId() == null || Objects.equals(value.line().getId(), carton.getLineId()))
.filter(value -> carton.getPlanId() == null || Objects.equals(value.plan().getId(), carton.getPlanId()))
.filter(value -> Objects.equals(value.line().getOrderId(), carton.getOrderId())).toList();
if (matches.size() != 1) throw conflict("Carton mark belongs to another container");
return new CartonRef(carton, matches.get(0));
return new CartonRef(matches.get(0));
}
private CartonRef resolveFbaCartonCodeWithoutManifest(String customerId, String containerNo, String cartonMark) {
int delimiter = cartonMark == null ? -1 : cartonMark.indexOf('#');
if (delimiter < 1) throw conflict("Carton mark must contain a non-empty inbound code prefix");
String inboundCode = cartonMark.substring(0, delimiter).trim();
if (inboundCode.isEmpty()) throw conflict("Carton mark must contain a non-empty inbound code prefix");
List<InboundRef> matches = refs(customerId, containerNo).stream()
.filter(value -> inboundCode.equals(value.line().getInboundCode())).toList();
if (matches.isEmpty()) {
boolean exists = lines.selectList(new LambdaQueryWrapper<InboundPlanLine>()
.eq(InboundPlanLine::getCustomerId, customerId)
.eq(InboundPlanLine::getInboundCode, inboundCode)).stream().findAny().isPresent();
if (exists) throw conflict("Carton mark belongs to another container");
throw notFound("Carton mark was not found");
}
if (matches.size() != 1) throw conflict("Carton mark inbound code is ambiguous in the current container");
InboundRef ref = matches.get(0);
if (!"FBA".equals(destinationType(ref.line(), ref.order()))) throw notFound("Carton mark was not found");
return new CartonRef(ref);
}
private List<InboundRef> requireFbaPlanRefs(String customerId, String containerNo, InboundRef selected) {
@@ -806,7 +826,7 @@ public class ReceivingContainerService {
private static ResponseStatusException notFound(String message) { return new ResponseStatusException(HttpStatus.NOT_FOUND, message); }
private record InboundRef(InboundPlan plan, InboundPlanLine line, LastlegOrder order) { }
private record CartonRef(InboundPlanCarton carton, InboundRef ref) { }
private record CartonRef(InboundRef ref) { }
private record SkuExpectation(String skuCode, String productName, int expectedPackages) { }
private record FbaSkuAllocation(InboundRef ref, String skuCode, String productName, int packages) { }
private record Totals(int inboundCount, List<String> destinationCodes, int plannedPalletCount,