fix: retain source plan identity in mixed-pallet BOL

This commit is contained in:
2026-10-23 03:40:02 +08:00
parent a7f680d69d
commit 5c5514436e
2 changed files with 21 additions and 1 deletions
@@ -39,7 +39,7 @@ public interface DispatchBolMapper {
LEFT JOIN ll_inbound_plan ip ON ip.id=p.plan_id AND ip.customer_id=di.customer_id
LEFT JOIN ll_inbound_plan_pallet_allocation a ON a.pallet_id=p.id AND a.customer_id=di.customer_id
AND di.return_receipt_id IS NULL AND COALESCE(di.source_business_type,'')<>'RELABEL_ORDER'
LEFT JOIN ll_inbound_plan_line l ON l.id=a.line_id AND l.customer_id=di.customer_id AND l.plan_id=p.plan_id
LEFT JOIN ll_inbound_plan_line l ON l.id=a.line_id AND l.customer_id=di.customer_id AND l.plan_id=a.plan_id
LEFT JOIN ll_order o ON o.id=l.order_id AND o.customer_id=di.customer_id
LEFT JOIN ll_order_detail od ON od.order_id=l.order_id AND od.customer_id=l.customer_id
WHERE di.dispatch_order_id=#{dispatchOrderId}
@@ -158,6 +158,26 @@ class DispatchBolReadPersistenceTest {
assertThat(lines.stream().mapToInt(DispatchBolData.Line::packageCount).sum()).isEqualTo(5);
}
/** 合法混托按分配所属计划定位来源;仍拒绝分配计划与来源行不一致的坏记录。 */
@Test void receivedPalletRetainsEachSourcePlansIdentityAfterCrossPlanPalletMixing() throws Exception {
for(boolean brokenPlan:List.of(false,true)) {
var f=new Fixture();f.source(11,"101",1,1000,3,"ONT8","RECEIVED",0);
f.db.update("UPDATE ll_dispatch_item SET package_count=5 WHERE id=11");
f.db.update("INSERT INTO ll_inbound_plan VALUES(20,'101','CN-2000')");
f.db.update("INSERT INTO ll_inbound_plan_line VALUES(120,'101',20,2000,'ONT8','ONT8','ONT8','IN-2000')");
f.db.update("INSERT INTO ll_inbound_plan_pallet_allocation VALUES(121,'101',?,1,120,0,0,2)",brokenPlan?99:20);
f.db.update("INSERT INTO ll_order VALUES(2000,'101','CN-2000')");
if(brokenPlan) assertThatThrownBy(f::read).isInstanceOf(BizException.class).hasMessageContaining("尚未核实");
else {
var lines=f.read().bolLines();
assertThat(lines).extracting(DispatchBolData.Line::orderId).containsExactly(1000L,2000L);
assertThat(lines).extracting(DispatchBolData.Line::packageCount).containsExactly(3,2);
assertThat(lines).extracting(DispatchBolData.Line::warehouseNo).containsExactly("IN-1000","IN-2000");
assertThat(lines).allSatisfy(line->assertThat(line.dispatchItemId()).isEqualTo(11L));
}
}
}
/** BOOKING来源通过原预约item的持久order_id关联,不把真实稳定键改拼成ORDER。 */
@Test void bookingSourceUsesPersistedAppointmentOrderMapping() throws Exception {
var f=new Fixture();f.source(11,"101",1,1000,5,"ONT8","RECEIVED",0);