优化
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
const MODULE = 'manual-state-ocean-trucking'
|
||||
const OPTIONS = { scenario: 'manual-ocean-trucking-state-matrix', deploymentBlocker: true }
|
||||
const OCEAN_BASE = '/api/platform/v1/first-leg/ocean-bookings'
|
||||
const OCEAN_BASE = '/api/platform/v1/ocean-bookings'
|
||||
const TRUCK_BASE = '/api/platform/v1/truck-appointments'
|
||||
const OCEAN_STATUSES = ['DRAFT', 'SUBMITTED', 'CONFIRMED', 'RELEASED', 'FAILED', 'CHANGE_PENDING', 'CANCELLED']
|
||||
const TRUCK_STATUSES = ['DRAFT', 'PENDING_DISPATCH', 'DISPATCHED', 'PICKUP_IN_PROGRESS', 'ARRIVED_WAREHOUSE',
|
||||
@@ -71,10 +71,12 @@ async function buildOcean(context, template, status, index) {
|
||||
throw new Error(`unsupported ocean status ${status}`)
|
||||
}
|
||||
|
||||
function truckPayload(context, oceanBookingId, index) {
|
||||
function truckPayload(context, oceanBooking, index) {
|
||||
const value = suffix(context, index)
|
||||
return { outboundOrderId: null, oceanBookingId, containerBookingId: null, loadingPlanId: null,
|
||||
warehouseId: '193000000000200001', customerId: '10001', customerName: 'IT 测试客户',
|
||||
return { outboundOrderId: null, oceanBookingId: oceanBooking.id,
|
||||
containerBookingId: null, loadingPlanId: null,
|
||||
warehouseId: oceanBooking.warehouseId, customerId: oceanBooking.customerId,
|
||||
customerName: oceanBooking.customerName,
|
||||
carrierName: `人工验收车队-${value}`, fleetContact: '人工验收联系人', fleetPhone: '13800000004',
|
||||
driverName: `人工司机-${value}`, driverPhone: '13800000005', vehicleNo: `粤B${value.slice(-6)}`,
|
||||
storeName: '人工验收仓', storeContact: '仓库联系人', storePhone: '13800000006',
|
||||
@@ -84,8 +86,8 @@ function truckPayload(context, oceanBookingId, index) {
|
||||
receivableAmount: 150, currency: 'RMB', remark: `${context.marker} 人工列表状态 ${index}`, expectedVersion: 0 }
|
||||
}
|
||||
|
||||
async function createTruck(context, oceanBookingId, index) {
|
||||
const response = await context.request('POST', TRUCK_BASE, truckPayload(context, oceanBookingId, index))
|
||||
async function createTruck(context, oceanBooking, index) {
|
||||
const response = await context.request('POST', TRUCK_BASE, truckPayload(context, oceanBooking, index))
|
||||
const value = context.apiSuccess(MODULE, `创建拖车状态样本 ${index}`, response, '', OPTIONS)
|
||||
if (!value?.id) throw new Error(`创建拖车样本 ${index} 失败`)
|
||||
return value
|
||||
@@ -99,8 +101,8 @@ async function truckAction(context, value, endpoint) {
|
||||
return next
|
||||
}
|
||||
|
||||
async function buildTruck(context, oceanBookingId, status, index) {
|
||||
let value = await createTruck(context, oceanBookingId, index)
|
||||
async function buildTruck(context, oceanBooking, status, index) {
|
||||
let value = await createTruck(context, oceanBooking, index)
|
||||
if (status === 'DRAFT') return value
|
||||
if (status === 'RESCHEDULED') {
|
||||
const response = await post(context,
|
||||
@@ -139,16 +141,23 @@ export async function run(context, matrix = context.createdResources.manualState
|
||||
for (const [index, status] of OCEAN_STATUSES.entries()) {
|
||||
const value = await buildOcean(context, template, status, index)
|
||||
const resourceId = id(value?.oceanBooking?.id); const actual = value?.oceanBooking?.status
|
||||
matrix.pages.oceanBookings.fixtures[status] = { id: resourceId, status: actual, detailPath: `/ocean-bookings/${resourceId}` }
|
||||
matrix.pages.oceanBookings.fixtures[status] = {
|
||||
id: resourceId, status: actual, detailPath: `/ocean-bookings/${resourceId}`,
|
||||
customerId: id(value?.oceanBooking?.customerId), customerName: value?.oceanBooking?.customerName,
|
||||
warehouseId: id(value?.oceanBooking?.warehouseId),
|
||||
}
|
||||
context.assert(MODULE, `订舱保留 ${status}`, null, resourceId && actual === status,
|
||||
`id=${resourceId || 'missing'}, actual=${actual || 'missing'}`, OPTIONS)
|
||||
await verify(context, OCEAN_BASE, status, resourceId)
|
||||
}
|
||||
|
||||
const releasedOceanId = matrix.pages.oceanBookings.fixtures.RELEASED.id
|
||||
const releasedOcean = matrix.pages.oceanBookings.fixtures.RELEASED
|
||||
if (!releasedOcean.id || !releasedOcean.customerId || !releasedOcean.warehouseId) {
|
||||
throw new Error('RELEASED 订舱缺少拖车所需的客户或仓库归属')
|
||||
}
|
||||
matrix.pages.truckAppointments = { requiredStatuses: TRUCK_STATUSES, fixtures: {} }
|
||||
for (const [index, status] of TRUCK_STATUSES.entries()) {
|
||||
const value = await buildTruck(context, releasedOceanId, status, index)
|
||||
const value = await buildTruck(context, releasedOcean, status, index)
|
||||
const resourceId = id(value?.id)
|
||||
matrix.pages.truckAppointments.fixtures[status] = { id: resourceId, status: value?.status, detailPath: `/truck-appointments/${resourceId}` }
|
||||
context.assert(MODULE, `拖车保留 ${status}`, null, resourceId && value?.status === status,
|
||||
|
||||
Reference in New Issue
Block a user