fix: 修正总库存计算,区分在库/待交车/异动状态
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
- 总库存 = 在库 + 异动(不含待交车) - 待交车独立展示 - 库 = 纯在库数量 - 异 = 异动数量 - 验证: 运营 + 库存 + 待交 = 总资产 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -112,11 +112,12 @@ function mapInventoryRegion(region: string): string {
|
|||||||
|
|
||||||
// Map rental status to frontend status
|
// Map rental status to frontend status
|
||||||
// Actual DB values: 在库(0), 自营(1), 租赁(2), 待交车(7), 挂靠(8), 异动(12)
|
// 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';
|
if (!rentStatus) return 'Inventory';
|
||||||
const s = rentStatus.trim();
|
const s = rentStatus.trim();
|
||||||
if (s === '租赁' || s === '自营' || s === '挂靠') return 'Operating';
|
if (s === '租赁' || s === '自营' || s === '挂靠') return 'Operating';
|
||||||
if (s === '在库' || s === '待交车') return 'Inventory';
|
if (s === '在库') return 'Inventory';
|
||||||
|
if (s === '待交车') return 'Pending';
|
||||||
if (s === '异动') return 'Abnormal';
|
if (s === '异动') return 'Abnormal';
|
||||||
return 'Inventory';
|
return 'Inventory';
|
||||||
}
|
}
|
||||||
@@ -324,7 +325,7 @@ function getStats(list: Vehicle[], weeklyIds?: WeeklyTruckIds) {
|
|||||||
list.filter((v) => v.status === 'Inventory'),
|
list.filter((v) => v.status === 'Inventory'),
|
||||||
REGIONS,
|
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,
|
operating: list.filter((v) => v.status === 'Operating').length,
|
||||||
weeklyDelivered: weeklyIds ? strIds.filter((id) => weeklyIds.delivered.has(id)).length : 0,
|
weeklyDelivered: weeklyIds ? strIds.filter((id) => weeklyIds.delivered.has(id)).length : 0,
|
||||||
weeklyReturned: weeklyIds ? strIds.filter((id) => weeklyIds.returned.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,
|
hanging: vehicles.filter((v) => v.status === 'Operating' && v.ownership === 'Hanging').length,
|
||||||
},
|
},
|
||||||
inventory: {
|
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,
|
inStock: vehicles.filter((v) => v.status === 'Inventory').length,
|
||||||
abnormal: vehicles.filter((v) => v.status === 'Abnormal').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);
|
return c.json(summary);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ export interface Vehicle {
|
|||||||
color: string;
|
color: string;
|
||||||
location: string;
|
location: string;
|
||||||
region: string;
|
region: string;
|
||||||
status: 'Operating' | 'Inventory' | 'Abnormal';
|
status: 'Operating' | 'Inventory' | 'Pending' | 'Abnormal';
|
||||||
ownership: string;
|
ownership: string;
|
||||||
rentCompany: string;
|
rentCompany: string;
|
||||||
contractNo: string | null;
|
contractNo: string | null;
|
||||||
|
|||||||
Reference in New Issue
Block a user