This commit is contained in:
2026-08-27 11:38:53 +08:00
parent c1b136c3d6
commit 575cee7a86
6 changed files with 85 additions and 23 deletions
@@ -71,7 +71,6 @@ async function waitForCompletedMeasurement(context, measurementPath, attempts =
async function provisionWarehouseResources(context, { inboundId, warehouseId, palletCount }) {
if (!warehouseId || !Number.isInteger(palletCount) || palletCount < 1) return null
const suffix = `${String(context.marker).replace(/\D/g, '').slice(-8)}${String(inboundId).slice(-6)}`
const resources = []
const candidates = await reusablePallets(context, warehouseId)
if (!candidates) return null
@@ -82,20 +81,9 @@ async function provisionWarehouseResources(context, { inboundId, warehouseId, pa
context.assert(MODULE, `随机复用原有称重托盘 ${index}/${palletCount}`, null,
REUSABLE_PALLET_CODES.includes(candidates.find((item) => item.id === palletId)?.code),
`warehouseId=${warehouseId}, palletId=${palletId}`, OPTIONS)
const resourceSuffix = `${suffix}${String(index).padStart(2, '0')}`
let locationId = null
if (context.context?.phase3LoadingRequireSharedOverflow !== true) {
const locationResponse = await context.request('POST', '/api/platform/v1/locations?tenantId=0', {
warehouseId, zoneCode: `E2E-${String(context.marker).slice(-8)}`, zoneName: '自动化验收区',
locationCode: `E2E-${resourceSuffix}`, locationName: `测量验收库位-${index}`,
locationType: 'PALLET', maxWeightKg: 1000, status: 'AVAILABLE',
remark: `${context.marker}-INBOUND-${inboundId}`,
})
locationId = asId(context.apiSuccess(MODULE, `创建测量占用库位 ${index}/${palletCount}`,
locationResponse, `warehouseId=${warehouseId}`, OPTIONS))
}
if (context.context?.phase3LoadingRequireSharedOverflow !== true && !locationId) return null
resources.push({ palletId, locationId })
// 库位由 Warehouse 在测量审核时按正式规则分配;普通位不足会复用唯一的 A0 共享溢出位。
// 验收脚本不得为了制造容量而新增普通库位。
resources.push({ palletId, locationId: null })
}
context.createdResources.inboundWarehouseResources ??= {}