fix(scheduling): use current year mileage for consistent data display
- Add currentYearMileage to SchedulingVehicleInfo (backend + frontend) - Compute completionRate as currentYearMileage/yearTarget (year-based) instead of using overall completion_rate from DB - Display "本年已跑" instead of "累计" in detail modal - Fix reason text to show year completion rate Before: 累计 4.6万, 考核 3.0万, 完成率 12.1% (mismatched periods) After: 本年已跑 8.3万, 考核 3.0万, 完成率 275% (consistent year-based) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -35,13 +35,16 @@ export function classifyVehicle(
|
||||
import type { SchedulingVehicleInfo } from './types.js';
|
||||
|
||||
export function toVehicleInfo(v: EnrichedVehicle): SchedulingVehicleInfo {
|
||||
// Use current year completion rate instead of overall
|
||||
const yearCompletionRate = v.yearTarget > 0 ? v.currentYearMileage / v.yearTarget : 0;
|
||||
return {
|
||||
plateNumber: v.plateNumber,
|
||||
targetId: v.targetId,
|
||||
targetName: v.targetName,
|
||||
vehicleType: v.vehicleType,
|
||||
totalMileage: v.totalMileage,
|
||||
completionRate: v.completionRate,
|
||||
currentYearMileage: v.currentYearMileage,
|
||||
completionRate: yearCompletionRate,
|
||||
yearTarget: v.yearTarget,
|
||||
region: v.region,
|
||||
province: v.province,
|
||||
@@ -152,7 +155,8 @@ export function generateSuggestions(
|
||||
})
|
||||
.slice(0, 5);
|
||||
|
||||
const reason = `${vehicle.customer}日均里程 ${Math.round(vehicle.customerAvgDaily)} KM(高里程),该车已达标(完成率 ${Math.round(vehicle.completionRate * 100)}%),建议换上里程缺口大的车辆以加速达标。`;
|
||||
const yearRate = vehicle.yearTarget > 0 ? Math.round((vehicle.currentYearMileage / vehicle.yearTarget) * 100) : 0;
|
||||
const reason = `${vehicle.customer}日均里程 ${Math.round(vehicle.customerAvgDaily)} KM(高里程),该车本年完成率 ${yearRate}%,建议换上里程缺口大的车辆以加速达标。`;
|
||||
|
||||
suggestions.push({
|
||||
id: `qualified-${vehicle.plateNumber}`,
|
||||
|
||||
Reference in New Issue
Block a user