优化
This commit is contained in:
+12
-3
@@ -135,12 +135,12 @@ public class LoadingDeliveryService {
|
||||
key, request, target, acceptedPdaCompletion);
|
||||
}
|
||||
if ("LOADED".equals(inbound.processStatus()) || "DELIVERED".equals(inbound.processStatus())) {
|
||||
loadingModelBridge.requireCompleted(tenantId, inboundId);
|
||||
requireLoadingPlanGate(tenantId, inboundId, acceptedPdaCompletion);
|
||||
return complete(tenantId, inboundId, operatorId, COMPLETE_LOADING, key,
|
||||
new LoadingActionResponse(inbound.processStatus(), evidenceResponse(tenantId, inboundId)));
|
||||
}
|
||||
if (!"LOADING".equals(inbound.processStatus())) throw new BizException(ResultCode.CONFLICT, "当前订单不在装柜中");
|
||||
loadingModelBridge.requireCompleted(tenantId, inboundId);
|
||||
requireLoadingPlanGate(tenantId, inboundId, acceptedPdaCompletion);
|
||||
completionGate.requireReleasedBooking(tenantId, inboundId);
|
||||
requirePickingGate(tenantId, inboundId, acceptedPdaCompletion);
|
||||
requireCompletionEvidence(tenantId, evidenceInboundId);
|
||||
@@ -206,7 +206,7 @@ public class LoadingDeliveryService {
|
||||
if (!"LOADING".equals(target.loadedChildStatus())) {
|
||||
throw new BizException(ResultCode.CONFLICT, "实装履约分片不在装柜中");
|
||||
}
|
||||
loadingModelBridge.requireCompleted(tenantId, target.sourceInboundId());
|
||||
requireLoadingPlanGate(tenantId, target.sourceInboundId(), acceptedPdaCompletion);
|
||||
completionGate.requireReleasedBooking(tenantId, target.sourceInboundId());
|
||||
requirePickingGate(tenantId, target.sourceInboundId(), acceptedPdaCompletion);
|
||||
requireCompletionEvidence(tenantId, evidenceInboundId);
|
||||
@@ -321,6 +321,15 @@ public class LoadingDeliveryService {
|
||||
task.getExpectedCount(), task.getPickedCount(), task.getRemark());
|
||||
}
|
||||
|
||||
/** worker 先完成各入库单,之后才完成柜次计划;这里不能循环要求计划已经 COMPLETED。 */
|
||||
private void requireLoadingPlanGate(long tenantId, long inboundId, boolean acceptedPdaCompletion) {
|
||||
if (acceptedPdaCompletion) {
|
||||
loadingModelBridge.requireStarted(tenantId, inboundId);
|
||||
return;
|
||||
}
|
||||
loadingModelBridge.requireCompleted(tenantId, inboundId);
|
||||
}
|
||||
|
||||
/** completion worker 已持有 durable lease;此时 task 尚为 COMPLETING,不能循环要求最终 COMPLETED。 */
|
||||
private void requirePickingGate(long tenantId, long inboundId, boolean acceptedPdaCompletion) {
|
||||
CanonicalPicking picking = canonicalPicking(tenantId, inboundId);
|
||||
|
||||
+24
@@ -196,6 +196,8 @@ class LoadingDeliveryServiceTest {
|
||||
verify(repository).findInboundForUpdate(10, 20);
|
||||
verify(repository).completeLoadedChild(10, 20, 7, 7);
|
||||
verify(repository, never()).completeLoadedChild(10, 20, 7, 6);
|
||||
verify(loadingModelBridge).requireStarted(10, 20);
|
||||
verify(loadingModelBridge, never()).requireCompleted(10, 20);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -223,6 +225,26 @@ class LoadingDeliveryServiceTest {
|
||||
verify(repository).completeLoadedChild(10, 20, 7, 7);
|
||||
verify(repository).completeOperation(eq(10L), eq(20L), eq(7L),
|
||||
eq("COMPLETE_LOADING"), eq("pda-resume"), anyString());
|
||||
verify(loadingModelBridge).requireStarted(10, 20);
|
||||
verify(loadingModelBridge, never()).requireCompleted(10, 20);
|
||||
}
|
||||
|
||||
@Test
|
||||
void pdaFinalizeConvergesAnAlreadyLoadedInboundBeforeThePlanIsCompleted() {
|
||||
when(repository.claimOperation(anyLong(), anyLong(), anyLong(), anyString(), anyString(), anyString()))
|
||||
.thenReturn(true);
|
||||
when(repository.findInboundForUpdate(10, 20)).thenReturn(new Snapshot(20L, 10L, "LOADED", 8));
|
||||
when(repository.findInbound(10, 20)).thenReturn(new Snapshot(20L, 10L, "LOADED", 8));
|
||||
when(repository.listEvidence(10, 20)).thenReturn(List.of());
|
||||
|
||||
LoadingActionResponse result = service.completeAfterPdaSettlement(
|
||||
10, 20, 7, "admin", "pda-already-loaded", "完成");
|
||||
|
||||
assertThat(result.mainStatus()).isEqualTo("LOADED");
|
||||
verify(loadingModelBridge).requireStarted(10, 20);
|
||||
verify(loadingModelBridge, never()).requireCompleted(10, 20);
|
||||
verify(repository).completeOperation(eq(10L), eq(20L), eq(7L),
|
||||
eq("COMPLETE_LOADING"), eq("pda-already-loaded"), anyString());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -251,6 +273,8 @@ class LoadingDeliveryServiceTest {
|
||||
assertThat(result.mainStatus()).isEqualTo("LOADED");
|
||||
verify(repository).findInboundForUpdate(10, 21);
|
||||
verify(repository).completeLoadedChild(10, 20, 7, 2);
|
||||
verify(loadingModelBridge).requireStarted(10, 20);
|
||||
verify(loadingModelBridge, never()).requireCompleted(10, 20);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user