优化
This commit is contained in:
@@ -100,11 +100,11 @@ async function loadProducerResources(context) {
|
||||
must(id(data.overseasWarehouseId) === sources[0].warehouseId && same((data.items || []).map(row => id(row.warehousePalletId)).sort(), sources.map(row => id(row.candidate.warehousePalletId)).sort()), 'Dispatch birth response differs from producer selection')
|
||||
add('dispatch', data.dispatchNo, sources[0].customerId, sources[0].warehouseId, e, { dispatch: data, arrangeBody: e.body })
|
||||
}
|
||||
match = path.match(/\/dispatches\/([^/]+)\/transfer-delivery$/)
|
||||
match = path.match(/\/dispatches\/([^/]+)$/)
|
||||
const dispatched = match && own.dispatch.get(decodeURIComponent(match[1]))
|
||||
if (e.method === 'POST' && dispatched && data.outboundNo && !data.replayed) {
|
||||
add('outbound', data.outboundNo, dispatched.customerId, dispatched.warehouseId, e, { dispatchNo: dispatched.key })
|
||||
for (const row of data.deliveries || []) add('delivery', row.deliveryNo, dispatched.customerId, dispatched.warehouseId, e, { outboundNo: data.outboundNo, dispatchNo: dispatched.key })
|
||||
if (e.method === 'GET' && dispatched && data.stage === 'DELIVERING') {
|
||||
for (const row of data.documents?.outbounds || []) if (id(row.customerId) === dispatched.customerId) add('outbound', row.outboundNo, dispatched.customerId, dispatched.warehouseId, e, { dispatchNo: dispatched.key })
|
||||
for (const row of data.documents?.deliveries || []) if (id(row.customerId) === dispatched.customerId && own.outbound.has(row.outboundNo)) add('delivery', row.deliveryNo, dispatched.customerId, dispatched.warehouseId, e, { outboundNo: row.outboundNo, dispatchNo: dispatched.key })
|
||||
}
|
||||
match = path.match(/\/delivery-orders\/([^/]+)\/return-inbound-options$/)
|
||||
if (e.method === 'GET' && match && own.delivery.has(decodeURIComponent(match[1])) && Array.isArray(data)) {
|
||||
@@ -242,39 +242,7 @@ export async function verifyDispatchRepair(context, fixtures, { execute = false
|
||||
finally { await context.checkpoint() }
|
||||
}
|
||||
try {
|
||||
await run('cancellation', async f => {
|
||||
must(f.allowDispatchCancellation === true && f.dispatchNo && f.transferBody && f.rearrangeBody, 'Owned cancellation fixture and explicit business cancel scope required')
|
||||
const path = `${BASE}/dispatches/${encodeURIComponent(f.dispatchNo)}`
|
||||
const original = await call('GET', path)
|
||||
must(original.status === 'PENDING_DEPARTURE' && original.createdAt && original.actions?.canTransfer, 'New unpicked execution required')
|
||||
const transferBody = { ...f.transferBody, idempotencyKey: key() }
|
||||
const transfer = await call('POST', `${path}/transfer-delivery`, transferBody)
|
||||
must(transfer.outboundNo && transfer.deliveries?.length, 'New outbound and delivery required')
|
||||
const dpath = scope(`${BASE}/delivery-orders/${encodeURIComponent(transfer.deliveries[0].deliveryNo)}`, f.customerId)
|
||||
const before = await call('GET', dpath)
|
||||
must(before.order?.status === 'WAIT_DELIVERY' && before.order.outboundNo === transfer.outboundNo, 'Delivery must belong to new unexecuted outbound')
|
||||
for (const status of ['DELIVERING', 'REJECTED', 'CANCELLED']) {
|
||||
await call('PUT', scope(`${BASE}/delivery-orders/${encodeURIComponent(before.order.deliveryNo)}/status`, f.customerId),
|
||||
{ status, expectedVersion: before.order.version, remark: context.marker }, { failure: true })
|
||||
}
|
||||
must(same(shipment((await call('GET', dpath)).order), shipment(before.order)), 'Rejected status commands changed delivery')
|
||||
const opath = `${BASE}/outbound-orders/${encodeURIComponent(transfer.outboundNo)}`
|
||||
await call('POST', `${opath}/cancel`, { reason: context.marker })
|
||||
must((await call('GET', opath)).outbound?.status === 'CANCELLED', 'Outbound cancellation did not persist')
|
||||
must((await call('GET', dpath)).order?.status === 'CANCELLED', 'Linked delivery cancellation did not persist')
|
||||
await call('DELETE', path, undefined, { cancel: true })
|
||||
must((await call('GET', path)).status === 'CANCELLED', 'Original dispatch was not retained as cancelled')
|
||||
const candidateQuery = new URLSearchParams(f.candidateQuery)
|
||||
const candidates = await call('GET', `${BASE}/dispatches/candidates?${candidateQuery}`)
|
||||
const expected = f.rearrangeBody.planPalletIds.map(id)
|
||||
must(expected.length && expected.every(value => candidates.some(row => id(row.planPalletId) === value)), 'Cancelled source pallets were not released')
|
||||
const replacement = await call('POST', `${BASE}/dispatches/pre-arrange`, f.rearrangeBody)
|
||||
must(replacement.dispatchNo && replacement.dispatchNo !== f.dispatchNo && replacement.status === 'PENDING_DEPARTURE'
|
||||
&& same(replacement.items.map(row => id(row.planPalletId)).sort(), [...expected].sort()), 'Released source was not re-arranged exactly once')
|
||||
const replay = await call('POST', `${path}/transfer-delivery`, transferBody)
|
||||
must(replay.outboundNo === transfer.outboundNo && replay.replayed, 'Old transfer replay generated another outbound')
|
||||
return { originalDispatchNo: f.dispatchNo, cancelledOutboundNo: transfer.outboundNo, replacementDispatchNo: replacement.dispatchNo }
|
||||
})
|
||||
proof.cases.cancellation = { status: 'NOT_APPLICABLE', reason: '装车完成即派送,已撤销未发车出库取消及人工安排派送场景' }
|
||||
await run('departedGate', async f => {
|
||||
const opath = `${BASE}/outbound-orders/${encodeURIComponent(f.outboundNo)}`
|
||||
const dpath = scope(`${BASE}/delivery-orders/${encodeURIComponent(f.deliveryNo)}`, f.customerId)
|
||||
|
||||
Reference in New Issue
Block a user