fleetmap-reports 1.0.736 → 1.0.738
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,7 +1,7 @@
|
|
|
1
1
|
const automaticReports = require('../automaticReports')
|
|
2
2
|
const traccarHelper = require('../util/traccar')
|
|
3
3
|
const { getUncompletedTrip } = require('../util/trips')
|
|
4
|
-
const {
|
|
4
|
+
const { getEndTripMessages, getCanDriverStyleMessages, parseEndTripMessage, parseCanDriverStyleMessage } = require('../util/xpert')
|
|
5
5
|
|
|
6
6
|
async function createPerformanceReport (from, to, userData, traccar) {
|
|
7
7
|
const reportData = []
|
|
@@ -22,30 +22,25 @@ async function createPerformanceReport (from, to, userData, traccar) {
|
|
|
22
22
|
deviceTrips.push(uncompletedTrip)
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const canDriverStyle = getCanDriverStyleMessage(t, deviceRoute)
|
|
28
|
-
|
|
29
|
-
t.endTripData = endTripData && parseEndTripMessage(endTripData.xpertString)
|
|
30
|
-
t.canDriverStyle = canDriverStyle && parseCanDriverStyleMessage(canDriverStyle.xpertString)
|
|
31
|
-
})
|
|
25
|
+
const endTripData = getEndTripMessages(deviceRoute).map(m => parseEndTripMessage(m.xpertString || m))
|
|
26
|
+
const canDriverStyle = getCanDriverStyleMessages(deviceRoute).map(m => parseCanDriverStyleMessage(m.xpertString || m))
|
|
32
27
|
|
|
33
28
|
const deviceData = {
|
|
34
29
|
device: d.name,
|
|
35
|
-
drivingTime:
|
|
36
|
-
idleTime:
|
|
37
|
-
drivingConsumption:
|
|
38
|
-
idleConsumption:
|
|
39
|
-
drivingDistance:
|
|
40
|
-
cruiseControlTime:
|
|
41
|
-
cruiseControlConsumption:
|
|
42
|
-
cruiseControlDistance:
|
|
43
|
-
economicTime:
|
|
44
|
-
economicConsumption:
|
|
45
|
-
economicDistance:
|
|
46
|
-
highEngineRPM:
|
|
47
|
-
hardBreaking:
|
|
48
|
-
hardAcceleration:
|
|
30
|
+
drivingTime: endTripData.reduce((a, b) => a + b.totalTimeDriving, 0),
|
|
31
|
+
idleTime: endTripData.reduce((a, b) => a + b.totalTimeInIdle, 0),
|
|
32
|
+
drivingConsumption: endTripData.reduce((a, b) => a + b.totalFuelConsumptionDriving, 0),
|
|
33
|
+
idleConsumption: endTripData.reduce((a, b) => a + b.totalFuelConsumptionInIdle, 0),
|
|
34
|
+
drivingDistance: endTripData.reduce((a, b) => a + b.totalDistanceTravelled, 0),
|
|
35
|
+
cruiseControlTime: endTripData.reduce((a, b) => a + b.totalTimeWithCruiseControl, 0),
|
|
36
|
+
cruiseControlConsumption: endTripData.reduce((a, b) => a + b.totalFuelConsumptionWithCruiseControl, 0),
|
|
37
|
+
cruiseControlDistance: endTripData.reduce((a, b) => a + b.totalDistanceTravelledWithCruiseControl, 0),
|
|
38
|
+
economicTime: canDriverStyle.reduce((a, b) => a + b.totalTimeInEcoRange, 0),
|
|
39
|
+
economicConsumption: canDriverStyle.reduce((a, b) => a + b.totalFuelConsumptionInEcoRange, 0),
|
|
40
|
+
economicDistance: canDriverStyle.reduce((a, b) => a + b.totalDistanceInEcoRange, 0),
|
|
41
|
+
highEngineRPM: canDriverStyle.reduce((a, b) => a + b.totalTimeWithHighRpmAndTorque, 0),
|
|
42
|
+
hardBreaking: canDriverStyle.reduce((a, b) => a + b.totalNumberOfHarshBrakes, 0),
|
|
43
|
+
hardAcceleration: canDriverStyle.reduce((a, b) => a + b.totalNumberOfHarshAccelerations, 0)
|
|
49
44
|
}
|
|
50
45
|
reportData.push(deviceData)
|
|
51
46
|
})
|
|
@@ -2,6 +2,7 @@ const { getReports } = require('./index')
|
|
|
2
2
|
const { createPerformanceReport } = require('../partnerReports/performance-report')
|
|
3
3
|
// eslint-disable-next-line no-undef
|
|
4
4
|
describe('performance', function () {
|
|
5
|
+
this.timeout(500000)
|
|
5
6
|
// eslint-disable-next-line no-undef
|
|
6
7
|
it('performance report', async () => {
|
|
7
8
|
const report = await getReports()
|
package/src/util/xpert.js
CHANGED
|
@@ -42,23 +42,21 @@ function parseCanDriverStyleMessage (xpertMessage) {
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
function
|
|
46
|
-
const
|
|
47
|
-
p.attributes.xpert
|
|
48
|
-
p.attributes.xpert.find(x => x.type === '3'))
|
|
45
|
+
function getEndTripMessages (route) {
|
|
46
|
+
const positions = route.filter(p => p.attributes.xpert &&
|
|
47
|
+
(Array.isArray(p.attributes.xpert) ? p.attributes.xpert.find(x => x.type === '3') : p.attributes.xpert.split(';').find(m => m.startsWith('3'))))
|
|
49
48
|
|
|
50
|
-
return p
|
|
49
|
+
return positions.map(p => (Array.isArray(p.attributes.xpert) ? p.attributes.xpert.find(x => x.type === '3') : p.attributes.xpert.split(';').find(m => m.startsWith('3'))))
|
|
51
50
|
}
|
|
52
51
|
|
|
53
|
-
function
|
|
54
|
-
const
|
|
55
|
-
p.attributes.xpert
|
|
56
|
-
p.attributes.xpert.find(x => x.type === '4'))
|
|
52
|
+
function getCanDriverStyleMessages (route) {
|
|
53
|
+
const positions = route.filter(p => p.attributes.xpert &&
|
|
54
|
+
(Array.isArray(p.attributes.xpert) ? p.attributes.xpert.find(x => x.type === '4') : p.attributes.xpert.split(';').find(m => m.startsWith('4'))))
|
|
57
55
|
|
|
58
|
-
return p
|
|
56
|
+
return positions.map(p => (Array.isArray(p.attributes.xpert) ? p.attributes.xpert.find(x => x.type === '4') : p.attributes.xpert.split(';').find(m => m.startsWith('4'))))
|
|
59
57
|
}
|
|
60
58
|
|
|
61
59
|
exports.parseEndTripMessage = parseEndTripMessage
|
|
62
|
-
exports.
|
|
60
|
+
exports.getEndTripMessages = getEndTripMessages
|
|
63
61
|
exports.parseCanDriverStyleMessage = parseCanDriverStyleMessage
|
|
64
|
-
exports.
|
|
62
|
+
exports.getCanDriverStyleMessages = getCanDriverStyleMessages
|