fix(mileage): 未到期年度累计对齐实时监控
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
@@ -192,6 +192,10 @@ app.get('/', async (c) => {
|
||||
}
|
||||
cutoffMileageMapByDate.set(date, map);
|
||||
}
|
||||
const currentMileageMap = new Map<string, number>();
|
||||
for (const vehicle of await queryDateMileage(todayStr)) {
|
||||
if (vehicle.totalKm != null) currentMileageMap.set(vehicle.plate, vehicle.totalKm);
|
||||
}
|
||||
|
||||
const yearlyMetricMap = new Map<string, {
|
||||
actualMileage: number;
|
||||
@@ -221,7 +225,7 @@ app.get('/', async (c) => {
|
||||
const key = `${row.target_id}-${year}`;
|
||||
const goal = annualMileage * year;
|
||||
const endDate = addYearsMinusOneDay(row.assessment_start_date, year);
|
||||
const cutoffMap = endDate < todayStr ? cutoffMileageMapByDate.get(endDate) : undefined;
|
||||
const cutoffMap = endDate < todayStr ? cutoffMileageMapByDate.get(endDate) : currentMileageMap;
|
||||
const mileageAtCutoff = Math.max(0, cutoffMap?.get(row.plate_number) ?? (Number(row.current_mileage) || 0));
|
||||
const completed = Math.min(mileageAtCutoff, goal);
|
||||
const draft = yearlyMetricDraftMap.get(key) || {
|
||||
|
||||
Reference in New Issue
Block a user