fix: limit dispatch vehicles to 15 and 30 pallets

This commit is contained in:
2026-09-15 12:17:16 +08:00
parent 37c3e676a4
commit 9888072d8c
7 changed files with 20 additions and 4 deletions
@@ -181,6 +181,7 @@ class PlatformDispatchOutboundContractTest {
assertTrue(yaml.contains("platform:overseas-warehouse:outbound:list"));
assertTrue(yaml.contains("platform:overseas-warehouse:outbound:create"));
assertTrue(yaml.contains("platform:overseas-warehouse:outbound:cancel"));
assertTrue(yaml.contains("vehicleSize: { type: string, nullable: true, enum: [15托, 30托] }"));
}
private static void assertPermission(Method method, String permission) {
@@ -25,6 +25,7 @@ class SmartDispatchOpenApiContractTest {
assertTrue(yaml.contains("/api/platform/v1/last-leg/dispatches/drafts/{draftToken}/containers/{containerId}:"));
assertTrue(yaml.contains("draftContainerId:"));
assertTrue(yaml.contains("SmartDispatchDraftContainer:"));
assertTrue(yaml.contains("capacity: { type: integer, enum: [15, 30] }"));
assertTrue(yaml.contains("SmartDispatchDraft:"));
assertTrue(yaml.contains("platform:overseas-warehouse:inbound-order:list"));
assertTrue(yaml.contains("platform:overseas-warehouse:inbound-order:smart-dispatch"));
@@ -252,6 +252,17 @@ class DispatchServiceTest {
verify(locks).findActiveByDraftContainer("draft-1", 21L);
}
@Test
void draftContainerOnlyAcceptsFifteenOrThirtyPalletVehicles() {
ResponseStatusException exception = assertThrows(ResponseStatusException.class,
() -> service.createDraftContainer("7", new DispatchRequests.DraftContainer("draft-1", 14)));
assertEquals(409, exception.getStatusCode().value());
assertEquals("车辆大小仅支持15托或30托", exception.getReason());
verify(drafts, never()).lockActive(any(), any());
verify(draftContainers, never()).insert(any(DispatchDraftContainer.class));
}
@Test
void rejectsPalletAlreadyLockedByAnotherDispatch() {
when(candidates.lockSelected("100", List.of(10L))).thenReturn(List.of(candidate(10L, null, "ONT8")));