收敛海外PDA回归夹具选择
This commit is contained in:
@@ -48,22 +48,27 @@ async function ensureMatsonSupplier(context, records) {
|
||||
}
|
||||
|
||||
export function stableLoadedCartonMarks(items) {
|
||||
const used = new Set()
|
||||
return [...(Array.isArray(items) ? items : [])]
|
||||
const groups = new Map()
|
||||
for (const item of [...(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 labels = [...new Set((item?.boxCodes || [])
|
||||
.map((value) => String(value || '').trim()).filter((value) => value && !used.has(value)))]
|
||||
// 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
|
||||
})
|
||||
) {
|
||||
const groupKey = id(item?.inboundId) || `item:${id(item?.loadingPlanItemId)}`
|
||||
const group = groups.get(groupKey) || { count: 0, labels: new Set() }
|
||||
group.count += Math.max(0, Number(item?.pickedPackageCount) || 0)
|
||||
for (const value of item?.boxCodes || []) {
|
||||
const label = String(value || '').trim()
|
||||
if (label) group.labels.add(label)
|
||||
}
|
||||
groups.set(groupKey, group)
|
||||
}
|
||||
// Settlement transfers the highest carton indexes to the remainder child for the whole
|
||||
// inbound, not per cargo line. Aggregate task rows by inbound before selecting the retained
|
||||
// low indexes so the downstream fixture mirrors the persisted container manifest.
|
||||
return [...groups.entries()]
|
||||
.sort(([left], [right]) => left.localeCompare(right))
|
||||
.flatMap(([, group]) => [...group.labels]
|
||||
.sort((left, right) => left.localeCompare(right, undefined, { numeric: true, sensitivity: 'base' }))
|
||||
.slice(0, group.count))
|
||||
}
|
||||
|
||||
async function request(context, method, path, body, headers = {}) {
|
||||
|
||||
Reference in New Issue
Block a user