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 ??= {}
@@ -6,6 +6,7 @@ const acceptance = readFileSync(new URL('../admin-test-env-acceptance.mjs', impo
const orders = readFileSync(new URL('./orders.mjs', import.meta.url), 'utf8')
const measurement = readFileSync(new URL('./inbound-measurement.mjs', import.meta.url), 'utf8')
const runner = readFileSync(new URL('../it-test-wait-split-bulk.mjs', import.meta.url), 'utf8')
const warehouseLocationResources = readFileSync(new URL('../../warehouse/src/main/java/com/baiyue/warehouse/service/LocationResourceService.java', import.meta.url), 'utf8')
test('单票随机箱数严格分配到各 SKU 并限制为1到1000', () => {
assert.match(acceptance, /--wait-split-package-count <n>/)
@@ -35,6 +36,13 @@ test('称重只随机复用义乌仓原有两个托盘且禁止按订单新增',
assert.doesNotMatch(measurement, /创建称重托盘主数据/)
})
test('称重脚本不新增库位且容量不足由仓库服务复用 A0 公共位', () => {
assert.doesNotMatch(measurement, /context\.request\('POST', '\/api\/platform\/v1\/locations/)
assert.doesNotMatch(measurement, /创建测量占用库位/)
assert.match(measurement, /普通位不足会复用唯一的 A0 共享溢出位/)
assert.match(warehouseLocationResources, /selected\.size\(\) < quantity[\s\S]*lockOrCreateSharedOverflow/)
})
test('八千票执行器逐票记录且失败后继续', () => {
assert.match(runner, /positiveInteger\(values\.get\('count'\), 8000/)
assert.match(runner, /positiveInteger\(values\.get\('box-max'\), 300/)