feat(mileage): 接入区间汇总并复用查询结果
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
shishengliang
2026-10-29 09:11:21 +08:00
parent 8afe13c9a3
commit e2f932232f
33 changed files with 1056 additions and 172 deletions
+6 -4
View File
@@ -11,7 +11,7 @@ interface ExportContext {
const BASE_HEADERS = [
'状态', '数据来源', '车牌号', '客户', '业务部门', '项目', '租赁状态',
'运营区域',
'运营区域', '有效天数', '缺失天数', '异常天数', '质量说明',
] as const;
function sourceLabel(v: MonitoringVehicle): string {
@@ -22,6 +22,7 @@ function sourceLabel(v: MonitoringVehicle): string {
}
function statusLabel(v: MonitoringVehicle): string {
if (v.qualityStatus) return { NORMAL: '有效', PARTIAL_DATA: '部分缺失', NO_DATA: '无数据', DATA_ANOMALY: '部分异常' }[v.qualityStatus];
if (!v.isDataSynced) return '未对接';
return v.isOnline ? '在线' : '离线';
}
@@ -30,7 +31,7 @@ function mileageCell(v: MonitoringVehicle, kind: 'today' | 'total'): string | nu
if (kind === 'today') {
return monitoringMileageValue(v);
}
return v.totalKm != null ? v.totalKm : '未对接';
return v.totalKm != null ? v.totalKm : '—';
}
export function exportMileageXlsx(vehicles: MonitoringVehicle[], ctx: ExportContext): void {
@@ -62,7 +63,7 @@ export function exportMileageXlsx(vehicles: MonitoringVehicle[], ctx: ExportCont
v.department || '',
v.project || '',
v.rentStatus || '',
v.region || '',
v.region || '', v.validDays ?? '', v.missingDays ?? '', v.anomalyDays ?? '', v.qualityReasons?.join(', ') || '',
];
const dailyCols = dayKeys.map(day => v.dailyMileage?.[day] ?? '—');
return [
@@ -86,6 +87,7 @@ export function exportMileageXlsx(vehicles: MonitoringVehicle[], ctx: ExportCont
{ wch: 16 }, // 项目
{ wch: 10 }, // 租赁状态
{ wch: 12 }, // 运营区域
{ wch: 10 }, { wch: 10 }, { wch: 10 }, { wch: 36 },
];
for (let i = 0; i < dayKeys.length; i++) wsCols.push({ wch: 12 });
wsCols.push({ wch: 14 }); // 区间合计
@@ -177,6 +179,6 @@ export function exportMileageXlsx(vehicles: MonitoringVehicle[], ctx: ExportCont
: ctx.sortBy === 'statisticTime'
? '统计时间'
: isRange ? '区间' : '今日';
const filename = `里程看板_${dateTag}_${hh}${mm}_${sortLabel}.xlsx`;
const filename = `${dayKeys.length ? '里程逐日明细' : '里程区间汇总'}_${dateTag}_${hh}${mm}_${sortLabel}.xlsx`;
XLSX.writeFile(wb, filename);
}