fleetmap-reports 1.0.613 → 1.0.615
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/events-report.js +6 -1
- package/src/trip-report.js +7 -7
- package/src/util/driver.js +2 -4
package/package.json
CHANGED
package/src/events-report.js
CHANGED
|
@@ -156,7 +156,9 @@ async function exportSpeedingReportToPDF (userData, reportData) {
|
|
|
156
156
|
userData.eventTypes.forEach(e => {
|
|
157
157
|
const data = e.startsWith('alarm') ? { type: 'alarm', attributes: { alarm: e.slice(6) } } : { type: e }
|
|
158
158
|
const value = e.startsWith('alarm') ? d.alerts.filter(a => a.attributes.alarm === data.attributes.alarm).length : d.alerts.filter(a => a.type === e).length
|
|
159
|
-
|
|
159
|
+
if (value > 0) {
|
|
160
|
+
headerEventTypes.push([getEventType(data, translations, d.device), value])
|
|
161
|
+
}
|
|
160
162
|
})
|
|
161
163
|
|
|
162
164
|
doc.autoTable({
|
|
@@ -281,6 +283,9 @@ function deviceName (device) {
|
|
|
281
283
|
}
|
|
282
284
|
|
|
283
285
|
function getAlertInfo (drivers, alert, device, translations) {
|
|
286
|
+
if (alert.type === 'alarm' && alert.attributes.alarm === 'sensor') {
|
|
287
|
+
return device ? device.attributes.sensor1on : ''
|
|
288
|
+
}
|
|
284
289
|
if (alert.type === 'alarm' && alert.position) {
|
|
285
290
|
return getDigitalPortValue(alert.position, 1, translations, device.attributes)
|
|
286
291
|
}
|
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
|
|