fleetmap-reports 1.0.981 → 1.0.982
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/zone-report.js +27 -10
package/package.json
CHANGED
package/src/zone-report.js
CHANGED
|
@@ -94,7 +94,7 @@ async function processDevices (from, to, devices, userData, data) {
|
|
|
94
94
|
for (const d of devices) {
|
|
95
95
|
const alerts = data.alerts.filter(t => t.deviceId === d.id)
|
|
96
96
|
const deviceRoute = data.route.filter(p => p.deviceId === d.id)
|
|
97
|
-
|
|
97
|
+
let zoneInOutData = analyseAlerts(alerts, deviceRoute, userData, from, to, d).filter(d => !userData.onlyWithStop || d.stopped)
|
|
98
98
|
|
|
99
99
|
if (userData.groupByDay || userData.zonesByColumn) {
|
|
100
100
|
const dates = getDates(from, to, userData.user.attributes.timezone)
|
|
@@ -191,18 +191,35 @@ async function processDevices (from, to, devices, userData, data) {
|
|
|
191
191
|
if (zoneInOutData.length > 0) {
|
|
192
192
|
if (userData.tripsBetweenZones) {
|
|
193
193
|
const tripsBetweenZones = []
|
|
194
|
-
zoneInOutData.
|
|
195
|
-
|
|
194
|
+
zoneInOutData = zoneInOutData.sort((a, b) => a.inTime && b.inTime && new Date(a.inTime.fixTime).getTime() - new Date(b.inTime.fixTime).getTime())
|
|
195
|
+
let outGeofence
|
|
196
|
+
let inGeofence
|
|
197
|
+
for (let i = 0; i < zoneInOutData.length - 1; i++) {
|
|
198
|
+
if (!outGeofence) {
|
|
199
|
+
outGeofence = zoneInOutData[i]
|
|
200
|
+
}
|
|
201
|
+
inGeofence = zoneInOutData[i + 1]
|
|
202
|
+
|
|
203
|
+
if (outGeofence.outTime &&
|
|
204
|
+
inGeofence.inTime &&
|
|
205
|
+
new Date(outGeofence.outTime.fixTime).getTime() < new Date(inGeofence.inTime.fixTime).getTime()) {
|
|
196
206
|
tripsBetweenZones.push({
|
|
197
|
-
outTime:
|
|
198
|
-
outGeofenceName:
|
|
199
|
-
inTime:
|
|
200
|
-
inGeofenceName:
|
|
201
|
-
distanceOut:
|
|
202
|
-
totalOutTime: new Date(
|
|
207
|
+
outTime: outGeofence.outTime,
|
|
208
|
+
outGeofenceName: outGeofence.geofenceName,
|
|
209
|
+
inTime: inGeofence.inTime,
|
|
210
|
+
inGeofenceName: inGeofence.geofenceName,
|
|
211
|
+
distanceOut: outGeofence.distanceOutAny,
|
|
212
|
+
totalOutTime: new Date(inGeofence.inTime.fixTime).getTime() - new Date(outGeofence.outTime.fixTime).getTime()
|
|
203
213
|
})
|
|
214
|
+
outGeofence = undefined
|
|
215
|
+
} else {
|
|
216
|
+
if (outGeofence.outTime &&
|
|
217
|
+
inGeofence.outTime &&
|
|
218
|
+
new Date(outGeofence.outTime.fixTime).getTime() <= new Date(inGeofence.outTime.fixTime).getTime()) {
|
|
219
|
+
outGeofence = undefined
|
|
220
|
+
}
|
|
204
221
|
}
|
|
205
|
-
}
|
|
222
|
+
}
|
|
206
223
|
if (tripsBetweenZones.length > 0) {
|
|
207
224
|
devicesResult.push({
|
|
208
225
|
device: d,
|