refactor(scheduling): improve reason text, fix classification, polish detail view
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
- Classification: qualified requires actual completionRate >= 100% (not just predicted) - Reason text: structured two-column layout (客户日均 | 考核周期剩余) - Conclusion line in red bold (预估无法达标,需替换 / 已达标,建议换上未达标车辆) - Remove verbose subtitle from candidate section - Remove redundant middle line (预估考核期里程 vs 考核里程) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -25,11 +25,15 @@ export function isTypeCompatible(sourceType: string, candidateType: string): boo
|
||||
|
||||
export function classifyVehicle(
|
||||
currentYearIsQualified: boolean,
|
||||
predictedYearEnd: number,
|
||||
currentYearMileage: number,
|
||||
yearTarget: number,
|
||||
predictedYearEnd: number,
|
||||
): VehicleClassification {
|
||||
if (currentYearIsQualified || predictedYearEnd / yearTarget >= 1.2) return 'qualified';
|
||||
if (predictedYearEnd / yearTarget < 0.6) return 'hopeless';
|
||||
// qualified: current year mileage already >= target (actually done, not just predicted)
|
||||
const actualRate = yearTarget > 0 ? currentYearMileage / yearTarget : 0;
|
||||
if (currentYearIsQualified || actualRate >= 1.0) return 'qualified';
|
||||
// hopeless: even with remaining days, predicted < 60% of target
|
||||
if (yearTarget > 0 && predictedYearEnd / yearTarget < 0.6) return 'hopeless';
|
||||
return 'normal';
|
||||
}
|
||||
|
||||
@@ -127,9 +131,10 @@ export function generateSuggestions(
|
||||
})
|
||||
.slice(0, 5);
|
||||
|
||||
const yearRate = vehicle.yearTarget > 0 ? Math.round((vehicle.currentYearMileage / vehicle.yearTarget) * 100) : 0;
|
||||
const gap = Math.max(0, vehicle.yearTarget - vehicle.currentYearMileage);
|
||||
const reason = `客户日均 ${Math.round(vehicle.customerAvgDaily)} km · 完成率 ${yearRate}% · 缺口 ${fmtKmSimple(gap)} km · 剩余 ${vehicle.daysLeft} 天(约 ${fmtKmSimple(Math.round(customerCanAdd))} km)`;
|
||||
const dailyReq = vehicle.daysLeft > 0 ? Math.round(gap / vehicle.daysLeft) : 0;
|
||||
const predictedTotal = Math.round(vehicle.currentYearMileage + customerCanAdd);
|
||||
const reason = `客户日均 ${Math.round(vehicle.customerAvgDaily)} km | 考核周期剩余 ${vehicle.daysLeft} 天 · 日均需 ${fmtKmSimple(dailyReq)} km\n!!预估无法达标,需替换`;
|
||||
|
||||
suggestions.push({
|
||||
id: `hopeless-${vehicle.plateNumber}`,
|
||||
@@ -194,7 +199,7 @@ export function generateSuggestions(
|
||||
|
||||
const yearRate = vehicle.yearTarget > 0 ? Math.round((vehicle.currentYearMileage / vehicle.yearTarget) * 100) : 0;
|
||||
const canAddKm = vehicle.customerAvgDaily * vehicle.daysLeft;
|
||||
const reason = `客户日均 ${Math.round(vehicle.customerAvgDaily)} km · 完成率 ${yearRate}% · 剩余 ${vehicle.daysLeft} 天(约 ${fmtKmSimple(Math.round(canAddKm))} km)`;
|
||||
const reason = `客户日均 ${Math.round(vehicle.customerAvgDaily)} km\n已完成考核(完成率 ${yearRate}%)\n考核周期剩余 ${vehicle.daysLeft} 天,可为新车贡献约 ${fmtKmSimple(Math.round(canAddKm))} km\n!!已达标,建议换上未达标车辆`;
|
||||
|
||||
suggestions.push({
|
||||
id: `qualified-${vehicle.plateNumber}`,
|
||||
|
||||
@@ -212,7 +212,7 @@ app.get('/', async (c) => {
|
||||
const predictedYearEnd = currentYearMileage + customerAvgDaily * daysLeft;
|
||||
|
||||
const currentYearIsQualified = row.current_year_is_qualified === 1;
|
||||
const classification = classifyVehicle(currentYearIsQualified, predictedYearEnd, yearTarget);
|
||||
const classification = classifyVehicle(currentYearIsQualified, currentYearMileage, yearTarget, predictedYearEnd);
|
||||
|
||||
enrichedVehicles.push({
|
||||
plateNumber: plate,
|
||||
|
||||
Reference in New Issue
Block a user