fleetmap-reports 1.0.352 → 1.0.355
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/activity-report.js +13 -2
- package/src/automaticReports.js +1 -1
- package/src/events-report.js +1 -1
- package/src/idle-report.js +1 -0
- package/src/index.test.js +14 -2
- package/src/zone-report.js +1 -0
package/package.json
CHANGED
package/src/activity-report.js
CHANGED
|
@@ -85,7 +85,7 @@ async function createActivityReportByDevice(from, to, userData, traccarInstance)
|
|
|
85
85
|
devicesToProcess.sort((a, b) => (a.name > b.name) ? 1 : -1)
|
|
86
86
|
|
|
87
87
|
let summaries = []
|
|
88
|
-
const {trips, route, summary} = await traccar.getAllInOne(traccarInstance, from, to, devicesToProcess,
|
|
88
|
+
const {trips, route, summary} = await traccar.getAllInOne(traccarInstance, from, to, devicesToProcess, true, true, false, !userData.groupByDay)
|
|
89
89
|
|
|
90
90
|
if(userData.groupByDay) {
|
|
91
91
|
console.log('trips:' + trips.length)
|
|
@@ -142,6 +142,15 @@ async function createActivityReportByDriver(from, to, userData, traccarInstance)
|
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
|
|
145
|
+
function getActivityEnd(deviceTrips, deviceRoute) {
|
|
146
|
+
const route = deviceRoute.filter(p => p.attributes.ignition)
|
|
147
|
+
const tripEndDate = deviceTrips.length && deviceTrips[deviceTrips.length-1].endTime
|
|
148
|
+
if(route.length && new Date(route[route.length-1].fixTime).getTime() > new Date(tripEndDate).getTime()) {
|
|
149
|
+
return route[route.length-1].fixTime
|
|
150
|
+
}
|
|
151
|
+
return tripEndDate
|
|
152
|
+
}
|
|
153
|
+
|
|
145
154
|
function processDevices(from, to, devices, data, userData) {
|
|
146
155
|
const devicesResult = []
|
|
147
156
|
|
|
@@ -195,10 +204,12 @@ function processDevices(from, to, devices, data, userData) {
|
|
|
195
204
|
if (summary.length) {
|
|
196
205
|
summary.forEach(s => {
|
|
197
206
|
const deviceTrips = data.trips.filter(t => t.deviceId === d.id)
|
|
207
|
+
const deviceRoute = data.route.filter(t => t.deviceId === d.id)
|
|
208
|
+
|
|
198
209
|
s.distance = deviceTrips.reduce((a, b) => a + b.distance, 0)
|
|
199
210
|
s.convertedSpentFuel = automaticReports.calculateSpentFuel(s.spentFuel, d)
|
|
200
211
|
s.startTime = deviceTrips.length && deviceTrips[0].startTime
|
|
201
|
-
s.endTime = deviceTrips
|
|
212
|
+
s.endTime = getActivityEnd(deviceTrips, deviceRoute)
|
|
202
213
|
})
|
|
203
214
|
}
|
|
204
215
|
}
|
package/src/automaticReports.js
CHANGED
|
@@ -3,7 +3,7 @@ const moment = require('moment')
|
|
|
3
3
|
function sliceArray(longArray) {
|
|
4
4
|
const arrayToSlice = longArray.slice()
|
|
5
5
|
|
|
6
|
-
const size =
|
|
6
|
+
const size = 5
|
|
7
7
|
const arrayOfArrays = []
|
|
8
8
|
for (let i=0; i<arrayToSlice.length; i+=size) {
|
|
9
9
|
arrayOfArrays.push(arrayToSlice.slice(i,i+size));
|
package/src/events-report.js
CHANGED
|
@@ -115,7 +115,7 @@ async function processDevices(from, to, devices, geofences, drivers, data, tracc
|
|
|
115
115
|
|
|
116
116
|
async function exportSpeedingReportToPDF(userData, reportData) {
|
|
117
117
|
console.log('Export to PDF')
|
|
118
|
-
|
|
118
|
+
const lang = userData.user.attributes.lang || (navigator && navigator.language)
|
|
119
119
|
const translations = getTranslations(userData)
|
|
120
120
|
const timezone = userData.user.attributes.timezone
|
|
121
121
|
|
package/src/idle-report.js
CHANGED
|
@@ -124,6 +124,7 @@ async function exportIdleReportToPDF(userData, reportData) {
|
|
|
124
124
|
console.log('Export to PDF')
|
|
125
125
|
|
|
126
126
|
const timezone = userData.user.attributes.timezone
|
|
127
|
+
const lang = userData.user.attributes.lang || (navigator && navigator.language)
|
|
127
128
|
const translations = getTranslations(userData)
|
|
128
129
|
|
|
129
130
|
const idleData = userData.byDriver ? reportData.drivers : reportData.devices
|
package/src/index.test.js
CHANGED
|
@@ -165,8 +165,20 @@ describe('Test_Reports', function() {
|
|
|
165
165
|
assert.equal(device.summary[0].startOdometer, 122502742.59)
|
|
166
166
|
assert.equal(device.summary[0].distance, 1386519.1300000101)
|
|
167
167
|
assert.equal(device.summary[0].startTime, '2022-01-01T13:35:47.000+0000')
|
|
168
|
-
assert.equal(device.summary[0].endTime, '2022-01-
|
|
169
|
-
},
|
|
168
|
+
assert.equal(device.summary[0].endTime, '2022-01-30T14:08:13.000+0000')
|
|
169
|
+
}, 40000)
|
|
170
|
+
it('Activity 2 by device', async () => {
|
|
171
|
+
const report = await getReports()
|
|
172
|
+
const userData = await report.getUserData()
|
|
173
|
+
userData.devices = userData.devices.filter(d => d.id === 11437)
|
|
174
|
+
const data = await report.activityReport(new Date(2022, 2, 5, 0, 0, 0, 0),
|
|
175
|
+
new Date(2022, 2, 5, 23, 59, 59, 0),
|
|
176
|
+
userData)
|
|
177
|
+
assert.equal(data.length, 1)
|
|
178
|
+
const device = data[0].devices.find(d => d.device.id===11437)
|
|
179
|
+
assert.equal(device.summary[0].endTime, '2022-03-05T23:59:55.000+0000')
|
|
180
|
+
|
|
181
|
+
}, 40000)
|
|
170
182
|
it('Activity byDevice groupByDay', async () => {
|
|
171
183
|
const report = await getReports()
|
|
172
184
|
const userData = await report.getUserData()
|
package/src/zone-report.js
CHANGED
|
@@ -150,6 +150,7 @@ async function exportZoneReportToPDF(userData, reportData) {
|
|
|
150
150
|
|
|
151
151
|
const timezone = userData.user.attributes.timezone
|
|
152
152
|
const translations = getTranslations(userData)
|
|
153
|
+
const lang = userData.user.attributes.lang || (navigator && navigator.language)
|
|
153
154
|
|
|
154
155
|
const headers = [
|
|
155
156
|
translations.report.enter,
|