fleetmap-reports 1.0.838 → 1.0.840
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
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const automaticReports = require('../automaticReports')
|
|
2
2
|
const traccarHelper = require('../util/traccar')
|
|
3
|
+
const distance = require('@turf/distance')
|
|
3
4
|
|
|
4
5
|
async function createGPSJumpReport (from, to, userData, traccar) {
|
|
5
6
|
const reportData = []
|
|
@@ -9,12 +10,11 @@ async function createGPSJumpReport (from, to, userData, traccar) {
|
|
|
9
10
|
const sliced = automaticReports.sliceArray(devices, 5)
|
|
10
11
|
let deviceCount = 0
|
|
11
12
|
for (const slice of sliced) {
|
|
12
|
-
|
|
13
|
-
const deviceData = {
|
|
13
|
+
const allInOne = await traccarHelper.getAllInOne(traccar, from, to, slice, true, false, false, false, deviceCount, devices.length)
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
deviceData
|
|
17
|
-
reportData.push(deviceData)
|
|
15
|
+
slice.forEach(d => {
|
|
16
|
+
const deviceData = getDeviceData(allInOne, d)
|
|
17
|
+
reportData.push(...deviceData)
|
|
18
18
|
})
|
|
19
19
|
|
|
20
20
|
deviceCount = deviceCount + slice.length
|
|
@@ -23,4 +23,25 @@ async function createGPSJumpReport (from, to, userData, traccar) {
|
|
|
23
23
|
return reportData
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
function getDeviceData (allInOne, d) {
|
|
27
|
+
const deviceRoute = allInOne.route.filter(t => t.deviceId === d.id)
|
|
28
|
+
|
|
29
|
+
return deviceRoute.map((pA, index) => {
|
|
30
|
+
if (index < deviceRoute.length - 1) {
|
|
31
|
+
const pB = deviceRoute[index + 1]
|
|
32
|
+
const distanceValue = distance.default([pA.longitude, pA.latitude], [pB.longitude, pB.latitude], 'meters')
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
device: d.name,
|
|
36
|
+
dateA: pA.fixTime,
|
|
37
|
+
addressA: pA.address,
|
|
38
|
+
dateB: pB.fixTime,
|
|
39
|
+
addressB: pB.address,
|
|
40
|
+
distance: distanceValue
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return undefined
|
|
44
|
+
})
|
|
45
|
+
}
|
|
46
|
+
|
|
26
47
|
exports.createGPSJumpReport = createGPSJumpReport
|
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,18 @@ 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()
|
|
28
|
+
const userData = await report.getUserData()
|
|
29
|
+
const data = await createGPSJumpReport(new Date(2022, 0, 3, 0, 0, 0, 0),
|
|
30
|
+
new Date(2022, 0, 3, 23, 59, 59, 0),
|
|
31
|
+
userData, report.traccar)
|
|
32
|
+
console.log(data)
|
|
33
|
+
}, 40000)
|
|
27
34
|
it('Idle by device', async () => {
|
|
28
35
|
const report = await getReports()
|
|
29
36
|
const userData = await report.getUserData()
|
|
@@ -54,7 +61,7 @@ describe('Test_Reports', function () {
|
|
|
54
61
|
const totalIdleTime = driver.idleEvents.reduce((a, b) => a + b.idleTime, 0)
|
|
55
62
|
assert.equal(driver.idleEvents.length, 15) // Total Alerts
|
|
56
63
|
assert.equal(totalIdleTime, 16000) // Total Duration
|
|
57
|
-
}, 20000)
|
|
64
|
+
}, 20000),
|
|
58
65
|
// eslint-disable-next-line no-undef
|
|
59
66
|
it('test allinone', async () => {
|
|
60
67
|
console.log('Start')
|