fix(acceptance): follow reserved pallet workflows

This commit is contained in:
2026-09-09 01:30:22 +08:00
parent b11ad31d5f
commit f7e3863898
7 changed files with 55 additions and 14 deletions
@@ -332,12 +332,28 @@ async function convertReceivingContainers(context, producers) {
const convertedInboundCodes = new Set(plans
.flatMap((item) => Array.isArray(item?.lines) ? item.lines : [])
.map((line) => id(line?.inboundCode)).filter(nonBlank))
const reservedPalletsByInbound = {}
for (const plan of plans) {
const reserved = Array.isArray(plan?.pallets) ? plan.pallets.find((item) =>
longId(item?.warehousePalletId) && longId(item?.warehouseLocationId)
&& longId(item?.warehouseResourceLockId)
&& ['RESERVED', 'ASSIGNED', 'LOCKED'].includes(item?.assignmentStatus)) : null
for (const line of Array.isArray(plan?.lines) ? plan.lines : []) {
if (reserved && nonBlank(line?.inboundCode)) reservedPalletsByInbound[id(line.inboundCode)] = {
palletId: id(reserved.warehousePalletId), palletCode: reserved.palletNo,
locationId: id(reserved.warehouseLocationId), retained: true,
}
}
}
const reservedCoverage = [...convertedInboundCodes].every((inboundCode) =>
nonBlank(reservedPalletsByInbound[inboundCode]?.palletCode))
context.addStep(MODULE, `整柜转换为逐入仓码独立计划 ${containerNo}`, convertedResponse,
plans.length === inboundCodes
&& plans.every((item) => Array.isArray(item?.lines) && item.lines.length > 0)
&& convertedInboundCodes.size === inboundCodes,
`plans=${plans.length}, inboundCodes=${convertedInboundCodes.size}, expected=${inboundCodes}; ${trace(convertedResponse)}`, OPTIONS)
if (plans.length !== inboundCodes) return false
&& convertedInboundCodes.size === inboundCodes && reservedCoverage,
`plans=${plans.length}, inboundCodes=${convertedInboundCodes.size}, reserved=${Object.keys(reservedPalletsByInbound).length}, expected=${inboundCodes}; ${trace(convertedResponse)}`, OPTIONS)
if (plans.length !== inboundCodes || !reservedCoverage) return false
producer.receivingPalletsByInbound = reservedPalletsByInbound
const replayResponse = await context.requestOverseas('POST',
'/api/platform/v1/last-leg/inbound-plans/convert-container', body,
{ 'Idempotency-Key': key }, context.overseasToken)
@@ -614,14 +630,19 @@ async function runReceiving(context, token, secondaryToken, merchantToken, prefe
if (!success(afterResolve.response) || receivingSnapshot(afterResolve.data) !== beforeResolve) return
const pallets = new Map()
for (const [index, inbound] of current.data.inbounds.entries()) {
const pallet = await createPallet(context, inbound, index)
const reservedPallet = preferredProducer?.receivingPalletsByInbound?.[inbound.inboundCode]
const pallet = reservedPallet || await createPallet(context, inbound, index)
if (reservedPallet) context.addStep(MODULE, `${inbound.destinationType}复用整柜转换预留托盘`, null,
longId(reservedPallet.palletId) && nonBlank(reservedPallet.palletCode)
&& longId(reservedPallet.locationId),
`inboundCode=${inbound.inboundCode}, palletCode=${reservedPallet.palletCode}`, OPTIONS)
if (!pallet) {
blockerGap(context, `${inbound.destinationType}入仓码${inbound.inboundCode}实物托盘`,
`无法在实际海外收货仓 ${inbound.overseasWarehouseId || 'missing'} 创建可解析真实托盘;目的仓 ${inbound.destinationWarehouseId || 'missing'} 不得代替物理仓`, 'warehouse-resource')
continue
}
pallets.set(inbound.inboundCode, pallet)
context.createdResources.phase4OverseasPda.palletIds.push(pallet.palletId)
if (!reservedPallet) context.createdResources.phase4OverseasPda.palletIds.push(pallet.palletId)
const resolved = await pda(context, token, 'POST', `解析${inbound.destinationType}实物托盘`,
'/api/pda/v1/last-leg/receiving-containers/current/pallets/resolve', { palletCode: pallet.palletCode, inboundCode: inbound.inboundCode })
context.assert(MODULE, `${inbound.destinationType}托盘目的模式匹配`, resolved.response,