优化
This commit is contained in:
@@ -5,6 +5,7 @@ import {
|
||||
listContainers, listSmartLoadingCandidates, pushSmartLoadingPreload, removeSmartLoadingItem,
|
||||
getContainerClearance, uploadContainerClearance, completeContainerClearance,
|
||||
getContainerOverview, markContainerException, cancelContainerException, uploadContainerDocument, downloadContainerDocument, downloadContainerPdaPhoto,
|
||||
getCustomerContainerTransitSummary,
|
||||
updateContainer, updateContainerTransport,
|
||||
} from './platformContainerLoading'
|
||||
|
||||
@@ -19,6 +20,15 @@ const plan = { id: 9007199254740993, bookingId: 9007199254740994, version: '3',
|
||||
describe('platform container loading API', () => {
|
||||
beforeEach(() => vi.clearAllMocks())
|
||||
|
||||
it('uses the customer transit summary and preserves fractional TEU', async () => {
|
||||
vi.mocked(http.get).mockResolvedValueOnce({ code: '200', data: { customerId: '9007199254740993', containerCount: 2, totalTeu: '2.25', unknownContainerCount: 0, asOf: '2026-08-13T12:00:00', definition: '已开船未到仓' } })
|
||||
|
||||
const result = await getCustomerContainerTransitSummary('9007199254740993')
|
||||
|
||||
expect(http.get).toHaveBeenCalledWith('/platform/v1/customers/9007199254740993/container-transit-summary')
|
||||
expect(result).toMatchObject({ customerId: '9007199254740993', containerCount: 2, totalTeu: '2.25', unknownContainerCount: 0 })
|
||||
})
|
||||
|
||||
it('normalizes paged container ids and numeric metadata', async () => {
|
||||
vi.mocked(http.get).mockResolvedValueOnce({ code: '200', data: { records: [container], page: '1', size: '20', total: '1', pages: '1' } })
|
||||
const result = await listContainers({ page: 1, size: 20 })
|
||||
|
||||
@@ -1,4 +1,13 @@
|
||||
import { http, unwrapApiResponse, type ApiEnvelope } from '@/shared/api/http'
|
||||
|
||||
export interface CustomerContainerTransitSummary {
|
||||
customerId: string
|
||||
containerCount: number
|
||||
totalTeu: number | string
|
||||
unknownContainerCount: number
|
||||
asOf: string
|
||||
definition: string
|
||||
}
|
||||
import type {
|
||||
ContainerBookingResource,
|
||||
ContainerPage,
|
||||
@@ -90,6 +99,18 @@ export async function listContainers(query: ContainerQuery): Promise<ContainerPa
|
||||
return { ...result, records: (result.records || []).map(container), page: numberValue(result.page, query.page), size: numberValue(result.size, query.size), total: numberValue(result.total), pages: numberValue(result.pages) }
|
||||
}
|
||||
|
||||
export async function getCustomerContainerTransitSummary(customerId: string): Promise<CustomerContainerTransitSummary> {
|
||||
const response = await http.get<ApiEnvelope<Record<string, unknown>>, ApiEnvelope<Record<string, unknown>>>(
|
||||
`/platform/v1/customers/${encodeURIComponent(customerId)}/container-transit-summary`,
|
||||
)
|
||||
const result = unwrapApiResponse(response)
|
||||
return {
|
||||
customerId: id(result.customerId), containerCount: numberValue(result.containerCount),
|
||||
totalTeu: String(result.totalTeu ?? '0'), unknownContainerCount: numberValue(result.unknownContainerCount),
|
||||
asOf: id(result.asOf), definition: id(result.definition),
|
||||
}
|
||||
}
|
||||
|
||||
export async function getContainer(containerId: string) {
|
||||
const response = await http.get<ApiEnvelope<ContainerBookingResource>, ApiEnvelope<ContainerBookingResource>>(`${containerPath}/${encodeURIComponent(containerId)}`)
|
||||
return container(unwrapApiResponse(response))
|
||||
|
||||
Reference in New Issue
Block a user