fix(dispatch): limit appointment prerequisite to inbound cargo

This commit is contained in:
2026-10-22 15:39:33 +08:00
parent 56f2853fb7
commit 86889d7e0e
4 changed files with 18 additions and 12 deletions
@@ -129,12 +129,17 @@ class DispatchDraftPersistenceTest {
assertThat(db.queryForObject("SELECT COUNT(*) FROM ll_dispatch_pallet_lock",Integer.class)).isZero();
assertThat(service.drafts(owner).get(0).sources()).isEmpty();
}
/** FBA来源尚不能关联正式预约时不得借其他来源类型绕过确认门禁。 */
@Test void fbaWithoutAuthoritativeAppointmentSourceCannotEnterDraft() {
var state=empty(1);var choice=new DispatchCommands.CargoSelection(SourceType.RELABEL,null,null,"RL-1",1001L,"version-1");choices.put(1L,choice);
/** 本轮门禁限普通入仓,独立换标和退货FBA保留原排车流程。 */
@ParameterizedTest
@org.junit.jupiter.params.provider.EnumSource(value=SourceType.class,names={"RELABEL","RETURN_RECEIPT"})
void independentFbaKeepsExistingDraftFlow(SourceType sourceType) {
var state=empty(1);var choice=sourceType==SourceType.RELABEL
?new DispatchCommands.CargoSelection(sourceType,null,null,"RL-1",1001L,"version-1")
:new DispatchCommands.CargoSelection(sourceType,null,1L,null,1001L,"version-1");choices.put(1L,choice);
doAnswer(call->{var resolved=whole(choice);resolved.candidate().destinationType("FBA");return List.of(resolved);}).when(sources).lockDraftSources(anyString(),anyList());
assertThatThrownBy(()->select(state,0,1)).hasMessageContaining("缺少可核对的正式预约来源");
assertThat(db.queryForObject("SELECT COUNT(*) FROM ll_dispatch_pallet_lock",Integer.class)).isZero();
assertThat(select(state,0,1).sources()).hasSize(1);
assertThat(db.queryForObject("SELECT COUNT(*) FROM ll_dispatch_pallet_lock",Integer.class)).isOne();
verify(appointmentProvider,never()).candidateBatches(anyList());
}
/** 新实例只依赖数据库命令结果,关闭内存对象也能恢复创建及原布局结果。 */
@Test void restartRecoversOriginalResultsAndRejectsChangedActorVersionOrPayload(){
@@ -540,8 +545,8 @@ class DispatchDraftPersistenceTest {
.returnReceiptId(selection.sourceType()==SourceType.RETURN_RECEIPT?sourceId:null)
.customerId(sourceId%2==0?"102":"101").customerName("客户"+sourceId).overseasWarehouseId("92")
.overseasWarehouseCode("WH").overseasWarehouseName("海外仓").packageCount(10).palletNo("P-"+pallet)
.sourceStage(selection.sourceType()==SourceType.RELABEL?"RELABEL":"RECEIVED").destinationType(selection.sourceType()==SourceType.INBOUND_PLAN?"FBA":"PRIVATE")
.destinationWarehouseCode(destination).fbaWarehouseCode(selection.sourceType()==SourceType.INBOUND_PLAN?destination:null);
.sourceStage(selection.sourceType()==SourceType.RELABEL?"RELABEL":"RECEIVED").destinationType("FBA")
.destinationWarehouseCode(destination).fbaWarehouseCode(destination);
return new DispatchService.WholeSource(row,selection,DispatchService.wholeSourceKey(selection),selection.sourceVersion());
}
/** 受控事实按原来源类型及服务器版本产生完整组,不把组装责任交给前端。 */