优化
This commit is contained in:
@@ -819,11 +819,9 @@ export async function run(context) {
|
||||
const skippedInboundId = id(partialTarget.inboundId)
|
||||
const partialBatchItems = (partialPda.task.items || []).map((item) => id(item.inboundId) === skippedInboundId
|
||||
? { itemId: id(item.id), action: 'SKIP', pickedPackageCount: null,
|
||||
finalPickedPackageCount: null, releaseMode: null,
|
||||
locationIds: [], version: Number(item.version), reason: '同柜不可拆组短拣验收' }
|
||||
finalPickedPackageCount: null, version: Number(item.version), reason: '同柜不可拆组短拣验收' }
|
||||
: { itemId: id(item.id), action: 'PICK', pickedPackageCount: Number(item.plannedPackageCount),
|
||||
finalPickedPackageCount: null, releaseMode: 'MANUAL', locationIds: [],
|
||||
version: Number(item.version), reason: null })
|
||||
finalPickedPackageCount: null, version: Number(item.version), reason: null })
|
||||
const partialBatchResponse = await context.request('POST', `${PDA}/tasks/${partialPda.taskId}/batch`, {
|
||||
warehouseId: first.warehouseId, loadingPlanId: partialChain.planId,
|
||||
containerBookingId: partialChain.containerBookingId, expectedVersion: Number(partialPda.task.version),
|
||||
@@ -863,8 +861,7 @@ export async function run(context) {
|
||||
const fullTreesBefore = await fulfillmentTrees(context, fullChain.fixtures, '足量完成前')
|
||||
const fullBatchItems = (fullPda.task?.items || []).map((item) => ({
|
||||
itemId: id(item.id), action: 'PICK', pickedPackageCount: Number(item.plannedPackageCount),
|
||||
finalPickedPackageCount: null, releaseMode: 'MANUAL', locationIds: [],
|
||||
version: Number(item.version), reason: null,
|
||||
finalPickedPackageCount: null, version: Number(item.version), reason: null,
|
||||
}))
|
||||
const fullBatchResponse = await context.request('POST', `${PDA}/tasks/${fullPda.taskId}/batch`, {
|
||||
warehouseId: third.warehouseId, loadingPlanId: fullChain.planId,
|
||||
@@ -910,8 +907,7 @@ export async function run(context) {
|
||||
const normalTreeBefore = await fulfillmentTrees(context, normalChain.fixtures, '普通单完成前')
|
||||
const normalBatchItems = (normalPda.task?.items || []).map((item) => ({
|
||||
itemId: id(item.id), action: 'PICK', pickedPackageCount: Number(item.plannedPackageCount),
|
||||
finalPickedPackageCount: null, releaseMode: 'MANUAL', locationIds: [],
|
||||
version: Number(item.version), reason: null,
|
||||
finalPickedPackageCount: null, version: Number(item.version), reason: null,
|
||||
}))
|
||||
const normalBatchResponse = await context.request('POST', `${PDA}/tasks/${normalPda.taskId}/batch`, {
|
||||
warehouseId: seventh.warehouseId, loadingPlanId: normalChain.planId,
|
||||
|
||||
@@ -291,7 +291,7 @@ async function pickAll(context, chain, label) {
|
||||
expectedVersion: Number(chain.task.version), inventorySnapshotToken: snapshot.snapshotToken,
|
||||
items: chain.task.items.map((item) => ({ itemId: id(item.id), action: 'PICK',
|
||||
pickedPackageCount: Number(item.plannedPackageCount), finalPickedPackageCount: null,
|
||||
releaseMode: 'MANUAL', locationIds: [], version: Number(item.version), reason: null })),
|
||||
version: Number(item.version), reason: null })),
|
||||
}, `${label}-batch`)
|
||||
chain.task = context.apiSuccess(MODULE, `${label} 完成 PDA 拣货`, response, '', OPTIONS)
|
||||
return chain
|
||||
|
||||
@@ -243,9 +243,22 @@ export async function run(context) {
|
||||
inboundId, inboundDetailId: id(candidate.inboundDetailId), packageCount: 1,
|
||||
expectedVersion: Number(foreignPlan?.version), operationId: `${context.marker}-other-channel-assign`.slice(0, 128),
|
||||
})
|
||||
context.addStep(MODULE, '两个真实有效渠道之间拒绝跨渠道装柜', foreignAssignResponse,
|
||||
foreignAssignResponse.http === 200 && ['A0422', '422'].includes(codeOf(foreignAssignResponse)),
|
||||
const foreignAssigned = foreignAssignResponse.body?.data
|
||||
const foreignItem = Array.isArray(foreignAssigned?.items)
|
||||
? foreignAssigned.items.find((item) => id(item.inboundId) === inboundId
|
||||
&& id(item.inboundDetailId) === id(candidate.inboundDetailId))
|
||||
: null
|
||||
context.addStep(MODULE, '手工装柜允许两个真实有效渠道之间跨渠道分配', foreignAssignResponse,
|
||||
foreignAssignResponse.http === 200 && codeOf(foreignAssignResponse) === '200' && Boolean(foreignItem?.id),
|
||||
`primary=${channelCode}, foreign=${foreignChannel.channelCode}, HTTP=${foreignAssignResponse.http}, code=${codeOf(foreignAssignResponse)}`, OPTIONS)
|
||||
if (foreignItem?.id) {
|
||||
const foreignRemoveResponse = await request(context, 'DELETE',
|
||||
`${SMART}/plans/${foreignPlan?.id}/items/${foreignItem.id}`, {
|
||||
expectedPlanVersion: Number(foreignAssigned.version), expectedItemVersion: Number(foreignItem.version),
|
||||
operationId: `${context.marker}-other-channel-remove`.slice(0, 128),
|
||||
})
|
||||
context.apiSuccess(MODULE, '跨渠道分配验收后释放入仓码供主流程继续', foreignRemoveResponse, '', OPTIONS)
|
||||
}
|
||||
}
|
||||
|
||||
const containerDetailResponse = await context.request('GET', `${CONTAINERS}/${containerId}`)
|
||||
@@ -681,8 +694,7 @@ export async function run(context) {
|
||||
|
||||
const batchPath = `${PDA}/tasks/${taskId}/batch`
|
||||
const batchItems = [{ itemId: id(pickItem.id), action: 'PICK', pickedPackageCount: 1,
|
||||
finalPickedPackageCount: null, releaseMode: 'MANUAL', locationIds: [],
|
||||
version: Number(pickItem.version), reason: null }]
|
||||
finalPickedPackageCount: null, version: Number(pickItem.version), reason: null }]
|
||||
const staleBatchResponse = await request(context, 'POST', batchPath, {
|
||||
warehouseId, loadingPlanId: planId, containerBookingId: containerId,
|
||||
expectedVersion: Number(task.version) + 1,
|
||||
|
||||
@@ -655,7 +655,7 @@ export async function run(context) {
|
||||
inventorySnapshotToken: inventory.snapshotToken,
|
||||
items: [{
|
||||
itemId: id(canonicalItem.id), action: 'PICK', pickedPackageCount: 1,
|
||||
releaseMode: 'MANUAL', locationIds: [], version: Number(canonicalItem.version),
|
||||
version: Number(canonicalItem.version),
|
||||
}],
|
||||
}
|
||||
|
||||
@@ -1279,7 +1279,7 @@ export async function run(context) {
|
||||
expectedVersion: Number(afterUnresolvedCompleteTask?.version),
|
||||
inventorySnapshotToken: partialInventory?.snapshotToken,
|
||||
items: [{ itemId: id(unresolvedTaskItem?.id), action: 'PARTIAL', finalPickedPackageCount: 1,
|
||||
releaseMode: 'MANUAL', locationIds: [], version: Number(unresolvedTaskItem?.version) }],
|
||||
version: Number(unresolvedTaskItem?.version) }],
|
||||
}, { 'Idempotency-Key': partialBatchKey })
|
||||
const partialTask = context.apiSuccess(MODULE, '合法 PARTIAL 解决未完成明细', partialBatchResponse, '', OPTIONS)
|
||||
const partialTaskItem = partialTask?.items?.find?.((item) => id(item?.id) === id(unresolvedTaskItem?.id))
|
||||
@@ -1349,7 +1349,7 @@ export async function run(context) {
|
||||
expectedVersion: Number(incrementedTask?.version),
|
||||
inventorySnapshotToken: effectiveBatchPayload.inventorySnapshotToken,
|
||||
items: [{ itemId: id(incrementalTaskItem.id), action: 'PICK', pickedPackageCount: 1,
|
||||
releaseMode: 'MANUAL', locationIds: [], version: Number(incrementalTaskItem.version) }],
|
||||
version: Number(incrementalTaskItem.version) }],
|
||||
}, { 'Idempotency-Key': `${context.marker}-dynamic-stale-inventory`.slice(0, 128) })
|
||||
context.addStep(MODULE, '增量后旧 inventory token 明确 A0409 并要求刷新', staleIncrementBatch,
|
||||
staleIncrementBatch.http === 200 && codeOf(staleIncrementBatch) === 'A0409'
|
||||
@@ -1426,7 +1426,7 @@ export async function run(context) {
|
||||
expectedVersion: Number(refreshedDynamicTask?.version),
|
||||
inventorySnapshotToken: refreshedDynamicInventory?.snapshotToken,
|
||||
items: [{ itemId: id(refreshedDynamicTaskItem?.id), action: 'PICK', pickedPackageCount: Number(reassignedPlanItem?.packageCount),
|
||||
releaseMode: 'MANUAL', locationIds: [], version: Number(refreshedDynamicTaskItem?.version) }],
|
||||
version: Number(refreshedDynamicTaskItem?.version) }],
|
||||
}, { 'Idempotency-Key': dynamicBatchKey })
|
||||
const dynamicPickedTask = context.apiSuccess(MODULE, '刷新后完成动态新增项拣货', dynamicBatchResponse, '', OPTIONS)
|
||||
context.assert(MODULE, '动态新增项拣完后同一任务重新进入 AWAITING_REVIEW', dynamicBatchResponse,
|
||||
|
||||
@@ -75,7 +75,7 @@ test('each remainder settles only through inventory snapshot, atomic batch and e
|
||||
assert.match(source, /expectedVersion: Number\(inventory\.taskVersion\)/)
|
||||
assert.match(source, /inventorySnapshotToken: inventory\.snapshotToken/)
|
||||
assert.match(source, /action: 'PICK', pickedPackageCount: 1/)
|
||||
assert.match(source, /version: Number\(claimedItem\.version\), releaseMode: 'MANUAL', locationIds: \[\]/)
|
||||
assert.doesNotMatch(source, /releaseMode|locationIds|reservationIds/)
|
||||
assert.match(source, /'Idempotency-Key': batchKey/)
|
||||
assert.match(source, /differentReplay/)
|
||||
assert.match(source, /workflowStatus === 'AWAITING_REVIEW'/)
|
||||
|
||||
@@ -392,7 +392,7 @@ async function loadOneFragment(context, state) {
|
||||
expectedVersion: Number(inventory.taskVersion), inventorySnapshotToken: inventory.snapshotToken,
|
||||
items: [{
|
||||
itemId: id(claimedItem.id), action: 'PICK', pickedPackageCount: 1,
|
||||
version: Number(claimedItem.version), releaseMode: 'MANUAL', locationIds: [],
|
||||
version: Number(claimedItem.version),
|
||||
}],
|
||||
}
|
||||
const staleBatch = await request(context, 'POST', batchPath, {
|
||||
|
||||
@@ -383,12 +383,23 @@ test('channel isolation reports BLOCKED_FIXTURE instead of inventing a second ch
|
||||
assert.match(value, /context\.createdResources\?\.platformLogisticsChannels/)
|
||||
})
|
||||
|
||||
test('container loading enforces channel isolation and stable PDA identity across container number changes', () => {
|
||||
test('manual cross-channel loading fixture releases the inbound before the primary flow', () => {
|
||||
const value = source('./phase3-container-loading.mjs')
|
||||
assertOrder(value, [
|
||||
'新增真实异渠道模拟柜',
|
||||
'手工装柜允许两个真实有效渠道之间跨渠道分配',
|
||||
'跨渠道分配验收后释放入仓码供主流程继续',
|
||||
'人工分配本轮候选货物',
|
||||
])
|
||||
})
|
||||
|
||||
test('container loading permits manual cross-channel allocation and keeps stable PDA identity across container number changes', () => {
|
||||
const value = source('./phase3-container-loading.mjs')
|
||||
assertOrder(value, [
|
||||
'新增内部模拟柜',
|
||||
'新增真实异渠道模拟柜',
|
||||
'两个真实有效渠道之间拒绝跨渠道装柜',
|
||||
'手工装柜允许两个真实有效渠道之间跨渠道分配',
|
||||
'跨渠道分配验收后释放入仓码供主流程继续',
|
||||
'人工分配本轮候选货物',
|
||||
'无真实柜号推送预装计划成功',
|
||||
'无号 push 成功后 PDA 查询 A0404',
|
||||
|
||||
Reference in New Issue
Block a user