fleetmap-reports 2.0.264 → 2.0.266
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/location-report.js +37 -15
- package/src/util/route.js +2 -1
package/package.json
CHANGED
package/src/location-report.js
CHANGED
|
@@ -41,25 +41,45 @@ async function createLocationReport (from, to, userData, traccar) {
|
|
|
41
41
|
return reportData
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
async function _process (traccar, from, to, slice, deviceCount, devices, userData) {
|
|
45
|
+
const url = `https://${process.env.SERVER_HOST}/pinmeapi/process-report/get-driver-route'`
|
|
46
|
+
return traccar.axios.post(url, {
|
|
47
|
+
from,
|
|
48
|
+
to,
|
|
49
|
+
slice,
|
|
50
|
+
deviceCount,
|
|
51
|
+
devices,
|
|
52
|
+
userData
|
|
53
|
+
}).then(d => d.data)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
async function process (traccar, from, to, slice, deviceCount, devices, userData) {
|
|
57
|
+
const allInOne = await traccarHelper.getAllInOne(
|
|
58
|
+
traccar, from, to, slice, true, false, false, false,
|
|
59
|
+
deviceCount,
|
|
60
|
+
devices.length,
|
|
61
|
+
5,
|
|
62
|
+
1,
|
|
63
|
+
undefined,
|
|
64
|
+
false,
|
|
65
|
+
true
|
|
66
|
+
)
|
|
67
|
+
await processDrivers(from, to, userData, allInOne)
|
|
68
|
+
}
|
|
69
|
+
|
|
44
70
|
async function createLocationReportByDriver (from, to, userData, traccar) {
|
|
45
71
|
// server side only
|
|
46
72
|
const url = `http://${process.env.TRACCAR_HOST}/api/devices`
|
|
47
73
|
const devices = await traccar.axios.get(url).then(d => d.data)
|
|
48
74
|
console.log(devices.length)
|
|
49
75
|
|
|
50
|
-
if (!devices.length) {
|
|
51
|
-
// Empty report
|
|
52
|
-
return { drivers: [] }
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const sliced = automaticReports.sliceArray(devices, 3)
|
|
56
|
-
const driversResult = []
|
|
76
|
+
if (!devices.length) { return { drivers: [] } }
|
|
57
77
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
return { drivers:
|
|
78
|
+
const sliced = automaticReports.sliceArray(devices, 1)
|
|
79
|
+
const deviceCount = 0
|
|
80
|
+
const promises = sliced.map(slice => _process(traccar, from, to, slice, deviceCount, devices, userData))
|
|
81
|
+
const result = await Promise.all(promises)
|
|
82
|
+
return { drivers: result.flat() }
|
|
63
83
|
}
|
|
64
84
|
|
|
65
85
|
async function createLocationReportByGroup (from, to, userData, traccar) {
|
|
@@ -166,7 +186,8 @@ function processDevices (from, to, devices, data) {
|
|
|
166
186
|
return devicesResult
|
|
167
187
|
}
|
|
168
188
|
|
|
169
|
-
async function processDrivers (from, to, userData, data
|
|
189
|
+
async function processDrivers (from, to, userData, data) {
|
|
190
|
+
const result = []
|
|
170
191
|
for (const d of userData.drivers) {
|
|
171
192
|
const { route } = await getDriverData(d, data, userData)
|
|
172
193
|
if (route.length > 0) {
|
|
@@ -186,10 +207,10 @@ async function processDrivers (from, to, userData, data, driversResult) {
|
|
|
186
207
|
positions: route
|
|
187
208
|
}
|
|
188
209
|
console.log('pushing', route.length, 'for', d.name)
|
|
189
|
-
|
|
210
|
+
result.push(driverData)
|
|
190
211
|
}
|
|
191
212
|
}
|
|
192
|
-
|
|
213
|
+
return result
|
|
193
214
|
}
|
|
194
215
|
|
|
195
216
|
async function exportLocationReportToPDF (userData, reportData) {
|
|
@@ -472,3 +493,4 @@ exports.create = createLocationReport
|
|
|
472
493
|
exports.exportToPDF = exportLocationReportToPDF
|
|
473
494
|
exports.exportToExcel = exportLocationReportToExcel
|
|
474
495
|
exports.getDigitalPortValue = getDigitalPortValue
|
|
496
|
+
exports.process = process
|