feat(appointments): unify pre-inbound planning and confirmed FBA bookings

This commit is contained in:
2026-10-10 10:38:06 +08:00
parent 24f5ccf7ff
commit c4c1bddeec
54 changed files with 1623 additions and 744 deletions
@@ -28,10 +28,11 @@ class FleetPoolOrderBridgeTest {
UsTruckOrderStatusHistoryMapper truckHistory=mock(UsTruckOrderStatusHistoryMapper.class);
LastlegOrderNoGenerator numbers=mock(LastlegOrderNoGenerator.class);
DeliverySourceEvidenceMapper evidence=mock(DeliverySourceEvidenceMapper.class);
com.baiyue.lastleg.appointmentplanning.AppointmentSourceLinker appointmentSources=mock(com.baiyue.lastleg.appointmentplanning.AppointmentSourceLinker.class);
FleetPoolOrderBridge service;
FleetPoolOrderLink row; LocalLooseboardOrder looseOrder; UsTruckOrder truckOrder;
@BeforeEach void setup(){
service=new FleetPoolOrderBridge(links,loose,looseHistory,trucks,truckHistory,numbers,new ObjectMapper().findAndRegisterModules(),evidence);
service=new FleetPoolOrderBridge(links,loose,looseHistory,trucks,truckHistory,numbers,new ObjectMapper().findAndRegisterModules(),evidence,appointmentSources);
when(evidence.dispatchIds("9",77)).thenReturn(List.of(70L));
when(evidence.returns("9",70)).thenReturn(List.of());
when(numbers.next(anyString(),any(),anyLong())).thenReturn("LOCAL-001");
@@ -48,6 +49,23 @@ class FleetPoolOrderBridgeTest {
LocalDateTime.of(2030,1,1,12,0),"SELF_DELIVERY","客户自送",null,"货物",4,2,
BigDecimal.TEN,BigDecimal.ONE,"USD","联系人","123456","本轮池订单");}
void incoming(){service.bindIncoming("FB-7","9","WT-7",77,"92","FBA:ONT8","op");}
@Test void materializesTheOriginalAppointmentAfterActualIncomingAssociationAndNeverOnReplay() {
service.confirm(input("LOCAL_LOOSEBOARD"),"op");
incoming();
var writes=inOrder(links,loose,appointmentSources);
writes.verify(links).updateById(row);
writes.verify(loose).updateById(looseOrder);
writes.verify(appointmentSources).materialized("9","FB-7",77L);
incoming();
verify(appointmentSources,times(1)).materialized("9","FB-7",77L);
}
@Test void appointmentBindingFailurePropagatesToTheMandatoryIncomingTransaction() {
service.confirm(input("US_TRUCK"),"op");
doThrow(new IllegalStateException("appointment binding conflict")).when(appointmentSources).materialized("9","FB-7",77L);
assertThatThrownBy(this::incoming).isInstanceOf(IllegalStateException.class).hasMessageContaining("appointment binding conflict");
}
FleetBookingIncomingGateway.Evidence receipt(){return new FleetBookingIncomingGateway.Evidence("WT-7","WT-7","92","FBA:ONT8","READY_FOR_DISPATCH","hash",List.of(
new FleetBookingIncomingGateway.Pallet("101","PALLET-1",2,BigDecimal.TEN,BigDecimal.ONE),
new FleetBookingIncomingGateway.Pallet("102","PALLET-2",2,BigDecimal.TEN,BigDecimal.ONE)),4);}