From 19334fc4a21a85fdbbc7e83b0213e025a6dacb48 Mon Sep 17 00:00:00 2001 From: ouyangxq <775153912@qq.com> Date: Wed, 16 Sep 2026 11:05:22 +0800 Subject: [PATCH] fix: refresh PDA task version after immediate pick --- api/pda-loading.js | 6 +++++- tests/pda-loading-api.test.mjs | 12 +++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/api/pda-loading.js b/api/pda-loading.js index cd26ccc..7022f4e 100644 --- a/api/pda-loading.js +++ b/api/pda-loading.js @@ -191,7 +191,11 @@ export function normalizePickingTask(task = {}) { orderNo: task.orderNo ?? task.order?.orderNo ?? '', inboundCode: task.inboundCode ?? task.inbound?.inboundCode ?? '', warehouseName: task.warehouseName ?? task.warehouse?.name ?? '', - pickingVersion: task.pickingVersion ?? task.version ?? null, + // `version` is the canonical task version returned by the loading API. + // Prefer it over a previously normalized alias when merging a mutation + // response, otherwise the next immediate pallet action reuses a stale + // expectedTaskVersion and is rejected as a concurrent update. + pickingVersion: task.version ?? task.pickingVersion ?? null, inboundVersion: task.inboundVersion ?? null } } diff --git a/tests/pda-loading-api.test.mjs b/tests/pda-loading-api.test.mjs index 8b5af3e..b6a71a9 100644 --- a/tests/pda-loading-api.test.mjs +++ b/tests/pda-loading-api.test.mjs @@ -62,7 +62,7 @@ test('C02 identifiers and separate picking/inbound versions are normalized expli assert.match(source, /inboundId: row\.inboundId/) assert.match(source, /inboundVersion: row\.inboundVersion/) assert.match(source, /pickingVersion: row\.pickingVersion \?\? row\.loading\?\.pickingVersion/) - assert.match(source, /pickingVersion: task\.pickingVersion \?\? task\.version/) + assert.match(source, /pickingVersion: task\.version \?\? task\.pickingVersion/) assert.match(page, /version: Number\(this\.pickingVersion\)/) assert.match(page, /ITEM_STATUS, classifyScan, createItemStates, getPickSummary, isSealedPalletItem, submitStates/) assert.match(page, /taskItemId: item\.id \?\? item\.itemId/) @@ -100,6 +100,16 @@ test('picking page exposes five evidence slots, retry and remote completion stat assert.match(page, /evidenceComplete/) }) +test('immediate task responses replace a stale normalized picking version', () => { + const normalizeSource = source.match(/export function normalizePickingTask\(task = \{\}\) \{[\s\S]*?\n\}/)?.[0] + assert.ok(normalizeSource) + const normalizePickingTask = new Function(`${normalizeSource.replace('export function', 'function')}; return normalizePickingTask`)() + const previous = normalizePickingTask({ id: 'task-1', version: 3 }) + assert.equal(previous.pickingVersion, 3) + const mergedMutationResponse = normalizePickingTask({ ...previous, version: 4 }) + assert.equal(mergedMutationResponse.pickingVersion, 4) +}) + test('PDA evidence binding normalizes string ids from the task-scoped DTO', () => { assert.match(page, /evidenceItems\(result\)[\s\S]*?id: String\(item\.evidenceId \?\? item\.id/) assert.match(page, /fileId: String\(item\.fileId/)