|
|
|
@@ -201,7 +201,7 @@ export async function run(context) {
|
|
|
|
|
const pushKey = `${context.marker}-container-push`.slice(0, 128)
|
|
|
|
|
const pushResponse = await request(context, 'POST', `${SMART}/plans/${planId}/push-preload`,
|
|
|
|
|
{ expectedVersion: Number(assigned.version) }, { 'Idempotency-Key': pushKey })
|
|
|
|
|
const pushed = context.apiSuccess(MODULE, '推送预装并创建 PDA 任务', pushResponse, '', OPTIONS)
|
|
|
|
|
const pushed = context.apiSuccess(MODULE, '推送预装计划', pushResponse, '', OPTIONS)
|
|
|
|
|
context.assert(MODULE, '推送后计划保持 EDITING 且版本递增', pushResponse,
|
|
|
|
|
pushed?.status === 'EDITING' && Number(pushed?.version) === Number(assigned.version) + 1,
|
|
|
|
|
`status=${pushed?.status || 'missing'}, version=${pushed?.version ?? 'missing'}`, OPTIONS)
|
|
|
|
@@ -232,11 +232,34 @@ export async function run(context) {
|
|
|
|
|
containerNo: `TST-${suffix}`.slice(0, 64), voyageNo: `V-${suffix}`.slice(0, 64),
|
|
|
|
|
version: Number(containerDetail?.version ?? 0), reason: context.marker,
|
|
|
|
|
})
|
|
|
|
|
const transported = context.apiSuccess(MODULE, '绑定本轮真实箱号并补建 PDA 任务', transportResponse, '', OPTIONS)
|
|
|
|
|
const transported = context.apiSuccess(MODULE, '在放舱前绑定本轮真实箱号', transportResponse, '', OPTIONS)
|
|
|
|
|
context.assert(MODULE, '绑定后柜次保留本轮箱号', transportResponse,
|
|
|
|
|
transported?.containerNo === `TST-${suffix}`.slice(0, 64),
|
|
|
|
|
`containerNo=${transported?.containerNo || 'missing'}`, OPTIONS)
|
|
|
|
|
|
|
|
|
|
const confirmedTaskResponse = await context.request('GET',
|
|
|
|
|
`${PDA}/tasks?loadingPlanId=${encodeURIComponent(planId)}&warehouseId=${encodeURIComponent(warehouseId)}`)
|
|
|
|
|
context.addStep(MODULE, '订舱 CONFIRMED 即使已有真实柜号也不开放 PDA 任务', confirmedTaskResponse,
|
|
|
|
|
failure(confirmedTaskResponse) || !id(confirmedTaskResponse?.body?.id || confirmedTaskResponse?.body?.data?.id),
|
|
|
|
|
`HTTP=${confirmedTaskResponse.http}, code=${codeOf(confirmedTaskResponse)}, task=${id(confirmedTaskResponse?.body?.id || confirmedTaskResponse?.body?.data?.id) || 'none'}`, OPTIONS)
|
|
|
|
|
|
|
|
|
|
const sailingAt = new Date(Date.now() + 24 * 60 * 60 * 1000).toISOString()
|
|
|
|
|
const arrivalAt = new Date(Date.now() + 20 * 24 * 60 * 60 * 1000).toISOString()
|
|
|
|
|
const releaseResponse = await request(context, 'POST', `/api/platform/v1/ocean-bookings/${bookingId}/release`, {
|
|
|
|
|
expectedVersion: Number(confirmedBooking?.oceanBooking?.version),
|
|
|
|
|
billOfLadingNo: `BL-${suffix}`.slice(0, 128), vesselName: `VESSEL-${suffix}`.slice(0, 128),
|
|
|
|
|
voyageNo: `V-${suffix}`.slice(0, 64), estimatedSailingAt: sailingAt,
|
|
|
|
|
estimatedArrivalAt: arrivalAt, reason: context.marker,
|
|
|
|
|
}, { 'Idempotency-Key': `${context.marker}-loading-booking-release`.slice(0, 128) })
|
|
|
|
|
const releasedBooking = context.apiSuccess(MODULE, '订舱放舱并开放现场 PDA 任务', releaseResponse, '', OPTIONS)
|
|
|
|
|
context.assert(MODULE, '放舱后订舱进入 RELEASED 且柜次分配保持稳定', releaseResponse,
|
|
|
|
|
releasedBooking?.oceanBooking?.status === 'RELEASED'
|
|
|
|
|
&& releasedBooking?.containerAllocations?.some?.((item) => id(item.containerBookingId) === containerId),
|
|
|
|
|
`status=${releasedBooking?.oceanBooking?.status || 'missing'}, containerBookingId=${containerId}`, OPTIONS)
|
|
|
|
|
|
|
|
|
|
const releasedContainerResponse = await context.request('GET', `${CONTAINERS}/${containerId}`)
|
|
|
|
|
const releasedContainer = context.apiSuccess(MODULE, '放舱后回查货柜运输版本', releasedContainerResponse, '', OPTIONS)
|
|
|
|
|
|
|
|
|
|
const taskResponse = await context.request('GET',
|
|
|
|
|
`${PDA}/tasks?loadingPlanId=${encodeURIComponent(planId)}&warehouseId=${encodeURIComponent(warehouseId)}`)
|
|
|
|
|
const task = context.apiSuccess(MODULE, '查询本轮柜次 PDA 拣货任务', taskResponse, '', OPTIONS)
|
|
|
|
@@ -263,7 +286,7 @@ export async function run(context) {
|
|
|
|
|
const replacementContainerNo = `TST-R-${suffix}`.slice(0, 64)
|
|
|
|
|
const replacementResponse = await request(context, 'PATCH', `${CONTAINERS}/${containerId}/transport`, {
|
|
|
|
|
containerNo: replacementContainerNo, voyageNo: `V-${suffix}`.slice(0, 64),
|
|
|
|
|
version: Number(transported?.version), reason: `${context.marker}-replace-container-no`,
|
|
|
|
|
version: Number(releasedContainer?.version), reason: `${context.marker}-replace-container-no`,
|
|
|
|
|
})
|
|
|
|
|
const replaced = context.apiSuccess(MODULE, 'PDA 任务创建后替换真实柜号', replacementResponse, '', OPTIONS)
|
|
|
|
|
context.assert(MODULE, '任务创建后真实柜号替换成功', replacementResponse,
|
|
|
|
|