fix(mileage): preserve anomalous odometer readings and show data quality
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
shishengliang
2026-09-18 09:54:08 +08:00
parent 9c13ab6d3b
commit 746edeb72c
8 changed files with 34 additions and 11 deletions
+5 -3
View File
@@ -6,7 +6,8 @@ export interface OneOsDailyMileage {
date: string;
dailyMileageKm: number | null;
totalMileageKm: number | null;
status: 'NORMAL' | 'NO_DATA';
status: 'NORMAL' | 'NO_DATA' | 'DATA_ANOMALY';
dataQuality?: string;
dataTime: string | null;
calculatedAt: string | null;
updatedAt: string | null;
@@ -44,7 +45,7 @@ export function normalizeOneOsRows(value: unknown, requestedDate: string): OneOs
const vin = typeof row.vin === 'string' ? row.vin.trim() : '';
const plateNumber = typeof row.plateNumber === 'string' ? row.plateNumber.trim() : '';
const date = typeof row.date === 'string' ? row.date : requestedDate;
const status = row.status === 'NORMAL' ? 'NORMAL' : 'NO_DATA';
const status = row.status === 'NORMAL' || row.status === 'DATA_ANOMALY' ? row.status : 'NO_DATA';
// The aliases keep the BI compatible while the Open API formalizes its fields.
const dataTime = stringField(row, 'dataTime', 'statisticTime', 'recordTime');
@@ -60,8 +61,9 @@ export function normalizeOneOsRows(value: unknown, requestedDate: string): OneOs
plateNumber,
date,
dailyMileageKm: nonNegativeMileage(row.dailyMileageKm, status),
totalMileageKm: nonNegativeMileage(row.totalMileageKm, status),
totalMileageKm: nonNegativeMileage(row.totalMileageKm, status === 'DATA_ANOMALY' ? 'NORMAL' : status),
status,
...(status === 'DATA_ANOMALY' ? { dataQuality: stringField(row, 'dataQuality') || 'DATA_ANOMALY' } : {}),
dataTime,
calculatedAt,
updatedAt,