优化
This commit is contained in:
@@ -129,6 +129,7 @@ async function createConfirmedWeightEvidence(context, {
|
||||
}) {
|
||||
if (!Array.isArray(palletIds) || palletIds.length < 1) return null
|
||||
const confirmedResults = []
|
||||
const guideEvolution = []
|
||||
for (let index = 0; index < palletIds.length; index += 1) {
|
||||
const palletId = palletIds[index]
|
||||
const uploadResponse = await context.requestMultipart('POST',
|
||||
@@ -180,6 +181,40 @@ async function createConfirmedWeightEvidence(context, {
|
||||
id: asId(created.id), palletId, netWeightKg, grossWeightKg,
|
||||
version: Number(confirmed?.version),
|
||||
})
|
||||
|
||||
if (context.options?.verifyPalletLocationGuide) {
|
||||
const guideResponse = await context.request('GET',
|
||||
`/api/platform/v1/first-leg/inbounds/${inboundId}/measurement?${query(tenantId)}`)
|
||||
const guideWorkspace = context.apiSuccess(MODULE,
|
||||
`逐张确认后回查整票库位块 ${index + 1}/${palletIds.length}`, guideResponse,
|
||||
`resultId=${asId(created.id)}, confirmedCount=${confirmedResults.length}`, OPTIONS)
|
||||
const verified = verifyPalletLocationGuide(context, guideResponse, guideWorkspace,
|
||||
confirmedResults.map((result) => result.id), `第${index + 1}张确认后`)
|
||||
const previous = guideEvolution.at(-1)
|
||||
if (previous) {
|
||||
const priorSlotsStable = previous.slots.every((prior) => {
|
||||
const current = verified.slots.find((slot) => Number(slot?.slotNo) === Number(prior?.slotNo))
|
||||
return current
|
||||
&& asId(current.reservationId) === asId(prior.reservationId)
|
||||
&& asId(current.locationId) === asId(prior.locationId)
|
||||
&& String(current.locationCode || '') === String(prior.locationCode || '')
|
||||
&& Boolean(current.sharedOverflow) === Boolean(prior.sharedOverflow)
|
||||
})
|
||||
context.assert(MODULE, `第${index + 1}张确认后扩容只追加且既有槽身份不漂移`, guideResponse,
|
||||
asId(verified.guide?.blockId) === previous.blockId
|
||||
&& verified.slots.length >= previous.slots.length && priorSlotsStable,
|
||||
`beforeBlock=${previous.blockId || 'missing'}, afterBlock=${asId(verified.guide?.blockId) || 'missing'}, beforeSlots=${previous.slots.length}, afterSlots=${verified.slots.length}`,
|
||||
OPTIONS)
|
||||
}
|
||||
guideEvolution.push({
|
||||
blockId: asId(verified.guide?.blockId),
|
||||
slots: verified.slots.map((slot) => ({
|
||||
slotNo: Number(slot?.slotNo), reservationId: asId(slot?.reservationId),
|
||||
locationId: asId(slot?.locationId), locationCode: String(slot?.locationCode || ''),
|
||||
sharedOverflow: Boolean(slot?.sharedOverflow),
|
||||
})),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const workspaceResponse = await context.request('GET',
|
||||
@@ -200,7 +235,9 @@ async function createConfirmedWeightEvidence(context, {
|
||||
context.assert(MODULE, '图片张数决定托数且净重汇总已落地', workspaceResponse, persisted,
|
||||
`confirmedImages=${confirmedRows.length}, expectedPallets=${palletIds.length}, grossWeight=${grossWeightKg}, netWeight=${netWeightKg}, actualGross=${workspace?.actualGrossWeightKg ?? 'missing'}, actualNet=${workspace?.actualNetWeightKg ?? 'missing'}`,
|
||||
OPTIONS)
|
||||
return persisted ? { count: confirmedRows.length, grossWeightKg, netWeightKg, confirmedResults } : null
|
||||
return persisted
|
||||
? { count: confirmedRows.length, grossWeightKg, netWeightKg, confirmedResults, guideEvolution }
|
||||
: null
|
||||
}
|
||||
|
||||
function verifyPalletLocationGuide(context, response, workspace, expectedWeightResultIds, name) {
|
||||
|
||||
Reference in New Issue
Block a user