fleetmap-reports 1.0.378 → 1.0.381
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/index.test.js +6 -6
- package/src/speeding-report.js +5 -2
- package/src/trip-report.js +22 -12
- package/src/util/traccar.js +0 -3
package/package.json
CHANGED
package/src/index.test.js
CHANGED
|
@@ -200,9 +200,9 @@ describe('Test_Reports', function() {
|
|
|
200
200
|
assert.equal(data.length, 1)
|
|
201
201
|
const device = data[0].devices.find(d => d.device.id===22326)
|
|
202
202
|
assert.equal(device.summary[0].startOdometer, 122502742.59)
|
|
203
|
-
assert.equal(device.summary[0].distance,
|
|
203
|
+
assert.equal(device.summary[0].distance, 1423529.600000009)
|
|
204
204
|
assert.equal(device.summary[0].startTime, '2022-01-01T13:35:47.000+0000')
|
|
205
|
-
assert.equal(device.summary[0].endTime, '2022-01-
|
|
205
|
+
assert.equal(device.summary[0].endTime, '2022-01-31T17:36:27.000+0000')
|
|
206
206
|
}, 40000)
|
|
207
207
|
it('Activity 2 by device', async () => {
|
|
208
208
|
const report = await getReports()
|
|
@@ -235,16 +235,16 @@ describe('Test_Reports', function() {
|
|
|
235
235
|
const reports = await getReports()
|
|
236
236
|
const userData = await reports.getUserData()
|
|
237
237
|
const r = await require('./util/traccar').getAllInOne(reports.traccar,
|
|
238
|
-
new Date(2022, 1, 1),
|
|
239
|
-
new Date(2022, 1, 4),
|
|
238
|
+
new Date(2022, 1, 1, 0, 0, 0, 0),
|
|
239
|
+
new Date(2022, 1, 4, 23, 59, 59, 0),
|
|
240
240
|
userData.devices,
|
|
241
241
|
false,
|
|
242
242
|
true,
|
|
243
243
|
true,
|
|
244
244
|
false)
|
|
245
245
|
|
|
246
|
-
assert.equal(r.trips.filter(t => t.deviceId === 22327).length,
|
|
247
|
-
assert.equal(r.stops.filter(t => t.deviceId === 22327).length,
|
|
246
|
+
assert.equal(r.trips.filter(t => t.deviceId === 22327).length, 20)
|
|
247
|
+
assert.equal(r.stops.filter(t => t.deviceId === 22327).length, 21)
|
|
248
248
|
}, 20000)
|
|
249
249
|
it('Total KMS', async () => {
|
|
250
250
|
const report = await getReports()
|
package/src/speeding-report.js
CHANGED
|
@@ -72,7 +72,8 @@ async function createSpeedingReportByDevice(from, to, userData, traccarInstance)
|
|
|
72
72
|
|
|
73
73
|
devices.sort((a, b) => (a.name > b.name) ? 1 : -1)
|
|
74
74
|
|
|
75
|
-
const
|
|
75
|
+
const allInOne = await traccarHelper.getAllInOne(traccarInstance, from, to, devices, true, false, false, false)
|
|
76
|
+
const routes = allInOne.route
|
|
76
77
|
const events = []
|
|
77
78
|
if(!userData.useVehicleSpeedLimit && userData.customSpeed){
|
|
78
79
|
events.push(...await getCustomSpeedLimitEvents(devices, routes, userData.customSpeed))
|
|
@@ -104,7 +105,9 @@ async function createSpeedingReportByDriver(from, to, userData, traccarInstance)
|
|
|
104
105
|
return { drivers: [] }
|
|
105
106
|
}
|
|
106
107
|
|
|
107
|
-
const
|
|
108
|
+
const allInOne = await traccarHelper.getAllInOne(traccarInstance, from, to, devices, true, false, false, false)
|
|
109
|
+
const routes = allInOne.route
|
|
110
|
+
|
|
108
111
|
const events = []
|
|
109
112
|
if(!userData.useVehicleSpeedLimit && userData.customSpeed){
|
|
110
113
|
events.push(...await getCustomSpeedLimitEvents(devices, routes, userData.customSpeed))
|
package/src/trip-report.js
CHANGED
|
@@ -45,16 +45,28 @@ async function createTripReportByDevice(from, to, userData, traccar) {
|
|
|
45
45
|
devices.sort((a, b) => (a.name > b.name) ? 1 : -1)
|
|
46
46
|
|
|
47
47
|
const devicesToSlice = devices.slice()
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
48
|
+
const sliced = automaticReports.sliceArray(devicesToSlice, 5)
|
|
49
|
+
|
|
50
|
+
console.log('LOADING_MESSAGE:' + devices.map(d => d.name).join(', '))
|
|
51
|
+
let deviceCount = 0
|
|
52
|
+
for(const slice of sliced) {
|
|
53
|
+
const allInOne = await traccarHelper.getAllInOne(traccar, from, to, slice, true, true, true, false)
|
|
54
|
+
const tripsData = allInOne.trips
|
|
55
|
+
const stopsData = allInOne.stops
|
|
56
|
+
const routeData = allInOne.route
|
|
57
|
+
|
|
58
|
+
console.log('Trips:' + tripsData.length)
|
|
59
|
+
|
|
60
|
+
if (tripsData.length > 0) {
|
|
61
|
+
trips.checkTripsKms(traccar, from, to, slice, {trips: tripsData, route: routeData})
|
|
62
|
+
allData.devices.push(...processDevices(from, to, slice, {
|
|
63
|
+
trips: tripsData,
|
|
64
|
+
stops: stopsData,
|
|
65
|
+
route: routeData
|
|
66
|
+
}, userData))
|
|
67
|
+
}
|
|
68
|
+
deviceCount = deviceCount + slice.length
|
|
69
|
+
console.log(`PROGRESS_PERC:${deviceCount / devices.length * 100}`)
|
|
58
70
|
}
|
|
59
71
|
|
|
60
72
|
return allData
|
|
@@ -133,8 +145,6 @@ function processDevices(from, to, devices, data, userData) {
|
|
|
133
145
|
const trips = deviceTrips.filter(t => userData.allWeek || !userData.weekDays || isInsideTimetable(t, userData) || isPartialInsideTimetable(t, userData, deviceRoute))
|
|
134
146
|
const stops = data.stops.filter(s => s.deviceId === d.id)
|
|
135
147
|
|
|
136
|
-
console.log('LOADING_MESSAGE:' + d.name)
|
|
137
|
-
|
|
138
148
|
addNearestPOIs(trips, userData)
|
|
139
149
|
|
|
140
150
|
trips.forEach(trip => {
|
package/src/util/traccar.js
CHANGED
|
@@ -71,10 +71,8 @@ async function getAllInOne(traccar, from, to, devices, getRoutes, getTrips, getS
|
|
|
71
71
|
if(getTrips) url += `&type=trips`
|
|
72
72
|
if(getStops) url += `&type=stops`
|
|
73
73
|
if(getSummary) url += `&type=summary`
|
|
74
|
-
console.log('LOADING_MESSAGE:' + devices.map(d => d.name).join(', '))
|
|
75
74
|
|
|
76
75
|
const sliced = automaticReports.sliceArray(devices, 5)
|
|
77
|
-
let deviceCount = 0
|
|
78
76
|
const result = []
|
|
79
77
|
for(const chunk of sliced) {
|
|
80
78
|
const requests = chunk.map(d =>
|
|
@@ -83,7 +81,6 @@ async function getAllInOne(traccar, from, to, devices, getRoutes, getTrips, getS
|
|
|
83
81
|
withCredentials: true
|
|
84
82
|
}).then(r => r.data).then(x => {
|
|
85
83
|
console.log('LOADING_MESSAGE:' + d.name)
|
|
86
|
-
console.log(`PROGRESS_PERC:${++deviceCount / devices.length * 100}`)
|
|
87
84
|
return x
|
|
88
85
|
}))
|
|
89
86
|
result.push(...(await Promise.all(requests)))
|