fix(lastleg): retain physical carton labels from frozen relabel contributions

This commit is contained in:
2026-10-23 05:19:54 +08:00
parent 139f6b1932
commit 18ef338036
6 changed files with 25 additions and 5 deletions
@@ -416,8 +416,8 @@ class DispatchItemSourcePersistenceTest {
long balance, long sourceBalance, long inbound, long packages, Long pieces, String mark) {
return new BoundSource(app, no, item, customer, "1001", pallet, position, balance, sourceBalance, inbound,
"IN-" + inbound, "CODE-" + inbound, packages, packages, pieces, "b".repeat(64),
List.of(new UnitFact(item, mark, "NEW-" + mark, "RELABELLED", 1),
new UnitFact(item + 1000, "EXCEPTION-" + item, null, "EXCEPTION", 1)));
List.of(new UnitFact(item, mark, "NEW-" + mark, "RELABELLED", 1, "NEW-" + mark),
new UnitFact(item + 1000, "EXCEPTION-" + item, null, "EXCEPTION", 1, null)));
}
/** 同一实托可以含不同客户位置,每个位置的 HOLD 独立守恒。 */
@@ -93,6 +93,7 @@ class DispatchMergedRelabelPersistenceTest {
var context=f.f.service.preview(f.f.actor,created.dispatchNo());assertThat(context.cargo()).hasSize(2);
assertThat(context.cargo()).extracting(c->c.sourceOrigin().sourceInboundOrderNo()).containsExactlyInAnyOrder("ORIGIN-A","ORIGIN-B");
assertThat(context.cargo()).extracting(c->c.orderId()).containsExactlyInAnyOrder(9001L,9002L);
assertThat(context.cargo()).extracting(c->c.cartonMark()).containsExactlyInAnyOrder("NEW-A","NEW-B");
var preview=f.f.service.loading(f.f.actor,created.dispatchNo());assertThat(preview.pallets()).hasSize(1);assertThat(preview.pallets().get(0).scheduledPackages()).isEqualTo(5);
var pallet=preview.pallets().get(0);
var loaded=f.f.tx.execute(s->f.f.service.loadingComplete(f.picker,created.dispatchNo(),new DispatchCommands.LoadingComplete(last.recordVersion(),"load",preview.manifestHash(),
@@ -157,6 +157,7 @@ class RelabelDispatchSourcePersistenceTest {
assertEquals(3, facts.size());
assertEquals(2, facts.stream().filter(f -> f.result().equals("RELABELLED")).count());
assertEquals(1, facts.stream().filter(f -> f.result().equals("EXCEPTION")).count());
assertTrue(facts.stream().filter(f -> f.result().equals("RELABELLED")).allMatch(f -> f.newLabel().equals(f.cartonMark())));
assertTrue(snapshot.sources().stream().allMatch(source -> source.productQuantity() == null));
}
@@ -169,6 +170,8 @@ class RelabelDispatchSourcePersistenceTest {
assertNull(snapshot().sources().stream().filter(s -> s.itemId() == 11).findFirst().orElseThrow().productQuantity());
skuScan(31, 1, 7, "INITIAL");
assertEquals(12L, snapshot().sources().stream().filter(s -> s.itemId() == 11).findFirst().orElseThrow().productQuantity());
assertTrue(snapshot().sources().stream().filter(s -> s.itemId() == 11).flatMap(s -> s.unitFacts().stream())
.allMatch(f -> f.oldLabel().equals(f.cartonMark())), "仅换SKU不能把SKU标签当作出库箱标");
jdbc.update("UPDATE ll_relabel_pda_history SET detail_json=? WHERE id=31",
"{\"round\":\"INITIAL\",\"itemId\":\"11\",\"skuIndex\":1,\"quantity\":99}");
assertNull(snapshot().sources().stream().filter(s -> s.itemId() == 11).findFirst().orElseThrow().productQuantity());