This commit is contained in:
2026-08-15 09:49:09 +08:00
parent 2bf3ff9d8e
commit c07af65c3b
3 changed files with 45 additions and 7 deletions
@@ -2,15 +2,52 @@ const MODULE = 'phase3-evidence-gate'
const OPTIONS = { scenario: 'loading-evidence-gate', deploymentBlocker: true }
function id(value) { return value == null ? '' : String(value) }
function successful(response) { return response?.http === 200 && String(response?.body?.code ?? '') === '200' }
export async function run(context) {
const fixture = context.createdResources?.phase3Loading
if (!fixture?.tenantId || !fixture?.inboundId || fixture.marker !== context.marker) {
const tenantId = id(fixture?.tenantId)
const inboundId = id(fixture?.inboundId)
const taskId = id(fixture?.canonicalPdaTaskId || fixture?.pickingTaskId)
const loadingPlanId = id(fixture?.loadingPlanId)
const containerBookingId = id(fixture?.containerBookingId)
const warehouseId = id(fixture?.warehouseId)
if (!tenantId || !inboundId || !taskId || !loadingPlanId || !containerBookingId || !warehouseId
|| fixture.marker !== context.marker) {
context.addCoverageGap(MODULE, OPTIONS.scenario, '五类证据多图追加、作废审计和有效证据门禁',
'本轮未取得 phase3-loading 的 marker 隔离证据 fixture,未使用历史资源', 'fixture')
'本轮未取得带 taskId/inboundId/loadingPlanId/containerBookingId 的 phase3-loading marker 隔离证据 fixture,未使用历史资源', 'fixture')
return
}
const path = `/api/platform/v1/inbounds/${fixture.inboundId}/loading/evidence?tenantId=${encodeURIComponent(fixture.tenantId)}`
// AWAITING_REVIEW is a PDA workflow state, not evidence permission. Evidence is
// opened only after the server-side inbound aggregate has entered LOADING.
const taskResponse = await context.request('GET',
`/api/platform/v1/first-leg/pda-loading/tasks?loadingPlanId=${encodeURIComponent(loadingPlanId)}&warehouseId=${encodeURIComponent(warehouseId)}`)
const task = successful(taskResponse) ? taskResponse.body?.data : null
const taskItem = task?.items?.find?.((item) => id(item?.inboundId) === inboundId)
const taskIdentityValid = id(task?.id) === taskId
&& id(task?.loadingPlanId) === loadingPlanId
&& id(task?.containerBookingId) === containerBookingId
&& Boolean(taskItem) && id(taskItem?.inboundId) === inboundId
context.assert(MODULE, '证据前置任务身份使用本轮四元稳定关联', taskResponse,
taskIdentityValid,
`taskId=${id(task?.id) || 'missing'}, inboundId=${id(taskItem?.inboundId) || 'missing'}, loadingPlanId=${id(task?.loadingPlanId) || 'missing'}, containerBookingId=${id(task?.containerBookingId) || 'missing'}`, OPTIONS)
if (!taskIdentityValid) return
const inboundResponse = await context.request('GET',
`/api/platform/inbounds/${encodeURIComponent(inboundId)}?tenantId=${encodeURIComponent(tenantId)}`)
const inbound = successful(inboundResponse) ? inboundResponse.body?.data : null
const serverLoading = inbound?.summary?.processStatus === 'LOADING'
context.assert(MODULE, '服务端入库进入 LOADING 后才开放装柜证据', inboundResponse,
serverLoading,
`processStatus=${inbound?.summary?.processStatus || 'missing'}, taskWorkflow=${task?.workflowStatus || 'missing'}`, OPTIONS)
if (!serverLoading) {
context.addCoverageGap(MODULE, OPTIONS.scenario, '服务端装柜阶段前不请求证据',
`taskId=${taskId}, inboundId=${inboundId}, loadingPlanId=${loadingPlanId}, containerBookingId=${containerBookingId}, processStatus=${inbound?.summary?.processStatus || 'missing'};AWAITING_REVIEW 不作为证据开放条件`, 'deployment-blocker')
return
}
const path = `/api/platform/v1/inbounds/${inboundId}/loading/evidence?tenantId=${encodeURIComponent(tenantId)}`
const response = await context.request('GET', path)
const data = context.apiSuccess(MODULE, '复核本轮装柜证据聚合', response, `inboundId=${fixture.inboundId}`, OPTIONS)
const evidences = Array.isArray(data?.evidences) ? data.evidences : []