import type { InboundOrderSummary } from '@/modules/inbounds' import type { UnifiedOrderResource } from './api/unifiedOrders' /** 将统一订单查询的审核待办映射到现有测量审核操作,保留原始客户、入库单与版本。 */ export function toMeasurementReviewTask(row: UnifiedOrderResource): InboundOrderSummary { if (row.inboundId == null) throw new Error('测量审核订单缺少入库单标识,请刷新后重试') return { id: String(row.inboundId), tenantId: String(row.tenantId), orderId: String(row.orderId), orderNo: row.orderNo, inboundCode: row.inboundCode, processStatus: 'MEASURE_PENDING', orderStatusSnapshot: row.internalOrderStatus, measureReviewStatus: row.measurement?.reviewStatus ?? null, feeStatus: null, feeReviewStatus: row.feeReviewStatus, notificationStatus: null, version: row.inboundVersion, expectedArrivalAt: row.expectedArrivalAt, customerId: row.customerId == null ? null : String(row.customerId), customerName: row.customerName, companyId: null, companyName: row.companyName ?? null, warehouseId: row.receivingWarehouseId == null ? null : String(row.receivingWarehouseId), warehouseName: row.receivingWarehouseName, deliveryWarehouseId: row.destinationWarehouseId == null ? null : String(row.destinationWarehouseId), deliveryWarehouseName: row.destinationWarehouseName, businessType: row.businessType ?? null, fulfillmentType: row.fulfillmentType ?? null, channelCode: row.channelCode, channelName: row.channelName, taxMode: row.taxMode ?? null, containerMode: null, customsInspection: row.customsInspection ?? null, destinationType: row.destinationType ?? null, destinationWarehouseId: row.destinationWarehouseId == null ? null : String(row.destinationWarehouseId), destinationCode: null, destinationName: row.destinationWarehouseName, holdFlag: row.holdFlag, currentHoldReason: row.currentHoldReason, totalPackageCount: row.totalPackageCount, actualGrossWeightKg: row.measurement?.actualGrossWeightKg ?? row.actualGrossWeightKg, actualNetWeightKg: row.totalNetWeightKg, actualVolumeCbm: row.measurement?.actualVolumeCbm ?? row.actualVolumeCbm, volumeWeightKg: row.volumetricWeightKg, chargeableWeightKg: row.measurement?.chargeableWeightKg ?? null, chargeableVolumeCbm: row.chargeableVolumeCbm, palletCount: row.totalPalletCount, locationCodes: row.locationCodes, measureCompletedAt: row.measurement?.completedAt ?? row.measurementCompletedAt, inboundedAt: row.inboundCompletedAt, expressCompanyCode: null, expressCompanyName: row.expressCompany, expressTrackingNo: row.expressTrackingNo, loadingStatus: row.transport?.loadingStatus ?? null, containerNo: row.transport?.containerNo ?? null, cabinetNo: row.transport?.cabinetNo ?? null, vesselName: row.transport?.vesselName ?? null, voyageNo: row.transport?.voyageNo ?? null, sailingAt: row.transport?.effectiveSailingAt ?? null, portArrivalAt: row.transport?.effectivePortArrivalAt ?? null, createdAt: row.createdAt, updatedAt: row.updatedAt, } }