fleetmap-reports 2.0.265 → 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 -24
package/package.json
CHANGED
package/src/location-report.js
CHANGED
|
@@ -41,34 +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
|
-
}
|
|
76
|
+
if (!devices.length) { return { drivers: [] } }
|
|
54
77
|
|
|
55
|
-
const sliced = automaticReports.sliceArray(devices,
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
traccar, from, to, slice, true, false, false, false,
|
|
61
|
-
0,
|
|
62
|
-
slice.length,
|
|
63
|
-
5,
|
|
64
|
-
1,
|
|
65
|
-
undefined,
|
|
66
|
-
true,
|
|
67
|
-
true
|
|
68
|
-
)
|
|
69
|
-
await processDrivers(from, to, userData, allInOne, driversResult)
|
|
70
|
-
}
|
|
71
|
-
return { drivers: driversResult }
|
|
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() }
|
|
72
83
|
}
|
|
73
84
|
|
|
74
85
|
async function createLocationReportByGroup (from, to, userData, traccar) {
|
|
@@ -175,7 +186,8 @@ function processDevices (from, to, devices, data) {
|
|
|
175
186
|
return devicesResult
|
|
176
187
|
}
|
|
177
188
|
|
|
178
|
-
async function processDrivers (from, to, userData, data
|
|
189
|
+
async function processDrivers (from, to, userData, data) {
|
|
190
|
+
const result = []
|
|
179
191
|
for (const d of userData.drivers) {
|
|
180
192
|
const { route } = await getDriverData(d, data, userData)
|
|
181
193
|
if (route.length > 0) {
|
|
@@ -195,10 +207,10 @@ async function processDrivers (from, to, userData, data, driversResult) {
|
|
|
195
207
|
positions: route
|
|
196
208
|
}
|
|
197
209
|
console.log('pushing', route.length, 'for', d.name)
|
|
198
|
-
|
|
210
|
+
result.push(driverData)
|
|
199
211
|
}
|
|
200
212
|
}
|
|
201
|
-
|
|
213
|
+
return result
|
|
202
214
|
}
|
|
203
215
|
|
|
204
216
|
async function exportLocationReportToPDF (userData, reportData) {
|
|
@@ -481,3 +493,4 @@ exports.create = createLocationReport
|
|
|
481
493
|
exports.exportToPDF = exportLocationReportToPDF
|
|
482
494
|
exports.exportToExcel = exportLocationReportToExcel
|
|
483
495
|
exports.getDigitalPortValue = getDigitalPortValue
|
|
496
|
+
exports.process = process
|