fix: calculate jt808 daily mileage from metric endpoints

This commit is contained in:
lingniu
2026-07-01 09:52:24 +08:00
parent bb051391c2
commit 0236884f81
7 changed files with 53 additions and 15 deletions

View File

@@ -60,7 +60,7 @@ public final class JdbcVehicleStatMetricRepository implements VehicleStatReposit
DailyMileageState existingState = findDailyMileageState(normalizedVin, date).orElse(null);
double firstTotalMileage = existingState == null || !Double.isFinite(existingState.firstTotalMileageKm())
? totalMileageKm
: existingState.firstTotalMileageKm();
: Math.min(existingState.firstTotalMileageKm(), totalMileageKm);
double latestTotalMileage = existingState == null || !Double.isFinite(existingState.latestTotalMileageKm())
? totalMileageKm
: Math.max(existingState.latestTotalMileageKm(), totalMileageKm);