fix(lastleg): group same-code FBA cargo with optional internal warehouse reference
This commit is contained in:
+22
@@ -1,6 +1,8 @@
|
||||
package com.baiyue.lastleg.delivery;
|
||||
|
||||
import com.baiyue.lastleg.delivery.model.DeliveryCargoGroups;
|
||||
import com.baiyue.lastleg.dispatch.port.DispatchContracts.CargoLine;
|
||||
import com.baiyue.lastleg.dispatch.port.DispatchContracts.Destination;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import java.util.List;
|
||||
@@ -27,4 +29,24 @@ class DeliveryCargoGroupsTest {
|
||||
assertThrows(org.springframework.web.server.ResponseStatusException.class,()->policy.groups(context(List.of(row,row),false)));
|
||||
assertThrows(org.springframework.web.server.ResponseStatusException.class,()->policy.groups(context(List.of(row,cargo(2,"101","LAX9",51,3)),false)));
|
||||
}
|
||||
@Test void sameFbaCodeKeepsKnownWarehouseReferenceWhenIncomingCargoHasNoInternalId() {
|
||||
var incoming=cargo(1,"101","ONT8",51,3);
|
||||
var known=destination(cargo(2,"101","ONT8",52,4),new Destination("FBA:ONT8","FBA","900","ONT8","ONT8",null,null,null,null));
|
||||
var group=policy.groups(context(List.of(known,incoming),false)).get(0);
|
||||
assertEquals("900",group.destination().warehouseId());assertEquals(7,group.packages());
|
||||
assertNull(group.cargo().get(0).destination().warehouseId(),"真实来源快照不被覆盖");
|
||||
assertEquals(group,policy.groups(context(List.of(incoming,known),false)).get(0));
|
||||
var conflicting=destination(incoming,new Destination("FBA:ONT8","FBA","901","ONT8","ONT8",null,null,null,null));
|
||||
assertThrows(org.springframework.web.server.ResponseStatusException.class,()->policy.groups(context(List.of(known,conflicting),false)));
|
||||
var wrongCode=destination(incoming,new Destination("FBA:ONT8","FBA",null,"LAX9","ONT8",null,null,null,null));
|
||||
assertThrows(org.springframework.web.server.ResponseStatusException.class,()->policy.groups(context(List.of(known,wrongCode),false)));
|
||||
var changedAddress=destination(incoming,new Destination("FBA:ONT8","FBA",null,"ONT8","ONT8","other",null,null,null));
|
||||
assertThrows(org.springframework.web.server.ResponseStatusException.class,()->policy.groups(context(List.of(known,changedAddress),false)));
|
||||
}
|
||||
private CargoLine destination(CargoLine row,Destination destination) {
|
||||
return new CargoLine(row.dispatchItemId(),row.customerId(),row.customerName(),row.orderId(),row.orderNo(),row.sourceKey(),row.sourceStage(),row.sourceRegion(),
|
||||
row.sourceInboundId(),row.inboundCode(),row.planPalletId(),row.warehousePalletId(),row.palletNo(),row.pickId(),row.attributionId(),row.inventoryPositionId(),
|
||||
row.receiptId(),row.returnReceiptId(),row.returnCartonId(),row.cartonMark(),row.relabelNo(),destination,row.packages(),row.productQuantity(),
|
||||
row.grossWeightKg(),row.volumeCbm(),row.batchAllocations(),row.sourceOrigin());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user