fleetmap-reports 1.0.392 → 1.0.399
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 +10 -5
- package/src/activity-report.js +26 -8
- package/src/index.test.js +340 -328
- package/src/refueling-report.js +149 -147
- package/src/speeding-report.js +112 -111
- package/src/tests/index.js +14 -16
- package/src/util/utils.js +151 -153
- package/src/zone-report.js +6 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fleetmap-reports",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.399",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -10,11 +10,13 @@
|
|
|
10
10
|
"author": "",
|
|
11
11
|
"license": "ISC",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@turf/
|
|
13
|
+
"@turf/distance": "^6.5.0",
|
|
14
|
+
"@turf/helpers": "^6.5.0",
|
|
15
|
+
"@turf/point-on-feature": "^6.5.0",
|
|
16
|
+
"@turf/point-to-line-distance": "^6.5.0",
|
|
14
17
|
"axios": "^0.21.1",
|
|
15
18
|
"axios-cookiejar-support": "^1.0.1",
|
|
16
19
|
"docx": "^7.3.0",
|
|
17
|
-
"eslint": "^8.8.0",
|
|
18
20
|
"file-saver": "^2.0.5",
|
|
19
21
|
"fleetmap-partners": "^1.0.76",
|
|
20
22
|
"json-as-xlsx": "^1.2.1",
|
|
@@ -23,12 +25,15 @@
|
|
|
23
25
|
"moment": "^2.29.1",
|
|
24
26
|
"tough-cookie": "^4.0.0",
|
|
25
27
|
"traccar-api": "^1.0.5",
|
|
26
|
-
"turf": "^3.0.14",
|
|
27
|
-
"turf-point": "^2.0.1",
|
|
28
28
|
"wkt": "^0.1.1"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"axios-debug-log": "^0.8.4",
|
|
32
|
+
"eslint": "^8.15.0",
|
|
33
|
+
"eslint-config-standard": "^17.0.0",
|
|
34
|
+
"eslint-plugin-import": "^2.26.0",
|
|
35
|
+
"eslint-plugin-n": "^15.2.0",
|
|
36
|
+
"eslint-plugin-promise": "^6.0.0",
|
|
32
37
|
"jest": "^27.5.0",
|
|
33
38
|
"mocha": "^9.0.3",
|
|
34
39
|
"webpack": "^5.24.3",
|
package/src/activity-report.js
CHANGED
|
@@ -197,15 +197,33 @@ function processDevices(from, to, devices, data, userData) {
|
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
199
|
} else {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
summary.
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
200
|
+
if(!userData.allWeek && userData.weekDays && userData.dayHours) {
|
|
201
|
+
const trips = deviceTrips.filter(t => userData.allWeek || !userData.weekDays || isInsideTimetable(t, userData) || isPartialInsideTimetable(t, userData, deviceRoute))
|
|
202
|
+
const distance = trips.reduce((a, b) => a + b.distance, 0)
|
|
203
|
+
summary.push({
|
|
204
|
+
deviceId: d.id,
|
|
205
|
+
averageSpeed: distance > 0 ? ((trips.reduce((a, b) => a + (b.averageSpeed * b.distance), 0)) / distance) : 0,
|
|
206
|
+
distance: distance,
|
|
207
|
+
engineHours: trips.reduce((a, b) => a + b.duration, 0),
|
|
208
|
+
maxSpeed: trips.reduce((a, b) => {
|
|
209
|
+
return a > b.maxSpeed ? a : b.maxSpeed
|
|
210
|
+
}, 0),
|
|
211
|
+
startOdometer: trips.length ? trips[0].startOdometer : 0,
|
|
212
|
+
endOdometer: trips.length ? trips[trips.length - 1].endOdometer : 0,
|
|
213
|
+
startTime: trips.length && trips[0].startTime,
|
|
214
|
+
endTime: trips.length && trips[trips.length - 1].endTime
|
|
208
215
|
})
|
|
216
|
+
} else {
|
|
217
|
+
summary.push(...data.summaries.filter(s => s.deviceId === d.id))
|
|
218
|
+
|
|
219
|
+
if (summary.length) {
|
|
220
|
+
summary.forEach(s => {
|
|
221
|
+
s.distance = deviceTrips.reduce((a, b) => a + b.distance, 0)
|
|
222
|
+
s.convertedSpentFuel = automaticReports.calculateSpentFuel(s.spentFuel, d)
|
|
223
|
+
s.startTime = deviceTrips.length && deviceTrips[0].startTime
|
|
224
|
+
s.endTime = deviceTrips.length && deviceTrips[deviceTrips.length - 1].endTime
|
|
225
|
+
})
|
|
226
|
+
}
|
|
209
227
|
}
|
|
210
228
|
}
|
|
211
229
|
|