fix: preserve receiving session on duplicate pallet scans

This commit is contained in:
2026-09-15 14:44:10 +08:00
parent 791918c0dc
commit c65389b2c2
4 changed files with 20 additions and 2 deletions
@@ -507,8 +507,8 @@ public class ReceivingContainerService {
accepted += packages;
match.allocation().setPickedPackageCount(packages);
}
markReceiving(session);
}
markReceiving(session);
List<InboundRef> group = matches.stream().map(DropshipPalletRef::ref).distinct().toList();
List<String> inboundCodes = group.stream().map(value -> value.line().getInboundCode()).distinct().sorted().toList();
int total = matches.stream().mapToInt(value -> value(value.allocation().getPlannedPackageCount())).sum();
@@ -939,6 +939,11 @@ class ReceivingContainerServiceBehaviorTest {
assertThat(result.receivedPackages()).isEqualTo(2);
assertThat(result.pendingPackages()).isZero();
assertThat(result.palletCode()).isEqualTo("DP-260909-0001");
var duplicate = service.receiveWholePallet("7", "receiver",
new ReceivingContainerRequests.WholePalletReceive("DP-260909-0001", "whole-new-key"));
assertThat(duplicate.result()).isEqualTo("ALREADY_RECEIVED");
assertThat(duplicate.acceptedPackages()).isZero();
verify(sessions, org.mockito.Mockito.times(1)).updateById(any(ReceivingContainerSession.class));
verify(workflow).pickWholePallet(org.mockito.ArgumentMatchers.eq("100"),
org.mockito.ArgumentMatchers.eq("PLAN-1"), org.mockito.ArgumentMatchers.eq(30L),
any(com.baiyue.lastleg.inboundplan.pda.dto.PdaRequests.WholePalletOperation.class));
@@ -197,6 +197,9 @@ test('allocation checks both physical summaries and uncollapsed per-inbound quan
})
test('each scenario reaches physical loading through released booking and asynchronous completion', () => {
assert.match(source, /装柜前保存柜级预计到仓时间/)
assert.match(source, /capacityCbm: 68, maxWeightKg: 19500, estimatedWarehouseArrivalAt/)
assert.ok(source.indexOf('装柜前保存柜级预计到仓时间') < source.indexOf('读取自动生成装柜计划'))
assert.match(source, /ocean-booking-link/)
assert.match(source, /readiness\?\.canConfirm === true/)
assert.match(source, /action: 'PICK_PALLET'/)
@@ -141,10 +141,20 @@ async function runWorkflow(context, stopBeforeOverseasPda, mixedContainer = fals
check(`${record.label}初始费用已计算`, null, Boolean(fee))
}
const summary = group[0].summary
const cabinet = await command('创建本场景模拟柜', 'POST', '/api/platform/v1/containers', {
let cabinet = await command('创建本场景模拟柜', 'POST', '/api/platform/v1/containers', {
channelGroupCode: channelGroup(summary.channelCode), warehouseId: String(summary.warehouseId),
containerType: '40HQ', capacityCbm: 68, maxWeightKg: 19500,
})
// Arrival is frozen by the loading event; prepare it while the cabinet is editable.
const estimatedWarehouseArrivalAt = `${new Date(Date.now() + 86400000).toISOString().slice(0, 10)}T10:00:00`
cabinet = await command('装柜前保存柜级预计到仓时间', 'PUT', `/api/platform/v1/containers/${cabinet.id}`, {
version: Number(cabinet.version), data: {
warehouseId: String(summary.warehouseId), containerType: '40HQ',
capacityCbm: 68, maxWeightKg: 19500, estimatedWarehouseArrivalAt,
},
})
check(`${label}预计到仓时间已写入正式柜资料`, null,
cabinet.estimatedWarehouseArrivalAt?.slice(0, 16) === estimatedWarehouseArrivalAt.slice(0, 16))
let plan = await command('读取自动生成装柜计划', 'GET', `${smart}/plans/by-booking/${cabinet.id}`)
const path = `${smart}/plans/${plan.id}`
async function conserve(name) {