fleetmap-reports 1.0.614 → 1.0.616
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/trip-report.js +7 -7
- package/src/util/driver.js +2 -4
- package/src/util/odoo.js +10 -5
package/package.json
CHANGED
package/src/trip-report.js
CHANGED
|
@@ -135,10 +135,6 @@ async function createTripReportByDriver (from, to, userData, traccar) {
|
|
|
135
135
|
d.totalDuration = d.trips.reduce((a, b) => a + b.duration, 0)
|
|
136
136
|
d.totalDistance = d.trips.reduce((a, b) => a + b.distance, 0)
|
|
137
137
|
d.maxSpeed = d.trips.reduce((a, b) => { return a > b.maxSpeed ? a : b.maxSpeed }, 0)
|
|
138
|
-
d.trips = d.trips.sort((a, b) => new Date(a.startTime).getTime() - new Date(b.startTime).getTime())
|
|
139
|
-
d.trips.forEach(function (trip, i) {
|
|
140
|
-
trip.stopDuration = i !== d.trips.length - 1 ? (new Date(d.trips[i + 1].startTime) - new Date(trip.endTime)) : 0
|
|
141
|
-
})
|
|
142
138
|
})
|
|
143
139
|
|
|
144
140
|
return report
|
|
@@ -220,9 +216,11 @@ function processDrivers (from, to, userData, data) {
|
|
|
220
216
|
const driversResult = []
|
|
221
217
|
userData.drivers.forEach(d => {
|
|
222
218
|
const route = data.route.filter(p => p.attributes.driverUniqueId === d.uniqueId)
|
|
223
|
-
|
|
219
|
+
let trips = data.trips.filter(t => t.driverUniqueId === d.uniqueId &&
|
|
224
220
|
(userData.allWeek || !userData.weekDays || isInsideTimetable(t, userData) || isPartialInsideTimetable(t, userData, route)))
|
|
225
221
|
|
|
222
|
+
trips = trips.sort((a, b) => new Date(a.startTime).getTime() - new Date(b.startTime).getTime())
|
|
223
|
+
|
|
226
224
|
const idleEvents = getIdleEvents(data.route, d)
|
|
227
225
|
|
|
228
226
|
trips.forEach(function (trip, i) {
|
|
@@ -233,8 +231,10 @@ function processDrivers (from, to, userData, data) {
|
|
|
233
231
|
trip.endPOIName = nearestPOIs[0].p.name
|
|
234
232
|
}
|
|
235
233
|
|
|
236
|
-
|
|
237
|
-
|
|
234
|
+
const stop = data.stops.find(s => s.deviceId === trip.deviceId && (new Date(s.startTime).getTime() === new Date(trip.endTime).getTime()))
|
|
235
|
+
|
|
236
|
+
trip.stopEngineHours = getTripIdleTime(trip, idleEvents) + (stop ? stop.engineHours : 0)
|
|
237
|
+
trip.stopDuration = (i !== trips.length - 1 ? (new Date(trips[i + 1].startTime) - new Date(trip.endTime)) : (to - new Date(trip.endTime))) - trip.stopEngineHours
|
|
238
238
|
})
|
|
239
239
|
|
|
240
240
|
if (trips.length > 0) {
|
package/src/util/driver.js
CHANGED
|
@@ -25,11 +25,9 @@ async function reportByDriver (devices, traccar, from, to, userData, processor)
|
|
|
25
25
|
|
|
26
26
|
let deviceCount = 0
|
|
27
27
|
for (const slice of sliced) {
|
|
28
|
-
const allInOne = await traccarHelper.getAllInOne(traccar, from, to, slice, true, true,
|
|
29
|
-
const tripsData = allInOne.trips
|
|
30
|
-
const routeData = allInOne.route
|
|
28
|
+
const allInOne = await traccarHelper.getAllInOne(traccar, from, to, slice, true, true, true, false, deviceCount, devices.length)
|
|
31
29
|
|
|
32
|
-
const results = processor(from, to, userData, { trips:
|
|
30
|
+
const results = processor(from, to, userData, { trips: allInOne.trips, route: allInOne.route, stops: allInOne.stops })
|
|
33
31
|
|
|
34
32
|
report.drivers.push(...results)
|
|
35
33
|
|
package/src/util/odoo.js
CHANGED
|
@@ -2,12 +2,17 @@
|
|
|
2
2
|
async function getOdooFuelServices (traccar, from, to) {
|
|
3
3
|
const url = `/odoo/reports/refuelingServices?startDate=${from.toDateString()}&endDate=${to.toDateString()}`
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
try {
|
|
6
|
+
const { data } = await traccar.axios.get(url, {
|
|
7
|
+
jar: traccar.cookieJar,
|
|
8
|
+
withCredentials: true
|
|
9
|
+
})
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
return data
|
|
12
|
+
} catch (e) {
|
|
13
|
+
console.log(e)
|
|
14
|
+
return []
|
|
15
|
+
}
|
|
11
16
|
}
|
|
12
17
|
|
|
13
18
|
exports.getOdooFuelServices = getOdooFuelServices
|