fleetmap-reports 1.0.843 → 1.0.845
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,6 +1,7 @@
|
|
|
1
1
|
const automaticReports = require('../automaticReports')
|
|
2
2
|
const traccarHelper = require('../util/traccar')
|
|
3
3
|
const distance = require('@turf/distance')
|
|
4
|
+
const { convertToLocaleString } = require('../util/utils')
|
|
4
5
|
|
|
5
6
|
const minDistance = 5000
|
|
6
7
|
|
|
@@ -15,7 +16,7 @@ async function createGPSJumpReport (from, to, userData, traccar) {
|
|
|
15
16
|
const allInOne = await traccarHelper.getAllInOne(traccar, from, to, slice, true, false, false, false, deviceCount, devices.length)
|
|
16
17
|
|
|
17
18
|
slice.forEach(d => {
|
|
18
|
-
const deviceData = getDeviceData(allInOne, d)
|
|
19
|
+
const deviceData = getDeviceData(allInOne, d, userData.user)
|
|
19
20
|
reportData = reportData.concat(deviceData)
|
|
20
21
|
})
|
|
21
22
|
|
|
@@ -25,19 +26,19 @@ async function createGPSJumpReport (from, to, userData, traccar) {
|
|
|
25
26
|
return reportData
|
|
26
27
|
}
|
|
27
28
|
|
|
28
|
-
function getDeviceData (allInOne, d) {
|
|
29
|
+
function getDeviceData (allInOne, d, user) {
|
|
29
30
|
const deviceRoute = allInOne.route.filter(t => t.deviceId === d.id)
|
|
30
31
|
|
|
31
32
|
return deviceRoute.map((pA, index) => {
|
|
32
33
|
if (index < deviceRoute.length - 1) {
|
|
33
34
|
const pB = deviceRoute[index + 1]
|
|
34
|
-
const distanceValue = distance.default([pA.longitude, pA.latitude], [pB.longitude, pB.latitude], 'meters')
|
|
35
|
+
const distanceValue = distance.default([pA.longitude, pA.latitude], [pB.longitude, pB.latitude], { units: 'meters' })
|
|
35
36
|
|
|
36
37
|
return {
|
|
37
38
|
device: d.name,
|
|
38
|
-
dateA:
|
|
39
|
+
dateA: convertToLocaleString(pA.fixTime, user.attributes.lang, user.attributes.timezone, user),
|
|
39
40
|
addressA: pA.address,
|
|
40
|
-
dateB:
|
|
41
|
+
dateB: convertToLocaleString(pB.fixTime, user.attributes.lang, user.attributes.timezone, user),
|
|
41
42
|
addressB: pB.address,
|
|
42
43
|
distance: distanceValue
|
|
43
44
|
}
|
package/src/tests/index.test.js
CHANGED
|
@@ -24,10 +24,11 @@ describe('Test_Reports', function () {
|
|
|
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()
|
|
27
|
+
const report = await getReports('HASSANE', 'movitec.1637')
|
|
28
28
|
const userData = await report.getUserData()
|
|
29
|
-
|
|
30
|
-
|
|
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),
|
|
31
32
|
userData, report.traccar)
|
|
32
33
|
console.log(data)
|
|
33
34
|
}, 40000)
|
package/src/util/utils.js
CHANGED
|
@@ -152,12 +152,12 @@ async function getImgFromUrl (hostname) {
|
|
|
152
152
|
|
|
153
153
|
function isClientSide () { return (typeof window !== 'undefined') }
|
|
154
154
|
|
|
155
|
-
function convertToLocaleString (value, lang, timezone) {
|
|
155
|
+
function convertToLocaleString (value, lang, timezone, user) {
|
|
156
156
|
if (isClientSide()) {
|
|
157
157
|
return new Date(value).toLocaleString()
|
|
158
158
|
} else {
|
|
159
|
-
return new Date(value).toLocaleString(lang, {
|
|
160
|
-
timeZone: timezone,
|
|
159
|
+
return new Date(value).toLocaleString(lang || getUserPartner(user).lang, {
|
|
160
|
+
timeZone: timezone || getUserPartner(user).timezone,
|
|
161
161
|
hour12: false
|
|
162
162
|
})
|
|
163
163
|
}
|