diff --git a/src/server/routes/vehicles.ts b/src/server/routes/vehicles.ts index af314d3..ec8b889 100644 --- a/src/server/routes/vehicles.ts +++ b/src/server/routes/vehicles.ts @@ -26,8 +26,9 @@ const MAIN_SQL = `SELECT vi.rental_company AS 租赁公司, CASE vi.vehicle_source WHEN '0' THEN '自有' - WHEN '1' THEN '外租' - WHEN '2' THEN '挂靠' + WHEN '1' THEN '挂靠' + WHEN '2' THEN '外租' + WHEN '3' THEN '自有' ELSE vi.actual_ownership END AS 车辆归属状态Label, vm.model AS 车辆型号Label, @@ -190,13 +191,14 @@ function mapStatus(operationStatus: string | null, vehicleStatus: string | null) } // Map ownership from vehicle_info.vehicle_source. -// DB values: 0/自有, 1/外租, 2/挂靠. +// ln_asset_management vehicle_source values: 1=挂靠, 2=外租, 3=自有. Keep 0=自有 for legacy rows. function mapOwnership(rentStatusLabel: string | null): string { if (!rentStatusLabel) return 'Unknown'; const s = rentStatusLabel.trim(); if (s === '0') return 'Self'; - if (s === '1') return 'Leased'; - if (s === '2') return 'Hanging'; + if (s === '1') return 'Hanging'; + if (s === '2') return 'Leased'; + if (s === '3') return 'Self'; if (s === '自有') return 'Self'; if (s === '外租') return 'Leased'; if (s === '自营') return 'Self'; @@ -244,8 +246,10 @@ function normalizeModelLabel(modelLabel: string | null): string | null { const MODEL_ALIAS_MAP: Record = { // 4.5T 普货 '现代-4.5吨货车-白色广州开发区交投氢能运营管理有限公司': { alias: '现代4.5T普货(交投)', order: 101 }, + '现代-4.5吨货车-白恒运': { alias: '现代4.5T普货(恒运)', order: 102 }, + '现代-4.5吨货车-白色恒运': { alias: '现代4.5T普货(恒运)', order: 102 }, '现代-4.5吨货车-白色': { alias: '现代4.5T普货', order: 101 }, - '现代-4.5吨货车-白': { alias: '现代4.5T普货(恒运)', order: 102 }, + '现代-4.5吨货车-白': { alias: '现代4.5T普货', order: 101 }, // 4.5T 冷链 '帕力安牌-4.5吨冷链车-白色广州开发区交投氢能运营管理有限公司': { alias: '现代4.5T冷链(交投)', order: 201 }, '帕力安牌-4.5吨冷链车-白色': { alias: '现代4.5T冷链(羚牛)', order: 202 }, @@ -299,6 +303,7 @@ function deriveModelTag( const brand = (brandLabel || '').trim(); const model = (normalizeModelLabel(modelLabel) || '').trim(); const c = (color || '').trim(); + if (model === '公务用车/小客车') return '公务车/挂靠车'; const isRented = ownershipLabel?.trim() === '外租'; const company = isRented ? (rentCompany || '').trim() : '';