fix: enforce pickup-ready receiving candidates
This commit is contained in:
+3
-2
@@ -113,6 +113,7 @@ public class ReceivingContainerService {
|
|||||||
return grouped.entrySet().stream()
|
return grouped.entrySet().stream()
|
||||||
.map(entry -> readiness(entry.getKey(), entry.getValue(), planFacts, lineFacts, overseasWarehouseId))
|
.map(entry -> readiness(entry.getKey(), entry.getValue(), planFacts, lineFacts, overseasWarehouseId))
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
|
.filter(ContainerReadiness::shippingReady)
|
||||||
.filter(value -> !reservedByOthers.contains(activeContainerKey(value.containerNo())))
|
.filter(value -> !reservedByOthers.contains(activeContainerKey(value.containerNo())))
|
||||||
.map(value -> candidate(value, current)).toList();
|
.map(value -> candidate(value, current)).toList();
|
||||||
}
|
}
|
||||||
@@ -479,7 +480,7 @@ public class ReceivingContainerService {
|
|||||||
inboundValues.stream().mapToInt(ReceivingContainerResponses.Inbound::totalPackages).sum(),
|
inboundValues.stream().mapToInt(ReceivingContainerResponses.Inbound::totalPackages).sum(),
|
||||||
inboundValues.stream().mapToInt(ReceivingContainerResponses.Inbound::receivedPackages).sum());
|
inboundValues.stream().mapToInt(ReceivingContainerResponses.Inbound::receivedPackages).sum());
|
||||||
return new ContainerReadiness(sourceContainerBookingId, containerNo, totalOrders, inboundCodes,
|
return new ContainerReadiness(sourceContainerBookingId, containerNo, totalOrders, inboundCodes,
|
||||||
totalOrders - inboundCodes, planCount, plannedOrders, pending, allPlansReady, operable,
|
totalOrders - inboundCodes, planCount, plannedOrders, pending, allPlansReady, shippingReady, operable,
|
||||||
blockReason, arrival, factHash, totals);
|
blockReason, arrival, factHash, totals);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -982,7 +983,7 @@ public class ReceivingContainerService {
|
|||||||
private record ContainerReadiness(String sourceContainerBookingId, String containerNo,
|
private record ContainerReadiness(String sourceContainerBookingId, String containerNo,
|
||||||
int totalOrderCount, int inboundCodeCount, int missingInboundCodeCount,
|
int totalOrderCount, int inboundCodeCount, int missingInboundCodeCount,
|
||||||
int planCount, int plannedInboundCodeCount, int pendingPlanCount,
|
int planCount, int plannedInboundCodeCount, int pendingPlanCount,
|
||||||
boolean allPlansReady, boolean operable, String blockReason,
|
boolean allPlansReady, boolean shippingReady, boolean operable, String blockReason,
|
||||||
LocalDateTime plannedArrivalAt, String factHash, Totals totals) { }
|
LocalDateTime plannedArrivalAt, String factHash, Totals totals) { }
|
||||||
private record PrepareCommand(String containerNo, String idempotencyKey) { }
|
private record PrepareCommand(String containerNo, String idempotencyKey) { }
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-10
@@ -87,18 +87,14 @@ class ReceivingContainerServiceBehaviorTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void containerRemainsVisibleButPrepareIsRejectedBeforePickupReady() {
|
void containerIsHiddenAndPrepareIsRejectedBeforePickupReady() {
|
||||||
when(plans.selectList(any())).thenReturn(List.of(plan("CONT-A")));
|
when(plans.selectList(any())).thenReturn(List.of(plan("CONT-A")));
|
||||||
when(lines.selectList(any())).thenReturn(List.of(line("FBA")));
|
when(lines.selectList(any())).thenReturn(List.of(line("FBA")));
|
||||||
LastlegOrder order = containerOrder(1L, "100", "CONT-A", "BOOKING-A", "IN-1");
|
LastlegOrder order = containerOrder(1L, "100", "CONT-A", "BOOKING-A", "IN-1");
|
||||||
when(orders.selectList(any())).thenReturn(List.of(order));
|
when(orders.selectList(any())).thenReturn(List.of(order));
|
||||||
when(shippingGates.receivingAvailable("100", "CONT-A")).thenReturn(0);
|
when(shippingGates.receivingAvailable("100", "CONT-A")).thenReturn(0);
|
||||||
|
|
||||||
assertThat(service.candidates("7", 100L)).singleElement().satisfies(candidate -> {
|
assertThat(service.candidates("7", 100L)).isEmpty();
|
||||||
assertThat(candidate.operable()).isFalse();
|
|
||||||
assertThat(candidate.allPlansReady()).isTrue();
|
|
||||||
assertThat(candidate.blockReason()).contains("尚未达到");
|
|
||||||
});
|
|
||||||
assertThatThrownBy(() -> service.prepare("7", "receiver", 100L, "CONT-A",
|
assertThatThrownBy(() -> service.prepare("7", "receiver", 100L, "CONT-A",
|
||||||
new ReceivingContainerRequests.Action("not-ready")))
|
new ReceivingContainerRequests.Action("not-ready")))
|
||||||
.isInstanceOf(ResponseStatusException.class).hasMessageContaining("409");
|
.isInstanceOf(ResponseStatusException.class).hasMessageContaining("409");
|
||||||
@@ -155,10 +151,7 @@ class ReceivingContainerServiceBehaviorTest {
|
|||||||
when(orders.selectList(any())).thenReturn(List.of(
|
when(orders.selectList(any())).thenReturn(List.of(
|
||||||
containerOrder(1L, "100", "CONT-A", "BOOKING-A", "IN-1"),
|
containerOrder(1L, "100", "CONT-A", "BOOKING-A", "IN-1"),
|
||||||
containerOrder(2L, "200", "CONT-A", "BOOKING-A", "IN-2")));
|
containerOrder(2L, "200", "CONT-A", "BOOKING-A", "IN-2")));
|
||||||
assertThat(service.candidates("7", 100L)).singleElement().satisfies(candidate -> {
|
assertThat(service.candidates("7", 100L)).isEmpty();
|
||||||
assertThat(candidate.operable()).isFalse();
|
|
||||||
assertThat(candidate.blockReason()).contains("未操作/缺入仓码");
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user