fix: 出勤率改为当天计算(当天出勤数/总运营数)
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
之前用近30天activeDays/totalDays计算,现改为: 当天里程>0的车辆数 / 部门总运营车辆数 × 100% Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -693,23 +693,20 @@ app.get('/dept-stats', async (c) => {
|
||||
mgrMap.get(mgr)!.push(v);
|
||||
}
|
||||
|
||||
// Compute attendance & mileage for a set of vehicles
|
||||
// Compute attendance (today) & avg mileage (30d) for a set of vehicles
|
||||
const getMileageStats = (vList: Vehicle[]) => {
|
||||
let totalActive = 0;
|
||||
let totalDays = 0;
|
||||
const todayActive = vList.filter((v) => (todayMileageMap.get(v.plateNumber) || 0) > 0).length;
|
||||
let totalMileage = 0;
|
||||
let count = 0;
|
||||
for (const v of vList) {
|
||||
const m = mileageMap.get(v.plateNumber);
|
||||
if (m) {
|
||||
totalActive += m.activeDays;
|
||||
totalDays += m.totalDays;
|
||||
totalMileage += m.avgMileage;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return {
|
||||
attendanceRate: totalDays > 0 ? Math.round((totalActive / totalDays) * 1000) / 10 : 0,
|
||||
attendanceRate: vList.length > 0 ? Math.round((todayActive / vList.length) * 1000) / 10 : 0,
|
||||
avgMileage: count > 0 ? Math.round(totalMileage / count) : 0,
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user