优化
This commit is contained in:
@@ -114,8 +114,6 @@ export async function run(context) {
|
||||
['跨链路开始提货', 'pickup', 'PICKUP_IN_PROGRESS'],
|
||||
['跨链路拖车到仓', 'arrive', 'ARRIVED_WAREHOUSE'],
|
||||
['跨链路开始装货', 'load', 'LOADING'],
|
||||
['跨链路拖车离仓', 'depart', 'DEPARTED'],
|
||||
['完成跨链路拖车', 'complete', 'COMPLETED'],
|
||||
]) {
|
||||
const action = await actionRequest(context, path, endpoint, version)
|
||||
const changed = context.apiSuccess(MODULE, name, action, '', OPTIONS)
|
||||
@@ -125,9 +123,9 @@ export async function run(context) {
|
||||
version = Number(changed.version)
|
||||
}
|
||||
const detail = await context.request('GET', `${TRUCK}/${appointmentId}`)
|
||||
const final = context.apiSuccess(MODULE, '回查跨服务链路安全终态', detail, '', OPTIONS)
|
||||
context.assert(MODULE, '跨服务链路终态持久化且关联订舱未漂移', detail,
|
||||
final?.status === 'COMPLETED' && id(final?.oceanBookingId) === id(ocean.id)
|
||||
const final = context.apiSuccess(MODULE, '回查跨服务链路离仓前状态', detail, '', OPTIONS)
|
||||
context.assert(MODULE, '跨服务链路离仓前状态持久化且关联订舱未漂移', detail,
|
||||
final?.status === 'LOADING' && id(final?.oceanBookingId) === id(ocean.id)
|
||||
&& !Object.hasOwn(final || {}, 'containerBookingId')
|
||||
&& !Object.hasOwn(final || {}, 'loadingPlanId'),
|
||||
`status=${final?.status || 'missing'}, oceanBookingId=${final?.oceanBookingId || 'missing'}, containerBookingId=${final?.containerBookingId || 'n/a'}, loadingPlanId=${final?.loadingPlanId || 'n/a'}`, OPTIONS)
|
||||
@@ -135,19 +133,19 @@ export async function run(context) {
|
||||
const historyResponse = await context.request('GET', `${TRUCK}/${appointmentId}/history`)
|
||||
const history = context.apiSuccess(MODULE, '查询跨服务链路拖车预约状态历史', historyResponse, '', OPTIONS)
|
||||
const actions = Array.isArray(history) ? history.filter((item) => item?.action !== 'CREATE') : []
|
||||
const expectedActions = ['SUBMIT', 'DISPATCH', 'PICKUP', 'ARRIVE', 'LOAD', 'DEPART', 'COMPLETE']
|
||||
const expectedActions = ['SUBMIT', 'DISPATCH', 'PICKUP', 'ARRIVE', 'LOAD']
|
||||
context.assert(MODULE, '跨服务链路历史包含完整状态链、操作者、时间和备注', historyResponse,
|
||||
expectedActions.every((action) => actions.some((item) => item.action === action
|
||||
&& id(item.appointmentId) === appointmentId && Boolean(item.operatorId)
|
||||
&& Boolean(item.operatorName) && Boolean(item.createdAt) && item.reason === context.marker)),
|
||||
`history=${history?.length ?? 'n/a'}, actions=${actions.map((item) => item.action).join(',')}`,
|
||||
OPTIONS)
|
||||
if (final?.status === 'COMPLETED') {
|
||||
if (final?.status === 'LOADING') {
|
||||
context.createdResources.serviceCenterFlow = {
|
||||
appointmentId, oceanBookingId: ocean.id,
|
||||
containerBookingId: null,
|
||||
loadingPlanId: null,
|
||||
marker: context.marker, finalStatus: 'COMPLETED',
|
||||
marker: context.marker, finalStatus: 'LOADING',
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user