fleetmap-reports 2.0.138 → 2.0.139
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -12,25 +12,37 @@ const { calculateConsumption } = require('../util/fuel')
|
|
|
12
12
|
const { getCanAvgConsumption } = require('../fuel-consumption-report')
|
|
13
13
|
|
|
14
14
|
const distanceTarget = 10000 // meters
|
|
15
|
-
const distanceCoefficient = 0.
|
|
15
|
+
const distanceCoefficient = 0.5
|
|
16
16
|
|
|
17
17
|
const consumptionTarget = 11.5 // minutes
|
|
18
|
-
const consumptionCoefficient = 0.
|
|
18
|
+
const consumptionCoefficient = 0.7
|
|
19
19
|
|
|
20
20
|
const rpmTarget = 60 // minutes
|
|
21
|
-
const rpmCoefficient = 0.
|
|
21
|
+
const rpmCoefficient = 0.8
|
|
22
22
|
|
|
23
23
|
const hardBrakingTarget = 1
|
|
24
|
-
const hardBrakingCoefficient = 0.
|
|
24
|
+
const hardBrakingCoefficient = 0.10
|
|
25
25
|
|
|
26
26
|
const hardAccelerationTarget = 1
|
|
27
|
-
const hardAccelerationCoefficient = 0.
|
|
27
|
+
const hardAccelerationCoefficient = 0.10
|
|
28
28
|
|
|
29
29
|
const hardCorneringTarget = 1
|
|
30
|
-
const hardCorneringCoefficient = 0.
|
|
30
|
+
const hardCorneringCoefficient = 0.10
|
|
31
31
|
|
|
32
32
|
const overspeedTarget = 2
|
|
33
|
-
const overspeedCoefficient = 0.
|
|
33
|
+
const overspeedCoefficient = 0.15
|
|
34
|
+
|
|
35
|
+
const geofenceTarget = 1
|
|
36
|
+
const geofenceCoefficient = 0.15
|
|
37
|
+
|
|
38
|
+
const continuesDrivingTarget = 1
|
|
39
|
+
const continuesDrivingCoefficient = 0.1
|
|
40
|
+
|
|
41
|
+
const reverseTarget = 1
|
|
42
|
+
const reverseCoefficient = 0.1
|
|
43
|
+
|
|
44
|
+
const otherTarget = 1
|
|
45
|
+
const otherCoefficient = 0.1
|
|
34
46
|
|
|
35
47
|
async function create (from, to, userData, traccar) {
|
|
36
48
|
const reportData = []
|
|
@@ -44,11 +56,17 @@ async function create (from, to, userData, traccar) {
|
|
|
44
56
|
const allInOne = await traccarHelper.getAllInOne(traccar, from, to, [device], true, true, false, false, deviceCount, devices.length)
|
|
45
57
|
const hereResults = await getRoadSpeedLimits([device], allInOne.route, 5)
|
|
46
58
|
|
|
59
|
+
// getEvents
|
|
60
|
+
const geofenceAlarm = 0
|
|
61
|
+
const continuesDrivingAlarm = 0
|
|
62
|
+
const reverseAlarm = 0
|
|
63
|
+
const otherAlarm = 0
|
|
64
|
+
|
|
47
65
|
for (const d of drivers) {
|
|
48
66
|
const { trips, route } = await getDriverData(d, allInOne, userData)
|
|
49
67
|
const positionIds = route.map(p => p.id)
|
|
50
68
|
const driverOverSpeedEvents = hereResults.filter(e => positionIds.includes(e.positionId))
|
|
51
|
-
const spentFuel = calculateConsumption(
|
|
69
|
+
const spentFuel = calculateConsumption(device, { trips, route })
|
|
52
70
|
|
|
53
71
|
let driverData = driversData.get(d.id)
|
|
54
72
|
if (!driverData) {
|
|
@@ -60,7 +78,11 @@ async function create (from, to, userData, traccar) {
|
|
|
60
78
|
hardAcceleration: 0,
|
|
61
79
|
hardCornering: 0,
|
|
62
80
|
overspeed: 0,
|
|
63
|
-
spentFuel: 0
|
|
81
|
+
spentFuel: 0,
|
|
82
|
+
geofenceAlarm: 0,
|
|
83
|
+
continuesDrivingAlarm: 0,
|
|
84
|
+
reverseAlarm: 0,
|
|
85
|
+
otherAlarm: 0
|
|
64
86
|
}
|
|
65
87
|
driversData.set(d.id, driverData)
|
|
66
88
|
}
|
|
@@ -93,6 +115,10 @@ async function create (from, to, userData, traccar) {
|
|
|
93
115
|
driverData.hardCornering = driverData.hardCornering + hardCornering
|
|
94
116
|
driverData.overspeed = driverData.overspeed + driverOverSpeedEvents.length
|
|
95
117
|
driverData.spentFuel = driverData.spentFuel + spentFuel
|
|
118
|
+
driverData.geofenceAlarm = driverData.geofenceAlarm + geofenceAlarm
|
|
119
|
+
driverData.continuesDrivingAlarm = driverData.continuesDrivingAlarm + continuesDrivingAlarm
|
|
120
|
+
driverData.reverseAlarm = driverData.reverseAlarm + reverseAlarm
|
|
121
|
+
driverData.otherAlarm = driverData.otherAlarm + otherAlarm
|
|
96
122
|
}
|
|
97
123
|
|
|
98
124
|
deviceCount++
|
|
@@ -107,14 +133,34 @@ async function create (from, to, userData, traccar) {
|
|
|
107
133
|
const hardCorneringScore = (d.hardCornering / hardCorneringTarget) * hardCorneringCoefficient
|
|
108
134
|
const overspeedScore = (d.overspeed / overspeedTarget) * overspeedCoefficient
|
|
109
135
|
const consumptionScore = (getCanAvgConsumption(d.distance, d.spentFuel).byKms / consumptionTarget) * consumptionCoefficient
|
|
136
|
+
const geofenceAlarmScore = (d.geofenceAlarm / geofenceTarget) * geofenceCoefficient
|
|
137
|
+
const continuesDrivingAlarmScore = (d.continuesDrivingAlarm / continuesDrivingTarget) * continuesDrivingCoefficient
|
|
138
|
+
const reverseAlarmScore = (d.reverseAlarm / reverseTarget) * reverseCoefficient
|
|
139
|
+
const otherAlarmScore = (d.otherAlarm / otherTarget) * otherCoefficient
|
|
110
140
|
|
|
111
141
|
d.avgConsumption = getCanAvgConsumption(d.distance, d.spentFuel).byKms
|
|
112
|
-
d.score = distanceScore + rpmScore + hardBrakingScore + hardAccelerationScore +
|
|
142
|
+
d.score = distanceScore + rpmScore + hardBrakingScore + hardAccelerationScore +
|
|
143
|
+
hardCorneringScore + consumptionScore + overspeedScore + geofenceAlarmScore +
|
|
144
|
+
continuesDrivingAlarmScore + reverseAlarmScore + otherAlarmScore
|
|
113
145
|
})
|
|
114
146
|
allDriversData.sort((a, b) => (a.score > b.score) ? 1 : -1)
|
|
115
147
|
|
|
116
148
|
reportData.push(...allDriversData)
|
|
117
149
|
|
|
150
|
+
reportData.targetValues = {
|
|
151
|
+
distanceTarget,
|
|
152
|
+
rpmTarget,
|
|
153
|
+
hardBrakingTarget,
|
|
154
|
+
hardAccelerationTarget,
|
|
155
|
+
hardCorneringTarget,
|
|
156
|
+
consumptionTarget,
|
|
157
|
+
overspeedTarget,
|
|
158
|
+
geofenceTarget,
|
|
159
|
+
continuesDrivingTarget,
|
|
160
|
+
reverseTarget,
|
|
161
|
+
otherCoefficient
|
|
162
|
+
}
|
|
163
|
+
|
|
118
164
|
return reportData
|
|
119
165
|
}
|
|
120
166
|
|