fleetmap-reports 1.0.988 → 1.0.990
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/location-report.js +4 -4
- package/src/tests/zones.test.js +30 -2
- package/src/zone-report.js +2 -2
package/package.json
CHANGED
package/src/location-report.js
CHANGED
|
@@ -323,13 +323,13 @@ function getDigitalPortValue (row, index, translations, dAttributes) {
|
|
|
323
323
|
if (row.attributes && row.attributes.door1 !== undefined) {
|
|
324
324
|
return translations.report[row.attributes.door1]
|
|
325
325
|
}
|
|
326
|
-
if (row.attributes && row.attributes.
|
|
327
|
-
return row.attributes.
|
|
326
|
+
if (row.attributes && row.attributes[dAttributes.sensor1Attribute] !== undefined) {
|
|
327
|
+
return row.attributes[dAttributes.sensor1Attribute]
|
|
328
328
|
? dAttributes.sensor1on || row.attributes.sensor
|
|
329
329
|
: dAttributes.sensor1off || row.attributes.sensor
|
|
330
330
|
}
|
|
331
|
-
if (row.attributes && row.attributes
|
|
332
|
-
return row.attributes
|
|
331
|
+
if (row.attributes && row.attributes.sensor !== undefined) {
|
|
332
|
+
return row.attributes.sensor
|
|
333
333
|
? dAttributes.sensor1on || row.attributes.sensor
|
|
334
334
|
: dAttributes.sensor1off || row.attributes.sensor
|
|
335
335
|
}
|
package/src/tests/zones.test.js
CHANGED
|
@@ -27,6 +27,17 @@ describe('zones', function () {
|
|
|
27
27
|
console.log('result', result)
|
|
28
28
|
}, 4000000)
|
|
29
29
|
|
|
30
|
+
it('trips between geofences', async () => {
|
|
31
|
+
const report = await getReports(process.env.USER_MOVIFLOTTE, process.env.PASS_MOVIFLOTTE)
|
|
32
|
+
const userData = await report.getUserData()
|
|
33
|
+
userData.tripsBetweenZones = true
|
|
34
|
+
const result = await report.zoneReport(
|
|
35
|
+
new Date(Date.UTC(2024, 0, 8, 0, 0, 0, 0)),
|
|
36
|
+
new Date(Date.UTC(2024, 0, 8, 23, 59, 59, 0)),
|
|
37
|
+
userData)
|
|
38
|
+
console.log('result', result)
|
|
39
|
+
}, 4000000)
|
|
40
|
+
|
|
30
41
|
// eslint-disable-next-line no-undef
|
|
31
42
|
it('works with casais', async () => {
|
|
32
43
|
const report = await getReports(process.env.USER_CASAIS, process.env.PASS_CASAIS)
|
|
@@ -111,7 +122,24 @@ describe('zones', function () {
|
|
|
111
122
|
userData)
|
|
112
123
|
const first = result[0].devices[0]
|
|
113
124
|
console.log(first)
|
|
114
|
-
assert.equal(first.days[0].distanceOut,
|
|
115
|
-
assert.equal(first.days[1].distanceOut,
|
|
125
|
+
assert.equal(first.days[0].distanceOut, 0)
|
|
126
|
+
assert.equal(first.days[1].distanceOut, 24)
|
|
127
|
+
}, 4000000)
|
|
128
|
+
|
|
129
|
+
it('works with casais zones in columns 5', async () => {
|
|
130
|
+
const report = await getReports()
|
|
131
|
+
const userData = await report.getUserData()
|
|
132
|
+
userData.zonesByColumn = true
|
|
133
|
+
userData.devices = userData.devices.filter(d => d.id === 81172)
|
|
134
|
+
userData.geofences = userData.geofences.filter(g => g.name === 'baliza 1 - raio verde ' ||
|
|
135
|
+
g.name === 'baliza 2 - raio amarelo')
|
|
136
|
+
userData.onlyWithKmsOut = false
|
|
137
|
+
const result = await report.zoneReport(
|
|
138
|
+
new Date(Date.UTC(2023, 8, 3, 0, 0, 0, 0)),
|
|
139
|
+
new Date(Date.UTC(2023, 8, 10, 23, 59, 59, 0)),
|
|
140
|
+
userData)
|
|
141
|
+
const first = result[0].devices[0]
|
|
142
|
+
console.log(first)
|
|
143
|
+
assert.equal(first.days[1].distanceOut, 347.06754247750894)
|
|
116
144
|
}, 4000000)
|
|
117
145
|
})
|
package/src/zone-report.js
CHANGED
|
@@ -329,7 +329,7 @@ function calculateDistanceOut (zoneInOutDayData, dayRoute, fromByDay, toByDay, f
|
|
|
329
329
|
const dataInsideDay = zoneInOutDayData.filter(z => z.outTime && new Date(z.outTime.fixTime) < toByDay)
|
|
330
330
|
let distanceOut = dataInsideDay.reduce((a, b) => a + (b[field] || 0), 0)
|
|
331
331
|
|
|
332
|
-
if (zoneInOutDayData[0].inTime && new Date(zoneInOutDayData[0].inTime.fixTime) > fromByDay
|
|
332
|
+
if (zoneInOutDayData[0].inTime && new Date(zoneInOutDayData[0].inTime.fixTime) > fromByDay) {
|
|
333
333
|
// Add distanceOut before the first entry
|
|
334
334
|
const routeOut = dayRoute.filter(p =>
|
|
335
335
|
new Date(p.fixTime).getTime() < new Date(zoneInOutDayData[0].inTime.fixTime).getTime() &&
|
|
@@ -338,7 +338,7 @@ function calculateDistanceOut (zoneInOutDayData, dayRoute, fromByDay, toByDay, f
|
|
|
338
338
|
distanceOut = distanceOut + calculateDistance(routeOut, device.attributes['report.ignoreOdometer'])
|
|
339
339
|
}
|
|
340
340
|
|
|
341
|
-
if (zoneInOutDayData[zoneInOutDayData.length - 1].outTime && new Date(zoneInOutDayData[zoneInOutDayData.length - 1].outTime.fixTime) < toByDay
|
|
341
|
+
if (zoneInOutDayData[zoneInOutDayData.length - 1].outTime && new Date(zoneInOutDayData[zoneInOutDayData.length - 1].outTime.fixTime) < toByDay) {
|
|
342
342
|
// Add distanceOut after last exit
|
|
343
343
|
distanceOut = distanceOut - zoneInOutDayData[zoneInOutDayData.length - 1][field]
|
|
344
344
|
const routeOut = dayRoute.filter(p =>
|