fleetmap-reports 1.0.246 → 1.0.250
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 +75 -23
- package/package.json +1 -1
- package/src/index.js +2 -2
- package/src/index.test.js +23 -1
- package/src/kms-report.js +88 -27
- package/src/speeding-report.js +110 -63
- package/src/trip-report.js +49 -47
- package/src/util/driver.js +3 -9
- package/src/util/traccar.js +14 -0
- package/src/util/utils.js +16 -0
- package/.idea/shelf/Uncommitted_changes_before_Update_at_25_11_2021,_13_06_[Changes]/shelved.patch +0 -302
- package/.idea/shelf/Uncommitted_changes_before_Update_at_25_11_2021,_13_10_[Changes]/shelved.patch +0 -233
- package/.idea/shelf/Uncommitted_changes_before_Update_at_25_11_2021__13_06__Changes_.xml +0 -4
- package/.idea/shelf/Uncommitted_changes_before_Update_at_25_11_2021__13_10__Changes_.xml +0 -4
package/.idea/workspace.xml
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
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="kms report - show every selected day">
|
|
5
5
|
<change beforePath="$PROJECT_DIR$/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/package.json" afterDir="false" />
|
|
6
|
+
<change beforePath="$PROJECT_DIR$/src/index.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/index.js" afterDir="false" />
|
|
6
7
|
<change beforePath="$PROJECT_DIR$/src/index.test.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/index.test.js" afterDir="false" />
|
|
7
8
|
<change beforePath="$PROJECT_DIR$/src/speeding-report.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/speeding-report.js" afterDir="false" />
|
|
8
|
-
<change beforePath="$PROJECT_DIR$/src/util/traccar.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/util/traccar.js" afterDir="false" />
|
|
9
9
|
</list>
|
|
10
10
|
<option name="SHOW_DIALOG" value="false" />
|
|
11
11
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
|
@@ -37,23 +37,28 @@
|
|
|
37
37
|
<property name="ts.external.directory.path" value="$APPLICATION_HOME_DIR$/plugins/JavaScriptLanguage/jsLanguageServicesImpl/external" />
|
|
38
38
|
<property name="vue.rearranger.settings.migration" value="true" />
|
|
39
39
|
</component>
|
|
40
|
-
<component name="RunManager" selected="Mocha.
|
|
41
|
-
<configuration name="
|
|
40
|
+
<component name="RunManager" selected="Mocha.Reports.test event report">
|
|
41
|
+
<configuration name="Reports.test event report" type="mocha-javascript-test-runner" temporary="true" nameIsGenerated="true">
|
|
42
42
|
<node-interpreter>project</node-interpreter>
|
|
43
43
|
<node-options />
|
|
44
44
|
<mocha-package>$PROJECT_DIR$/node_modules/mocha</mocha-package>
|
|
45
45
|
<working-directory>$PROJECT_DIR$</working-directory>
|
|
46
46
|
<pass-parent-env>true</pass-parent-env>
|
|
47
|
+
<envs>
|
|
48
|
+
<env name="email" value="jppenas@gmail.com" />
|
|
49
|
+
<env name="password" value="penas46881" />
|
|
50
|
+
</envs>
|
|
47
51
|
<ui>bdd</ui>
|
|
48
52
|
<extra-mocha-options />
|
|
49
53
|
<test-kind>TEST</test-kind>
|
|
50
54
|
<test-file>$PROJECT_DIR$/src/index.test.js</test-file>
|
|
51
55
|
<test-names>
|
|
52
|
-
<name value="
|
|
56
|
+
<name value="Reports" />
|
|
57
|
+
<name value="test event report" />
|
|
53
58
|
</test-names>
|
|
54
59
|
<method v="2" />
|
|
55
60
|
</configuration>
|
|
56
|
-
<configuration name="
|
|
61
|
+
<configuration name="Reports.test trip report" type="mocha-javascript-test-runner" temporary="true" nameIsGenerated="true">
|
|
57
62
|
<node-interpreter>project</node-interpreter>
|
|
58
63
|
<node-options />
|
|
59
64
|
<mocha-package>$PROJECT_DIR$/node_modules/mocha</mocha-package>
|
|
@@ -68,12 +73,12 @@
|
|
|
68
73
|
<test-kind>TEST</test-kind>
|
|
69
74
|
<test-file>$PROJECT_DIR$/src/index.test.js</test-file>
|
|
70
75
|
<test-names>
|
|
71
|
-
<name value="
|
|
72
|
-
<name value="test
|
|
76
|
+
<name value="Reports" />
|
|
77
|
+
<name value="test trip report" />
|
|
73
78
|
</test-names>
|
|
74
79
|
<method v="2" />
|
|
75
80
|
</configuration>
|
|
76
|
-
<configuration name="speedingReport.test
|
|
81
|
+
<configuration name="speedingReport.test kmsReport by day" type="mocha-javascript-test-runner" temporary="true" nameIsGenerated="true">
|
|
77
82
|
<node-interpreter>project</node-interpreter>
|
|
78
83
|
<node-options />
|
|
79
84
|
<mocha-package>$PROJECT_DIR$/node_modules/mocha</mocha-package>
|
|
@@ -89,11 +94,11 @@
|
|
|
89
94
|
<test-file>$PROJECT_DIR$/src/index.test.js</test-file>
|
|
90
95
|
<test-names>
|
|
91
96
|
<name value="speedingReport" />
|
|
92
|
-
<name value="test
|
|
97
|
+
<name value="test kmsReport by day" />
|
|
93
98
|
</test-names>
|
|
94
99
|
<method v="2" />
|
|
95
100
|
</configuration>
|
|
96
|
-
<configuration name="test
|
|
101
|
+
<configuration name="speedingReport.test speeding" type="mocha-javascript-test-runner" temporary="true" nameIsGenerated="true">
|
|
97
102
|
<node-interpreter>project</node-interpreter>
|
|
98
103
|
<node-options />
|
|
99
104
|
<mocha-package>$PROJECT_DIR$/node_modules/mocha</mocha-package>
|
|
@@ -105,43 +110,47 @@
|
|
|
105
110
|
</envs>
|
|
106
111
|
<ui>bdd</ui>
|
|
107
112
|
<extra-mocha-options />
|
|
108
|
-
<test-kind>
|
|
113
|
+
<test-kind>TEST</test-kind>
|
|
109
114
|
<test-file>$PROJECT_DIR$/src/index.test.js</test-file>
|
|
110
115
|
<test-names>
|
|
111
|
-
<name value="
|
|
116
|
+
<name value="speedingReport" />
|
|
117
|
+
<name value="test speeding" />
|
|
112
118
|
</test-names>
|
|
113
119
|
<method v="2" />
|
|
114
120
|
</configuration>
|
|
115
|
-
<configuration name="test reports
|
|
121
|
+
<configuration name="test reports" type="mocha-javascript-test-runner" temporary="true" nameIsGenerated="true">
|
|
116
122
|
<node-interpreter>project</node-interpreter>
|
|
117
123
|
<node-options />
|
|
118
124
|
<mocha-package>$PROJECT_DIR$/node_modules/mocha</mocha-package>
|
|
119
125
|
<working-directory>$PROJECT_DIR$</working-directory>
|
|
120
126
|
<pass-parent-env>true</pass-parent-env>
|
|
127
|
+
<envs>
|
|
128
|
+
<env name="email" value="jppenas@gmail.com" />
|
|
129
|
+
<env name="password" value="penas46881" />
|
|
130
|
+
</envs>
|
|
121
131
|
<ui>bdd</ui>
|
|
122
132
|
<extra-mocha-options />
|
|
123
|
-
<test-kind>
|
|
133
|
+
<test-kind>SUITE</test-kind>
|
|
124
134
|
<test-file>$PROJECT_DIR$/src/index.test.js</test-file>
|
|
125
135
|
<test-names>
|
|
126
136
|
<name value="test reports" />
|
|
127
|
-
<name value="test queue" />
|
|
128
137
|
</test-names>
|
|
129
138
|
<method v="2" />
|
|
130
139
|
</configuration>
|
|
131
140
|
<list>
|
|
132
|
-
<item itemvalue="Mocha.speedingReport" />
|
|
133
141
|
<item itemvalue="Mocha.test reports" />
|
|
134
|
-
<item itemvalue="Mocha.test reports.test queue" />
|
|
135
142
|
<item itemvalue="Mocha.speedingReport.test kmsReport by day" />
|
|
136
143
|
<item itemvalue="Mocha.speedingReport.test speeding" />
|
|
144
|
+
<item itemvalue="Mocha.Reports.test trip report" />
|
|
145
|
+
<item itemvalue="Mocha.Reports.test event report" />
|
|
137
146
|
</list>
|
|
138
147
|
<recent_temporary>
|
|
139
148
|
<list>
|
|
149
|
+
<item itemvalue="Mocha.Reports.test event report" />
|
|
150
|
+
<item itemvalue="Mocha.Reports.test trip report" />
|
|
140
151
|
<item itemvalue="Mocha.speedingReport.test speeding" />
|
|
141
152
|
<item itemvalue="Mocha.speedingReport.test kmsReport by day" />
|
|
142
153
|
<item itemvalue="Mocha.test reports" />
|
|
143
|
-
<item itemvalue="Mocha.test reports.test queue" />
|
|
144
|
-
<item itemvalue="Mocha.speedingReport" />
|
|
145
154
|
</list>
|
|
146
155
|
</recent_temporary>
|
|
147
156
|
</component>
|
|
@@ -176,7 +185,18 @@
|
|
|
176
185
|
<workItem from="1637868513425" duration="1650000" />
|
|
177
186
|
<workItem from="1637928687573" duration="37000" />
|
|
178
187
|
<workItem from="1637931438656" duration="621000" />
|
|
179
|
-
<workItem from="1637952151523" duration="
|
|
188
|
+
<workItem from="1637952151523" duration="17766000" />
|
|
189
|
+
<workItem from="1638270786569" duration="6960000" />
|
|
190
|
+
<workItem from="1638455902437" duration="120000" />
|
|
191
|
+
<workItem from="1638486745343" duration="4126000" />
|
|
192
|
+
<workItem from="1638792860278" duration="2140000" />
|
|
193
|
+
<workItem from="1638839462028" duration="50000" />
|
|
194
|
+
<workItem from="1638840110567" duration="597000" />
|
|
195
|
+
<workItem from="1638888787940" duration="19894000" />
|
|
196
|
+
<workItem from="1639074912454" duration="257000" />
|
|
197
|
+
<workItem from="1639090037682" duration="2514000" />
|
|
198
|
+
<workItem from="1639135460686" duration="3092000" />
|
|
199
|
+
<workItem from="1639151097761" duration="12693000" />
|
|
180
200
|
</task>
|
|
181
201
|
<task id="LOCAL-00001" summary="Fix getStyle">
|
|
182
202
|
<created>1636983717385</created>
|
|
@@ -227,7 +247,35 @@
|
|
|
227
247
|
<option name="project" value="LOCAL" />
|
|
228
248
|
<updated>1638179219256</updated>
|
|
229
249
|
</task>
|
|
230
|
-
<
|
|
250
|
+
<task id="LOCAL-00008" summary="fix speeding report">
|
|
251
|
+
<created>1638186780966</created>
|
|
252
|
+
<option name="number" value="00008" />
|
|
253
|
+
<option name="presentableId" value="LOCAL-00008" />
|
|
254
|
+
<option name="project" value="LOCAL" />
|
|
255
|
+
<updated>1638186780967</updated>
|
|
256
|
+
</task>
|
|
257
|
+
<task id="LOCAL-00009" summary="refactor speeding and trip report">
|
|
258
|
+
<created>1638288337133</created>
|
|
259
|
+
<option name="number" value="00009" />
|
|
260
|
+
<option name="presentableId" value="LOCAL-00009" />
|
|
261
|
+
<option name="project" value="LOCAL" />
|
|
262
|
+
<updated>1638288337135</updated>
|
|
263
|
+
</task>
|
|
264
|
+
<task id="LOCAL-00010" summary="Kms report with time period">
|
|
265
|
+
<created>1639057192380</created>
|
|
266
|
+
<option name="number" value="00010" />
|
|
267
|
+
<option name="presentableId" value="LOCAL-00010" />
|
|
268
|
+
<option name="project" value="LOCAL" />
|
|
269
|
+
<updated>1639057192382</updated>
|
|
270
|
+
</task>
|
|
271
|
+
<task id="LOCAL-00011" summary="kms report - show every selected day">
|
|
272
|
+
<created>1639139696407</created>
|
|
273
|
+
<option name="number" value="00011" />
|
|
274
|
+
<option name="presentableId" value="LOCAL-00011" />
|
|
275
|
+
<option name="project" value="LOCAL" />
|
|
276
|
+
<updated>1639139696408</updated>
|
|
277
|
+
</task>
|
|
278
|
+
<option name="localTasksCounter" value="12" />
|
|
231
279
|
<servers />
|
|
232
280
|
</component>
|
|
233
281
|
<component name="TypeScriptGeneratedFilesManager">
|
|
@@ -253,6 +301,10 @@
|
|
|
253
301
|
<MESSAGE value="Fix pdf logo" />
|
|
254
302
|
<MESSAGE value="kms report with parallel requests" />
|
|
255
303
|
<MESSAGE value="Kms Report - Calculate distance with traccar trips" />
|
|
256
|
-
<
|
|
304
|
+
<MESSAGE value="fix speeding report" />
|
|
305
|
+
<MESSAGE value="refactor speeding and trip report" />
|
|
306
|
+
<MESSAGE value="Kms report with time period" />
|
|
307
|
+
<MESSAGE value="kms report - show every selected day" />
|
|
308
|
+
<option name="LAST_COMMIT_MESSAGE" value="kms report - show every selected day" />
|
|
257
309
|
</component>
|
|
258
310
|
</project>
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -19,8 +19,8 @@ function Reports(config, axios) {
|
|
|
19
19
|
byGroup: false
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
-
this.speedingReport = (from, to, userData
|
|
23
|
-
return require('./speeding-report').createSpeedingReport(from, to, userData, this.traccar
|
|
22
|
+
this.speedingReport = (from, to, userData) => {
|
|
23
|
+
return require('./speeding-report').createSpeedingReport(from, to, userData, this.traccar)
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
this.speedingReportToPDF = (userData, reportData) => {
|
package/src/index.test.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const {getReports} = require("./tests");
|
|
2
2
|
|
|
3
|
-
describe('
|
|
3
|
+
describe('Reports', function() {
|
|
4
4
|
this.timeout(500000)
|
|
5
5
|
it('test speeding', async () => {
|
|
6
6
|
const report = await getReports()
|
|
@@ -12,6 +12,28 @@ describe('speedingReport', function() {
|
|
|
12
12
|
|
|
13
13
|
console.log(reportData)
|
|
14
14
|
|
|
15
|
+
})
|
|
16
|
+
it('test trip report', async () => {
|
|
17
|
+
const report = await getReports()
|
|
18
|
+
const userData = await report.getUserData()
|
|
19
|
+
userData.byGroup = true
|
|
20
|
+
const reportData = await report.tripReport(new Date(2021, 2, 30, 0, 0, 0, 0),
|
|
21
|
+
new Date(2021, 2, 30, 23, 59, 59, 0),
|
|
22
|
+
userData)
|
|
23
|
+
|
|
24
|
+
console.log(reportData)
|
|
25
|
+
|
|
26
|
+
})
|
|
27
|
+
it('test event report', async () => {
|
|
28
|
+
const report = await getReports()
|
|
29
|
+
const userData = await report.getUserData()
|
|
30
|
+
userData.eventTypes = []
|
|
31
|
+
const reportData = await report.eventsReport(new Date(2021, 10, 20, 0, 0, 0, 0),
|
|
32
|
+
new Date(2021, 10, 30, 23, 59, 59, 0),
|
|
33
|
+
userData)
|
|
34
|
+
|
|
35
|
+
console.log(reportData)
|
|
36
|
+
|
|
15
37
|
})
|
|
16
38
|
it('test kmsReport by day', async () => {
|
|
17
39
|
const reports = await getReports()
|
package/src/kms-report.js
CHANGED
|
@@ -6,13 +6,15 @@ const {getStyle} = require("./reportStyle");
|
|
|
6
6
|
const {headerFromUser,addTable} = require("./util/pdfDocument");
|
|
7
7
|
const {getUserPartner} = require("fleetmap-partners");
|
|
8
8
|
const traccar = require("./util/traccar");
|
|
9
|
+
const {getDates} = require("./util/utils");
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
let traccarInstance
|
|
13
|
+
let userData
|
|
12
14
|
|
|
13
15
|
const fileName = 'KmsReport'
|
|
14
16
|
|
|
15
|
-
async function createKmsReportByDevice(from, to
|
|
17
|
+
async function createKmsReportByDevice(from, to) {
|
|
16
18
|
const groupIds = userData.groups.map(g => g.id)
|
|
17
19
|
const devicesToProcess = userData.byGroup ? userData.devices.filter(d => !groupIds.includes(d.groupId)) : userData.devices
|
|
18
20
|
|
|
@@ -23,54 +25,110 @@ async function createKmsReportByDevice(from, to, userData) {
|
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
devicesToProcess.sort((a, b) => (a.name > b.name) ? 1 : -1)
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
+
const route = userData.allWeek ? [] : await traccar.getRoute(traccarInstance, from, to, devicesToProcess)
|
|
29
|
+
const trips = await traccar.getTrips(traccarInstance, from, to, devicesToProcess)
|
|
28
30
|
|
|
29
|
-
console.log('trips:' +
|
|
31
|
+
console.log('trips:' + trips.length)
|
|
30
32
|
|
|
31
|
-
if (
|
|
32
|
-
allData.devices = processDevices(from, to, devicesToProcess,
|
|
33
|
+
if (trips.length > 0) {
|
|
34
|
+
allData.devices = processDevices(from, to, devicesToProcess, route, trips)
|
|
33
35
|
}
|
|
34
36
|
|
|
35
37
|
return allData
|
|
36
38
|
}
|
|
37
39
|
|
|
38
|
-
async function createKmsReportByDriver(from, to
|
|
40
|
+
async function createKmsReportByDriver(from, to) {
|
|
39
41
|
|
|
40
42
|
}
|
|
41
43
|
|
|
42
|
-
async function createKmsReportByGroup(from, to
|
|
44
|
+
async function createKmsReportByGroup(from, to) {
|
|
43
45
|
|
|
44
46
|
}
|
|
45
47
|
|
|
46
|
-
function processDevices(from, to, devices,
|
|
48
|
+
function processDevices(from, to, devices, route, trips) {
|
|
47
49
|
const devicesResult = []
|
|
48
50
|
|
|
49
51
|
for (const d of devices) {
|
|
50
|
-
const
|
|
52
|
+
const deviceTrips = trips.filter(t => t.deviceId === d.id)
|
|
51
53
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const groupedTrips =
|
|
54
|
+
if (deviceTrips.length > 0) {
|
|
55
|
+
deviceTrips.forEach(t => t.tripDay = new Date(t.startTime).toISOString().split('T')[0] + ' 12:00 PM')
|
|
56
|
+
const groupedTrips = deviceTrips.reduce(
|
|
55
57
|
(entryMap, e) => entryMap.set(e.tripDay, [...entryMap.get(e.tripDay)||[], e]),
|
|
56
58
|
new Map()
|
|
57
59
|
)
|
|
58
60
|
|
|
59
|
-
const
|
|
60
|
-
const keys = Array.from(groupedTrips.keys())
|
|
61
|
+
const allDates = getDates(from, to)
|
|
61
62
|
|
|
62
|
-
|
|
63
|
-
|
|
63
|
+
const days = []
|
|
64
|
+
let keys = Array.from(groupedTrips.keys())
|
|
65
|
+
allDates.forEach(d => {
|
|
66
|
+
const day = d.toISOString().split('T')[0] + ' 12:00 PM'
|
|
67
|
+
if(!keys.includes(day)){
|
|
68
|
+
groupedTrips.set(day, [])
|
|
69
|
+
}
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
keys = Array.from(groupedTrips.keys())
|
|
73
|
+
keys.sort((a,b)=>new Date(a).getTime()-new Date(b).getTime());
|
|
74
|
+
keys.forEach(key => {
|
|
75
|
+
const currentDate = new Date(key)
|
|
76
|
+
let dayTrips = groupedTrips.get(key)
|
|
64
77
|
const day = {
|
|
65
|
-
date:
|
|
66
|
-
kms:
|
|
78
|
+
date: currentDate,
|
|
79
|
+
kms: 0
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if(userData.allWeek){
|
|
83
|
+
day.kms = dayTrips.reduce((a, b) => a + b.distance, 0) || 0
|
|
84
|
+
} else {
|
|
85
|
+
if((currentDate.getDay() === 0 && userData.weekDays.sunday) ||
|
|
86
|
+
(currentDate.getDay() === 1 && userData.weekDays.monday) ||
|
|
87
|
+
(currentDate.getDay() === 2 && userData.weekDays.tuesday) ||
|
|
88
|
+
(currentDate.getDay() === 3 && userData.weekDays.wednesday) ||
|
|
89
|
+
(currentDate.getDay() === 4 && userData.weekDays.thursday) ||
|
|
90
|
+
(currentDate.getDay() === 5 && userData.weekDays.friday) ||
|
|
91
|
+
(currentDate.getDay() === 6 && userData.weekDays.saturday)) {
|
|
92
|
+
|
|
93
|
+
const startDate = new Date(new Date(key).toISOString().split('T')[0] + ' '+userData.dayHours.startTime)
|
|
94
|
+
const endDate = new Date(new Date(key).toISOString().split('T')[0] + ' '+userData.dayHours.endTime)
|
|
95
|
+
|
|
96
|
+
console.log(key, startDate, endDate)
|
|
97
|
+
|
|
98
|
+
//Trips inside time period
|
|
99
|
+
const filteredTrips = dayTrips.filter(t => new Date(t.startTime).getTime() > startDate.getTime()
|
|
100
|
+
&& new Date(t.endTime).getTime() < endDate.getTime())
|
|
101
|
+
|
|
102
|
+
//Trip starts outside time period and ends inside time period
|
|
103
|
+
const startIncompleteTrip = dayTrips.filter(t => new Date(t.startTime).getTime() < startDate.getTime()
|
|
104
|
+
&& new Date(t.endTime).getTime() > startDate.getTime())
|
|
105
|
+
|
|
106
|
+
//Trip starts inside time period and ends outside time period
|
|
107
|
+
const endIncompleteTrip = dayTrips.filter(t => new Date(t.startTime).getTime() < endDate.getTime()
|
|
108
|
+
&& new Date(t.endTime).getTime() > endDate.getTime())
|
|
109
|
+
|
|
110
|
+
day.kms = filteredTrips.reduce((a, b) => a + b.distance, 0) || 0
|
|
111
|
+
console.log('Inside trips:'+day.kms)
|
|
112
|
+
|
|
113
|
+
if(startIncompleteTrip.length){
|
|
114
|
+
const routeInside = route.filter(p => new Date(p.fixTime).getTime() > startDate.getTime() && new Date(p.fixTime).getTime() < new Date(startIncompleteTrip[0].endTime).getTime())
|
|
115
|
+
day.kms = day.kms + (routeInside.reduce((a, b) => a + b.distance, 0) || 0)
|
|
116
|
+
console.log('startIncompleteTrip:'+day.kms)
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if(endIncompleteTrip.length){
|
|
120
|
+
const routeInside = route.filter(p => new Date(p.fixTime).getTime() < endDate.getTime() && new Date(p.fixTime).getTime() > new Date(endIncompleteTrip[0].startTime).getTime())
|
|
121
|
+
day.kms = day.kms + (routeInside.reduce((a, b) => a + b.distance, 0) || 0)
|
|
122
|
+
console.log('endIncompleteTrip:'+day.kms)
|
|
123
|
+
}
|
|
124
|
+
}
|
|
67
125
|
}
|
|
126
|
+
|
|
68
127
|
days.push(day)
|
|
69
128
|
})
|
|
70
|
-
|
|
71
129
|
devicesResult.push({
|
|
72
|
-
|
|
73
|
-
|
|
130
|
+
device: d,
|
|
131
|
+
days: days
|
|
74
132
|
})
|
|
75
133
|
}
|
|
76
134
|
}
|
|
@@ -78,23 +136,26 @@ function processDevices(from, to, devices, data) {
|
|
|
78
136
|
return devicesResult
|
|
79
137
|
}
|
|
80
138
|
|
|
81
|
-
async function createKmsReport(from, to,
|
|
139
|
+
async function createKmsReport(from, to, reportUserData, traccar) {
|
|
82
140
|
console.log('Create KmsReport')
|
|
141
|
+
|
|
142
|
+
console.log(from, to)
|
|
83
143
|
traccarInstance = traccar
|
|
144
|
+
userData = reportUserData
|
|
84
145
|
if(userData.groupByDay){
|
|
85
146
|
const reportData = []
|
|
86
147
|
|
|
87
148
|
if(userData.byDriver){
|
|
88
|
-
const allData = await createKmsReportByDriver(from, to
|
|
149
|
+
const allData = await createKmsReportByDriver(from, to)
|
|
89
150
|
reportData.push(allData)
|
|
90
151
|
}
|
|
91
152
|
else if(userData.byGroup){
|
|
92
|
-
const allGroupsData = await createKmsReportByGroup(from, to
|
|
153
|
+
const allGroupsData = await createKmsReportByGroup(from, to)
|
|
93
154
|
allGroupsData.forEach(data => reportData.push(data))
|
|
94
|
-
const withoutGroupDevices = await createKmsReportByDevice(from, to
|
|
155
|
+
const withoutGroupDevices = await createKmsReportByDevice(from, to)
|
|
95
156
|
reportData.push(withoutGroupDevices)
|
|
96
157
|
} else {
|
|
97
|
-
const allData = await createKmsReportByDevice(from, to
|
|
158
|
+
const allData = await createKmsReportByDevice(from, to)
|
|
98
159
|
reportData.push(allData)
|
|
99
160
|
}
|
|
100
161
|
|