fleetmap-reports 1.0.814 → 1.0.816
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 +2 -2
- package/src/activity-report.js +26 -17
- package/src/util/pdfDocument.js +3 -3
- package/src/util/utils.js +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fleetmap-reports",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.816",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"file-saver": "^2.0.5",
|
|
21
21
|
"fleetmap-partners": "^1.0.76",
|
|
22
22
|
"json-as-xlsx": "^1.2.1",
|
|
23
|
-
"jspdf": "^2.
|
|
23
|
+
"jspdf": "^2.5.1",
|
|
24
24
|
"jspdf-autotable": "^3.5.14",
|
|
25
25
|
"moment": "^2.29.4",
|
|
26
26
|
"tough-cookie": "^4.0.0",
|
package/src/activity-report.js
CHANGED
|
@@ -59,7 +59,6 @@ async function createActivityReportByGroup (from, to, userData, traccarInstance)
|
|
|
59
59
|
devices.sort((a, b) => (a.name > b.name) ? 1 : -1)
|
|
60
60
|
|
|
61
61
|
if (summary.length > 0) {
|
|
62
|
-
console.log('Summary:' + summary.length)
|
|
63
62
|
groupData.devices = processDevices(from, to, devices, { summary, trips }, userData)
|
|
64
63
|
|
|
65
64
|
reportData.push(groupData)
|
|
@@ -85,6 +84,7 @@ async function executeServerSide (allData, sliced, from, to, userData, totalDevi
|
|
|
85
84
|
}
|
|
86
85
|
|
|
87
86
|
async function createActivityReportByDevice (from, to, userData, traccarInstance) {
|
|
87
|
+
console.log('createActivityReportByDevice')
|
|
88
88
|
const allDevices = devicesToProcess(userData)
|
|
89
89
|
|
|
90
90
|
const allData = {
|
|
@@ -120,23 +120,36 @@ async function createActivityReportByDevice (from, to, userData, traccarInstance
|
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
async function createActivityReportByDriver (from, to, userData, traccarInstance) {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
let tripsData = []
|
|
126
|
-
let routeData = []
|
|
127
|
-
if (devices.length > 0) {
|
|
128
|
-
const allInOne = await traccar.getAllInOne(traccarInstance, from, to, devices, true, true, false, false)
|
|
129
|
-
tripsData = allInOne.trips
|
|
130
|
-
routeData = allInOne.route
|
|
131
|
-
}
|
|
123
|
+
console.log('createActivityReportByDriver')
|
|
124
|
+
const allDevices = await traccarInstance.devices.devicesGet().then(d => d.data)
|
|
132
125
|
|
|
133
126
|
const allData = {
|
|
134
127
|
drivers: [],
|
|
135
128
|
from,
|
|
136
129
|
to
|
|
137
130
|
}
|
|
131
|
+
const driversData = new Map()
|
|
132
|
+
|
|
133
|
+
let deviceCount = 0
|
|
134
|
+
const sliced = automaticReports.sliceArray(allDevices, 10)
|
|
135
|
+
for (const devices of sliced) {
|
|
136
|
+
const data = await traccar.getAllInOne(traccarInstance, from, to, devices, true, true, false, false, deviceCount, allDevices.length)
|
|
137
|
+
|
|
138
|
+
userData.drivers.forEach(d => {
|
|
139
|
+
const { trips, route } = getDriverData(d, data)
|
|
140
|
+
let driverData = driversData.get(d.id)
|
|
141
|
+
if (!driverData) {
|
|
142
|
+
driverData = { trips: [], route: [] }
|
|
143
|
+
driversData.set(d.id, driverData)
|
|
144
|
+
}
|
|
145
|
+
driverData.trips = driverData.trips.concat(...(trips || []))
|
|
146
|
+
driverData.route = driverData.route.concat(...(route || []))
|
|
147
|
+
})
|
|
148
|
+
|
|
149
|
+
deviceCount += devices.length
|
|
150
|
+
}
|
|
138
151
|
|
|
139
|
-
allData.drivers = processDrivers(from, to, userData.drivers,
|
|
152
|
+
allData.drivers = processDrivers(from, to, userData.drivers, driversData, userData)
|
|
140
153
|
|
|
141
154
|
return allData
|
|
142
155
|
}
|
|
@@ -253,10 +266,10 @@ function processDevices (from, to, devices, data, userData) {
|
|
|
253
266
|
return devicesResult
|
|
254
267
|
}
|
|
255
268
|
|
|
256
|
-
function processDrivers (from, to, drivers,
|
|
269
|
+
function processDrivers (from, to, drivers, driversData, userData) {
|
|
257
270
|
const driversResult = []
|
|
258
271
|
drivers.forEach(d => {
|
|
259
|
-
const {
|
|
272
|
+
const { trips, route } = driversData.get(d.id)
|
|
260
273
|
trips.sort((a, b) => new Date(a.startTime).getTime() - new Date(b.startTime).getTime())
|
|
261
274
|
if (trips.length > 0) {
|
|
262
275
|
const driverData = {
|
|
@@ -526,7 +539,6 @@ function exportActivityReportToExcelVehicleGroupByDay (settings, translations, r
|
|
|
526
539
|
}
|
|
527
540
|
}))
|
|
528
541
|
})
|
|
529
|
-
console.log(data)
|
|
530
542
|
return {
|
|
531
543
|
headers,
|
|
532
544
|
data,
|
|
@@ -651,7 +663,6 @@ function exportActivityReportToExcelDriverGroupByDay (settings, translations, re
|
|
|
651
663
|
}
|
|
652
664
|
}))
|
|
653
665
|
})
|
|
654
|
-
console.log(data)
|
|
655
666
|
return {
|
|
656
667
|
headers,
|
|
657
668
|
data,
|
|
@@ -682,7 +693,6 @@ function exportActivityReportToExcelDriver (settings, translations, reportData)
|
|
|
682
693
|
engineHours: convertMS(d.summary[0].engineHours)
|
|
683
694
|
}])
|
|
684
695
|
})
|
|
685
|
-
console.log(data)
|
|
686
696
|
return {
|
|
687
697
|
headers,
|
|
688
698
|
data,
|
|
@@ -725,7 +735,6 @@ function exportActivityReportToExcelVehicle (settings, translations, reportData,
|
|
|
725
735
|
}])
|
|
726
736
|
}
|
|
727
737
|
})
|
|
728
|
-
console.log(data)
|
|
729
738
|
return {
|
|
730
739
|
headers,
|
|
731
740
|
data,
|
package/src/util/pdfDocument.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
require('jspdf-autotable')
|
|
2
2
|
const { getStyle } = require('../reportStyle')
|
|
3
3
|
const { getUserPartner } = require('fleetmap-partners')
|
|
4
|
-
const {
|
|
4
|
+
const { getLogoUrl } = require('./utils')
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
function header (doc, title, hostname, style, orientation) {
|
|
7
7
|
doc.setFontSize(16)
|
|
8
8
|
doc.setFont('helvetica', 'bold')
|
|
9
9
|
doc.text(title, 15, 15)
|
|
10
10
|
|
|
11
11
|
if (style.imgWidth && style.imgHeight) {
|
|
12
12
|
try {
|
|
13
|
-
const image =
|
|
13
|
+
const image = getLogoUrl(hostname)
|
|
14
14
|
if (image) {
|
|
15
15
|
doc.addImage(image, 'PNG', (orientation === 'l' ? 220 : 135) + (style.imgWidth < 50 ? 25 : 0), 5, style.imgWidth, style.imgHeight)
|
|
16
16
|
}
|
package/src/util/utils.js
CHANGED