fleetmap-reports 1.0.486 → 1.0.487
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/speeding-report.js +25 -19
package/package.json
CHANGED
package/src/speeding-report.js
CHANGED
|
@@ -111,30 +111,35 @@ async function createSpeedingReportByDriver (from, to, userData, traccarInstance
|
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
async function getEvents (traccarInstance, from, to, devices, userData, deviceCount, totalDevices, sliceSize) {
|
|
114
|
-
|
|
114
|
+
if (process.env.PROCESS_HERE_EVENTS && process.env.PROCESS_HERE_EVENTS === 'server') {
|
|
115
|
+
const url = `${process.env.REPORTS_SERVER}/reports/speeding-report/getEvents`
|
|
116
|
+
return axios.post(url, { from, to, devices, userData, deviceCount, totalDevices, sliceSize }).then(d => d.data)
|
|
117
|
+
} else {
|
|
118
|
+
const geofencesFeatures = userData.geofences.filter(g => g.area.startsWith('POLYGON') &&
|
|
115
119
|
g.attributes.speedLimit).map(g => convertToFeature(g))
|
|
116
120
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
} else {
|
|
129
|
-
const traccarEvents = await traccarHelper.getEvents(traccarInstance, from, to, devices, eventTypes)
|
|
130
|
-
if (geofencesFeatures.length) {
|
|
131
|
-
events.push(...getGeofenceSpeedLimitEvents(geofencesFeatures, routes, devices))
|
|
132
|
-
events.push(...traccarEvents.filter(e => !(e.geofenceId)))
|
|
121
|
+
const allInOne = await traccarHelper.getAllInOne(traccarInstance, from, to, devices, true, false,
|
|
122
|
+
false, false, deviceCount, totalDevices, sliceSize)
|
|
123
|
+
const routes = allInOne.route
|
|
124
|
+
|
|
125
|
+
const events = []
|
|
126
|
+
if (userData.roadSpeedLimits) {
|
|
127
|
+
const hereResults = await getHereEvents(devices, routes, userData.maxSpeedThreshold)
|
|
128
|
+
console.log('got', hereResults.length, 'from here')
|
|
129
|
+
events.push(...hereResults)
|
|
130
|
+
} else if (!userData.useVehicleSpeedLimit && userData.customSpeed) {
|
|
131
|
+
events.push(...await getCustomSpeedLimitEvents(devices, routes, userData.customSpeed))
|
|
133
132
|
} else {
|
|
134
|
-
|
|
133
|
+
const traccarEvents = await traccarHelper.getEvents(traccarInstance, from, to, devices, eventTypes)
|
|
134
|
+
if (geofencesFeatures.length) {
|
|
135
|
+
events.push(...getGeofenceSpeedLimitEvents(geofencesFeatures, routes, devices))
|
|
136
|
+
events.push(...traccarEvents.filter(e => !(e.geofenceId)))
|
|
137
|
+
} else {
|
|
138
|
+
events.push(...traccarEvents)
|
|
139
|
+
}
|
|
135
140
|
}
|
|
141
|
+
return { routes, events }
|
|
136
142
|
}
|
|
137
|
-
return { routes, events }
|
|
138
143
|
}
|
|
139
144
|
|
|
140
145
|
function getGeofenceSpeedLimitEvents (geofencesFeatures, routes, devices) {
|
|
@@ -557,3 +562,4 @@ function getMaxSpeed (data) {
|
|
|
557
562
|
exports.createSpeedingReport = createSpeedingReport
|
|
558
563
|
exports.exportSpeedingReportToPDF = exportSpeedingReportToPDF
|
|
559
564
|
exports.exportSpeedingReportToExcel = exportSpeedingReportToExcel
|
|
565
|
+
exports.getEvents = getEvents
|