fleetmap-reports 1.0.252 → 1.0.257
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/.idea/workspace.xml +23 -10
- package/lang/enGB.js +0 -1
- package/lang/esCL.js +0 -1
- package/lang/ptBR.js +0 -1
- package/lang/ptPT.js +0 -1
- package/package.json +1 -1
- package/src/kms-report.js +6 -4
- package/src/location-report.js +1 -1
- package/src/trip-report.js +13 -10
- package/src/util/trips.js +23 -0
package/.idea/workspace.xml
CHANGED
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
2
|
<project version="4">
|
|
3
3
|
<component name="ChangeListManager">
|
|
4
|
-
<list default="true" id="eb665c86-c893-4333-bd2a-721dc27980b9" name="Changes" comment="
|
|
4
|
+
<list default="true" id="eb665c86-c893-4333-bd2a-721dc27980b9" name="Changes" comment="Fix trips distance because imported positions generate trips with 0 kms">
|
|
5
5
|
<change beforePath="$PROJECT_DIR$/lang/enGB.js" beforeDir="false" afterPath="$PROJECT_DIR$/lang/enGB.js" afterDir="false" />
|
|
6
6
|
<change beforePath="$PROJECT_DIR$/lang/esCL.js" beforeDir="false" afterPath="$PROJECT_DIR$/lang/esCL.js" afterDir="false" />
|
|
7
7
|
<change beforePath="$PROJECT_DIR$/lang/ptBR.js" beforeDir="false" afterPath="$PROJECT_DIR$/lang/ptBR.js" afterDir="false" />
|
|
8
8
|
<change beforePath="$PROJECT_DIR$/lang/ptPT.js" beforeDir="false" afterPath="$PROJECT_DIR$/lang/ptPT.js" afterDir="false" />
|
|
9
9
|
<change beforePath="$PROJECT_DIR$/package-lock.json" beforeDir="false" afterPath="$PROJECT_DIR$/package-lock.json" afterDir="false" />
|
|
10
10
|
<change beforePath="$PROJECT_DIR$/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/package.json" afterDir="false" />
|
|
11
|
-
<change beforePath="$PROJECT_DIR$/src/activity-report.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/activity-report.js" afterDir="false" />
|
|
12
11
|
<change beforePath="$PROJECT_DIR$/src/index.test.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/index.test.js" afterDir="false" />
|
|
13
|
-
<change beforePath="$PROJECT_DIR$/src/
|
|
14
|
-
<change beforePath="$PROJECT_DIR$/src/
|
|
15
|
-
<change beforePath="$PROJECT_DIR$/src/trip-report.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/trip-report.js" afterDir="false" />
|
|
16
|
-
<change beforePath="$PROJECT_DIR$/src/util/traccar.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/util/traccar.js" afterDir="false" />
|
|
17
|
-
<change beforePath="$PROJECT_DIR$/src/util/utils.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/util/utils.js" afterDir="false" />
|
|
12
|
+
<change beforePath="$PROJECT_DIR$/src/location-report.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/location-report.js" afterDir="false" />
|
|
13
|
+
<change beforePath="$PROJECT_DIR$/src/util/trips.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/util/trips.js" afterDir="false" />
|
|
18
14
|
</list>
|
|
19
15
|
<option name="SHOW_DIALOG" value="false" />
|
|
20
16
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
|
@@ -220,7 +216,8 @@
|
|
|
220
216
|
<workItem from="1639591829775" duration="681000" />
|
|
221
217
|
<workItem from="1639592539998" duration="27141000" />
|
|
222
218
|
<workItem from="1639766010908" duration="4991000" />
|
|
223
|
-
<workItem from="1639872937953" duration="
|
|
219
|
+
<workItem from="1639872937953" duration="1438000" />
|
|
220
|
+
<workItem from="1639954341221" duration="10938000" />
|
|
224
221
|
</task>
|
|
225
222
|
<task id="LOCAL-00001" summary="Fix getStyle">
|
|
226
223
|
<created>1636983717385</created>
|
|
@@ -313,7 +310,21 @@
|
|
|
313
310
|
<option name="project" value="LOCAL" />
|
|
314
311
|
<updated>1639248407782</updated>
|
|
315
312
|
</task>
|
|
316
|
-
<
|
|
313
|
+
<task id="LOCAL-00014" summary="Trip and activity report with time period">
|
|
314
|
+
<created>1639873766070</created>
|
|
315
|
+
<option name="number" value="00014" />
|
|
316
|
+
<option name="presentableId" value="LOCAL-00014" />
|
|
317
|
+
<option name="project" value="LOCAL" />
|
|
318
|
+
<updated>1639873766072</updated>
|
|
319
|
+
</task>
|
|
320
|
+
<task id="LOCAL-00015" summary="Fix trips distance because imported positions generate trips with 0 kms">
|
|
321
|
+
<created>1640000462824</created>
|
|
322
|
+
<option name="number" value="00015" />
|
|
323
|
+
<option name="presentableId" value="LOCAL-00015" />
|
|
324
|
+
<option name="project" value="LOCAL" />
|
|
325
|
+
<updated>1640000462825</updated>
|
|
326
|
+
</task>
|
|
327
|
+
<option name="localTasksCounter" value="16" />
|
|
317
328
|
<servers />
|
|
318
329
|
</component>
|
|
319
330
|
<component name="TypeScriptGeneratedFilesManager">
|
|
@@ -344,6 +355,8 @@
|
|
|
344
355
|
<MESSAGE value="kms report - show every selected day" />
|
|
345
356
|
<MESSAGE value="speeding report with customSpeed" />
|
|
346
357
|
<MESSAGE value="fix speeding report" />
|
|
347
|
-
<
|
|
358
|
+
<MESSAGE value="Trip and activity report with time period" />
|
|
359
|
+
<MESSAGE value="Fix trips distance because imported positions generate trips with 0 kms" />
|
|
360
|
+
<option name="LAST_COMMIT_MESSAGE" value="Fix trips distance because imported positions generate trips with 0 kms" />
|
|
348
361
|
</component>
|
|
349
362
|
</project>
|
package/lang/enGB.js
CHANGED
package/lang/esCL.js
CHANGED
package/lang/ptBR.js
CHANGED
package/lang/ptPT.js
CHANGED
package/package.json
CHANGED
package/src/kms-report.js
CHANGED
|
@@ -6,6 +6,7 @@ const {headerFromUser,addTable} = require("./util/pdfDocument");
|
|
|
6
6
|
const {getUserPartner} = require("fleetmap-partners");
|
|
7
7
|
const traccar = require("./util/traccar");
|
|
8
8
|
const {getDates} = require("./util/utils");
|
|
9
|
+
const trips = require("./util/trips");
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
let traccarInstance
|
|
@@ -25,12 +26,13 @@ async function createKmsReportByDevice(from, to) {
|
|
|
25
26
|
|
|
26
27
|
devicesToProcess.sort((a, b) => (a.name > b.name) ? 1 : -1)
|
|
27
28
|
const route = userData.allWeek ? [] : await traccar.getRoute(traccarInstance, from, to, devicesToProcess)
|
|
28
|
-
const
|
|
29
|
+
const tripsData = await traccar.getTrips(traccarInstance, from, to, devicesToProcess)
|
|
29
30
|
|
|
30
|
-
console.log('trips:' +
|
|
31
|
+
console.log('trips:' + tripsData.length)
|
|
31
32
|
|
|
32
|
-
if (
|
|
33
|
-
|
|
33
|
+
if (tripsData.length > 0) {
|
|
34
|
+
await trips.checkTripsKms(traccarInstance, from, to, route, tripsData, devicesToProcess)
|
|
35
|
+
allData.devices = processDevices(from, to, devicesToProcess, route, tripsData)
|
|
34
36
|
}
|
|
35
37
|
|
|
36
38
|
return allData
|
package/src/location-report.js
CHANGED
|
@@ -112,7 +112,7 @@ async function exportLocationReportToPDF(userData, reportData) {
|
|
|
112
112
|
translations.report.speed,
|
|
113
113
|
translations.report.ignition,
|
|
114
114
|
translations.report.driver,
|
|
115
|
-
translations.temperature
|
|
115
|
+
translations.report.temperature
|
|
116
116
|
]
|
|
117
117
|
|
|
118
118
|
if (reportData.devices) {
|
package/src/trip-report.js
CHANGED
|
@@ -9,37 +9,40 @@ const {getUserPartner} = require("fleetmap-partners")
|
|
|
9
9
|
const {headerFromUser, addTable} = require("./util/pdfDocument")
|
|
10
10
|
const {getStyle} = require("./reportStyle")
|
|
11
11
|
const traccar = require("./util/traccar")
|
|
12
|
+
const trips = require("./util/trips");
|
|
12
13
|
|
|
13
14
|
|
|
14
15
|
let traccarInstance
|
|
16
|
+
let userData
|
|
15
17
|
|
|
16
18
|
const fileName = 'TripReport'
|
|
17
19
|
|
|
18
|
-
async function createTripReport(from, to,
|
|
20
|
+
async function createTripReport(from, to, reportUserData, traccar) {
|
|
19
21
|
console.log('Create TripReport')
|
|
22
|
+
userData = reportUserData
|
|
20
23
|
traccarInstance = traccar
|
|
21
24
|
const reportData = []
|
|
22
25
|
|
|
23
26
|
if(userData.byDriver){
|
|
24
|
-
const allData = await createTripReportByDriver(from, to
|
|
27
|
+
const allData = await createTripReportByDriver(from, to)
|
|
25
28
|
reportData.push(allData)
|
|
26
29
|
}
|
|
27
30
|
else if(userData.byGroup){
|
|
28
31
|
console.log("ByGroup")
|
|
29
|
-
const allData = await createTripReportByGroup(from, to
|
|
32
|
+
const allData = await createTripReportByGroup(from, to)
|
|
30
33
|
reportData.push(...allData)
|
|
31
34
|
}
|
|
32
35
|
|
|
33
36
|
const groupIds = userData.groups.map(g => g.id)
|
|
34
37
|
const withoutGroupDevices = userData.byGroup ? userData.devices.filter(d => !groupIds.includes(d.groupId)) : userData.devices
|
|
35
38
|
|
|
36
|
-
const allData = await createTripReportByDevice(from, to,
|
|
39
|
+
const allData = await createTripReportByDevice(from, to, withoutGroupDevices)
|
|
37
40
|
reportData.push(allData)
|
|
38
41
|
|
|
39
42
|
return reportData
|
|
40
43
|
}
|
|
41
44
|
|
|
42
|
-
async function createTripReportByDevice(from, to,
|
|
45
|
+
async function createTripReportByDevice(from, to, devices) {
|
|
43
46
|
const allData = {
|
|
44
47
|
devices: [],
|
|
45
48
|
xpert: devices.filter(d => d.attributes.xpert).length > 0
|
|
@@ -54,14 +57,14 @@ async function createTripReportByDevice(from, to, userData, devices) {
|
|
|
54
57
|
console.log('Trips:' + data.length)
|
|
55
58
|
|
|
56
59
|
if (data.length > 0) {
|
|
57
|
-
|
|
58
|
-
|
|
60
|
+
await trips.checkTripsKms(traccarInstance, from, to,[], data, devices)
|
|
61
|
+
allData.devices = processDevices(from, to, devices, data, stopsData)
|
|
59
62
|
}
|
|
60
63
|
|
|
61
64
|
return allData
|
|
62
65
|
}
|
|
63
66
|
|
|
64
|
-
async function createTripReportByGroup(from, to
|
|
67
|
+
async function createTripReportByGroup(from, to) {
|
|
65
68
|
const reportData = []
|
|
66
69
|
for (const g of userData.groups) {
|
|
67
70
|
const devices = userData.devices.filter(d => d.groupId === g.id)
|
|
@@ -93,7 +96,7 @@ async function createTripReportByGroup(from, to, userData) {
|
|
|
93
96
|
return reportData
|
|
94
97
|
}
|
|
95
98
|
|
|
96
|
-
async function createTripReportByDriver(from, to
|
|
99
|
+
async function createTripReportByDriver(from, to){
|
|
97
100
|
const deviceIds = await drivers.devicesByDriver(traccarInstance, from, to, userData.drivers, userData.devices)
|
|
98
101
|
console.log(deviceIds.length)
|
|
99
102
|
|
|
@@ -112,7 +115,7 @@ async function createTripReportByDriver(from, to, userData){
|
|
|
112
115
|
return allData
|
|
113
116
|
}
|
|
114
117
|
|
|
115
|
-
function processDevices(from, to, devices, data, stopsData
|
|
118
|
+
function processDevices(from, to, devices, data, stopsData) {
|
|
116
119
|
const devicesResult = []
|
|
117
120
|
|
|
118
121
|
devices.forEach(d => {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const traccar = require("./traccar");
|
|
2
|
+
|
|
3
|
+
const minDistance = 0
|
|
4
|
+
const minAvgSpeed = 0
|
|
5
|
+
|
|
6
|
+
async function checkTripsKms(traccarInstance, from, to, routeData, tripsData, devices) {
|
|
7
|
+
console.log('checkTripsKms')
|
|
8
|
+
const trips = tripsData.filter(t => t.distance === minDistance && t.averageSpeed > minAvgSpeed)
|
|
9
|
+
if(trips.length > 0) {
|
|
10
|
+
//Vehicles with imported positions. calculate trip distance with route positions
|
|
11
|
+
const route = routeData.length === 0 ? await traccar.getRoute(traccarInstance, from, to, devices) : routeData
|
|
12
|
+
trips.forEach(t => {
|
|
13
|
+
if(t.distance === minDistance && t.averageSpeed > minAvgSpeed) {
|
|
14
|
+
const tripRoute = route.filter(p => p.deviceId === t.deviceId
|
|
15
|
+
&& new Date(p.fixTime).getTime() >= new Date(t.startTime).getTime()
|
|
16
|
+
&& new Date(p.fixTime).getTime() <= new Date(t.endTime).getTime())
|
|
17
|
+
t.distance = tripRoute.reduce((a, b) => a + b.attributes.distance, 0)
|
|
18
|
+
}
|
|
19
|
+
})
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
exports.checkTripsKms = checkTripsKms
|