feat(pda): validate live inventory before batch submit
This commit is contained in:
+12
-2
@@ -101,6 +101,15 @@ export function claimContainerPickingTask(taskId, expectedAssignmentVersion, ope
|
||||
})
|
||||
}
|
||||
|
||||
export function getPickingInventorySnapshot(taskId, warehouseId) {
|
||||
if (!taskId) throw new Error('缺少拣货任务标识,无法查询实时库存')
|
||||
if (!warehouseId) throw new Error('缺少作业仓库标识,无法查询实时库存')
|
||||
return request({
|
||||
url: `/first-leg/pda-loading/tasks/${encodeURIComponent(taskId)}/inventory-snapshot?warehouseId=${encodeURIComponent(warehouseId)}`,
|
||||
method: 'GET'
|
||||
})
|
||||
}
|
||||
|
||||
function itemAction(taskId, itemId, path, payload, operationId) {
|
||||
// Concrete routes include /items/${encodeURIComponent(itemId)}/pick, /items/${encodeURIComponent(itemId)}/partial and /items/${encodeURIComponent(itemId)}/skip.
|
||||
if (!taskId || itemId == null) throw new Error('缺少拣货任务或明细标识,无法提交')
|
||||
@@ -124,12 +133,13 @@ export function skipContainerItem(taskId, itemId, payload = {}) {
|
||||
return itemAction(taskId, itemId, 'skip', payload, payload.operationId)
|
||||
}
|
||||
|
||||
export async function submitContainerPickingBatch(task, actions, { warehouseId, operationId } = {}) {
|
||||
export async function submitContainerPickingBatch(task, actions, { warehouseId, operationId, inventorySnapshotToken } = {}) {
|
||||
if (!task?.taskId) throw new Error('缺少拣货任务标识,无法提交')
|
||||
const submitOperationId = operationId || `submit-${task.taskId}-${task.containerNo || ''}-${task.version ?? task.pickingVersion ?? ''}`
|
||||
const expectedVersion = task.version ?? task.pickingVersion
|
||||
if (expectedVersion == null) throw new Error('缺少拣货任务版本,无法整批提交')
|
||||
if (!warehouseId) throw new Error('缺少作业仓库标识,无法整批提交')
|
||||
if (!inventorySnapshotToken) throw new Error('缺少实时库存快照,请刷新后重试')
|
||||
if (!task.containerNo) throw new Error('缺少柜号,无法整批提交')
|
||||
const items = (actions || []).map((action) => ({
|
||||
itemId: action.itemId,
|
||||
@@ -145,7 +155,7 @@ export async function submitContainerPickingBatch(task, actions, { warehouseId,
|
||||
url: `/first-leg/pda-loading/tasks/${encodeURIComponent(task.taskId)}/batch`,
|
||||
method: 'POST',
|
||||
header: { 'Idempotency-Key': stableIdempotencyKey(submitOperationId) },
|
||||
data: { warehouseId, containerNo: task.containerNo, expectedVersion, items }
|
||||
data: { warehouseId, containerNo: task.containerNo, expectedVersion, inventorySnapshotToken, items }
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user