修正海外PDA实装箱唛验收夹具

This commit is contained in:
2026-09-02 15:47:13 +08:00
parent ecf4eb1211
commit 5f688d6131
2 changed files with 23 additions and 7 deletions
@@ -47,17 +47,19 @@ async function ensureMatsonSupplier(context, records) {
return supplierId ? { id: supplierId, name: MATSON_SUPPLIER_NAME, status: 'ACTIVE' } : null
}
export function stableLoadedCartonMarks(items, loadingPlanId) {
export function stableLoadedCartonMarks(items) {
const used = new Set()
return [...(Array.isArray(items) ? items : [])]
.sort((left, right) => id(left?.loadingPlanItemId).localeCompare(id(right?.loadingPlanItemId)))
.flatMap((item) => {
const count = Math.max(0, Number(item?.pickedPackageCount) || 0)
const seed = `${loadingPlanId}:${id(item?.loadingPlanItemId)}`
const labels = [...new Set((item?.boxCodes || [])
.map((value) => String(value || '').trim()).filter((value) => value && !used.has(value)))]
.sort((left, right) => createHash('sha256').update(`${seed}:${left}`).digest('hex')
.localeCompare(createHash('sha256').update(`${seed}:${right}`).digest('hex')))
// Partial loading keeps the lowest carton indexes on the loaded source inbound and
// transfers the highest indexes to the remainder child. Mirror that settlement rule
// instead of sampling labels, otherwise downstream PDA fixtures may reference cartons
// that were deliberately moved out of this container.
.sort((left, right) => left.localeCompare(right, undefined, { numeric: true, sensitivity: 'base' }))
.slice(0, count)
labels.forEach((value) => used.add(value))
return labels
@@ -1477,7 +1479,7 @@ export async function run(context) {
context.createdResources.phase3Loading = {
tenantId, orderId: id(source?.orderId), inboundId, preloadPlanId: planId,
cartonMark: source?.boxCode || source?.cartonMark || null,
cartonMarks: stableLoadedCartonMarks(stagedTask?.items, loadingPlanId),
cartonMarks: stableLoadedCartonMarks(stagedTask?.items),
fulfillmentType: source?.fulfillmentType || 'STANDARD',
skuCodes: [...new Set([...(Array.isArray(source?.skuCodes) ? source.skuCodes : []),
...(Array.isArray(incrementalFixture?.skuCodes) ? incrementalFixture.skuCodes : [])])],