fleetmap-reports 1.0.537 → 1.0.539
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/one +0 -0
- package/package.json +1 -1
- package/src/zone-report.js +49 -5
package/one
ADDED
|
File without changes
|
package/package.json
CHANGED
package/src/zone-report.js
CHANGED
|
@@ -63,12 +63,9 @@ async function createZoneReport (from, to, userData, traccar) {
|
|
|
63
63
|
|
|
64
64
|
let deviceCount = 0
|
|
65
65
|
for (const slice of sliced) {
|
|
66
|
-
const
|
|
66
|
+
const data = await getAllInOne(
|
|
67
67
|
traccar, from, to, slice, true, false, false, false,
|
|
68
|
-
deviceCount, devices.length,
|
|
69
|
-
const routeData = allInOne.route
|
|
70
|
-
|
|
71
|
-
const data = getInAndOutEvents(slice, routeData, userData)
|
|
68
|
+
deviceCount, devices.length, 100, 5, undefined, userData)
|
|
72
69
|
|
|
73
70
|
console.log('Geofence Enter/Exit Alerts:' + data.length)
|
|
74
71
|
|
|
@@ -83,6 +80,53 @@ async function createZoneReport (from, to, userData, traccar) {
|
|
|
83
80
|
return reportData
|
|
84
81
|
}
|
|
85
82
|
|
|
83
|
+
async function getAllInOne (
|
|
84
|
+
traccar,
|
|
85
|
+
from,
|
|
86
|
+
to,
|
|
87
|
+
devices,
|
|
88
|
+
getRoutes,
|
|
89
|
+
getTrips,
|
|
90
|
+
getStops,
|
|
91
|
+
getSummary,
|
|
92
|
+
currentDeviceCount = 0,
|
|
93
|
+
totalDevices = devices.length,
|
|
94
|
+
sliceSize = 5,
|
|
95
|
+
devicesPerRequest = 1,
|
|
96
|
+
counter = undefined,
|
|
97
|
+
userData) {
|
|
98
|
+
let url = `/reports/allinone?from=${from.toISOString()}&to=${to.toISOString()}`
|
|
99
|
+
if (getRoutes) url += '&type=route'
|
|
100
|
+
if (getTrips) url += '&type=trips'
|
|
101
|
+
if (getStops) url += '&type=stops'
|
|
102
|
+
if (getSummary) url += '&type=summary'
|
|
103
|
+
|
|
104
|
+
const sliced = automaticReports.sliceArray(devices, sliceSize)
|
|
105
|
+
const result = []
|
|
106
|
+
for (const chunk of sliced) {
|
|
107
|
+
const requests = []
|
|
108
|
+
for (const _chunk of automaticReports.sliceArray(chunk, devicesPerRequest)) {
|
|
109
|
+
const u = url + '&' + _chunk.map(d => `deviceId=${d.id}`).join('&')
|
|
110
|
+
requests.push(
|
|
111
|
+
traccar.axios.get(u, {
|
|
112
|
+
jar: traccar.cookieJar,
|
|
113
|
+
withCredentials: true
|
|
114
|
+
}).then(r => r.data).then(x => {
|
|
115
|
+
if (counter) {
|
|
116
|
+
counter.count += devicesPerRequest
|
|
117
|
+
console.log(`PROGRESS_PERC:${counter.count / totalDevices * 100}`)
|
|
118
|
+
} else {
|
|
119
|
+
currentDeviceCount += devicesPerRequest
|
|
120
|
+
console.log(`PROGRESS_PERC:${currentDeviceCount / totalDevices * 100}`)
|
|
121
|
+
}
|
|
122
|
+
return getInAndOutEvents(devices, x.route, userData)
|
|
123
|
+
}))
|
|
124
|
+
}
|
|
125
|
+
result.push(...(await Promise.all(requests)))
|
|
126
|
+
}
|
|
127
|
+
return result
|
|
128
|
+
}
|
|
129
|
+
|
|
86
130
|
async function processDevices (from, to, devices, drivers, geofences, data) {
|
|
87
131
|
const devicesResult = []
|
|
88
132
|
|