From 363399faed6e431feb84bd2b3cb0c7390e22fd0e Mon Sep 17 00:00:00 2001 From: kkfluous Date: Thu, 26 Mar 2026 15:03:44 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=AD=A3=E6=80=BB=E5=BA=93?= =?UTF-8?q?=E5=AD=98=E8=AE=A1=E7=AE=97=EF=BC=8C=E5=8C=BA=E5=88=86=E5=9C=A8?= =?UTF-8?q?=E5=BA=93/=E5=BE=85=E4=BA=A4=E8=BD=A6/=E5=BC=82=E5=8A=A8?= =?UTF-8?q?=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 总库存 = 在库 + 异动(不含待交车) - 待交车独立展示 - 库 = 纯在库数量 - 异 = 异动数量 - 验证: 运营 + 库存 + 待交 = 总资产 Co-Authored-By: Claude Opus 4.6 (1M context) --- src/server/routes/vehicles.ts | 16 +++++++++++----- src/server/types.ts | 2 +- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/server/routes/vehicles.ts b/src/server/routes/vehicles.ts index 7935116..034a78f 100644 --- a/src/server/routes/vehicles.ts +++ b/src/server/routes/vehicles.ts @@ -112,11 +112,12 @@ function mapInventoryRegion(region: string): string { // Map rental status to frontend status // Actual DB values: 在库(0), 自营(1), 租赁(2), 待交车(7), 挂靠(8), 异动(12) -function mapStatus(rentStatus: string | null): 'Operating' | 'Inventory' | 'Abnormal' { +function mapStatus(rentStatus: string | null): 'Operating' | 'Inventory' | 'Pending' | 'Abnormal' { if (!rentStatus) return 'Inventory'; const s = rentStatus.trim(); if (s === '租赁' || s === '自营' || s === '挂靠') return 'Operating'; - if (s === '在库' || s === '待交车') return 'Inventory'; + if (s === '在库') return 'Inventory'; + if (s === '待交车') return 'Pending'; if (s === '异动') return 'Abnormal'; return 'Inventory'; } @@ -324,7 +325,7 @@ function getStats(list: Vehicle[], weeklyIds?: WeeklyTruckIds) { list.filter((v) => v.status === 'Inventory'), REGIONS, ), - pending: weeklyIds ? strIds.filter((id) => weeklyIds.pending.has(id)).length : 0, + pending: list.filter((v) => v.status === 'Pending').length, operating: list.filter((v) => v.status === 'Operating').length, weeklyDelivered: weeklyIds ? strIds.filter((id) => weeklyIds.delivered.has(id)).length : 0, weeklyReturned: weeklyIds ? strIds.filter((id) => weeklyIds.returned.has(id)).length : 0, @@ -457,11 +458,16 @@ app.get('/summary', async (c) => { hanging: vehicles.filter((v) => v.status === 'Operating' && v.ownership === 'Hanging').length, }, inventory: { - total: vehicles.filter((v) => v.status === 'Inventory').length, + total: vehicles.filter((v) => v.status === 'Inventory' || v.status === 'Abnormal').length, inStock: vehicles.filter((v) => v.status === 'Inventory').length, abnormal: vehicles.filter((v) => v.status === 'Abnormal').length, }, - ...weekly, + pendingDelivery: vehicles.filter((v) => v.status === 'Pending').length, + weeklyNew: weekly.weeklyNew, + weeklyRemoved: weekly.weeklyRemoved, + weeklyDelivered: weekly.weeklyDelivered, + weeklyReturned: weekly.weeklyReturned, + weeklyReplaced: weekly.weeklyReplaced, }; return c.json(summary); }); diff --git a/src/server/types.ts b/src/server/types.ts index 9bc1a32..2920cc1 100644 --- a/src/server/types.ts +++ b/src/server/types.ts @@ -36,7 +36,7 @@ export interface Vehicle { color: string; location: string; region: string; - status: 'Operating' | 'Inventory' | 'Abnormal'; + status: 'Operating' | 'Inventory' | 'Pending' | 'Abnormal'; ownership: string; rentCompany: string; contractNo: string | null;