fleetmap-reports 1.0.494 → 1.0.496
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/here.js +0 -1
- package/src/speeding-report.js +11 -3
package/package.json
CHANGED
package/src/here.js
CHANGED
|
@@ -96,7 +96,6 @@ function fillGeocoding(rows) {
|
|
|
96
96
|
} */
|
|
97
97
|
|
|
98
98
|
exports.routeMatch = async (rows) => {
|
|
99
|
-
console.log('here sending', rows.length)
|
|
100
99
|
const csv = generateCSV(rows)
|
|
101
100
|
const response = await axios.post(calcRoute, csv, { headers: { 'Content-Type': 'application/binary' } })
|
|
102
101
|
const hereData = response.data
|
package/src/speeding-report.js
CHANGED
|
@@ -106,7 +106,7 @@ async function createSpeedingReportByDriver (from, to, userData, traccarInstance
|
|
|
106
106
|
const sliced = automaticReports.sliceArray(devices, 10)
|
|
107
107
|
let deviceCount = 0
|
|
108
108
|
for (const slice of sliced) {
|
|
109
|
-
const { routes, events } = await getEvents(traccarInstance, from, to,
|
|
109
|
+
const { routes, events } = await getEvents(traccarInstance, from, to, slice, userData, deviceCount, devices.length, slice.length)
|
|
110
110
|
if (processServerSide()) {
|
|
111
111
|
console.log('LOADING_MESSAGE:' + slice[0].name)
|
|
112
112
|
console.log(`PROGRESS_PERC:${deviceCount / devices.length * 100}`)
|
|
@@ -298,7 +298,7 @@ async function getCustomSpeedLimitEvents (devices, routes, customSpeed) {
|
|
|
298
298
|
|
|
299
299
|
async function getHereEvents (devices, routes, threshold) {
|
|
300
300
|
try {
|
|
301
|
-
console.log('
|
|
301
|
+
console.log('PROCESS_HERE_EVENTS', process.env.PROCESS_HERE_EVENTS)
|
|
302
302
|
console.log('here speed limit events', devices.length, 'devices')
|
|
303
303
|
const events = []
|
|
304
304
|
const promises = devices.map(d => new Promise((resolve) => {
|
|
@@ -307,12 +307,18 @@ async function getHereEvents (devices, routes, threshold) {
|
|
|
307
307
|
console.log('no positions on device', d.name)
|
|
308
308
|
resolve()
|
|
309
309
|
}
|
|
310
|
+
console.log(d.name, 'sending', positions.length, 'to here')
|
|
310
311
|
here.routeMatch(positions).then(results => {
|
|
311
312
|
console.log(d.name, 'got', results.length, 'from here')
|
|
313
|
+
const timestamps = []
|
|
314
|
+
for (const p of positions) {
|
|
315
|
+
timestamps[new Date(p.fixTime).getTime()] = p
|
|
316
|
+
}
|
|
312
317
|
const reduced = results.reduce((acc, cur, idx, src) => {
|
|
318
|
+
console.log('idx', idx)
|
|
313
319
|
cur.overSpeeding = cur.currentSpeedKmh > parseInt(cur.speedLimit) + (threshold || 0)
|
|
314
320
|
const last = acc.length && acc.slice(-1)[0]
|
|
315
|
-
cur.position =
|
|
321
|
+
cur.position = timestamps[cur.timestamp]
|
|
316
322
|
if (cur.overSpeeding && last && src[idx - 1].overSpeeding && last.speedLimit === cur.speedLimit) {
|
|
317
323
|
last.eventTime = cur.timestamp - last.timestamp
|
|
318
324
|
last.attributes.maxSpeed = Math.max(last.attributes.maxSpeed, cur.position.speed)
|
|
@@ -331,6 +337,8 @@ async function getHereEvents (devices, routes, threshold) {
|
|
|
331
337
|
if (!reduced.length) {
|
|
332
338
|
console.log('empty array after filter on device', d.name)
|
|
333
339
|
resolve()
|
|
340
|
+
} else {
|
|
341
|
+
console.log(d.name, 'reduced to', reduced.length)
|
|
334
342
|
}
|
|
335
343
|
events.push(...reduced)
|
|
336
344
|
resolve()
|