fleetmap-reports 1.0.626 → 1.0.627
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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const traccar = require('../util/traccar')
|
|
2
2
|
const { getIdleEvents } = require('../util/route')
|
|
3
|
-
const { insideGeofence } = require('../util/geofence')
|
|
3
|
+
const { insideGeofence, getNearestPOIs } = require('../util/geofence')
|
|
4
4
|
|
|
5
5
|
async function createActivityReport (from, to, userData, traccarInstance) {
|
|
6
6
|
const notAuthGroup = userData.groups.find(g => g.name === 'Zones Non Autorisées')
|
|
@@ -42,13 +42,19 @@ async function createActivityReport (from, to, userData, traccarInstance) {
|
|
|
42
42
|
|
|
43
43
|
const idleTimeArray = idleEvents.map(e => e.idleTime).filter(a => a > 0)
|
|
44
44
|
|
|
45
|
+
const startTrip = trips.length ? trips[0] : undefined
|
|
46
|
+
const endTrip = trips.length ? trips[trips.length - 1] : undefined
|
|
47
|
+
|
|
48
|
+
const startNearestPOIs = startTrip ? getNearestPOIs(startTrip.startLon, startTrip.startLat, userData.geofences) : []
|
|
49
|
+
const endNearestPOIs = endTrip ? getNearestPOIs(endTrip.endLon, endTrip.endLat, userData.geofences) : []
|
|
50
|
+
|
|
45
51
|
const deviceData = {
|
|
46
52
|
device: d.name,
|
|
47
53
|
group: group ? group.name : '',
|
|
48
|
-
startAddress:
|
|
49
|
-
startTime:
|
|
50
|
-
endAddress:
|
|
51
|
-
endTime:
|
|
54
|
+
startAddress: startNearestPOIs.length > 0 ? startNearestPOIs[0].p.name : (startTrip ? startTrip.startAddress : ''),
|
|
55
|
+
startTime: startTrip ? startTrip.startTime : '',
|
|
56
|
+
endAddress: endNearestPOIs.length > 0 ? endNearestPOIs[0].p.name : (endTrip ? endTrip.endAddress : ''),
|
|
57
|
+
endTime: endTrip ? endTrip.endTime : '',
|
|
52
58
|
drivingTime,
|
|
53
59
|
stopTime,
|
|
54
60
|
idleTime: idleEvents.reduce((a, b) => a + b.idleTime, 0),
|