fleetmap-reports 1.0.463 → 1.0.464
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 +1 -1
- package/src/events-report.js +22 -23
package/package.json
CHANGED
package/src/events-report.js
CHANGED
|
@@ -75,35 +75,34 @@ async function processDevices (from, to, devices, data, traccar, userData) {
|
|
|
75
75
|
await Promise.all(devices.map(async d => {
|
|
76
76
|
const deviceAlerts = data.filter(t => t.deviceId === d.id)
|
|
77
77
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
if (
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
a.geofenceName = geofence.name
|
|
92
|
-
}
|
|
78
|
+
const response = await traccar.reports.reportsRouteGet(from, to, [d.id])
|
|
79
|
+
const positions = response.data
|
|
80
|
+
|
|
81
|
+
for (const a of deviceAlerts) {
|
|
82
|
+
a.position = positions.find(p => p.id === a.positionId)
|
|
83
|
+
|
|
84
|
+
if (a.geofenceId) {
|
|
85
|
+
const geofence = userData.geofences.find(g => g.id === a.geofenceId)
|
|
86
|
+
if (geofence) {
|
|
87
|
+
if (a.type === 'deviceOverspeed') {
|
|
88
|
+
a.geofenceName = geofence.name + ' (' + Math.round(a.attributes.speedLimit * 1.85200) + ' Km/h)'
|
|
89
|
+
} else {
|
|
90
|
+
a.geofenceName = geofence.name
|
|
93
91
|
}
|
|
94
92
|
}
|
|
95
|
-
|
|
96
|
-
if (a.position && a.position.attributes.driverUniqueId) {
|
|
97
|
-
const driver = userData.drivers.find(d => d.uniqueId === a.position.attributes.driverUniqueId)
|
|
98
|
-
a.driver = driver && driver.name
|
|
99
|
-
}
|
|
100
93
|
}
|
|
101
94
|
|
|
102
|
-
|
|
95
|
+
if (a.position && a.position.attributes.driverUniqueId) {
|
|
96
|
+
const driver = userData.drivers.find(d => d.uniqueId === a.position.attributes.driverUniqueId)
|
|
97
|
+
a.driver = driver && driver.name
|
|
98
|
+
}
|
|
99
|
+
}
|
|
103
100
|
|
|
104
|
-
|
|
105
|
-
|
|
101
|
+
const alerts = deviceAlerts.filter(a => userData.allWeek || !userData.weekDays || (!a.position || isInside(a.position.fixTime, a.position.fixTime, userData)))
|
|
102
|
+
console.log('LOADING_MESSAGE:' + d.name)
|
|
103
|
+
console.log(`PROGRESS_PERC:${++i / devices.length * 100}`)
|
|
106
104
|
|
|
105
|
+
if (alerts.length > 0) {
|
|
107
106
|
devicesResult.push({
|
|
108
107
|
device: d,
|
|
109
108
|
from,
|