fix: isolate invalid receiving candidates

This commit is contained in:
2026-09-07 16:06:08 +08:00
parent ff2b02b102
commit d622ddd37f
2 changed files with 30 additions and 7 deletions
@@ -176,6 +176,27 @@ class ReceivingContainerServiceBehaviorTest {
.containsExactly("CONT-EARLY", "CONT-LATE", "CONT-NULL", "CONT-BLOCKED");
}
@Test
void invalidWarehouseSnapshotOnlyBlocksItsContainerWithoutFailingHealthyCandidates() {
InboundPlan brokenPlan = plan("CONT-BROKEN");
InboundPlan healthyPlan = plan("CONT-HEALTHY"); healthyPlan.setId(3L);
InboundPlanLine brokenLine = line("FBA");
InboundPlanLine healthyLine = line("FBA"); healthyLine.setId(11L); healthyLine.setOrderId(2L); healthyLine.setPlanId(3L);
LastlegOrder broken = containerOrder(1L, "100", "CONT-BROKEN", "BOOKING-A", "IN-1");
broken.setOverseasWarehouseCode(null);
LastlegOrder healthy = containerOrder(2L, "100", "CONT-HEALTHY", "BOOKING-B", "IN-2");
when(plans.selectList(any())).thenReturn(List.of(brokenPlan, healthyPlan));
when(lines.selectList(any())).thenReturn(List.of(brokenLine, healthyLine));
when(orders.selectList(any())).thenReturn(List.of(broken, healthy));
var result = service.candidates("7", 100L);
assertThat(result).extracting("containerNo").containsExactly("CONT-HEALTHY", "CONT-BROKEN");
assertThat(result.get(0).operable()).isTrue();
assertThat(result.get(1).operable()).isFalse();
assertThat(result.get(1).blockReason()).isEqualTo("柜内接柜仓业务快照不一致");
}
@Test
void candidatesIncludeUnassignedAndSameWarehouseButHideOtherWarehouse() {
InboundPlan unassigned = plan("CONT-A");