fleetmap-reports 1.0.953 → 1.0.955
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/tests/zones.test.js +1 -0
- package/src/trip-report.js +16 -6
- package/src/util/trips.js +2 -2
package/package.json
CHANGED
package/src/tests/zones.test.js
CHANGED
package/src/trip-report.js
CHANGED
|
@@ -62,7 +62,7 @@ async function createTripReportByDevice (from, to, userData, traccar) {
|
|
|
62
62
|
|
|
63
63
|
if (tripsData.length > 0) {
|
|
64
64
|
trips.checkTripsKms(traccar, from, to, slice, { trips: tripsData, route: routeData })
|
|
65
|
-
allData.devices.push(...processDevices(from, to, slice, {
|
|
65
|
+
allData.devices.push(...await processDevices(from, to, slice, {
|
|
66
66
|
trips: tripsData,
|
|
67
67
|
stops: stopsData,
|
|
68
68
|
route: routeData
|
|
@@ -99,7 +99,7 @@ async function createTripReportByGroup (from, to, userData, traccar) {
|
|
|
99
99
|
|
|
100
100
|
if (tripsData.length > 0) {
|
|
101
101
|
console.log('Trips:' + tripsData.length)
|
|
102
|
-
groupData.devices = processDevices(from, to, devices, { trips: tripsData, stops: stopsData, route: routeData }, userData)
|
|
102
|
+
groupData.devices = await processDevices(from, to, devices, { trips: tripsData, stops: stopsData, route: routeData }, userData)
|
|
103
103
|
|
|
104
104
|
reportData.push(groupData)
|
|
105
105
|
}
|
|
@@ -145,10 +145,10 @@ async function createTripReportByDriver (from, to, userData, traccar) {
|
|
|
145
145
|
return report
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
-
function processDevices (from, to, devices, data, userData, traccar) {
|
|
148
|
+
async function processDevices (from, to, devices, data, userData, traccar) {
|
|
149
149
|
const devicesResult = []
|
|
150
150
|
|
|
151
|
-
|
|
151
|
+
for (const d of devices) {
|
|
152
152
|
const deviceRoute = data.route.filter(t => t.deviceId === d.id)
|
|
153
153
|
const deviceTrips = data.trips.filter(t => t.deviceId === d.id)
|
|
154
154
|
|
|
@@ -157,7 +157,17 @@ function processDevices (from, to, devices, data, userData, traccar) {
|
|
|
157
157
|
deviceTrips.push(uncompletedTrip)
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
-
const trips =
|
|
160
|
+
const trips = []
|
|
161
|
+
|
|
162
|
+
for (const t of deviceTrips) {
|
|
163
|
+
if (userData.allWeek ||
|
|
164
|
+
!userData.weekDays ||
|
|
165
|
+
isInsideTimetable(t, userData) ||
|
|
166
|
+
await isPartialInsideTimetable(t, userData, deviceRoute)) {
|
|
167
|
+
trips.push(t)
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
161
171
|
const stops = data.stops.filter(s => s.deviceId === d.id)
|
|
162
172
|
|
|
163
173
|
trips.forEach(trip => {
|
|
@@ -224,7 +234,7 @@ function processDevices (from, to, devices, data, userData, traccar) {
|
|
|
224
234
|
|
|
225
235
|
devicesResult.push(deviceData)
|
|
226
236
|
}
|
|
227
|
-
}
|
|
237
|
+
}
|
|
228
238
|
|
|
229
239
|
return devicesResult
|
|
230
240
|
}
|
package/src/util/trips.js
CHANGED
|
@@ -148,8 +148,8 @@ function updateTrip (device, t, route) {
|
|
|
148
148
|
t.duration = new Date(route[route.length - 1].fixTime).getTime() - new Date(route[0].fixTime).getTime()
|
|
149
149
|
t.maxSpeed = route.reduce((a, b) => Math.max(a, b.speed), 0)
|
|
150
150
|
t.averageSpeed = distance > 0 ? ((route.reduce((a, b) => a + b.speed, 0)) / route.length) : 0
|
|
151
|
-
t.startOdometer = !device.attributes['report.ignoreOdometer'] && route[0].attributes.odometer ? route[0].attributes.odometer : route[0].attributes.totalDistance
|
|
152
|
-
t.endOdometer = !device.attributes['report.ignoreOdometer'] && route[route.length - 1].attributes.odometer ? route[route.length - 1].attributes.odometer : route[route.length - 1].attributes.totalDistance
|
|
151
|
+
t.startOdometer = device && !device.attributes['report.ignoreOdometer'] && route[0].attributes.odometer ? route[0].attributes.odometer : route[0].attributes.totalDistance
|
|
152
|
+
t.endOdometer = device && !device.attributes['report.ignoreOdometer'] && route[route.length - 1].attributes.odometer ? route[route.length - 1].attributes.odometer : route[route.length - 1].attributes.totalDistance
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
function getUncompletedTrip (device, deviceRoute, deviceTrips) {
|