fleetmap-reports 1.0.610 → 1.0.611
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/machines-report.js +13 -2
package/package.json
CHANGED
package/src/machines-report.js
CHANGED
|
@@ -73,7 +73,7 @@ function processDevices (from, to, devices, data, userData) {
|
|
|
73
73
|
const fromByDay = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0)
|
|
74
74
|
const toByDay = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 23, 59, 59)
|
|
75
75
|
|
|
76
|
-
const routeByDay = deviceRoute.filter(p => (new Date(p.fixTime) > fromByDay && new Date(p.fixTime) < toByDay) && p.valid
|
|
76
|
+
const routeByDay = deviceRoute.filter(p => (new Date(p.fixTime) > fromByDay && new Date(p.fixTime) < toByDay) && p.valid)
|
|
77
77
|
routeByDay.sort((a, b) => new Date(a.fixTime).getTime() - new Date(b.fixTime).getTime())
|
|
78
78
|
|
|
79
79
|
const ignitions = calculateIgnitions(routeByDay)
|
|
@@ -97,10 +97,21 @@ function processDevices (from, to, devices, data, userData) {
|
|
|
97
97
|
function getSummaryData (date, device, route, ignition, ignitions) {
|
|
98
98
|
const startTime = ignition ? ignition.on.fixTime : (ignitions.length ? ignitions[0].on.fixTime : undefined)
|
|
99
99
|
const endTime = ignition ? ignition.off.fixTime : (ignitions.length ? ignitions[ignitions.length - 1].off.fixTime : undefined)
|
|
100
|
-
|
|
100
|
+
let engineHours = ignition
|
|
101
101
|
? ignition.route[ignition.route.length - 1].attributes.hours - ignition.route[0].attributes.hours
|
|
102
102
|
: (ignitions ? ignitions.reduce((a, b) => a + (b.route[b.route.length - 1].attributes.hours - b.route[0].attributes.hours), 0) : undefined)
|
|
103
103
|
|
|
104
|
+
if (!engineHours) {
|
|
105
|
+
engineHours = 0
|
|
106
|
+
if (ignition) {
|
|
107
|
+
engineHours = new Date(endTime).getTime() - new Date(startTime).getTime()
|
|
108
|
+
} else {
|
|
109
|
+
ignitions.forEach(e => {
|
|
110
|
+
engineHours = engineHours + (new Date(e.off.fixTime).getTime() - new Date(e.on.fixTime).getTime())
|
|
111
|
+
})
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
104
115
|
return {
|
|
105
116
|
date,
|
|
106
117
|
deviceId: device.id,
|