feat: 客户多选筛选、统计报表里程与监控看板数据一致
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

- 资产管理按客户筛选改为多选(支持同时选多个客户)
- 新增 MultiSearchSelect 组件(搜索+标签+复选框)
- 统计报表 todayTotal 改用监控缓存数据,与里程看板一致

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
kkfluous
2026-04-02 11:31:54 +08:00
parent 8822ddf8ae
commit 997374cf25
3 changed files with 119 additions and 13 deletions

View File

@@ -380,6 +380,23 @@ app.get('/targets', async (c) => {
periodsMap.set(p.target_id, list);
}
// 使用监控缓存的里程数据(与里程看板一致)
const cacheVehicleMap = new Map<string, number>();
if (monitoringCache) {
for (const v of monitoringCache.vehicles) {
cacheVehicleMap.set(v.plate, Math.max(0, v.dailyKm || 0));
}
}
const [targetVehicleRows] = await pool.execute(
`SELECT target_id, plate_number FROM tab_mileage_assessment_vehicle WHERE is_deleted = 0`
) as any;
const targetIdPlatesMap = new Map<number, string[]>();
for (const r of targetVehicleRows) {
const list = targetIdPlatesMap.get(r.target_id) || [];
list.push(r.plate_number);
targetIdPlatesMap.set(r.target_id, list);
}
const now = new Date();
const result = targets.map((t: any) => {
const s = statsMap.get(t.id) || {};
@@ -409,7 +426,7 @@ app.get('/targets', async (c) => {
annualMileagePerVehicle: Number(t.annual_mileage_per_vehicle),
assessmentYears: t.assessment_years,
periods,
todayTotal: Number(s.today_total) || 0,
todayTotal: (targetIdPlatesMap.get(t.id) || []).reduce((sum: number, plate: string) => sum + (cacheVehicleMap.get(plate) || 0), 0),
cumulativeTotal: Number(s.cumulative_total) || 0,
avgCompletion: (Number(s.avg_completion) || 0) * 100,
qualifiedCount: Number(s.qualified_count) || 0,