test: align full-chain fixture invariants
This commit is contained in:
@@ -574,6 +574,16 @@ async function verifyRelabel(context, token, merchantToken, fixture) {
|
||||
const targets = [printedA.data, printedB.data]
|
||||
const beforeBySource = new Map()
|
||||
const movedFacts = []
|
||||
const sourceCodes = confirmed.items.map((itemDetail) => {
|
||||
const sourcePositionId = id(itemDetail?.sourceInventoryPositionId)
|
||||
return sourceLines.find((line) => id(line.position.positionId) === sourcePositionId)?.position?.palletNo || ''
|
||||
})
|
||||
const sourceFrequency = sourceCodes.reduce((counts, sourceCode) => {
|
||||
if (sourceCode) counts.set(sourceCode, (counts.get(sourceCode) || 0) + 1)
|
||||
return counts
|
||||
}, new Map())
|
||||
const splitSource = [...sourceFrequency.entries()].find(([, count]) => count >= 2)?.[0] || ''
|
||||
let splitSourceMoves = 0
|
||||
for (const [index, itemDetail] of confirmed.items.entries()) {
|
||||
const sourcePositionId = id(itemDetail?.sourceInventoryPositionId)
|
||||
const sourceLine = sourceLines.find((line) => id(line.position.positionId) === sourcePositionId)
|
||||
@@ -586,9 +596,8 @@ async function verifyRelabel(context, token, merchantToken, fixture) {
|
||||
`P5拆托${index + 1}前刷新来源托盘`)).data
|
||||
if (!sourceBefore) return false
|
||||
if (!beforeBySource.has(sourcePalletCode)) beforeBySource.set(sourcePalletCode, Number(sourceBefore.totalPackages))
|
||||
// A receives one carton, then B receives one and is reused as an occupied merge target.
|
||||
// If the first two cartons share a source, the same source is split across A and B.
|
||||
const targetSeed = index === 0 ? targets[0] : targets[1]
|
||||
// Split one repeated source across A and B; all other cartons reuse occupied B as the merge target.
|
||||
const targetSeed = sourcePalletCode === splitSource && splitSourceMoves++ === 0 ? targets[0] : targets[1]
|
||||
const targetBefore = (await resolvePallet(context, token, targetSeed.palletCode,
|
||||
`P5拆托${index + 1}前刷新目标托盘`)).data
|
||||
const reason = index === 0 ? null : `${context.marker}-场景${index + 1}`
|
||||
@@ -699,9 +708,11 @@ export async function run(context) {
|
||||
'phase4-overseas-pda未交接本轮primary picker会话与已完成库存事实')
|
||||
return
|
||||
}
|
||||
const fixture = handoff.completedFixtures.find((item) => Array.isArray(item?.inventory)
|
||||
const fixturesByAuxiliaryCapacity = [...handoff.completedFixtures]
|
||||
.sort((left, right) => (right?.auxiliaryPallets?.length || 0) - (left?.auxiliaryPallets?.length || 0))
|
||||
const fixture = fixturesByAuxiliaryCapacity.find((item) => Array.isArray(item?.inventory)
|
||||
&& item.inventory.some((line) => Number(line?.availablePackages) > 1))
|
||||
|| handoff.completedFixtures.find((item) => Array.isArray(item?.inventory)
|
||||
|| fixturesByAuxiliaryCapacity.find((item) => Array.isArray(item?.inventory)
|
||||
&& item.inventory.some((line) => Number(line?.availablePackages) > 0))
|
||||
if (!fixture) {
|
||||
blocker(context, 'P2-P5可操作库存', '本轮已完成柜没有可移动的真实库存位置')
|
||||
|
||||
Reference in New Issue
Block a user