优化
This commit is contained in:
@@ -112,7 +112,8 @@ async function createConfirmedContainer(context, source, label) {
|
||||
if (!agent) throw new Error(`${label} 未取得当前船公司关联的 ACTIVE 订舱代理`)
|
||||
const draft = {
|
||||
customerId: source.tenantId, customerName: summary.customerName || 'IT 测试客户',
|
||||
channelCode: summary.channelCode, warehouseId: source.warehouseId,
|
||||
// Ocean booking 当前契约接收稳定的渠道分组码;入库摘要仍保留真实渠道码用于候选匹配。
|
||||
channelCode: channelGroup(summary.channelCode), warehouseId: source.warehouseId,
|
||||
billOfLadingNo: `BL-${value}`.slice(0, 128),
|
||||
shippingCompanyId: id(carrier.id), shippingCompanyName: carrier.name, carrierCode: carrier.carrierCode,
|
||||
bookingAgentId: id(agent.id), bookingAgentName: agent.name, departurePortCode: 'CNSZX',
|
||||
|
||||
@@ -137,16 +137,18 @@ async function readOrder(context, fixture, orderId) {
|
||||
return { response, detail: context.apiSuccess(MODULE, '回读订单状态样本', response) }
|
||||
}
|
||||
|
||||
async function waitForInbound(context, fixture, orderId) {
|
||||
async function waitForInbound(context, fixture, orderId, allowCompletedOrder = false) {
|
||||
const path = `/api/platform/v1/orders/${query(orderId)}?tenantId=${query(fixture.tenantId)}`
|
||||
for (let attempt = 0; attempt < 20; attempt += 1) {
|
||||
// 审核/接受/完成会经过跨服务履约事件;测试环境高负载时可能超过10秒才落入库单。
|
||||
// 保持轮询只读并延长观察窗口,避免把异步延迟误判为“未生成入库单”。
|
||||
for (let attempt = 0; attempt < 240; attempt += 1) {
|
||||
const response = await context.request('GET', path)
|
||||
const summary = data(response)?.summary
|
||||
if (ok(response) && summary?.inboundId
|
||||
&& ['WAIT_MEASURE', 'MEASURING', 'MEASURE_PENDING', 'MEASURE_REJECTED', 'WAIT_SPLIT'].includes(summary.mainStatus)) {
|
||||
&& (allowCompletedOrder || ['WAIT_MEASURE', 'MEASURING', 'MEASURE_PENDING', 'MEASURE_REJECTED', 'WAIT_SPLIT'].includes(summary.mainStatus))) {
|
||||
return { response, summary }
|
||||
}
|
||||
if (attempt < 19) await wait(500)
|
||||
if (attempt < 239) await wait(500)
|
||||
}
|
||||
return { response: null, summary: null }
|
||||
}
|
||||
@@ -248,7 +250,7 @@ export async function run(context, matrix = context.createdResources.manualState
|
||||
}
|
||||
|
||||
if (actions.includes('approve')) {
|
||||
const inbound = await waitForInbound(context, fixture, orderId)
|
||||
const inbound = await waitForInbound(context, fixture, orderId, target === 'COMPLETED')
|
||||
const inboundId = id(inbound.summary?.inboundId)
|
||||
context.assert(MODULE, `${target} 订单生成待测量入库单`, inbound.response, Boolean(inboundId),
|
||||
`orderId=${orderId}, inboundId=${inboundId || 'missing'}`)
|
||||
|
||||
Reference in New Issue
Block a user