fleetmap-reports 1.0.972 → 1.0.974
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.js +0 -21
- package/src/partnerReports/dailyuse-report.js +1 -79
- package/src/speeding-report.js +1 -1
- package/src/tests/activity.test.js +2 -2
- package/src/tests/performance.test.js +6 -36
- package/src/util/trips.js +1 -1
- package/src/zone-report.js +7 -7
- package/RapportPerformance.xlsx +0 -0
- package/src/temperature-report.js +0 -11
- package/src/tests/dailyuse.test.js +0 -19
- package/src/tests/gpsjump.test.js +0 -23
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -19,7 +19,6 @@ function Reports (config, axios, cookieJar) {
|
|
|
19
19
|
drivers: await this.traccar.drivers.driversGet().then(d => d.data),
|
|
20
20
|
geofences: await this.traccar.geofences.geofencesGet().then(d => d.data),
|
|
21
21
|
byGroup: false,
|
|
22
|
-
allWeek: true,
|
|
23
22
|
dayHours: { startTime: '00:00', endTime: '23:59' }
|
|
24
23
|
}
|
|
25
24
|
}
|
|
@@ -184,25 +183,5 @@ function Reports (config, axios, cookieJar) {
|
|
|
184
183
|
this.stopReportToExcel = (userData, reportData) => {
|
|
185
184
|
return require('./stop-report').exportStopReportToExcel(userData, reportData)
|
|
186
185
|
}
|
|
187
|
-
|
|
188
|
-
this.performanceReport = (from, to, userData) => {
|
|
189
|
-
return require('./partnerReports/performance-report').createPerformanceReport(from, to, userData, this.traccar)
|
|
190
|
-
}
|
|
191
|
-
this.performanceReportToPDF = (userData, reportData) => {
|
|
192
|
-
return require('./partnerReports/performance-report').exportPerformanceReportToPDF(userData, reportData)
|
|
193
|
-
}
|
|
194
|
-
this.performanceReportToExcel = (userData, reportData) => {
|
|
195
|
-
return require('./partnerReports/performance-report').exportPerformanceReportToExcel(userData, reportData)
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
this.dailyUseReport = (from, to, userData) => {
|
|
199
|
-
return require('./partnerReports/dailyuse-report').createDailyUseReport(from, to, userData, this.traccar)
|
|
200
|
-
}
|
|
201
|
-
this.dailyUseReportToPDF = (userData, reportData) => {
|
|
202
|
-
return require('./partnerReports/dailyuse-report').exportDailyUseReportToPDF(userData, reportData)
|
|
203
|
-
}
|
|
204
|
-
this.dailyUseReportToExcel = (userData, reportData) => {
|
|
205
|
-
return require('./partnerReports/dailyuse-report').exportDailyUseReportToExcel(userData, reportData)
|
|
206
|
-
}
|
|
207
186
|
}
|
|
208
187
|
module.exports = Reports
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
const traccarHelper = require('../util/traccar')
|
|
2
2
|
const { isInsideTimetable } = require('../util/trips')
|
|
3
|
-
const { convertFromUTCDate
|
|
3
|
+
const { convertFromUTCDate } = require('../util/utils')
|
|
4
4
|
const automaticReports = require('../automaticReports')
|
|
5
|
-
const jsPDF = require('jspdf')
|
|
6
|
-
const { getStyle } = require('../reportStyle')
|
|
7
|
-
const { getUserPartner } = require('fleetmap-partners')
|
|
8
|
-
const { addTable, headerFromUser } = require('../util/pdfDocument')
|
|
9
5
|
|
|
10
6
|
async function createDailyUseReport (from, to, userData, traccar) {
|
|
11
7
|
const reportData = []
|
|
@@ -81,78 +77,4 @@ function processDeviceData (allInOne, d, userData) {
|
|
|
81
77
|
}
|
|
82
78
|
}
|
|
83
79
|
|
|
84
|
-
async function exportDailyUseReportToPDF (userData, reportData) {
|
|
85
|
-
const translations = getTranslations(userData)
|
|
86
|
-
|
|
87
|
-
const headers = [
|
|
88
|
-
translations.report.vehicle,
|
|
89
|
-
'Utilisation',
|
|
90
|
-
'Conduite',
|
|
91
|
-
'Ralenti',
|
|
92
|
-
'Totale (L)',
|
|
93
|
-
'Conduite (L)',
|
|
94
|
-
'Ralenti (L)',
|
|
95
|
-
'Conduite (Km)',
|
|
96
|
-
'Économique',
|
|
97
|
-
'Économique (L)',
|
|
98
|
-
'Économique (Km)',
|
|
99
|
-
'Cruise Control',
|
|
100
|
-
'Cruise Control (L)',
|
|
101
|
-
'Cruise Control (Km)',
|
|
102
|
-
'Tour moteur élevé',
|
|
103
|
-
'Accéleration brusque (Sum)',
|
|
104
|
-
'Freinage brusque (Sum)',
|
|
105
|
-
'Virages brusque'
|
|
106
|
-
]
|
|
107
|
-
|
|
108
|
-
const data = []
|
|
109
|
-
reportData.forEach(d => {
|
|
110
|
-
const row = [
|
|
111
|
-
d.device,
|
|
112
|
-
convertMS((d.drivingTime + d.idleTime) * 1000),
|
|
113
|
-
convertMS(d.drivingTime * 1000),
|
|
114
|
-
convertMS(d.idleTime * 1000),
|
|
115
|
-
d.drivingConsumption + d.idleConsumption,
|
|
116
|
-
d.drivingConsumption,
|
|
117
|
-
d.idleConsumption,
|
|
118
|
-
d.drivingDistance.toFixed(2),
|
|
119
|
-
convertMS(d.economicTime * 1000),
|
|
120
|
-
d.economicConsumption.toFixed(1),
|
|
121
|
-
d.economicDistance.toFixed(2),
|
|
122
|
-
convertMS(d.cruiseControlTime * 1000),
|
|
123
|
-
d.cruiseControlConsumption.toFixed(1),
|
|
124
|
-
d.cruiseControlDistance.toFixed(2),
|
|
125
|
-
convertMS(d.highEngineRPM * 1000),
|
|
126
|
-
d.hardAcceleration,
|
|
127
|
-
d.hardBraking,
|
|
128
|
-
d.hardCornering
|
|
129
|
-
]
|
|
130
|
-
data.push(row)
|
|
131
|
-
})
|
|
132
|
-
|
|
133
|
-
const doc = new jsPDF.jsPDF('l')
|
|
134
|
-
await headerFromUser(doc, 'Rapport de Performance', userData.user)
|
|
135
|
-
const style = getStyle(getUserPartner(userData.user))
|
|
136
|
-
|
|
137
|
-
const footValues = []
|
|
138
|
-
|
|
139
|
-
doc.setFontSize(11)
|
|
140
|
-
doc.text(new Date(userData.from).toLocaleString() + ' - ' + new Date(userData.to).toLocaleString(), 20, 33)
|
|
141
|
-
|
|
142
|
-
style.headerFontSize = 8
|
|
143
|
-
style.bodyFontSize = 7
|
|
144
|
-
const columnStyles = {}
|
|
145
|
-
for (let i = 1; i < 18; i++) {
|
|
146
|
-
columnStyles[i] = { halign: 'right' }
|
|
147
|
-
}
|
|
148
|
-
addTable(doc, headers, data, footValues, style, 40, columnStyles)
|
|
149
|
-
return doc
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
function exportDailyUseReportToExcel (userData, reportData) {
|
|
153
|
-
|
|
154
|
-
}
|
|
155
|
-
|
|
156
80
|
exports.createDailyUseReport = createDailyUseReport
|
|
157
|
-
exports.exportDailyUseReportToPDF = exportDailyUseReportToPDF
|
|
158
|
-
exports.exportDailyUseReportToExcel = exportDailyUseReportToExcel
|
package/src/speeding-report.js
CHANGED
|
@@ -674,7 +674,7 @@ function deviceName (device) {
|
|
|
674
674
|
}
|
|
675
675
|
|
|
676
676
|
function getAlertDate (row, user) {
|
|
677
|
-
return convertToLocaleString(row.position.fixTime, user.attributes.lang, user.attributes.timezone)
|
|
677
|
+
return convertToLocaleString(row.position.fixTime, user.attributes.lang, user.attributes.timezone, user)
|
|
678
678
|
}
|
|
679
679
|
|
|
680
680
|
function getMaxSpeed (data) {
|
|
@@ -35,8 +35,8 @@ describe('activity report', function () {
|
|
|
35
35
|
const report = await getReports()
|
|
36
36
|
const userData = await report.getUserData()
|
|
37
37
|
userData.groupByDay = true
|
|
38
|
-
const data = await report.activityReport(new Date(
|
|
39
|
-
new Date(
|
|
38
|
+
const data = await report.activityReport(new Date(2022, 0, 1, 0, 0, 0, 0),
|
|
39
|
+
new Date(2022, 0, 20, 23, 59, 59, 0),
|
|
40
40
|
userData)
|
|
41
41
|
assert.equal(data.length, 1)
|
|
42
42
|
const device = data[0].devices.find(d => d.device.id === 22326)
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
const { getReports } = require('./index')
|
|
2
|
-
const { createPerformanceReport
|
|
2
|
+
const { createPerformanceReport } = require('../partnerReports/performance-report')
|
|
3
3
|
const assert = require('assert')
|
|
4
4
|
const { convertMS } = require('../util/utils')
|
|
5
|
-
const xlsx = require('@jcardus/json-as-xlsx')
|
|
6
|
-
const {createActivityReport} = require("../activity-report");
|
|
7
|
-
const {createFuelConsumptionReport} = require("../fuelconsumption-report");
|
|
8
|
-
|
|
9
5
|
// eslint-disable-next-line no-undef
|
|
10
6
|
describe('performance', function () {
|
|
11
7
|
// eslint-disable-next-line no-undef
|
|
@@ -19,48 +15,22 @@ describe('performance', function () {
|
|
|
19
15
|
userData,
|
|
20
16
|
report.traccar)
|
|
21
17
|
console.log(data)
|
|
22
|
-
|
|
23
18
|
assert.equal(data[0].consumption, 19.799999999999997)
|
|
24
|
-
assert.equal(data[0].distance, 326.
|
|
25
|
-
assert.equal(convertMS(data[1].time * 1000, false), '08:
|
|
19
|
+
assert.equal(data[0].distance, 326.7657)
|
|
20
|
+
assert.equal(convertMS(data[1].time * 1000, false), '08:19')
|
|
26
21
|
}, 8000000)
|
|
27
22
|
|
|
28
23
|
// eslint-disable-next-line no-undef
|
|
29
24
|
it('performance report inofleet', async () => {
|
|
30
25
|
const report = await getReports()
|
|
31
26
|
const userData = await report.getUserData()
|
|
32
|
-
userData.devices = userData.devices.filter(d => d.id ===
|
|
27
|
+
userData.devices = userData.devices.filter(d => d.id === 69114)
|
|
33
28
|
const data = await createPerformanceReport(
|
|
34
|
-
new Date(Date.UTC(2023,
|
|
35
|
-
new Date(Date.UTC(2023,
|
|
29
|
+
new Date(Date.UTC(2023, 5, 11, 0, 0, 0, 0)),
|
|
30
|
+
new Date(Date.UTC(2023, 6, 11, 23, 59, 59, 0)),
|
|
36
31
|
userData,
|
|
37
32
|
report.traccar)
|
|
38
33
|
console.log(data)
|
|
39
|
-
|
|
40
|
-
const data2 = await createFuelConsumptionReport(
|
|
41
|
-
new Date(Date.UTC(2023, 11, 9, 14, 58, 0, 0)),
|
|
42
|
-
new Date(Date.UTC(2023, 11, 18, 9, 28, 0, 0)),
|
|
43
|
-
userData,
|
|
44
|
-
report.traccar)
|
|
45
|
-
console.log(data2)
|
|
46
|
-
|
|
47
34
|
assert.equal(data[0].consumption, 168.51989999999998)
|
|
48
35
|
}, 8000000)
|
|
49
|
-
|
|
50
|
-
it('performance report export excel', async () => {
|
|
51
|
-
const report = await getReports()
|
|
52
|
-
const userData = await report.getUserData()
|
|
53
|
-
const data = await createPerformanceReport(
|
|
54
|
-
new Date(Date.UTC(2023, 6, 1, 0, 0, 0, 0)),
|
|
55
|
-
new Date(Date.UTC(2023, 6, 17, 23, 59, 59, 0)),
|
|
56
|
-
userData,
|
|
57
|
-
report.traccar)
|
|
58
|
-
console.log(data)
|
|
59
|
-
const excel = exportPerformanceReportToExcel(userData, data)
|
|
60
|
-
xlsx([{
|
|
61
|
-
sheet: 'Sheet1',
|
|
62
|
-
columns: excel.headers,
|
|
63
|
-
content: excel.data
|
|
64
|
-
}], excel.settings)
|
|
65
|
-
}, 8000000)
|
|
66
36
|
})
|
package/src/util/trips.js
CHANGED
|
@@ -148,7 +148,7 @@ function isInsideTimetable (t, userData) {
|
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
function updateTrip (device, t, route) {
|
|
151
|
-
route = route.filter(p => p.attributes.ignition)
|
|
151
|
+
route = route.filter(p => p && p.attributes.ignition)
|
|
152
152
|
if (!route.length) { return }
|
|
153
153
|
const distance = calculateDistance(route, false) * 1000
|
|
154
154
|
t.distance = distance
|
package/src/zone-report.js
CHANGED
|
@@ -307,33 +307,33 @@ function calculateDistanceIn (zoneInOutDayData, deviceRoute, dayRoute, fromByDay
|
|
|
307
307
|
return distanceIn
|
|
308
308
|
}
|
|
309
309
|
|
|
310
|
-
function calculateDistanceOut (zoneInOutDayData, dayRoute,
|
|
310
|
+
function calculateDistanceOut (zoneInOutDayData, dayRoute, fromByDay, toByDay, field, device) {
|
|
311
311
|
if (zoneInOutDayData.length) {
|
|
312
|
-
const dataInsideDay = zoneInOutDayData.filter(z => z.outTime && new Date(z.outTime.fixTime) <
|
|
312
|
+
const dataInsideDay = zoneInOutDayData.filter(z => z.outTime && new Date(z.outTime.fixTime) < toByDay)
|
|
313
313
|
let distanceOut = dataInsideDay.reduce((a, b) => a + (b[field] || 0), 0)
|
|
314
314
|
|
|
315
|
-
if (zoneInOutDayData[0].inTime && new Date(zoneInOutDayData[0].inTime.fixTime) >
|
|
315
|
+
if (zoneInOutDayData[0].inTime && new Date(zoneInOutDayData[0].inTime.fixTime) > fromByDay && (field !== 'distanceOutAny' || zoneInOutDayData[0].anyLastExit)) {
|
|
316
316
|
// Add distanceOut before the first entry
|
|
317
317
|
const routeOut = dayRoute.filter(p =>
|
|
318
318
|
new Date(p.fixTime).getTime() < new Date(zoneInOutDayData[0].inTime.fixTime).getTime() &&
|
|
319
|
-
new Date(p.fixTime).getTime() >=
|
|
319
|
+
new Date(p.fixTime).getTime() >= fromByDay.getTime()
|
|
320
320
|
)
|
|
321
321
|
distanceOut = distanceOut + calculateDistance(routeOut, device.attributes['report.ignoreOdometer'])
|
|
322
322
|
}
|
|
323
323
|
|
|
324
|
-
if (zoneInOutDayData[zoneInOutDayData.length - 1].outTime && new Date(zoneInOutDayData[zoneInOutDayData.length - 1].outTime.fixTime) <
|
|
324
|
+
if (zoneInOutDayData[zoneInOutDayData.length - 1].outTime && new Date(zoneInOutDayData[zoneInOutDayData.length - 1].outTime.fixTime) < toByDay && (field !== 'distanceOutAny' || zoneInOutDayData[zoneInOutDayData.length - 1].anyNextIn)) {
|
|
325
325
|
// Add distanceOut after last exit
|
|
326
326
|
distanceOut = distanceOut - zoneInOutDayData[zoneInOutDayData.length - 1][field]
|
|
327
327
|
const routeOut = dayRoute.filter(p =>
|
|
328
328
|
new Date(p.fixTime) >= new Date(zoneInOutDayData[zoneInOutDayData.length - 1].outTime.fixTime).getTime() &&
|
|
329
|
-
new Date(p.fixTime) <
|
|
329
|
+
new Date(p.fixTime) < toByDay.getTime())
|
|
330
330
|
distanceOut = distanceOut + calculateDistance(routeOut, device.attributes['report.ignoreOdometer'])
|
|
331
331
|
}
|
|
332
332
|
|
|
333
333
|
return distanceOut
|
|
334
334
|
}
|
|
335
335
|
|
|
336
|
-
return calculateDistance(dayRoute.filter(p => new Date(p.fixTime) >=
|
|
336
|
+
return calculateDistance(dayRoute.filter(p => new Date(p.fixTime) >= fromByDay && new Date(p.fixTime) < toByDay), device.attributes['report.ignoreOdometer'])
|
|
337
337
|
}
|
|
338
338
|
|
|
339
339
|
function analyseAlerts (alerts, deviceRoute, userData, from, to, device) {
|
package/RapportPerformance.xlsx
DELETED
|
Binary file
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
const traccarHelper = require('./util/traccar')
|
|
2
|
-
const { devicesToProcess } = require('./util/device')
|
|
3
|
-
|
|
4
|
-
async function createTemperatureReport (from, to, userData, traccar) {
|
|
5
|
-
const devices = devicesToProcess(userData)
|
|
6
|
-
|
|
7
|
-
const allInOne = await traccarHelper.getAllInOne(traccar, from, to, devices, true, false, false, false)
|
|
8
|
-
const routeData = allInOne.route
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
const { getReports } = require('./index')
|
|
2
|
-
const assert = require('assert')
|
|
3
|
-
const { createDailyUseReport } = require('../partnerReports/dailyuse-report')
|
|
4
|
-
|
|
5
|
-
describe('dailyuse', function () {
|
|
6
|
-
// eslint-disable-next-line no-undef
|
|
7
|
-
it('dailyuse report', async () => {
|
|
8
|
-
const report = await getReports()
|
|
9
|
-
const userData = await report.getUserData()
|
|
10
|
-
|
|
11
|
-
const data = await createDailyUseReport(
|
|
12
|
-
new Date(Date.UTC(2023, 10, 1, 0, 0, 0, 0)),
|
|
13
|
-
new Date(Date.UTC(2023, 10, 6, 23, 59, 59, 0)),
|
|
14
|
-
userData,
|
|
15
|
-
report.traccar)
|
|
16
|
-
console.log(data)
|
|
17
|
-
assert.equal(data[0].consumption, 19.799999999999997)
|
|
18
|
-
}, 8000000)
|
|
19
|
-
})
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
const { getReports } = require('./index')
|
|
2
|
-
const assert = require('assert')
|
|
3
|
-
const { convertMS } = require('../util/utils')
|
|
4
|
-
const { createGPSJumpReport } = require('../partnerReports/gpsjump-report')
|
|
5
|
-
|
|
6
|
-
// eslint-disable-next-line no-undef
|
|
7
|
-
describe('gpsjump', function () {
|
|
8
|
-
// eslint-disable-next-line no-undef
|
|
9
|
-
it('gpsjump report', async () => {
|
|
10
|
-
const report = await getReports()
|
|
11
|
-
const userData = await report.getUserData()
|
|
12
|
-
userData.devices = userData.devices.filter(d => d.id === 22326)
|
|
13
|
-
const data = await createGPSJumpReport(
|
|
14
|
-
new Date(Date.UTC(2023, 6, 1, 0, 0, 0, 0)),
|
|
15
|
-
new Date(Date.UTC(2023, 6, 17, 23, 59, 59, 0)),
|
|
16
|
-
userData,
|
|
17
|
-
report.traccar)
|
|
18
|
-
console.log(data)
|
|
19
|
-
assert.equal(data[0].consumption, 19.799999999999997)
|
|
20
|
-
assert.equal(data[0].distance, 326.7657)
|
|
21
|
-
assert.equal(convertMS(data[1].time * 1000, false), '08:19')
|
|
22
|
-
}, 8000000)
|
|
23
|
-
})
|