fix(firstleg): continue same-plan loading allocations

This commit is contained in:
2026-08-25 13:59:03 +08:00
parent 72f3f9f971
commit 98766e2b1a
5 changed files with 31 additions and 15 deletions
@@ -44,7 +44,7 @@ class SmartLoadingCandidateMapperContractTest {
@Test
void detailUsesSameBatchRule() throws Exception {
Method detail = SmartLoadingCandidateMapper.class.getDeclaredMethod(
"candidate", long.class, long.class, long.class);
"candidate", long.class, long.class, long.class, long.class);
String sql = String.join(" ", detail.getAnnotation(Select.class).value());
assertThat(sql)
@@ -53,6 +53,12 @@ class SmartLoadingCandidateMapperContractTest {
.contains("SELECT MAX(m2.id)")
.contains("o.warehouse_id=#{warehouseId}")
.contains("o.process_status='WAIT_SPLIT'")
.contains("o.process_status='LOADING'")
.contains("same_plan_item.loading_plan_id=#{planId}")
.contains("same_plan_item.account_id=o.tenant_id")
.contains("same_plan_item.inbound_id=o.id")
.contains("same_plan_item.deleted=0")
.doesNotContain("o.process_status IN ('WAIT_SPLIT','LOADING')")
.contains("unitGrossWeightKg")
.contains("unitNetWeightKg")
.doesNotContain("i.unit_weight_kg")
@@ -242,7 +242,7 @@ class SmartLoadingServiceTest {
LoadingPlanEntity plan = plan("EDITING", 0);
when(repository.plan(1)).thenReturn(plan);
when(repository.booking(99L)).thenReturn(booking());
when(repository.candidate(100, 10, 20)).thenReturn(candidate(5));
when(repository.candidate(1, 100, 10, 20)).thenReturn(candidate(5));
when(repository.activeItem(1L, 9L, 20L)).thenReturn(item(7, 9, 20, 4));
BizException error = catchThrowableOfType(() -> service.assign(1,
@@ -259,7 +259,7 @@ class SmartLoadingServiceTest {
linked.setCustomerId(88L);
when(repository.plan(1L)).thenReturn(plan);
when(repository.booking(99L)).thenReturn(linked);
when(repository.candidate(100L, 10L, 20L)).thenReturn(candidate(5));
when(repository.candidate(1L, 100L, 10L, 20L)).thenReturn(candidate(5));
BizException error = catchThrowableOfType(() -> service.assign(1L,
new AssignRequest(10L, 20L, 1, 0, "assign-customer-mismatch"), 7L, "u"), BizException.class);
@@ -357,7 +357,7 @@ class SmartLoadingServiceTest {
when(repository.booking(99)).thenReturn(booking());
when(repository.touch(1, 5, 7, "u")).thenReturn(1);
when(repository.items(1)).thenReturn(List.of());
when(repository.candidate(100, 10, 20)).thenReturn(candidate(10));
when(repository.candidate(1, 100, 10, 20)).thenReturn(candidate(10));
when(repository.activeItem(1L, 9L, 20L)).thenReturn(null);
when(loadingPickService.mutationSnapshot(1L)).thenReturn(
new LoadingPickService.MutationSnapshot(77L, "LOADING", 6, Map.of()));
@@ -368,6 +368,7 @@ class SmartLoadingServiceTest {
Plan result = service.assign(1, new AssignRequest(10L, 20L, 1, 5, "assign-loading"), 7, "u");
assertThat(result.status()).isEqualTo("LOADING");
verify(repository).candidate(1L, 100L, 10L, 20L);
var order = inOrder(loadingPickService, splitPreloadService, repository, loadingModelBridge);
order.verify(loadingPickService).lockMutable(1L);
order.verify(splitPreloadService).ensureForRunningLoadingAllocation(9L, 10L, 7L, "u");
@@ -393,7 +394,7 @@ class SmartLoadingServiceTest {
Plan result = service.assign(1, request, 7, "u");
assertThat(result.status()).isEqualTo("LOADING");
verify(repository, never()).candidate(anyLong(), anyLong(), anyLong());
verify(repository, never()).candidate(anyLong(), anyLong(), anyLong(), anyLong());
verify(cargoClient, never()).detail(anyString(), anyLong(), anyLong(), anyLong());
}
@@ -592,7 +593,7 @@ class SmartLoadingServiceTest {
when(repository.plan(1L)).thenReturn(plan, plan("LOADING", 3));
when(repository.item(1L, 8L)).thenReturn(line);
when(repository.booking(99L)).thenReturn(booking());
when(repository.candidate(100L, 10L, 20L)).thenReturn(candidate(10));
when(repository.candidate(1L, 100L, 10L, 20L)).thenReturn(candidate(10));
when(repository.items(1L)).thenReturn(List.of(line));
when(repository.touch(1L, 2, 7L, "u")).thenReturn(1);
when(repository.update(line)).thenReturn(1);
@@ -617,7 +618,7 @@ class SmartLoadingServiceTest {
new AdjustRequest(1, 2, 0, "adjust-picked"), 7L, "u"))
.hasMessageContaining("不能低于已拣货箱数");
verify(repository, never()).candidate(anyLong(), anyLong(), anyLong());
verify(repository, never()).candidate(anyLong(), anyLong(), anyLong(), anyLong());
verify(repository, never()).touch(anyLong(), anyInt(), anyLong(), anyString());
}
@@ -878,7 +879,7 @@ class SmartLoadingServiceTest {
when(repository.plan(1)).thenReturn(plan, plan("EDITING", 1));
when(repository.booking(99)).thenReturn(booking());
when(repository.items(1)).thenReturn(List.of());
when(repository.candidate(100, 10, 20)).thenReturn(candidate(10));
when(repository.candidate(1, 100, 10, 20)).thenReturn(candidate(10));
when(repository.activeItem(1L, 9L, 20L)).thenReturn(null);
when(repository.touch(1, 0, 7, "u")).thenReturn(1);
}