fix(firstleg): scope loading evidence to cabinet tasks

This commit is contained in:
2026-08-31 18:14:36 +08:00
parent 4795ab958c
commit df0fbc1c7f
31 changed files with 695 additions and 1314 deletions
@@ -23,6 +23,7 @@ import com.baiyue.firstleg.entity.ContainerBookingEntity;
import com.baiyue.firstleg.entity.InboundStatusHistoryEntity;
import com.baiyue.firstleg.loading.mapper.LoadingInboundMapper;
import com.baiyue.firstleg.loading.service.LoadingDeliveryService;
import com.baiyue.firstleg.loading.service.CabinetLoadingEvidenceService;
import com.baiyue.firstleg.loading.bridge.dto.LoadingModelBridgeDtos.Link;
import com.baiyue.firstleg.loading.bridge.service.LoadingModelBridgeService;
import com.baiyue.firstleg.loading.coload.port.ColoadGroupAssignmentPort;
@@ -83,6 +84,8 @@ class LoadingPickServiceTest {
@MockBean
private LoadingDeliveryService loadingDeliveryService;
@MockBean
private CabinetLoadingEvidenceService cabinetEvidenceService;
@MockBean
private ColoadGroupAssignmentPort coloadGroups;
@MockBean
private TruckAppointmentService truckAppointmentService;
@@ -574,17 +577,17 @@ class LoadingPickServiceTest {
verify(loadingListService).finishFromPda(10L, 20L, 9L, "operator");
verify(settlementService).settle(20L, 9L, "operator");
verify(repository).syncInboundProjections(20L, 9L, "operator");
verify(loadingDeliveryService).requirePdaCompletionReady(101L, 50L, 101L, 50L);
verify(loadingDeliveryService).requirePdaCompletionReady(101L, 60L, 101L, 50L);
verify(loadingDeliveryService).requirePdaCompletionReady(101L, 50L);
verify(loadingDeliveryService).requirePdaCompletionReady(101L, 60L);
verify(truckAppointmentService).completeLoadingFromPda(99L, 20L, 9L, "operator");
verify(loadingDeliveryService).completeAfterPdaSettlement(101L, 50L, 101L, 50L, 9L, "operator",
verify(loadingDeliveryService).completeAfterPdaSettlement(101L, 50L, 9L, "operator",
"PDA-complete-1-50", "checked");
verify(loadingDeliveryService).completeAfterPdaSettlement(101L, 60L, 101L, 50L, 9L, "operator",
verify(loadingDeliveryService).completeAfterPdaSettlement(101L, 60L, 9L, "operator",
"PDA-complete-1-60", "checked");
verify(loadingListService).publishCompletedEvent(10L);
InOrder finalization = inOrder(loadingListService, loadingDeliveryService);
finalization.verify(loadingListService).finishFromPda(10L, 20L, 9L, "operator");
finalization.verify(loadingDeliveryService).completeAfterPdaSettlement(101L, 50L, 101L, 50L, 9L, "operator",
finalization.verify(loadingDeliveryService).completeAfterPdaSettlement(101L, 50L, 9L, "operator",
"PDA-complete-1-50", "checked");
finalization.verify(loadingListService).publishCompletedEvent(10L);
}
@@ -615,7 +618,7 @@ class LoadingPickServiceTest {
verify(settlementService).settle(20L, 9L, "operator");
verify(repository).approve(20L, 9L, "operator", "checked");
verify(loadingListService).finishFromPda(10L, 20L, 9L, "operator");
verify(loadingDeliveryService).completeAfterPdaSettlement(101L, 50L, 101L, 50L, 9L, "operator",
verify(loadingDeliveryService).completeAfterPdaSettlement(101L, 50L, 9L, "operator",
"PDA-complete-not-blocked-50", "checked");
verify(loadingListService).publishCompletedEvent(10L);
}
@@ -634,7 +637,7 @@ class LoadingPickServiceTest {
new LoadingInboundMapper.Snapshot(50L, 101L, "LOADING", 7));
doThrow(new BizException(com.baiyue.common.core.api.ResultCode.CONFLICT,
"入库单并发修改"))
.when(loadingDeliveryService).completeAfterPdaSettlement(101L, 50L, 101L, 50L, 9L, "operator",
.when(loadingDeliveryService).completeAfterPdaSettlement(101L, 50L, 9L, "operator",
"PDA-complete-finalize-fails-50", "checked");
assertThatThrownBy(() -> service.complete(20L,
@@ -694,7 +697,7 @@ class LoadingPickServiceTest {
verify(loadingListService, never()).finishFromPda(anyLong(), anyLong(), anyLong(), anyString());
verify(loadingListService, never()).publishCompletedEvent(anyLong());
verify(loadingDeliveryService, never()).completeAfterPdaSettlement(anyLong(), anyLong(), anyLong(),
anyLong(), anyLong(), anyString(), anyString(), anyString());
anyString(), anyString(), anyString());
}
@Test
@@ -869,7 +872,7 @@ class LoadingPickServiceTest {
}
@Test
void workerUsesOneStableCabinetEvidenceOwnerAcrossTwoCustomers() {
void workerUsesCabinetEvidenceOnceWithReversedTwoCustomerOwnerOrder() {
LoadingPickTaskEntity completing = task();
completing.setTaskStatus("COMPLETING");
when(repository.task(20L)).thenReturn(completing);
@@ -889,12 +892,13 @@ class LoadingPickServiceTest {
service.processCompletion(completionCommand(903L, "async-multi"), "worker-multi");
verify(loadingDeliveryService).requirePdaCompletionReady(101L, 50L, 101L, 50L);
verify(loadingDeliveryService).requirePdaCompletionReady(101L, 60L, 101L, 50L);
verify(loadingDeliveryService).requirePdaCompletionReady(202L, 70L, 101L, 50L);
verify(loadingDeliveryService).requirePdaCompletionReady(202L, 80L, 101L, 50L);
verify(cabinetEvidenceService, times(1)).requireComplete(99L);
verify(loadingDeliveryService).requirePdaCompletionReady(101L, 50L);
verify(loadingDeliveryService).requirePdaCompletionReady(101L, 60L);
verify(loadingDeliveryService).requirePdaCompletionReady(202L, 70L);
verify(loadingDeliveryService).requirePdaCompletionReady(202L, 80L);
verify(loadingDeliveryService).completeAfterPdaSettlement(
202L, 70L, 101L, 50L, 9L, "operator", "PDA-async-multi-70", "checked");
202L, 70L, 9L, "operator", "PDA-async-multi-70", "checked");
verify(settlementService, times(4)).settleOwner(eq(20L), anyLong(), eq(9L), eq("operator"));
verify(repository, times(1)).insert(argThat((LoadingPickOperationEntity operation) ->
"COMPLETE_LOADING".equals(operation.getActionType())
@@ -914,7 +918,7 @@ class LoadingPickServiceTest {
new LoadingPickItemMapper.InboundOwner(101L, 50L),
new LoadingPickItemMapper.InboundOwner(202L, 70L)));
doThrow(new BizException(com.baiyue.common.core.api.ResultCode.CONFLICT, "第二客户门禁未就绪"))
.when(loadingDeliveryService).requirePdaCompletionReady(202L, 70L, 101L, 50L);
.when(loadingDeliveryService).requirePdaCompletionReady(202L, 70L);
assertThatThrownBy(() -> service.processCompletion(
completionCommand(904L, "async-owner-ready-fails"), "worker-failure"))
@@ -924,7 +928,7 @@ class LoadingPickServiceTest {
verify(settlementService, never()).settleOwner(anyLong(), anyLong(), anyLong(), anyString());
verify(loadingDeliveryService, never()).completeAfterPdaSettlement(anyLong(), anyLong(), anyLong(),
anyLong(), anyLong(), anyString(), anyString(), anyString());
anyString(), anyString(), anyString());
verify(completionCommands).checkpoint(904L, 101L, 50L, 1, "READY");
verify(completionCommands, never()).checkpoint(eq(904L), anyLong(), anyLong(), anyInt(),
eq("SETTLED"));
@@ -952,8 +956,8 @@ class LoadingPickServiceTest {
verify(settlementService, never()).settleOwner(anyLong(), anyLong(), anyLong(), anyString());
verify(loadingDeliveryService, never()).completeAfterPdaSettlement(eq(101L), eq(50L), anyLong(),
anyLong(), anyLong(), anyString(), anyString(), anyString());
verify(loadingDeliveryService).completeAfterPdaSettlement(202L, 60L, 101L, 50L, 9L, "operator",
anyString(), anyString(), anyString());
verify(loadingDeliveryService).completeAfterPdaSettlement(202L, 60L, 9L, "operator",
"PDA-async-resume-60", "checked");
verify(loadingListService).publishCompletedEvent(10L);
verify(repository).insert(org.mockito.ArgumentMatchers.<LoadingPickOperationEntity>argThat(