fleetmap-reports 1.0.444 → 1.0.447
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/events-report.js +11 -8
package/package.json
CHANGED
package/src/events-report.js
CHANGED
|
@@ -56,14 +56,14 @@ async function getReportData (from, to, devices, types, traccar) {
|
|
|
56
56
|
const arrayOfArrays = automaticReports.sliceArray(devices)
|
|
57
57
|
const traccarTypes = new Set(types.map(t => t.startsWith('alarm') ? 'alarm' : t))
|
|
58
58
|
const traccarSubTypes = types.map(t => t.startsWith('alarm') ? t.replace('alarm_', '') : '').filter(Boolean)
|
|
59
|
-
|
|
59
|
+
await Promise.all(arrayOfArrays.map(async a => {
|
|
60
60
|
const response = await traccar.reports.reportsEventsGet(from, to, a.map(d => d.id), null, traccarTypes)
|
|
61
61
|
if (types.length > 0) {
|
|
62
62
|
data = data.concat(response.data.filter(e => e.type === 'alarm' ? traccarSubTypes.includes(e.attributes.alarm) : true))
|
|
63
63
|
} else {
|
|
64
64
|
data = data.concat(response.data)
|
|
65
65
|
}
|
|
66
|
-
}
|
|
66
|
+
}))
|
|
67
67
|
console.log('Alerts:' + data.length)
|
|
68
68
|
return data
|
|
69
69
|
}
|
|
@@ -71,9 +71,7 @@ async function getReportData (from, to, devices, types, traccar) {
|
|
|
71
71
|
async function processDevices (from, to, devices, geofences, drivers, data, traccar) {
|
|
72
72
|
const devicesResult = []
|
|
73
73
|
let i = 0
|
|
74
|
-
|
|
75
|
-
console.log('LOADING_MESSAGE:' + d.name)
|
|
76
|
-
console.log(`PROGRESS_PERC:${++i / devices.length * 100}`)
|
|
74
|
+
await Promise.all(devices.map(async d => {
|
|
77
75
|
const alerts = data.filter(t => t.deviceId === d.id)
|
|
78
76
|
|
|
79
77
|
if (alerts.length > 0) {
|
|
@@ -100,6 +98,9 @@ async function processDevices (from, to, devices, geofences, drivers, data, trac
|
|
|
100
98
|
}
|
|
101
99
|
}
|
|
102
100
|
|
|
101
|
+
console.log('LOADING_MESSAGE:' + d.name)
|
|
102
|
+
console.log(`PROGRESS_PERC:${++i / devices.length * 100}`)
|
|
103
|
+
|
|
103
104
|
devicesResult.push({
|
|
104
105
|
device: d,
|
|
105
106
|
from,
|
|
@@ -107,7 +108,7 @@ async function processDevices (from, to, devices, geofences, drivers, data, trac
|
|
|
107
108
|
alerts
|
|
108
109
|
})
|
|
109
110
|
}
|
|
110
|
-
}
|
|
111
|
+
}))
|
|
111
112
|
|
|
112
113
|
return devicesResult
|
|
113
114
|
}
|
|
@@ -218,6 +219,7 @@ function exportSpeedingReportToExcel (userData, reportData) {
|
|
|
218
219
|
{ label: translations.report.eventType, value: 'eventType' },
|
|
219
220
|
{ label: translations.report.date, value: 'fixTime' },
|
|
220
221
|
{ label: translations.report.address, value: 'address' },
|
|
222
|
+
{ label: translations.report.driver, value: 'driver' },
|
|
221
223
|
{ label: translations.report.info, value: 'info' }
|
|
222
224
|
]
|
|
223
225
|
let data = []
|
|
@@ -229,7 +231,8 @@ function exportSpeedingReportToExcel (userData, reportData) {
|
|
|
229
231
|
eventType: a.type === 'alarm' ? translations.report['event_' + a.attributes.alarm] : translations.report['event_' + a.type],
|
|
230
232
|
fixTime: getAlertDate(userData.user, a),
|
|
231
233
|
address: a.geofenceName || (a.position ? a.position.address : ''),
|
|
232
|
-
info: getAlertInfo(userData.drivers, a)
|
|
234
|
+
info: getAlertInfo(userData.drivers, a),
|
|
235
|
+
driver: a.driver
|
|
233
236
|
}
|
|
234
237
|
}))
|
|
235
238
|
})
|
|
@@ -261,7 +264,7 @@ function getAlertInfo (drivers, alert) {
|
|
|
261
264
|
const driver = drivers.find(d => d.uniqueId === alert.attributes.driverUniqueId)
|
|
262
265
|
return driver ? driver.name : alert.attributes.driverUniqueId
|
|
263
266
|
}
|
|
264
|
-
return
|
|
267
|
+
return ''
|
|
265
268
|
}
|
|
266
269
|
|
|
267
270
|
function getAlertDate (user, alert) {
|