Merge test fixes into dev dropship flow

This commit is contained in:
2026-09-10 18:18:41 +08:00
131 changed files with 3062 additions and 651 deletions
@@ -80,6 +80,16 @@ class OverseasFeeBusinessGuardTest {
assertThat(jdbc.sql()).singleElement().asString().contains("GROUP BY customer_id");
}
@Test
void returnsEmptyWhenContainerHasNoLastlegOrders() {
StubJdbc jdbc = new StubJdbc();
var result = new OverseasFeeBusinessGuard(jdbc).listContainerCustomers(701L);
assertThat(result).isEmpty();
assertThat(jdbc.sql()).singleElement().asString().contains("source_container_booking_id");
}
static SaveRequest containerFee(String customerId, Long bookingId, String containerNo) {
return new SaveRequest(customerId, "客户A", "OVERSEAS_CONTAINER_FEE", "OVERSEAS_CONTAINER",
bookingId, containerNo, null, null, null, null, bookingId, containerNo, 91L,
@@ -68,7 +68,7 @@ class InboundPlanControllerTest {
void platformManualPlanPassesVersionedIdempotentCommand() {
ManualInboundPlanRequest request = manualRequest();
controller.manual(platform(), "manual-key", request);
verify(service).convertManual(request, "manual-key", "7");
verify(containerConversion).convertManualAndAutoMaterialize(request, "manual-key", "7");
}
@Test
@@ -76,7 +76,7 @@ class InboundPlanControllerTest {
AuthenticatedUser customer = new AuthenticatedUser(8L, 100L, 100L, 9L, "customer", "MERCHANT", "WEB", Set.of());
assertThatThrownBy(() -> controller.manual(customer, "manual-key", manualRequest()))
.isInstanceOf(ResponseStatusException.class);
verify(service, never()).convertManual(org.mockito.ArgumentMatchers.any(),
verify(containerConversion, never()).convertManualAndAutoMaterialize(org.mockito.ArgumentMatchers.any(),
org.mockito.ArgumentMatchers.any(), org.mockito.ArgumentMatchers.any());
}
@@ -33,11 +33,11 @@ class HttpUnloadPhotoFileGatewayTest {
@Test
void forgedImageBusinessFailureMapsToBadRequestInsteadOfInternalError() {
server.expect(requestTo("http://file-service/internal/file/v1/business-files/100/OVERSEAS_UNLOAD_PHOTO/8"))
server.expect(requestTo("http://file-service/internal/file/v1/business-files/0/OVERSEAS_UNLOAD_PHOTO/8"))
.andRespond(withSuccess("{\"code\":\"A0400\",\"message\":\"上传内容不是有效图片\",\"data\":null}",
MediaType.APPLICATION_JSON));
assertThatThrownBy(() -> gateway.upload("100", 8L, 7L,
assertThatThrownBy(() -> gateway.upload("0", 8L, 7L,
new MockMultipartFile("file", "forged.png", "image/png", "<script>".getBytes())))
.isInstanceOfSatisfying(ResponseStatusException.class,
error -> assertThat(error.getStatusCode().value()).isEqualTo(400));
@@ -46,11 +46,11 @@ class HttpUnloadPhotoFileGatewayTest {
@Test
void mismatchedPhotoMetadataMapsToBadRequest() {
server.expect(requestTo("http://file-service/internal/file/v1/business-files/100/OVERSEAS_UNLOAD_PHOTO/8/9"))
.andRespond(withSuccess("{\"code\":\"200\",\"data\":{\"fileId\":9,\"tenantId\":101,\"businessType\":\"OVERSEAS_UNLOAD_PHOTO\",\"businessId\":\"8\"}}",
server.expect(requestTo("http://file-service/internal/file/v1/business-files/0/OVERSEAS_UNLOAD_PHOTO/8/9"))
.andRespond(withSuccess("{\"code\":\"200\",\"data\":{\"fileId\":9,\"tenantId\":1,\"businessType\":\"OVERSEAS_UNLOAD_PHOTO\",\"businessId\":\"8\"}}",
MediaType.APPLICATION_JSON));
assertThatThrownBy(() -> gateway.validate("100", 8L, 9L))
assertThatThrownBy(() -> gateway.validate("0", 8L, 9L))
.isInstanceOfSatisfying(ResponseStatusException.class,
error -> assertThat(error.getStatusCode().value()).isEqualTo(400));
server.verify();
@@ -59,12 +59,12 @@ class HttpUnloadPhotoFileGatewayTest {
@Test
void downloadUsesBusinessOwnershipPathAndPreservesBlobMetadata() {
server.expect(requestTo(
"http://file-service/internal/file/v1/business-files/100/OVERSEAS_UNLOAD_PHOTO/8/9/content"))
"http://file-service/internal/file/v1/business-files/0/OVERSEAS_UNLOAD_PHOTO/8/9/content"))
.andExpect(header("X-Internal-Service-Token", "internal-token"))
.andRespond(withSuccess("photo-bytes".getBytes(), MediaType.IMAGE_JPEG)
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=door.jpg"));
UnloadPhotoFileGateway.DownloadedFile result = gateway.download("100", 8L, 9L);
UnloadPhotoFileGateway.DownloadedFile result = gateway.download("0", 8L, 9L);
assertThat(result.content()).containsExactly("photo-bytes".getBytes());
assertThat(result.fileName()).isEqualTo("door.jpg");
@@ -75,10 +75,10 @@ class HttpUnloadPhotoFileGatewayTest {
@Test
void missingOwnedPhotoMapsToNotFound() {
server.expect(requestTo(
"http://file-service/internal/file/v1/business-files/100/OVERSEAS_UNLOAD_PHOTO/8/9/content"))
"http://file-service/internal/file/v1/business-files/0/OVERSEAS_UNLOAD_PHOTO/8/9/content"))
.andRespond(withStatus(HttpStatus.NOT_FOUND));
assertThatThrownBy(() -> gateway.download("100", 8L, 9L))
assertThatThrownBy(() -> gateway.download("0", 8L, 9L))
.isInstanceOfSatisfying(ResponseStatusException.class,
error -> assertThat(error.getStatusCode().value()).isEqualTo(404));
server.verify();
@@ -85,6 +85,7 @@ class ReceivingContainerServiceBehaviorTest {
ReflectionTestUtils.setField(service, "sourceObjectMapper", new ObjectMapper().findAndRegisterModules());
service.initializeObjectMapper();
org.mockito.Mockito.lenient().when(shippingGates.receivingAvailable(any(), any())).thenReturn(1);
org.mockito.Mockito.lenient().when(pallets.selectCount(any())).thenReturn(1L);
}
@Test
@@ -256,6 +257,23 @@ class ReceivingContainerServiceBehaviorTest {
verify(plans).updateById(unassigned);
}
@Test
void prepareRejectsManualPlanBeforeRealPalletsAreMaterialized() {
InboundPlan plan = plan("TSTU0195472");
InboundPlanLine planLine = line("FBA");
LastlegOrder order = containerOrder(1L, "100", "TSTU0195472", "BOOKING-472", "IN-472");
when(plans.selectList(any())).thenReturn(List.of(plan));
when(lines.selectList(any())).thenReturn(List.of(planLine));
when(orders.selectList(any())).thenReturn(List.of(order));
when(pallets.selectCount(any())).thenReturn(0L);
assertThatThrownBy(() -> service.prepare("7", "receiver", 100L, "TSTU0195472",
new ReceivingContainerRequests.Action("missing-real-pallets")))
.isInstanceOf(ResponseStatusException.class)
.hasMessageContaining("尚未完整绑定真实托盘");
verify(sessions, never()).insert(any(ReceivingContainerSession.class));
}
@Test
void candidatesHideContainersReservedByAnotherOperator() {
InboundPlan available = plan("CONT-A");
@@ -863,7 +881,7 @@ class ReceivingContainerServiceBehaviorTest {
private static InboundPlan plan(String containerNo) {
InboundPlan value = new InboundPlan();
value.setId(2L); value.setPlanNo("PLAN-1"); value.setCustomerId("100"); value.setContainerNo(containerNo);
value.setStatus("SIGNED"); value.setOverseasWarehouseId(100L);
value.setStatus("SIGNED"); value.setOverseasWarehouseId(100L); value.setPalletCount(1);
return value;
}
@@ -2,6 +2,8 @@ package com.baiyue.lastleg.inboundplan.service;
import com.baiyue.lastleg.inboundplan.dto.ConvertContainerInboundPlanRequest;
import com.baiyue.lastleg.inboundplan.dto.ContainerInboundPlanPreviewResponse;
import com.baiyue.lastleg.inboundplan.dto.InboundPlanResponse;
import com.baiyue.lastleg.inboundplan.dto.ManualInboundPlanRequest;
import com.baiyue.lastleg.inboundplan.entity.ContainerPlanConversionCommand;
import com.baiyue.lastleg.inboundplan.mapper.ContainerPlanConversionCommandMapper;
import com.baiyue.lastleg.inboundplan.pda.gateway.WarehouseResourceGateway;
@@ -18,6 +20,7 @@ import org.springframework.transaction.support.SimpleTransactionStatus;
import org.springframework.web.server.ResponseStatusException;
import java.time.LocalDateTime;
import java.time.LocalDate;
import java.math.BigDecimal;
import java.util.List;
@@ -28,6 +31,7 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.doReturn;
@ExtendWith(MockitoExtension.class)
class ContainerInboundPlanConversionCoordinatorTest {
@@ -57,6 +61,43 @@ class ContainerInboundPlanConversionCoordinatorTest {
.thenReturn(new SimpleTransactionStatus());
}
@Test
void finalManualPlanAutomaticallyMaterializesSingleOrderContainer() {
ManualInboundPlanRequest request = manualRequest();
InboundPlanResponse logical = plan("IP-MANUAL", List.of());
InboundPlanResponse physical = plan("IP-MANUAL", List.of(new InboundPlanResponse.Pallet(
31L, "MSCU6639870-101-001", null, "ACY2", "Amazon ACY2", BigDecimal.ONE,
BigDecimal.ONE, 1, 51L, 61L, 71L, "WOOD", "LOCKED", LocalDateTime.now(), null, 0)));
ContainerInboundPlanConversionCoordinator spy = org.mockito.Mockito.spy(coordinator);
when(plans.convertManual(request, "manual-key", "7")).thenReturn(logical);
when(plans.sourceContainerBookingId("100", 11L)).thenReturn(BOOKING_ID);
when(plans.previewContainer(BOOKING_ID)).thenReturn(manualPreview(List.of(resourcePendingOrder())));
doReturn(List.of(physical)).when(spy).confirm(any(ConvertContainerInboundPlanRequest.class), any(String.class));
assertEquals(physical, spy.convertManualAndAutoMaterialize(request, "manual-key", "7"));
verify(spy).confirm(eq(new ConvertContainerInboundPlanRequest(BOOKING_ID, 7L, SNAPSHOT_HASH)),
any(String.class));
}
@Test
void earlierManualPlanWaitsUntilEveryOrderInContainerHasAPlan() {
ManualInboundPlanRequest request = manualRequest();
InboundPlanResponse logical = plan("IP-MANUAL", List.of());
var ready = new ContainerInboundPlanPreviewResponse.Order(
"200", "Customer 200", "12", "LM-12", "RK-2", "FIRST_LEG", "FBA",
null, "ONT8", "Amazon ONT8", "ONT8", 10, BigDecimal.ONE, 1,
null, null, null, 0, "READY", List.of());
when(plans.convertManual(request, "manual-key", "7")).thenReturn(logical);
when(plans.sourceContainerBookingId("100", 11L)).thenReturn(BOOKING_ID);
when(plans.previewContainer(BOOKING_ID)).thenReturn(manualPreview(List.of(resourcePendingOrder(), ready)));
assertEquals(logical, coordinator.convertManualAndAutoMaterialize(request, "manual-key", "7"));
verify(commands, never()).findByBooking(any(String.class));
verify(warehouse, never()).ensurePalletBatch(any());
}
@Test
void anotherIdempotencyKeyForCompletedCabinetReplaysWithoutCreatingAnotherBatch() throws Exception {
ConvertContainerInboundPlanRequest request = request();
@@ -290,6 +331,72 @@ class ContainerInboundPlanConversionCoordinatorTest {
.map(ContainerInboundPlanConversionCoordinator.PreparedItem::palletCode).toList());
}
@Test
void standardFbaPreviewMaySupplementButNeverReduceHeadLegPalletCodes() {
ConvertContainerInboundPlanRequest request = request();
var order = new ContainerInboundPlanPreviewResponse.Order(
"100", "Customer 100", "11", "LM-11", "RK-FBA", "FIRST_LEG", "FBA",
null, "ACY2", "Amazon ACY2", "ACY2", 20, new BigDecimal("5.8000"), 3,
null, null, null, 0, "READY", List.of());
var preview = new ContainerInboundPlanPreviewResponse(BOOKING_ID, "MSCU6639870", "31", "US-LAX-01",
"Los Angeles", 7L, SNAPSHOT_HASH, 1, 1, 0, 1, 3, 0, 3, 0, true,
List.of(new ContainerInboundPlanPreviewResponse.Group("FBA", null, "ACY2", "Amazon ACY2",
1, 1, 3, 0, 3, 0, List.of(order))));
when(plans.previewContainer(BOOKING_ID)).thenReturn(preview);
when(numbers.next(eq("INBOUND_PLAN"), any(String.class), any(Long.class))).thenReturn("IP-ACY2");
when(plans.sourcePalletNos("100", 11L, "FIRST_LEG")).thenReturn(List.of(
"MSCU6639870-101-001", "MSCU6639870-101-002"));
ContainerPlanConversionCommand command = ReflectionTestUtils.invokeMethod(coordinator, "prepareCommand",
1L, 2L, BOOKING_ID, "FIRST-KEY", request,
ReflectionTestUtils.invokeMethod(coordinator, "hash",
List.of(BOOKING_ID, request.snapshotVersion(), request.snapshotHash())));
ContainerInboundPlanConversionCoordinator.Preparation preparation;
try {
preparation = objectMapper.readValue(command.getPreparationJson(),
ContainerInboundPlanConversionCoordinator.Preparation.class);
} catch (Exception exception) {
throw new AssertionError(exception);
}
assertEquals(List.of("MSCU6639870-101-001", "MSCU6639870-101-002", "MSCU6639870-101-003"),
preparation.items().stream().map(ContainerInboundPlanConversionCoordinator.PreparedItem::palletCode).toList());
}
@Test
void existingManualPlanIsPreparedForWarehouseMaterialization() {
ConvertContainerInboundPlanRequest request = request();
var order = new ContainerInboundPlanPreviewResponse.Order(
"100", "Customer 100", "11", "LM-11", "RK-FBA", "FIRST_LEG", "FBA",
null, "ACY2", "Amazon ACY2", "ACY2", 20, new BigDecimal("5.8000"), 3,
3, "IP-MANUAL", "PENDING_ASSIGNMENT", 1, "RESOURCE_PENDING", List.of());
var preview = new ContainerInboundPlanPreviewResponse(BOOKING_ID, "MSCU6639870", "31", "US-LAX-01",
"Los Angeles", 7L, SNAPSHOT_HASH, 1, 1, 0, 1, 3, 3, 3, 3, true,
List.of(new ContainerInboundPlanPreviewResponse.Group("FBA", null, "ACY2", "Amazon ACY2",
1, 1, 3, 3, 3, 3, List.of(order))));
when(plans.previewContainer(BOOKING_ID)).thenReturn(preview);
when(plans.sourcePalletNos("100", 11L, "FIRST_LEG")).thenReturn(List.of(
"MSCU6639870-101-001", "MSCU6639870-101-002"));
when(plans.existingPlanIdentity("100", 11L))
.thenReturn(new InboundPlanService.PlanIdentity(21L, "IP-MANUAL", 3));
ContainerPlanConversionCommand command = ReflectionTestUtils.invokeMethod(coordinator, "prepareCommand",
1L, 2L, BOOKING_ID, "FIRST-KEY", request,
ReflectionTestUtils.invokeMethod(coordinator, "hash",
List.of(BOOKING_ID, request.snapshotVersion(), request.snapshotHash())));
ContainerInboundPlanConversionCoordinator.Preparation preparation;
try {
preparation = objectMapper.readValue(command.getPreparationJson(),
ContainerInboundPlanConversionCoordinator.Preparation.class);
} catch (Exception exception) {
throw new AssertionError(exception);
}
assertEquals(21L, preparation.items().get(0).planId());
assertEquals("IP-MANUAL", preparation.items().get(0).planNo());
verify(numbers, never()).next(any(String.class), any(String.class), any(Long.class));
}
private ContainerInboundPlanPreviewResponse.Order previewOrder(String customerId, String orderId,
String inboundCode, String destinationCode,
String fbaWarehouseCode) {
@@ -300,6 +407,36 @@ class ContainerInboundPlanConversionCoordinatorTest {
fbaWarehouseCode, 10, BigDecimal.ONE, 1, null, null, null, 0, "READY", List.of());
}
private ManualInboundPlanRequest manualRequest() {
return new ManualInboundPlanRequest("100", 11L, 0, LocalDate.of(2026, 9, 10),
1, "WOOD", false, false, false, "自动生成");
}
private ContainerInboundPlanPreviewResponse.Order resourcePendingOrder() {
return new ContainerInboundPlanPreviewResponse.Order(
"100", "Customer 100", "11", "LM-11", "RK-1", "FIRST_LEG", "FBA",
null, "ACY2", "Amazon ACY2", "ACY2", 10, BigDecimal.ONE, 1,
1, "IP-MANUAL", "PENDING_ASSIGNMENT", 1, "RESOURCE_PENDING", List.of());
}
private ContainerInboundPlanPreviewResponse manualPreview(
List<ContainerInboundPlanPreviewResponse.Order> orders) {
int pending = (int) orders.stream().filter(order -> "RESOURCE_PENDING".equals(order.readiness())
|| "READY".equals(order.readiness())).count();
return new ContainerInboundPlanPreviewResponse(BOOKING_ID, "MSCU6639870", "31", "US-LAX-01",
"Los Angeles", 7L, SNAPSHOT_HASH, orders.size(), orders.size(), 0, pending, pending,
0, orders.size(), 1, true,
List.of(new ContainerInboundPlanPreviewResponse.Group("FBA", null, "ACY2", "Amazon ACY2",
orders.size(), pending, pending, 0, orders.size(), 1, orders)));
}
private InboundPlanResponse plan(String planNo, List<InboundPlanResponse.Pallet> pallets) {
return new InboundPlanResponse(21L, planNo, "100", 11L, "MSCU6639870", "US-LAX-01",
"Los Angeles", "PENDING_ASSIGNMENT", 1, 1, BigDecimal.ONE, 10, 0,
List.of(), pallets, List.of(), 1, LocalDate.of(2026, 9, 10), "WOOD", false,
false, false, "MANUAL", "自动生成");
}
private ConvertContainerInboundPlanRequest request() {
return new ConvertContainerInboundPlanRequest(BOOKING_ID, 7L, SNAPSHOT_HASH);
}
@@ -74,7 +74,7 @@ class ContainerInboundPlanPreviewTest {
new InboundPlanOrderMapper.ContainerPreviewOrderRow("100", 1L, "LM-1", "FO-1", "测试客户",
"FIRST_LEG", "OVERSEAS", "IN-1", "PENDING_ASSIGNMENT", null, null, 0, 0,
BigDecimal.ZERO, null, null, null, null, null, null, null, 0, false, 1,
null, null, null)));
null, null, null, null)));
var result = service.previewContainer("BOOKING-NULL");
@@ -103,9 +103,33 @@ class ContainerInboundPlanPreviewTest {
.map(ContainerInboundPlanPreviewResponse.Group::destinationType).toList());
}
@Test
void signedManualPlanWithoutWarehousePalletsRemainsResourcePending() {
when(orderMapper.containerPreviewOrders("BOOKING-SIGNED")).thenReturn(List.of(
row(1L, "LM-SIGNED", "FIRST_LEG", "FBA", "ACY2", "Amazon ACY2", 3,
"IP-SIGNED", 3, 1, "SIGNED", 0)
));
var result = service.previewContainer("BOOKING-SIGNED");
assertEquals(true, result.ready());
assertEquals(1, result.pendingOrderCount());
assertEquals(3, result.pendingPalletCount());
assertEquals("RESOURCE_PENDING", result.groups().get(0).orders().get(0).readiness());
}
private InboundPlanOrderMapper.ContainerPreviewOrderRow row(
long id, String orderNo, String orderType, String destinationType, String destinationCode, String destinationName,
int recommendedPallets, String planNo, Integer plannedPallets, int version) {
return row(id, orderNo, orderType, destinationType, destinationCode, destinationName,
recommendedPallets, planNo, plannedPallets, version,
planNo == null ? null : "PENDING_ASSIGNMENT", plannedPallets);
}
private InboundPlanOrderMapper.ContainerPreviewOrderRow row(
long id, String orderNo, String orderType, String destinationType, String destinationCode, String destinationName,
int recommendedPallets, String planNo, Integer plannedPallets, int version, String planStatus,
Integer materializedPallets) {
return new InboundPlanOrderMapper.ContainerPreviewOrderRow("100", id, orderNo, "FO-" + id,
"测试客户", orderType, destinationType, "IN-" + id, "PENDING_ASSIGNMENT", planNo,
"MSCU6639870", recommendedPallets, 10, new BigDecimal("1.0000"),
@@ -113,6 +137,6 @@ class ContainerInboundPlanPreviewTest {
"FBA".equals(destinationType) || destinationCode == null ? null : "WH-" + id,
"FBA".equals(destinationType) ? null : destinationCode, destinationName,
"FBA".equals(destinationType) || destinationCode == null ? 0 : 1, false, version, planNo,
planNo == null ? null : "PENDING_ASSIGNMENT", plannedPallets);
planStatus, plannedPallets, materializedPallets);
}
}
@@ -164,6 +164,54 @@ class InboundPlanServiceTest {
verify(orderMapper).lockContainerWarehouseFacts("100", 2L);
}
@Test
void manualPlanMayExceedButCannotUndercutPreviewPalletCount() {
SourceOrderSnapshot source = new SourceOrderSnapshot(2L, "100", "MSCU6639870", "RK-2",
"PENDING_ASSIGNMENT", null, new BigDecimal("5.8000"), 58, 2,
"193000000000200003", "US-LAX-01", "洛杉矶仓", "ACY2",
null, null, "Amazon ACY2", 0, 0, false, 0);
when(orderMapper.lockOrder("100", 2L)).thenReturn(List.of(source));
ResponseStatusException error = assertThrows(ResponseStatusException.class, () -> service.convertManual(
new ManualInboundPlanRequest("100", 2L, 0, LocalDate.of(2026, 9, 15),
2, "WOOD", false, false, false, null), "manual-below-preview", "900"));
assertEquals(400, error.getStatusCode().value());
verify(planMapper, never()).insert(any(InboundPlan.class));
verify(commandMapper, never()).insert(any(com.baiyue.lastleg.entity.LastlegOrderCommandRecord.class));
}
@Test
void containerConversionBindsRealWarehousePalletsBackToSignedManualPlanBeforeReceiving() {
InboundPlan plan = existingPlan("100", 2L, "IP-MANUAL");
plan.setCreationMode("MANUAL");
plan.setPalletCount(2);
plan.setStatus("SIGNED");
InboundPlanPallet first = new InboundPlanPallet();
first.setId(301L); first.setCustomerId("100"); first.setPlanId(plan.getId()); first.setSequenceNo(1);
InboundPlanPallet second = new InboundPlanPallet();
second.setId(302L); second.setCustomerId("100"); second.setPlanId(plan.getId()); second.setSequenceNo(2);
when(palletMapper.selectList(any())).thenReturn(List.of(first, second));
var firstReservation = new WarehouseResourceGateway.PalletBatchItem(100L, "CIP:1:1", "IP-MANUAL",
1, 401L, "MSCU6639870-101-001", 501L, 601L, "RESERVED");
var secondReservation = new WarehouseResourceGateway.PalletBatchItem(100L, "CIP:1:2", "IP-MANUAL",
2, 402L, "MSCU6639870-101-002", 502L, 602L, "RESERVED");
var prepared = new InboundPlanService.PreparedPlan(plan.getId(), plan.getPlanNo(), "100", 2L, List.of(
new InboundPlanService.PreparedPallet(1, "CIP:1:1", firstReservation),
new InboundPlanService.PreparedPallet(2, "CIP:1:2", secondReservation)));
ReflectionTestUtils.invokeMethod(service, "materializeExistingPlan", plan,
new InboundPlanOrderMapper.ContainerOrderRef("100", 2L, "INBOUND_PLANNED", "MSCU6639870", "FIRST_LEG"),
prepared);
assertEquals("MSCU6639870-101-001", first.getPalletNo());
assertEquals("MSCU6639870-101-001", first.getSourcePalletNo());
assertEquals(401L, first.getWarehousePalletId());
assertEquals("RESERVED", first.getAssignmentStatus());
assertEquals(402L, second.getWarehousePalletId());
verify(palletMapper, times(2)).updateById(any(InboundPlanPallet.class));
verify(planMapper).updateById(plan);
}
@Test
void manuallyCreatesPlanWhenStableWarehouseIdExistsWithoutDisplaySnapshots() {
SourceOrderSnapshot source = new SourceOrderSnapshot(2L, "100", "MSCU6639870", "RK-2",
@@ -27,7 +27,7 @@ class ContainerPlanProgressContractTest {
assertEquals(List.of("sourceContainerBookingId", "containerNo", "overseasWarehouseId",
"overseasWarehouseCode", "overseasWarehouseName", "assignmentVersion",
"canChangeReceivingWarehouse", "receivingWarehouseLockReason", "totalOrderCount", "inboundCodeCount",
"missingInboundCodeCount", "planCount", "plannedInboundCodeCount", "pendingPlanCount",
"missingInboundCodeCount", "planCount", "plannedInboundCodeCount", "pendingPlanCount", "resourcePendingPlanCount",
"plannedArrivalAt", "allPlansReady", "blockingReason"),
Arrays.stream(ContainerPlanProgressSummary.class.getRecordComponents())
.map(value -> value.getName()).toList());
@@ -40,6 +40,7 @@ class ContainerPlanProgressContractTest {
LastlegOrderRequests.ContainerProgressQuery.class, long.class, long.class).getAnnotation(Select.class);
String sql = String.join("", rows.value()).toLowerCase();
assertTrue(sql.contains("left join ll_inbound_plan"));
assertTrue(sql.contains("ll_inbound_plan_pallet"));
assertTrue(sql.contains("o.estimated_warehouse_at"));
assertTrue(sql.contains("group by o.source_container_booking_id"));
assertFalse(sql.contains("having "));
@@ -97,7 +97,7 @@ class LastlegOrderServiceTest {
}
var updated = new ContainerPlanProgressSummary("BOOKING-1", "MSCU6639870", "900",
"US-NYC-01", "纽约仓", 1, true, null, 2, 2, 0, 2, 2, 0,
null, true, null);
0, null, true, null);
when(orders.lockContainerOrders("BOOKING-1")).thenReturn(List.of(first, second));
when(warehouseResourceGateway.requireActiveSharedWarehouse(900L)).thenReturn(
new WarehouseResourceGateway.WarehouseReference(900L, "US-NYC-01", "纽约仓", "ACTIVE"));
@@ -382,7 +382,7 @@ class LastlegOrderServiceTest {
var healthy = summary(false, 3, "存在3票尚未生成有效入库计划");
var missingWarehouse = new ContainerPlanProgressSummary("BOOKING-2", "MSCU6639870",
null, null, null, 0, true, null, 2, 2, 0, 0, 0, 2,
LocalDateTime.of(2026, 10, 4, 9, 0), false, "存在2票尚未生成有效入库计划");
0, LocalDateTime.of(2026, 10, 4, 9, 0), false, "存在2票尚未生成有效入库计划");
when(orders.countContainerProgress(query)).thenReturn(2L);
when(orders.pageContainerProgress(query, 0, 10)).thenReturn(List.of(healthy, missingWarehouse));
@@ -402,7 +402,7 @@ class LastlegOrderServiceTest {
var locked = new ContainerPlanProgressSummary("BOOKING-2", "TSTU0000061",
"193000000000200003", "US-LAX-01", "洛杉矶仓", 4, false,
"海外PDA已建立接柜会话,接柜仓已永久锁定", 1, 1, 0, 1, 1, 0,
LocalDateTime.of(2026, 10, 4, 9, 0), true, null);
0, LocalDateTime.of(2026, 10, 4, 9, 0), true, null);
when(orders.countContainerProgress(query)).thenReturn(2L);
when(orders.pageContainerProgress(query, 0, 10)).thenReturn(List.of(ready, locked));
@@ -419,7 +419,7 @@ class LastlegOrderServiceTest {
private static ContainerPlanProgressSummary summary(boolean ready, long pending, String reason) {
return new ContainerPlanProgressSummary("BOOKING-1", "MSCU6639870", "193000000000200003",
"US-LAX-01", "洛杉矶仓", 0, true, null, 15, 15, 0,
15 - pending, 15 - pending, pending, LocalDateTime.of(2026, 10, 3, 9, 0), ready, reason);
15 - pending, 15 - pending, pending, 0, LocalDateTime.of(2026, 10, 3, 9, 0), ready, reason);
}
@Test