fleetmap-reports 1.0.657 → 1.0.659
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/stop-report.js +12 -19
package/package.json
CHANGED
package/src/stop-report.js
CHANGED
|
@@ -2,7 +2,7 @@ const { devicesToProcess, deviceName } = require('./util/device')
|
|
|
2
2
|
const automaticReports = require('./automaticReports')
|
|
3
3
|
const traccarHelper = require('./util/traccar')
|
|
4
4
|
const { getNearestPOIs, insideGeofence, loadGroupsData } = require('./util/geofence')
|
|
5
|
-
const { getTranslations, convertToLocaleString, convertMS
|
|
5
|
+
const { getTranslations, convertToLocaleString, convertMS } = require('./util/utils')
|
|
6
6
|
const jsPDF = require('jspdf')
|
|
7
7
|
const { headerFromUser, addTable } = require('./util/pdfDocument')
|
|
8
8
|
const { getStyle } = require('./reportStyle')
|
|
@@ -33,15 +33,11 @@ async function createStopReportByDevice (from, to, userData, traccar) {
|
|
|
33
33
|
|
|
34
34
|
let deviceCount = 0
|
|
35
35
|
for (const slice of sliced) {
|
|
36
|
-
const allInOne = await traccarHelper.getAllInOne(traccar, from, to, slice,
|
|
37
|
-
|
|
36
|
+
const allInOne = await traccarHelper.getAllInOne(traccar, from, to, slice, true, false, true, false, deviceCount, devices.length)
|
|
37
|
+
console.log('Stops:' + allInOne.stops.length)
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (stopsData.length > 0) {
|
|
42
|
-
allData.devices.push(...processDevices(from, to, slice, {
|
|
43
|
-
stops: stopsData
|
|
44
|
-
}, userData))
|
|
39
|
+
if (allInOne.stops.length > 0) {
|
|
40
|
+
allData.devices.push(...processDevices(from, to, slice, allInOne, userData))
|
|
45
41
|
}
|
|
46
42
|
deviceCount = deviceCount + slice.length
|
|
47
43
|
}
|
|
@@ -54,6 +50,7 @@ function processDevices (from, to, devices, data, userData) {
|
|
|
54
50
|
|
|
55
51
|
devices.forEach(d => {
|
|
56
52
|
const deviceStops = data.stops.filter(t => t.deviceId === d.id)
|
|
53
|
+
const route = data.route.filter(t => t.deviceId === d.id)
|
|
57
54
|
|
|
58
55
|
deviceStops.forEach(stop => {
|
|
59
56
|
const nearestPOIs = getNearestPOIs(stop.longitude, stop.latitude, userData.geofences)
|
|
@@ -75,6 +72,10 @@ function processDevices (from, to, devices, data, userData) {
|
|
|
75
72
|
})
|
|
76
73
|
|
|
77
74
|
if (deviceStops.length > 0) {
|
|
75
|
+
if (route.length && !route[0].attributes.ignition) {
|
|
76
|
+
deviceStops[0].startTime = undefined
|
|
77
|
+
}
|
|
78
|
+
|
|
78
79
|
const deviceData = {
|
|
79
80
|
device: d,
|
|
80
81
|
from,
|
|
@@ -98,7 +99,6 @@ async function exportStopReportToPDF (userData, reportData) {
|
|
|
98
99
|
const stopsData = userData.byDriver ? reportData.drivers : reportData.devices
|
|
99
100
|
|
|
100
101
|
const headers = [
|
|
101
|
-
translations.report.date,
|
|
102
102
|
translations.report.start,
|
|
103
103
|
translations.report.end,
|
|
104
104
|
translations.report.address,
|
|
@@ -131,7 +131,6 @@ async function exportStopReportToPDF (userData, reportData) {
|
|
|
131
131
|
|
|
132
132
|
d.stops.forEach(a => {
|
|
133
133
|
data.push([
|
|
134
|
-
getStopDate(userData.user, a),
|
|
135
134
|
getStopStart(userData.user, a),
|
|
136
135
|
getStopEnd(userData.user, a),
|
|
137
136
|
a.endPOIName || a.address,
|
|
@@ -172,7 +171,6 @@ function exportStopReportToExcel (userData, reportData) {
|
|
|
172
171
|
|
|
173
172
|
const headers = [
|
|
174
173
|
{ label: translations.report.vehicle, value: 'name' },
|
|
175
|
-
{ label: translations.report.date, value: 'date' },
|
|
176
174
|
{ label: translations.report.start, value: 'start' },
|
|
177
175
|
{ label: translations.report.end, value: 'end' },
|
|
178
176
|
{ label: translations.report.address, value: 'address' },
|
|
@@ -188,7 +186,6 @@ function exportStopReportToExcel (userData, reportData) {
|
|
|
188
186
|
data = data.concat(d.stops.map(a => {
|
|
189
187
|
return {
|
|
190
188
|
name: a.deviceName,
|
|
191
|
-
date: getStopDate(userData.user, a),
|
|
192
189
|
start: getStopStart(userData.user, a),
|
|
193
190
|
end: getStopEnd(userData.user, a),
|
|
194
191
|
address: a.endPOIName || a.address,
|
|
@@ -214,16 +211,12 @@ function exportStopReportToExcel (userData, reportData) {
|
|
|
214
211
|
}
|
|
215
212
|
}
|
|
216
213
|
|
|
217
|
-
function getStopDate (user, stop) {
|
|
218
|
-
return convertToLocaleDateString(stop.startTime, user.attributes.lang, user.attributes.timezone)
|
|
219
|
-
}
|
|
220
|
-
|
|
221
214
|
function getStopStart (user, stop) {
|
|
222
|
-
return
|
|
215
|
+
return stop.startTime ? convertToLocaleString(stop.startTime, user.attributes.lang, user.attributes.timezone) : ''
|
|
223
216
|
}
|
|
224
217
|
|
|
225
218
|
function getStopEnd (user, stop) {
|
|
226
|
-
return
|
|
219
|
+
return stop.endTime ? convertToLocaleString(stop.endTime, user.attributes.lang, user.attributes.timezone) : ''
|
|
227
220
|
}
|
|
228
221
|
|
|
229
222
|
exports.createStopReport = createStopReport
|