fleetmap-reports 1.0.329 → 1.0.331
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/activity-report.js +7 -5
- package/src/index.js +2 -1
- package/src/index.test.js +18 -0
- package/src/trip-report.js +7 -5
- package/src/util/traccar.js +42 -0
- package/.idea/aws.xml +0 -17
- package/.idea/codeStyles/Project.xml +0 -7
- package/.idea/codeStyles/codeStyleConfig.xml +0 -5
- package/.idea/fleetmap-reports.iml +0 -9
- package/.idea/jsLibraryMappings.xml +0 -6
- package/.idea/misc.xml +0 -6
- package/.idea/modules.xml +0 -8
- package/.idea/vcs.xml +0 -6
package/package.json
CHANGED
package/src/activity-report.js
CHANGED
|
@@ -87,10 +87,11 @@ async function createActivityReportByDevice(from, to, userData, traccarInstance)
|
|
|
87
87
|
|
|
88
88
|
let summaries = []
|
|
89
89
|
let routeData = []
|
|
90
|
-
const
|
|
90
|
+
const allInOne = await traccar.getAllInOne(traccarInstance, from, to, devicesToProcess, userData.groupByDay && !userData.allWeek, true, false, !userData.groupByDay)
|
|
91
|
+
const tripsData = allInOne.trips
|
|
91
92
|
|
|
92
93
|
if(userData.groupByDay) {
|
|
93
|
-
routeData =
|
|
94
|
+
routeData = allInOne.route
|
|
94
95
|
console.log('trips:' + tripsData.length)
|
|
95
96
|
|
|
96
97
|
if (tripsData.length > 0) {
|
|
@@ -109,7 +110,7 @@ async function createActivityReportByDevice(from, to, userData, traccarInstance)
|
|
|
109
110
|
}
|
|
110
111
|
}
|
|
111
112
|
} else {
|
|
112
|
-
summaries =
|
|
113
|
+
summaries = allInOne.summary
|
|
113
114
|
}
|
|
114
115
|
|
|
115
116
|
console.log('Summary:' + summaries.length)
|
|
@@ -128,8 +129,9 @@ async function createActivityReportByDriver(from, to, userData, traccarInstance)
|
|
|
128
129
|
let tripsData = []
|
|
129
130
|
let routeData = []
|
|
130
131
|
if(devices.length > 0) {
|
|
131
|
-
|
|
132
|
-
|
|
132
|
+
const allInOne = await traccar.getAllInOne(traccarInstance, from, to, devices, true, true, false, false)
|
|
133
|
+
tripsData = allInOne.trips
|
|
134
|
+
routeData = allInOne.route
|
|
133
135
|
}
|
|
134
136
|
|
|
135
137
|
const allData = {
|
package/src/index.js
CHANGED
|
@@ -7,7 +7,8 @@ function Reports(config, axios) {
|
|
|
7
7
|
devices: new DevicesApi(config, null, axios),
|
|
8
8
|
groups: new GroupsApi(config, null, axios),
|
|
9
9
|
drivers: new DriversApi(config, null, axios),
|
|
10
|
-
geofences: new GeofencesApi(config, null, axios)
|
|
10
|
+
geofences: new GeofencesApi(config, null, axios),
|
|
11
|
+
axios: axios || require('axios').create(config.baseOptions)
|
|
11
12
|
}
|
|
12
13
|
this.getUserData = async () => {
|
|
13
14
|
return {
|
package/src/index.test.js
CHANGED
|
@@ -19,4 +19,22 @@ describe('speedingReport', function() {
|
|
|
19
19
|
console.log('report', report)
|
|
20
20
|
console.log(reports.kmsReportToExcel(userData, report[0]))
|
|
21
21
|
})
|
|
22
|
+
it('test allinone', async() => {
|
|
23
|
+
console.log('Start')
|
|
24
|
+
|
|
25
|
+
const reports = await getReports()
|
|
26
|
+
|
|
27
|
+
const r = await require("./util/traccar").getAllInOne(reports.traccar,
|
|
28
|
+
new Date(2022, 1, 2),
|
|
29
|
+
new Date(2022, 1, 3),
|
|
30
|
+
[{"id":22327}],
|
|
31
|
+
false,
|
|
32
|
+
true,
|
|
33
|
+
true,
|
|
34
|
+
false)
|
|
35
|
+
|
|
36
|
+
console.log(r)
|
|
37
|
+
|
|
38
|
+
console.log('End')
|
|
39
|
+
})
|
|
22
40
|
})
|
package/src/trip-report.js
CHANGED
|
@@ -47,9 +47,10 @@ async function createTripReportByDevice(from, to, userData, traccar) {
|
|
|
47
47
|
devices.sort((a, b) => (a.name > b.name) ? 1 : -1)
|
|
48
48
|
|
|
49
49
|
const devicesToSlice = devices.slice()
|
|
50
|
-
const
|
|
51
|
-
const
|
|
52
|
-
const
|
|
50
|
+
const allInOne = await traccarHelper.getAllInOne(traccar, from, to, devicesToSlice, true, true, true, false)
|
|
51
|
+
const tripsData = allInOne.trips
|
|
52
|
+
const stopsData = allInOne.stops
|
|
53
|
+
const routeData = allInOne.route
|
|
53
54
|
|
|
54
55
|
console.log('Trips:' + tripsData.length)
|
|
55
56
|
|
|
@@ -108,8 +109,9 @@ async function createTripReportByDriver(from, to, userData, traccar){
|
|
|
108
109
|
return { drivers:[] }
|
|
109
110
|
}
|
|
110
111
|
|
|
111
|
-
const
|
|
112
|
-
const
|
|
112
|
+
const allInOne = await traccarHelper.getAllInOne(traccar, from, to, devices, true, true, false, false)
|
|
113
|
+
const tripsData = allInOne.trips
|
|
114
|
+
const routeData = allInOne.route
|
|
113
115
|
|
|
114
116
|
return { drivers: processDrivers(from, to, userData, {trips: tripsData, route: routeData})}
|
|
115
117
|
}
|
package/src/util/traccar.js
CHANGED
|
@@ -11,6 +11,7 @@ async function getRoute(traccar, from, to, devices){
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
const result = await Promise.all(requests)
|
|
14
|
+
|
|
14
15
|
return result.map(r => r.data).flat()
|
|
15
16
|
}
|
|
16
17
|
|
|
@@ -65,8 +66,49 @@ async function getSummary(traccar, from, to, devices){
|
|
|
65
66
|
return result.map(r => r.data).flat()
|
|
66
67
|
}
|
|
67
68
|
|
|
69
|
+
async function getAllInOne(traccar, from, to, devices, getRoutes, getTrips, getStops, getSummary){
|
|
70
|
+
|
|
71
|
+
let url = `/reports/allinone?&from=${from.toISOString()}&to=${to.toISOString()}`
|
|
72
|
+
if(getRoutes) url += `&type=route`
|
|
73
|
+
if(getTrips) url += `&type=trips`
|
|
74
|
+
if(getStops) url += `&type=stops`
|
|
75
|
+
if(getSummary) url += `&type=summary`
|
|
76
|
+
|
|
77
|
+
const devicesToSlice = devices.slice()
|
|
78
|
+
const arrayOfArrays = automaticReports.sliceArray(devicesToSlice)
|
|
79
|
+
let requests = []
|
|
80
|
+
|
|
81
|
+
for (const a of arrayOfArrays) {
|
|
82
|
+
let sliceUrl = url
|
|
83
|
+
for(const d of a){
|
|
84
|
+
sliceUrl += `&deviceId=${d.id}`
|
|
85
|
+
}
|
|
86
|
+
const promise = traccar.axios.get(sliceUrl)
|
|
87
|
+
requests = requests.concat(promise)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const resultList = await Promise.all(requests)
|
|
91
|
+
|
|
92
|
+
const result = {
|
|
93
|
+
route : [],
|
|
94
|
+
trips : [],
|
|
95
|
+
stops : [],
|
|
96
|
+
summary : []
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
for(const r of resultList){
|
|
100
|
+
if(getRoutes) result.route = result.route.concat(r.data.route)
|
|
101
|
+
if(getTrips) result.trips = result.trips.concat(r.data.trips)
|
|
102
|
+
if(getStops) result.stops = result.stops.concat(r.data.stops)
|
|
103
|
+
if(getSummary) result.summary = result.summary.concat(r.data.summary)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return result
|
|
107
|
+
}
|
|
108
|
+
|
|
68
109
|
exports.getRoute = getRoute
|
|
69
110
|
exports.getTrips = getTrips
|
|
70
111
|
exports.getStops = getStops
|
|
71
112
|
exports.getEvents = getEvents
|
|
72
113
|
exports.getSummary = getSummary
|
|
114
|
+
exports.getAllInOne = getAllInOne
|
package/.idea/aws.xml
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<project version="4">
|
|
3
|
-
<component name="accountSettings">
|
|
4
|
-
<option name="activeProfile" value="profile:default" />
|
|
5
|
-
<option name="activeRegion" value="us-east-1" />
|
|
6
|
-
<option name="recentlyUsedProfiles">
|
|
7
|
-
<list>
|
|
8
|
-
<option value="profile:default" />
|
|
9
|
-
</list>
|
|
10
|
-
</option>
|
|
11
|
-
<option name="recentlyUsedRegions">
|
|
12
|
-
<list>
|
|
13
|
-
<option value="us-east-1" />
|
|
14
|
-
</list>
|
|
15
|
-
</option>
|
|
16
|
-
</component>
|
|
17
|
-
</project>
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<module type="JAVA_MODULE" version="4">
|
|
3
|
-
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
|
4
|
-
<exclude-output />
|
|
5
|
-
<content url="file://$MODULE_DIR$" />
|
|
6
|
-
<orderEntry type="inheritedJdk" />
|
|
7
|
-
<orderEntry type="sourceFolder" forTests="false" />
|
|
8
|
-
</component>
|
|
9
|
-
</module>
|
package/.idea/misc.xml
DELETED
package/.idea/modules.xml
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<project version="4">
|
|
3
|
-
<component name="ProjectModuleManager">
|
|
4
|
-
<modules>
|
|
5
|
-
<module fileurl="file://$PROJECT_DIR$/.idea/fleetmap-reports.iml" filepath="$PROJECT_DIR$/.idea/fleetmap-reports.iml" />
|
|
6
|
-
</modules>
|
|
7
|
-
</component>
|
|
8
|
-
</project>
|