Test #1

Merged
admin merged 1726 commits from test into main 2026-09-17 11:52:45 +08:00
2 changed files with 38 additions and 1 deletions
Showing only changes of commit f3bbe0e15f - Show all commits
@@ -533,7 +533,9 @@ public class InboundPlanService {
wholePallets.add(sourcePallets);
List<String> standardNos = "ONE_CLICK_DROPSHIP".equals(ref.orderType()) ? List.of()
: sourcePalletMapper.palletNos(ref.customerId(), ref.orderId());
if (sourcePallets == null && standardNos.isEmpty()) throw new ResponseStatusException(
boolean standardFba = sourcePallets == null && orders.stream()
.anyMatch(order -> trimToNull(order.fbaWarehouseCode()) != null);
if (standardFba && standardNos.isEmpty()) throw new ResponseStatusException(
HttpStatus.CONFLICT, "散货订单缺少头程托盘码快照");
standardPalletNos.add(standardNos);
}
@@ -478,6 +478,41 @@ class InboundPlanServiceTest {
.map(InboundPlanPalletAllocation::getPlannedPackageCount).toList());
}
@Test
void standardOverseasContainerConversionAllowsMissingSourcePalletSnapshot() {
when(orderMapper.lockContainerOrders("BOOKING-1")).thenReturn(List.of(
new InboundPlanOrderMapper.ContainerOrderRef("100", 1L, "PENDING_ASSIGNMENT",
"MSCU6639870", "STANDARD")));
when(orderMapper.lockOrder("100", 1L)).thenReturn(List.of(order("100", 1L, "RK-1", "WH-A")));
when(sourcePalletMapper.palletNos("100", 1L)).thenReturn(List.of());
when(orderMapper.markPlanned(any(), any(), any(), org.mockito.ArgumentMatchers.anyInt(), any()))
.thenReturn(1);
var result = service.convertContainer("BOOKING-1");
assertEquals(1, result.size());
verify(planMapper).insert(any(InboundPlan.class));
}
@Test
void standardFbaContainerConversionStillRequiresSourcePalletSnapshot() {
when(orderMapper.lockContainerOrders("BOOKING-1")).thenReturn(List.of(
new InboundPlanOrderMapper.ContainerOrderRef("100", 1L, "PENDING_ASSIGNMENT",
"MSCU6639870", "STANDARD")));
SourceOrderSnapshot fba = new SourceOrderSnapshot(1L, "100", "MSCU6639870", "RK-1",
"PENDING_ASSIGNMENT", null, BigDecimal.ONE, 10, 1,
"193000000000200003", "US-LAX-01", "洛杉矶仓", "ABE3",
"FBA-1", "ABE3", "ABE3", 1, 0);
when(orderMapper.lockOrder("100", 1L)).thenReturn(List.of(fba));
when(sourcePalletMapper.palletNos("100", 1L)).thenReturn(List.of());
ResponseStatusException error = assertThrows(ResponseStatusException.class,
() -> service.convertContainer("BOOKING-1"));
assertEquals("散货订单缺少头程托盘码快照", error.getReason());
verify(planMapper, never()).insert(any(InboundPlan.class));
}
@Test
void invalidLaterOrderCausesNoWritesBecauseWholeContainerIsPrevalidated() {
when(orderMapper.lockContainerOrders("BOOKING-1")).thenReturn(List.of(