fleetmap-reports 1.0.962 → 1.0.963
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 +11 -7
package/package.json
CHANGED
package/src/zone-report.js
CHANGED
|
@@ -110,6 +110,8 @@ async function processDevices (from, to, devices, userData, data) {
|
|
|
110
110
|
const startDate = isClientSide() ? startDateLocal : convertFromLocal(startDateLocal, userData.user.attributes.timezone)
|
|
111
111
|
const endDate = isClientSide() ? endDateLocal : convertFromLocal(endDateLocal, userData.user.attributes.timezone)
|
|
112
112
|
|
|
113
|
+
console.log(startDate, endDate)
|
|
114
|
+
|
|
113
115
|
const { routeByDay, zoneInOutDayData } = await getDataByDay(d, date, { route: deviceRoute, zoneInOutData: filteredByGeofence }, userData)
|
|
114
116
|
|
|
115
117
|
const firstIn = zoneInOutDayData.find(z => z.inTime && new Date(z.inTime.fixTime) > startDate)
|
|
@@ -145,6 +147,8 @@ async function processDevices (from, to, devices, userData, data) {
|
|
|
145
147
|
const startDate = isClientSide() ? startDateLocal : convertFromLocal(startDateLocal, userData.user.attributes.timezone)
|
|
146
148
|
const endDate = isClientSide() ? endDateLocal : convertFromLocal(endDateLocal, userData.user.attributes.timezone)
|
|
147
149
|
|
|
150
|
+
console.log(startDate, endDate)
|
|
151
|
+
|
|
148
152
|
const { routeByDay, zoneInOutDayData } = await getDataByDay(d, date, { route: deviceRoute, zoneInOutData }, userData)
|
|
149
153
|
|
|
150
154
|
const distanceOut = calculateDistanceOut(zoneInOutDayData, routeByDay, startDate, endDate, 'distanceOutAny', d)
|
|
@@ -307,33 +311,33 @@ function calculateDistanceIn (zoneInOutDayData, deviceRoute, dayRoute, fromByDay
|
|
|
307
311
|
return distanceIn
|
|
308
312
|
}
|
|
309
313
|
|
|
310
|
-
function calculateDistanceOut (zoneInOutDayData, dayRoute,
|
|
314
|
+
function calculateDistanceOut (zoneInOutDayData, dayRoute, from, to, field, device) {
|
|
311
315
|
if (zoneInOutDayData.length) {
|
|
312
|
-
const dataInsideDay = zoneInOutDayData.filter(z => z.outTime && new Date(z.outTime.fixTime) <
|
|
316
|
+
const dataInsideDay = zoneInOutDayData.filter(z => z.outTime && new Date(z.outTime.fixTime) < to)
|
|
313
317
|
let distanceOut = dataInsideDay.reduce((a, b) => a + (b[field] || 0), 0)
|
|
314
318
|
|
|
315
|
-
if (zoneInOutDayData[0].inTime && new Date(zoneInOutDayData[0].inTime.fixTime) >
|
|
319
|
+
if (zoneInOutDayData[0].inTime && new Date(zoneInOutDayData[0].inTime.fixTime) > from && (field !== 'distanceOutAny' || zoneInOutDayData[0].anyLastExit)) {
|
|
316
320
|
// Add distanceOut before the first entry
|
|
317
321
|
const routeOut = dayRoute.filter(p =>
|
|
318
322
|
new Date(p.fixTime).getTime() < new Date(zoneInOutDayData[0].inTime.fixTime).getTime() &&
|
|
319
|
-
new Date(p.fixTime).getTime() >=
|
|
323
|
+
new Date(p.fixTime).getTime() >= from.getTime()
|
|
320
324
|
)
|
|
321
325
|
distanceOut = distanceOut + calculateDistance(routeOut, device.attributes['report.ignoreOdometer'])
|
|
322
326
|
}
|
|
323
327
|
|
|
324
|
-
if (zoneInOutDayData[zoneInOutDayData.length - 1].outTime && new Date(zoneInOutDayData[zoneInOutDayData.length - 1].outTime.fixTime) <
|
|
328
|
+
if (zoneInOutDayData[zoneInOutDayData.length - 1].outTime && new Date(zoneInOutDayData[zoneInOutDayData.length - 1].outTime.fixTime) < to && (field !== 'distanceOutAny' || zoneInOutDayData[zoneInOutDayData.length - 1].anyNextIn)) {
|
|
325
329
|
// Add distanceOut after last exit
|
|
326
330
|
distanceOut = distanceOut - zoneInOutDayData[zoneInOutDayData.length - 1][field]
|
|
327
331
|
const routeOut = dayRoute.filter(p =>
|
|
328
332
|
new Date(p.fixTime) >= new Date(zoneInOutDayData[zoneInOutDayData.length - 1].outTime.fixTime).getTime() &&
|
|
329
|
-
new Date(p.fixTime) <
|
|
333
|
+
new Date(p.fixTime) < to.getTime())
|
|
330
334
|
distanceOut = distanceOut + calculateDistance(routeOut, device.attributes['report.ignoreOdometer'])
|
|
331
335
|
}
|
|
332
336
|
|
|
333
337
|
return distanceOut
|
|
334
338
|
}
|
|
335
339
|
|
|
336
|
-
return calculateDistance(dayRoute.filter(p => new Date(p.fixTime) >=
|
|
340
|
+
return calculateDistance(dayRoute.filter(p => new Date(p.fixTime) >= from && new Date(p.fixTime) < to), device.attributes['report.ignoreOdometer'])
|
|
337
341
|
}
|
|
338
342
|
|
|
339
343
|
function analyseAlerts (alerts, deviceRoute, userData, from, to, device) {
|