2026-08-10 12:23:43 +08:00
|
|
|
const MODULE = 'phase3-waiting-for-loading'
|
|
|
|
|
const OPTIONS = { scenario: 'waiting-for-loading-status', deploymentBlocker: true }
|
|
|
|
|
const BASE = '/api/platform/v1/first-leg/outbound-dispatches'
|
2026-08-08 22:42:49 +08:00
|
|
|
|
|
|
|
|
export async function run(context) {
|
2026-08-10 12:23:43 +08:00
|
|
|
const fixture = context.createdResources?.phase3OutboundDispatch
|
|
|
|
|
if (!fixture?.inboundId || !fixture?.containerBookingId || fixture.marker !== context.marker) {
|
2026-08-24 19:58:35 +08:00
|
|
|
context.addStep(MODULE, '取得同 marker 的 WAITING_FOR_LOADING 前置', null, false,
|
|
|
|
|
`inboundId=${fixture?.inboundId || 'missing'}, containerBookingId=${fixture?.containerBookingId || 'missing'}, fixtureMarker=${fixture?.marker || 'missing'}, runMarker=${context.marker}`,
|
|
|
|
|
OPTIONS)
|
2026-08-10 12:23:43 +08:00
|
|
|
context.addCoverageGap(MODULE, OPTIONS.scenario, 'WAITING_FOR_LOADING 状态与历史',
|
|
|
|
|
'本轮未取得 phase3-outbound-dispatch 的 marker 隔离聚合,未使用历史资源', 'fixture')
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
const selector = `inboundId=${encodeURIComponent(fixture.inboundId)}&containerBookingId=${encodeURIComponent(fixture.containerBookingId)}`
|
|
|
|
|
const response = await context.request('GET', `${BASE}/detail?${selector}`)
|
|
|
|
|
const detail = context.apiSuccess(MODULE, '回查 WAITING_FOR_LOADING 状态历史', response, selector, OPTIONS)
|
|
|
|
|
const history = Array.isArray(detail?.timeline)
|
|
|
|
|
? detail.timeline.filter((item) => item.module === 'OUTBOUND_DISPATCH') : []
|
2026-08-25 13:06:09 +08:00
|
|
|
const confirmations = history.filter((item) => item.action === 'CONFIRM_DISPATCH')
|
|
|
|
|
const confirmed = confirmations[0]
|
|
|
|
|
const reversed = history.filter((item) => item.action === 'REVERSE_DISPATCH')
|
2026-08-10 12:23:43 +08:00
|
|
|
context.assert(MODULE, '确认出仓真实进入 WAITING_FOR_LOADING', response,
|
|
|
|
|
fixture.confirmedStatus === 'WAITING_FOR_LOADING'
|
|
|
|
|
&& fixture.confirmedInboundStatus === 'LOADED'
|
|
|
|
|
&& confirmed?.fromStatus === 'READY_FOR_DISPATCH' && confirmed?.toStatus === 'WAITING_FOR_LOADING'
|
|
|
|
|
&& Boolean(confirmed?.operatorId) && Boolean(confirmed?.operatorName) && Boolean(confirmed?.occurredAt),
|
|
|
|
|
`confirmed=${confirmed?.fromStatus || 'missing'}->${confirmed?.toStatus || 'missing'}, version=${fixture.confirmedVersion ?? 'missing'}`, OPTIONS)
|
2026-08-25 13:06:09 +08:00
|
|
|
context.assert(MODULE, '实际离仓节点冻结后保持一次确认且零次成功撤销', response,
|
|
|
|
|
detail?.aggregate?.dispatchStatus === 'WAITING_FOR_LOADING' && detail?.aggregate?.inboundStatus === 'LOADED'
|
|
|
|
|
&& confirmations.length === 1 && reversed.length === 0,
|
|
|
|
|
`current=${detail?.aggregate?.dispatchStatus || 'missing'}, confirmations=${confirmations.length}, reversals=${reversed.length}`, OPTIONS)
|
2026-08-08 22:42:49 +08:00
|
|
|
}
|