优化
This commit is contained in:
@@ -3,7 +3,7 @@ import { readFileSync } from 'node:fs'
|
||||
import { resolve } from 'node:path'
|
||||
import { http } from '@/shared/api/http'
|
||||
import {
|
||||
adjustSmartLoadingItem, assignSmartLoadingGroup, assignSmartLoadingItem, getContainer,
|
||||
adjustSmartLoadingItem, assignPendingReviewSmartLoadingOrder, assignSmartLoadingGroup, assignSmartLoadingItem, getContainer,
|
||||
listContainers, listSmartLoadingCandidates, listSmartLoadingWorkbenchContainers, removeSmartLoadingGroup, removeSmartLoadingItem,
|
||||
getContainerClearance, downloadContainerClearance, uploadContainerClearance, completeContainerClearance,
|
||||
getContainerOverview, markContainerException, cancelContainerException, uploadContainerDocument, downloadContainerDocument, downloadContainerPdaPhoto,
|
||||
@@ -88,21 +88,39 @@ describe('platform container loading API', () => {
|
||||
expect(vi.mocked(http.delete).mock.calls[0]?.[1]).toMatchObject({ data: { expectedPlanVersion: 9, expectedItemVersion: 10, operationId: expect.stringContaining('remove-') } })
|
||||
})
|
||||
|
||||
it('uses the dedicated provisional assignment command for a pending-review order', async () => {
|
||||
vi.mocked(http.post).mockResolvedValue({ code: '200', data: plan })
|
||||
|
||||
await assignPendingReviewSmartLoadingOrder('10', {
|
||||
customerId: '21', orderId: '31', inboundCode: 'EXXHK2609020361',
|
||||
packageCount: 100, expectedVersion: 5,
|
||||
})
|
||||
|
||||
expect(http.post).toHaveBeenCalledWith(
|
||||
'/platform/v1/first-leg/smart-loading/plans/10/pending-review-assignments',
|
||||
expect.objectContaining({
|
||||
customerId: '21', orderId: '31', inboundCode: 'EXXHK2609020361',
|
||||
packageCount: 100, expectedVersion: 5,
|
||||
operationId: expect.stringContaining('assign-pending-review-'),
|
||||
}),
|
||||
)
|
||||
})
|
||||
|
||||
it('queries workbench containers with the same global filters and excludes the retired booking parameter', async () => {
|
||||
vi.mocked(http.get).mockResolvedValueOnce({ code: '200', data: {
|
||||
records: [{ bookingId: 9007199254740993n, bookingNo: 'BK-1', cabinetNo: 'CAB-1', containerNo: null, warehouseId: 8, warehouseName: '义乌仓', channelCode: 'MATSON_CLX_TRUCK', channelName: '美森正班海卡', containerType: '40HC', planId: 9007199254740994n, planNo: 'LP-1', planStatus: 'EDITING', version: '2' }],
|
||||
page: '1', size: '200', total: '1', pages: '1',
|
||||
} })
|
||||
|
||||
const result = await listSmartLoadingWorkbenchContainers({ channelGroupCodes: ['MATSON_CLX', 'EXX'], customerId: '12', inboundCode: 'IN-1', expectedArrivalStart: '2026-09-01', expectedArrivalEnd: '2026-09-03', orderStatus: 'WAIT_SPLIT', page: 1, size: 200 })
|
||||
const result = await listSmartLoadingWorkbenchContainers({ channelGroupCodes: ['MATSON_CLX', 'EXX'], customerId: '12', inboundCode: 'IN-1', createdStart: '2026-09-01', createdEnd: '2026-09-03', orderStatus: 'WAIT_SPLIT', page: 1, size: 200 })
|
||||
|
||||
expect(result).toMatchObject({ records: [{ bookingId: '9007199254740993', warehouseId: '8', planId: '9007199254740994', version: 2 }], total: 1 })
|
||||
const params = vi.mocked(http.get).mock.calls.at(-1)?.[1]?.params as URLSearchParams
|
||||
expect(params.getAll('channelGroupCodes')).toEqual(['MATSON_CLX', 'EXX'])
|
||||
expect(params.get('customerId')).toBe('12')
|
||||
expect(params.get('inboundCode')).toBe('IN-1')
|
||||
expect(params.get('expectedArrivalStart')).toBe('2026-09-01')
|
||||
expect(params.get('expectedArrivalEnd')).toBe('2026-09-03')
|
||||
expect(params.get('createdStart')).toBe('2026-09-01')
|
||||
expect(params.get('createdEnd')).toBe('2026-09-03')
|
||||
expect(params.get('orderStatus')).toBe('WAIT_SPLIT')
|
||||
expect(params.has('bookingId')).toBe(false)
|
||||
})
|
||||
|
||||
@@ -233,7 +233,7 @@ function smartLoadingQueryParams(query: SmartLoadingCandidateQuery) {
|
||||
for (const channelGroupCode of query.channelGroupCodes) params.append('channelGroupCodes', channelGroupCode)
|
||||
const optionalParams: Array<[string, string | number | undefined]> = [
|
||||
['warehouseId', query.warehouseId], ['customerId', query.customerId], ['inboundCode', query.inboundCode],
|
||||
['expectedArrivalStart', query.expectedArrivalStart], ['expectedArrivalEnd', query.expectedArrivalEnd],
|
||||
['createdStart', query.createdStart], ['createdEnd', query.createdEnd],
|
||||
['orderStatus', query.orderStatus], ['page', query.page], ['size', query.size],
|
||||
]
|
||||
for (const [key, value] of optionalParams) if (value !== undefined && value !== '') params.append(key, String(value))
|
||||
@@ -249,7 +249,7 @@ export async function listSmartLoadingCandidates(query: SmartLoadingCandidateQue
|
||||
page: numberValue(result.page, query.page), size: numberValue(result.size, query.size),
|
||||
total: numberValue(result.total), pages: numberValue(result.pages),
|
||||
records: result.records.map((raw) => ({
|
||||
...raw, accountId: id(raw.accountId), customerId: id(raw.customerId), inboundId: id(raw.inboundId),
|
||||
...raw, accountId: id(raw.accountId), customerId: id(raw.customerId), inboundId: optionalId(raw.inboundId),
|
||||
orderId: id(raw.orderId), warehouseId: id(raw.warehouseId), destinationWarehouseId: optionalId(raw.destinationWarehouseId),
|
||||
coLoadGroupId: optionalId(raw.coLoadGroupId),
|
||||
memberCount: raw.memberCount == null ? null : numberValue(raw.memberCount),
|
||||
@@ -297,6 +297,14 @@ export async function assignSmartLoadingItem(planId: string, payload: { inboundI
|
||||
return plan(unwrapApiResponse(response))
|
||||
}
|
||||
|
||||
export async function assignPendingReviewSmartLoadingOrder(planId: string, payload: { customerId: string; orderId: string; inboundCode: string; packageCount: number; expectedVersion: number }) {
|
||||
const response = await http.post<ApiEnvelope<SmartLoadingPlan>, ApiEnvelope<SmartLoadingPlan>>(
|
||||
`${smartLoadingPath}/plans/${encodeURIComponent(planId)}/pending-review-assignments`,
|
||||
{ ...payload, operationId: operationId('assign-pending-review') },
|
||||
)
|
||||
return plan(unwrapApiResponse(response))
|
||||
}
|
||||
|
||||
export async function assignSmartLoadingGroup(planId: string, inboundId: string, expectedVersion: number) {
|
||||
const response = await http.post<ApiEnvelope<SmartLoadingPlan>, ApiEnvelope<SmartLoadingPlan>>(
|
||||
`${smartLoadingPath}/plans/${encodeURIComponent(planId)}/group-assignments`,
|
||||
|
||||
Reference in New Issue
Block a user