fleetmap-reports 1.0.289 → 1.0.293
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/.idea/aws.xml +17 -0
- package/.idea/codeStyles/Project.xml +7 -0
- package/{fleetmap-reports.iml → .idea/fleetmap-reports.iml} +2 -1
- package/.idea/jsLibraryMappings.xml +1 -1
- package/.idea/modules.xml +1 -1
- package/.idea/vcs.xml +1 -1
- package/package.json +1 -1
- package/src/speeding-report.js +12 -4
package/.idea/aws.xml
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="accountSettings">
|
|
4
|
+
<option name="activeProfile" value="profile:default" />
|
|
5
|
+
<option name="activeRegion" value="us-east-1" />
|
|
6
|
+
<option name="recentlyUsedProfiles">
|
|
7
|
+
<list>
|
|
8
|
+
<option value="profile:default" />
|
|
9
|
+
</list>
|
|
10
|
+
</option>
|
|
11
|
+
<option name="recentlyUsedRegions">
|
|
12
|
+
<list>
|
|
13
|
+
<option value="us-east-1" />
|
|
14
|
+
</list>
|
|
15
|
+
</option>
|
|
16
|
+
</component>
|
|
17
|
+
</project>
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<module type="
|
|
2
|
+
<module type="JAVA_MODULE" version="4">
|
|
3
3
|
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
|
4
4
|
<exclude-output />
|
|
5
5
|
<content url="file://$MODULE_DIR$" />
|
|
6
|
+
<orderEntry type="inheritedJdk" />
|
|
6
7
|
<orderEntry type="sourceFolder" forTests="false" />
|
|
7
8
|
</component>
|
|
8
9
|
</module>
|
package/.idea/modules.xml
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<project version="4">
|
|
3
3
|
<component name="ProjectModuleManager">
|
|
4
4
|
<modules>
|
|
5
|
-
<module fileurl="file://$PROJECT_DIR
|
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/fleetmap-reports.iml" filepath="$PROJECT_DIR$/.idea/fleetmap-reports.iml" />
|
|
6
6
|
</modules>
|
|
7
7
|
</component>
|
|
8
8
|
</project>
|
package/.idea/vcs.xml
CHANGED
package/package.json
CHANGED
package/src/speeding-report.js
CHANGED
|
@@ -19,7 +19,6 @@ const fileName = 'SpeedingReport'
|
|
|
19
19
|
const eventTypes = ['deviceOverspeed']
|
|
20
20
|
|
|
21
21
|
async function createSpeedingReport(from, to, reportUserData, traccar) {
|
|
22
|
-
console.log('Create SpeedingReport')
|
|
23
22
|
traccarInstance = traccar
|
|
24
23
|
userData = reportUserData
|
|
25
24
|
const reportData = []
|
|
@@ -34,7 +33,7 @@ async function createSpeedingReport(from, to, reportUserData, traccar) {
|
|
|
34
33
|
const allData = await createSpeedingReportByGroup(from, to)
|
|
35
34
|
reportData.push(...allData)
|
|
36
35
|
} else {
|
|
37
|
-
console.log("
|
|
36
|
+
console.log("createSpeedingReportByDevice")
|
|
38
37
|
const allData = await createSpeedingReportByDevice(from, to, userData.devices)
|
|
39
38
|
reportData.push(allData)
|
|
40
39
|
}
|
|
@@ -239,9 +238,14 @@ async function getHereEvents(devices, routes, threshold){
|
|
|
239
238
|
const events = []
|
|
240
239
|
for (const d of devices) {
|
|
241
240
|
const positions = routes.filter(p => p.deviceId === d.id)
|
|
241
|
+
if (!positions.length) {
|
|
242
|
+
console.log('no positions on device', d.name)
|
|
243
|
+
continue
|
|
244
|
+
}
|
|
245
|
+
let hereAlerts = null
|
|
242
246
|
try {
|
|
243
247
|
const results = await here.routeMatch(positions)
|
|
244
|
-
|
|
248
|
+
hereAlerts = results.filter(r => r.currentSpeedKmh > (parseInt(r.speedLimit) + threshold)).map(r => {
|
|
245
249
|
const position = positions.find(p => new Date(p.fixTime).getTime() === r.timestamp)
|
|
246
250
|
return {
|
|
247
251
|
...r,
|
|
@@ -252,6 +256,10 @@ async function getHereEvents(devices, routes, threshold){
|
|
|
252
256
|
attributes: {speedLimit: r.speedLimit, speed: r.currentSpeedKmh / 1.85200}
|
|
253
257
|
}
|
|
254
258
|
})
|
|
259
|
+
if (!hereAlerts.length) {
|
|
260
|
+
console.log('empty array after filter on device', d.name)
|
|
261
|
+
continue
|
|
262
|
+
}
|
|
255
263
|
const reduced = hereAlerts.reduce((acc, cur, idx, src) => {
|
|
256
264
|
if (idx === 1) {
|
|
257
265
|
return [cur]
|
|
@@ -263,7 +271,7 @@ async function getHereEvents(devices, routes, threshold){
|
|
|
263
271
|
})
|
|
264
272
|
events.push(...reduced)
|
|
265
273
|
} catch (e) {
|
|
266
|
-
console.error(e)
|
|
274
|
+
console.error(hereAlerts, e)
|
|
267
275
|
}
|
|
268
276
|
}
|
|
269
277
|
return events
|