fleetmap-reports 1.0.874 → 1.0.876
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/lang/enGB.js +4 -1
- package/lang/esCL.js +4 -1
- package/lang/ptBR.js +4 -1
- package/lang/ptPT.js +4 -1
- package/package.json +1 -1
- package/src/partnerReports/afriquia.js +0 -5
- package/src/speeding-report.js +1 -1
- package/src/tests/activity.test.js +10 -0
- package/src/tests/index.test.js +11 -3
- package/src/tests/zones.test.js +12 -0
- package/src/trip-report.js +69 -9
- package/src/util/pdfDocument.js +3 -3
package/lang/enGB.js
CHANGED
|
@@ -274,7 +274,10 @@ module.exports = {
|
|
|
274
274
|
firstIn: 'First In',
|
|
275
275
|
lastOut: 'Last Out',
|
|
276
276
|
timeIn: 'Time In',
|
|
277
|
-
timeOut: 'Time Out'
|
|
277
|
+
timeOut: 'Time Out',
|
|
278
|
+
maxTemp: 'Max Temp',
|
|
279
|
+
minTemp: 'Min Temp',
|
|
280
|
+
avgTemp: 'Avg Temp'
|
|
278
281
|
},
|
|
279
282
|
layout: {
|
|
280
283
|
deviceOnline: 'Device Online',
|
package/lang/esCL.js
CHANGED
|
@@ -263,7 +263,10 @@ module.exports = {
|
|
|
263
263
|
firstIn: 'Primeira Entrada',
|
|
264
264
|
lastOut: 'Última Saída',
|
|
265
265
|
timeIn: 'Tempo Adentro',
|
|
266
|
-
timeOut: 'Tempo Afuera'
|
|
266
|
+
timeOut: 'Tempo Afuera',
|
|
267
|
+
maxTemp: 'Temp.Max',
|
|
268
|
+
minTemp: 'Temp.Min',
|
|
269
|
+
avgTemp: 'Temp.Média'
|
|
267
270
|
},
|
|
268
271
|
layout: {
|
|
269
272
|
deviceOnline: 'Dispositivo en línea',
|
package/lang/ptBR.js
CHANGED
|
@@ -268,7 +268,10 @@ module.exports = {
|
|
|
268
268
|
firstIn: 'Primeira Entrada',
|
|
269
269
|
lastOut: 'Última Saída',
|
|
270
270
|
timeIn: 'Tempo Dentro',
|
|
271
|
-
timeOut: 'Tempo Fora'
|
|
271
|
+
timeOut: 'Tempo Fora',
|
|
272
|
+
maxTemp: 'Temp.Máx',
|
|
273
|
+
minTemp: 'Temp.Min',
|
|
274
|
+
avgTemp: 'Temp.Média'
|
|
272
275
|
},
|
|
273
276
|
layout: {
|
|
274
277
|
deviceOnline: 'Dispositivo Online',
|
package/lang/ptPT.js
CHANGED
|
@@ -277,7 +277,10 @@ module.exports = {
|
|
|
277
277
|
firstIn: 'Primeira Entrada',
|
|
278
278
|
lastOut: 'Última Saída',
|
|
279
279
|
timeIn: 'Tempo Dentro',
|
|
280
|
-
timeOut: 'Tempo Fora'
|
|
280
|
+
timeOut: 'Tempo Fora',
|
|
281
|
+
maxTemp: 'Temp.Máx',
|
|
282
|
+
minTemp: 'Temp.Min',
|
|
283
|
+
avgTemp: 'Temp.Média'
|
|
281
284
|
},
|
|
282
285
|
layout: {
|
|
283
286
|
test: 'Test Notification',
|
package/package.json
CHANGED
|
@@ -6,11 +6,6 @@ const { convertToFeature, convertPositionToFeature } = require('../util/utils')
|
|
|
6
6
|
function calculateLastStopTime (stopTime, to, time) {
|
|
7
7
|
return stopTime + (to.getTime() - new Date(time).getTime())
|
|
8
8
|
}
|
|
9
|
-
|
|
10
|
-
function calculateFirstStopTime (stopTime, from, time) {
|
|
11
|
-
return stopTime + (new Date(time).getTime() - from.getTime())
|
|
12
|
-
}
|
|
13
|
-
|
|
14
9
|
async function createActivityReport (from, to, userData, traccarInstance) {
|
|
15
10
|
const unauthorizedGeofences = []
|
|
16
11
|
const authorizedGeofences = []
|
package/src/speeding-report.js
CHANGED
|
@@ -305,7 +305,7 @@ function getCountry (position) {
|
|
|
305
305
|
}
|
|
306
306
|
|
|
307
307
|
async function getRoadSpeedLimits (devices, routes, threshold, minimumMinutes = 0) {
|
|
308
|
-
const position = routes
|
|
308
|
+
const position = routes.find(p => getCountry(p))
|
|
309
309
|
const country = getCountry(position)
|
|
310
310
|
const config = {
|
|
311
311
|
CHL: getOSMSpeedingEvents,
|
|
@@ -72,4 +72,14 @@ describe('activity report', function () {
|
|
|
72
72
|
console.log(device)
|
|
73
73
|
assert.equal(device.summary.reduce((a, b) => a + b.convertedSpentFuel, 0), 168.79999999999995)
|
|
74
74
|
}, 800000)
|
|
75
|
+
it('Activity test performance', async () => {
|
|
76
|
+
const report = await getReports('q.trans', 'quality1214')
|
|
77
|
+
const userData = await report.getUserData()
|
|
78
|
+
console.log(userData)
|
|
79
|
+
userData.groupByDay = true
|
|
80
|
+
const data = await report.activityReport(new Date(2023, 7, 1, 0, 0, 0, 0),
|
|
81
|
+
new Date(2023, 31, 5, 23, 59, 59, 0),
|
|
82
|
+
userData)
|
|
83
|
+
assert.equal(data.length, 1)
|
|
84
|
+
}, 8000000)
|
|
75
85
|
})
|
package/src/tests/index.test.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
const { getReports } = require('./index')
|
|
3
3
|
const assert = require('assert')
|
|
4
4
|
const utils = require('../util/utils')
|
|
5
|
+
const { createGPSJumpReport } = require('../partnerReports/gpsjump-report')
|
|
5
6
|
|
|
6
7
|
// eslint-disable-next-line no-undef
|
|
7
8
|
describe('Test_Reports', function () {
|
|
@@ -18,12 +19,19 @@ describe('Test_Reports', function () {
|
|
|
18
19
|
const pdf = await report.speedingReportToPDF(userData, data[0])
|
|
19
20
|
pdf.save()
|
|
20
21
|
}, 40000)
|
|
21
|
-
|
|
22
22
|
it('converts madrid time', async () => {
|
|
23
23
|
assert.equal(false, utils.isClientSide())
|
|
24
24
|
console.log(utils.convertToLocaleString(new Date(), 'es-CL', 'Europe/Madrid'))
|
|
25
25
|
})
|
|
26
|
-
|
|
26
|
+
it('gps jump device', async () => {
|
|
27
|
+
const report = await getReports('HASSANE', 'movitec.1637')
|
|
28
|
+
const userData = await report.getUserData()
|
|
29
|
+
userData.devices = userData.devices.filter(d => d.id === 148725)
|
|
30
|
+
const data = await createGPSJumpReport(new Date(2023, 8, 22, 0, 0, 0, 0),
|
|
31
|
+
new Date(2023, 8, 24, 23, 59, 59, 0),
|
|
32
|
+
userData, report.traccar)
|
|
33
|
+
console.log(data)
|
|
34
|
+
}, 40000)
|
|
27
35
|
it('Idle by device', async () => {
|
|
28
36
|
const report = await getReports()
|
|
29
37
|
const userData = await report.getUserData()
|
|
@@ -54,7 +62,7 @@ describe('Test_Reports', function () {
|
|
|
54
62
|
const totalIdleTime = driver.idleEvents.reduce((a, b) => a + b.idleTime, 0)
|
|
55
63
|
assert.equal(driver.idleEvents.length, 15) // Total Alerts
|
|
56
64
|
assert.equal(totalIdleTime, 16000) // Total Duration
|
|
57
|
-
}, 20000)
|
|
65
|
+
}, 20000),
|
|
58
66
|
// eslint-disable-next-line no-undef
|
|
59
67
|
it('test allinone', async () => {
|
|
60
68
|
console.log('Start')
|
package/src/tests/zones.test.js
CHANGED
|
@@ -27,6 +27,18 @@ describe('zones', function () {
|
|
|
27
27
|
console.log('result', result)
|
|
28
28
|
}, 4000000)
|
|
29
29
|
|
|
30
|
+
it('works with afriquia', async () => {
|
|
31
|
+
const report = await getReports(process.env.USER_AFRIQUIA, process.env.PASS_AFRIQUIA)
|
|
32
|
+
const userData = await report.getUserData()
|
|
33
|
+
console.log(userData.devices.length)
|
|
34
|
+
console.log(userData.geofences)
|
|
35
|
+
const result = await report.zoneReport(
|
|
36
|
+
new Date(Date.UTC(2023, 5, 11, 0, 0, 0, 0)),
|
|
37
|
+
new Date(Date.UTC(2023, 5, 11, 23, 59, 59, 0)),
|
|
38
|
+
userData)
|
|
39
|
+
console.log('result', result)
|
|
40
|
+
}, 4000000)
|
|
41
|
+
|
|
30
42
|
// eslint-disable-next-line no-undef
|
|
31
43
|
it('works with casais', async () => {
|
|
32
44
|
const report = await getReports(process.env.USER_CASAIS, process.env.PASS_CASAIS)
|
package/src/trip-report.js
CHANGED
|
@@ -168,6 +168,21 @@ function processDevices (from, to, devices, data, userData, traccar) {
|
|
|
168
168
|
trip.endPOIName = nearestPOIs[0].p.name
|
|
169
169
|
}
|
|
170
170
|
|
|
171
|
+
if (userData.includeTemperature) {
|
|
172
|
+
const tripRoute = deviceRoute.filter(p => trip.startTime <= p.fixTime && trip.endTime >= p.fixTime && p.attributes.temp1 !== 175)
|
|
173
|
+
trip.maxTemp = tripRoute.reduce((a, b) => {
|
|
174
|
+
return a > b.attributes.temp1 ? a : b.attributes.temp1
|
|
175
|
+
}, 0)
|
|
176
|
+
trip.minTemp = tripRoute.reduce((a, b) => {
|
|
177
|
+
return a < b.attributes.temp1 ? a : b.attributes.temp1
|
|
178
|
+
}, 0)
|
|
179
|
+
trip.avgTemp = tripRoute.length > 0
|
|
180
|
+
? (tripRoute.reduce((a, b) => {
|
|
181
|
+
return a + b.attributes.temp1
|
|
182
|
+
}, 0)) / tripRoute.length
|
|
183
|
+
: 0
|
|
184
|
+
}
|
|
185
|
+
|
|
171
186
|
const stop = getStop(new Date(trip.startTime), stops)
|
|
172
187
|
|
|
173
188
|
if (deviceRoute.some(r => r.attributes.fuel) ||
|
|
@@ -288,6 +303,12 @@ async function exportTripReportToPDF (userData, reportData) {
|
|
|
288
303
|
translations.report.maxSpeed
|
|
289
304
|
]
|
|
290
305
|
|
|
306
|
+
if (userData.includeTemperature) {
|
|
307
|
+
headers.push(translations.report.maxTemp)
|
|
308
|
+
headers.push(translations.report.minTemp)
|
|
309
|
+
headers.push(translations.report.avgTemp)
|
|
310
|
+
}
|
|
311
|
+
|
|
291
312
|
if (tripsData) {
|
|
292
313
|
const withFuelData = tripsData.find(t => t.totalFuelConsumption !== undefined)
|
|
293
314
|
|
|
@@ -353,6 +374,12 @@ async function exportTripReportToPDF (userData, reportData) {
|
|
|
353
374
|
Math.round(a.averageSpeed * 1.85200),
|
|
354
375
|
Math.round(a.maxSpeed * 1.85200))
|
|
355
376
|
|
|
377
|
+
if (userData.includeTemperature) {
|
|
378
|
+
temp.push(a.maxTemp)
|
|
379
|
+
temp.push(a.minTemp)
|
|
380
|
+
temp.push(a.avgTemp && a.avgTemp.toFixed(1))
|
|
381
|
+
}
|
|
382
|
+
|
|
356
383
|
if (withFuelData) {
|
|
357
384
|
temp.push(a.fuelConsumption && a.fuelConsumption.toFixed(1),
|
|
358
385
|
a.avgFuelConsumption && a.avgFuelConsumption.toFixed(1))
|
|
@@ -378,11 +405,23 @@ async function exportTripReportToPDF (userData, reportData) {
|
|
|
378
405
|
getSumAvgSpeed(d.trips),
|
|
379
406
|
getMaxSpeed(d.trips))
|
|
380
407
|
|
|
408
|
+
if (userData.includeTemperature) {
|
|
409
|
+
footValues.push(...['', '', ''])
|
|
410
|
+
}
|
|
411
|
+
|
|
381
412
|
if (withFuelData) {
|
|
382
|
-
footValues.push(
|
|
413
|
+
footValues.push(
|
|
414
|
+
d.totalFuelConsumption && parseFloat(d.totalFuelConsumption).toFixed(1),
|
|
415
|
+
d.avgFuelConsumption && parseFloat(d.avgFuelConsumption).toFixed(1))
|
|
383
416
|
}
|
|
384
417
|
|
|
385
418
|
const style = getStyle(getUserPartner(userData.user))
|
|
419
|
+
if (userData.includeTemperature && withFuelData) {
|
|
420
|
+
style.headerFontSize = 8
|
|
421
|
+
style.bodyFontSize = 6
|
|
422
|
+
style.footerFontSize = 7
|
|
423
|
+
}
|
|
424
|
+
|
|
386
425
|
addTable(doc,
|
|
387
426
|
headers, data, footValues, style,
|
|
388
427
|
space + (userData.allWeek ? 40 : 45),
|
|
@@ -393,12 +432,24 @@ async function exportTripReportToPDF (userData, reportData) {
|
|
|
393
432
|
7: { halign: 'right' },
|
|
394
433
|
8: { halign: 'right' },
|
|
395
434
|
9: { halign: 'right' },
|
|
396
|
-
...(
|
|
435
|
+
...(userData.includeTemperature
|
|
397
436
|
? {
|
|
398
437
|
10: { halign: 'right' },
|
|
399
|
-
11: { halign: 'right' }
|
|
438
|
+
11: { halign: 'right' },
|
|
439
|
+
12: { halign: 'right' }
|
|
400
440
|
}
|
|
401
|
-
: {})
|
|
441
|
+
: {}),
|
|
442
|
+
...(withFuelData && userData.includeTemperature
|
|
443
|
+
? {
|
|
444
|
+
13: { halign: 'right' },
|
|
445
|
+
14: { halign: 'right' }
|
|
446
|
+
}
|
|
447
|
+
: withFuelData
|
|
448
|
+
? {
|
|
449
|
+
10: { halign: 'right' },
|
|
450
|
+
11: { halign: 'right' }
|
|
451
|
+
}
|
|
452
|
+
: {})
|
|
402
453
|
})
|
|
403
454
|
})
|
|
404
455
|
return doc
|
|
@@ -430,6 +481,12 @@ function exportTripReportToExcel (userData, reportData) {
|
|
|
430
481
|
{ label: translations.report.maxSpeed, value: 'maxSpeed' }
|
|
431
482
|
]
|
|
432
483
|
|
|
484
|
+
if (userData.includeTemperature) {
|
|
485
|
+
headers.push({ label: translations.report.maxTemp, value: 'maxTemp' })
|
|
486
|
+
headers.push({ label: translations.report.minTemp, value: 'minTemp' })
|
|
487
|
+
headers.push({ label: translations.report.avgTemp, value: 'avgTemp' })
|
|
488
|
+
}
|
|
489
|
+
|
|
433
490
|
let data = []
|
|
434
491
|
if (tripsData) {
|
|
435
492
|
const withFuelData = tripsData.find(b => b.totalFuelConsumption !== undefined)
|
|
@@ -462,9 +519,12 @@ function exportTripReportToExcel (userData, reportData) {
|
|
|
462
519
|
distance: Number(a.totalKms.toFixed(1)),
|
|
463
520
|
averageSpeed: Math.round(a.averageSpeed * 1.85200),
|
|
464
521
|
maxSpeed: Math.round(a.maxSpeed * 1.85200),
|
|
465
|
-
consumption: a.fuelConsumption && a.fuelConsumption.toFixed(1),
|
|
466
|
-
avgConsumption: a.avgFuelConsumption && a.avgFuelConsumption.toFixed(1),
|
|
467
|
-
subname: userData.byDriver ? a.deviceName : getDriverName(a.driverUniqueId, a.startTime, userData)
|
|
522
|
+
consumption: a.fuelConsumption && Number(a.fuelConsumption.toFixed(1)),
|
|
523
|
+
avgConsumption: a.avgFuelConsumption && Number(a.avgFuelConsumption.toFixed(1)),
|
|
524
|
+
subname: userData.byDriver ? a.deviceName : getDriverName(a.driverUniqueId, a.startTime, userData),
|
|
525
|
+
maxTemp: a.maxTemp,
|
|
526
|
+
minTemp: a.minTemp,
|
|
527
|
+
avgTemp: Number(a.avgTemp.toFixed(1))
|
|
468
528
|
}
|
|
469
529
|
}))
|
|
470
530
|
// Totals
|
|
@@ -476,8 +536,8 @@ function exportTripReportToExcel (userData, reportData) {
|
|
|
476
536
|
distance: getSumTotalKms(userData.user, d.trips),
|
|
477
537
|
averageSpeed: getSumAvgSpeed(d.trips),
|
|
478
538
|
maxSpeed: getMaxSpeed(d.trips),
|
|
479
|
-
consumption: parseFloat(d.totalFuelConsumption).toFixed(1),
|
|
480
|
-
avgConsumption: parseFloat(d.avgFuelConsumption).toFixed(1)
|
|
539
|
+
consumption: d.totalFuelConsumption && Number(parseFloat(d.totalFuelConsumption).toFixed(1)),
|
|
540
|
+
avgConsumption: d.avgFuelConsumption && Number(parseFloat(d.avgFuelConsumption).toFixed(1))
|
|
481
541
|
}])
|
|
482
542
|
data = data.concat([{}])
|
|
483
543
|
})
|
package/src/util/pdfDocument.js
CHANGED
|
@@ -35,17 +35,17 @@ function addTable (doc, headers, data, footValues, style, startY, columnStyles =
|
|
|
35
35
|
headStyles: {
|
|
36
36
|
fillColor: style.pdfHeaderColor,
|
|
37
37
|
textColor: style.pdfHeaderTextColor,
|
|
38
|
-
fontSize: 10
|
|
38
|
+
fontSize: style.headerFontSize ? style.headerFontSize : 10
|
|
39
39
|
},
|
|
40
40
|
bodyStyles: {
|
|
41
41
|
fillColor: style.pdfBodyColor,
|
|
42
42
|
textColor: style.pdfBodyTextColor,
|
|
43
|
-
fontSize: 8
|
|
43
|
+
fontSize: style.bodyFontSize ? style.bodyFontSize : 8
|
|
44
44
|
},
|
|
45
45
|
footStyles: {
|
|
46
46
|
fillColor: style.pdfFooterColor,
|
|
47
47
|
textColor: style.pdfFooterTextColor,
|
|
48
|
-
fontSize: 9
|
|
48
|
+
fontSize: style.footerFontSize ? style.footerFontSize : 9
|
|
49
49
|
|
|
50
50
|
},
|
|
51
51
|
didDrawCell: (data) => {
|