优化
This commit is contained in:
+4
@@ -116,6 +116,10 @@ public class ReceivingContainerService {
|
||||
.filter(ContainerReadiness::shippingReady)
|
||||
.filter(value -> !value.allPlansCompleted())
|
||||
.filter(value -> !reservedByOthers.contains(activeContainerKey(value.containerNo())))
|
||||
.sorted(Comparator.comparing(ContainerReadiness::operable).reversed()
|
||||
.thenComparing(ContainerReadiness::plannedArrivalAt,
|
||||
Comparator.nullsLast(Comparator.naturalOrder()))
|
||||
.thenComparing(ContainerReadiness::sourceContainerBookingId))
|
||||
.map(value -> candidate(value, current)).toList();
|
||||
}
|
||||
|
||||
|
||||
+25
@@ -34,6 +34,7 @@ import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
import org.springframework.web.server.ResponseStatusException;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -154,6 +155,30 @@ class ReceivingContainerServiceBehaviorTest {
|
||||
assertThat(service.candidates("7", 100L)).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
void candidatesPutOperableContainersFirstThenOrderByPlannedArrival() {
|
||||
InboundPlan latePlan = plan("CONT-LATE");
|
||||
InboundPlan earlyPlan = plan("CONT-EARLY"); earlyPlan.setId(3L);
|
||||
InboundPlan nullArrivalPlan = plan("CONT-NULL"); nullArrivalPlan.setId(4L);
|
||||
InboundPlan blockedPlan = plan("CONT-BLOCKED"); blockedPlan.setId(5L);
|
||||
InboundPlanLine lateLine = line("FBA"); lateLine.setOrderId(2L);
|
||||
InboundPlanLine earlyLine = line("FBA"); earlyLine.setId(11L); earlyLine.setOrderId(3L); earlyLine.setPlanId(3L);
|
||||
InboundPlanLine nullArrivalLine = line("FBA"); nullArrivalLine.setId(12L); nullArrivalLine.setOrderId(4L); nullArrivalLine.setPlanId(4L);
|
||||
LastlegOrder blocked = containerOrder(1L, "100", "CONT-BLOCKED", "BOOKING-A", "IN-1");
|
||||
LastlegOrder late = containerOrder(2L, "100", "CONT-LATE", "BOOKING-B", "IN-2");
|
||||
LastlegOrder early = containerOrder(3L, "100", "CONT-EARLY", "BOOKING-C", "IN-3");
|
||||
LastlegOrder nullArrival = containerOrder(4L, "100", "CONT-NULL", "BOOKING-D", "IN-4");
|
||||
blocked.setEstimatedWarehouseAt(LocalDateTime.of(2026, 9, 1, 8, 0));
|
||||
late.setEstimatedWarehouseAt(LocalDateTime.of(2026, 9, 3, 8, 0));
|
||||
early.setEstimatedWarehouseAt(LocalDateTime.of(2026, 9, 2, 8, 0));
|
||||
when(plans.selectList(any())).thenReturn(List.of(latePlan, earlyPlan, nullArrivalPlan, blockedPlan));
|
||||
when(lines.selectList(any())).thenReturn(List.of(lateLine, earlyLine, nullArrivalLine));
|
||||
when(orders.selectList(any())).thenReturn(List.of(blocked, late, early, nullArrival));
|
||||
|
||||
assertThat(service.candidates("7", 100L)).extracting("containerNo")
|
||||
.containsExactly("CONT-EARLY", "CONT-LATE", "CONT-NULL", "CONT-BLOCKED");
|
||||
}
|
||||
|
||||
@Test
|
||||
void candidatesIncludeUnassignedAndSameWarehouseButHideOtherWarehouse() {
|
||||
InboundPlan unassigned = plan("CONT-A");
|
||||
|
||||
Reference in New Issue
Block a user