fleetmap-reports 1.0.328 → 1.0.329

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/aws.xml ADDED
@@ -0,0 +1,17 @@
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>
@@ -0,0 +1,7 @@
1
+ <component name="ProjectCodeStyleConfiguration">
2
+ <code_scheme name="Project" version="173">
3
+ <ScalaCodeStyleSettings>
4
+ <option name="MULTILINE_STRING_CLOSING_QUOTES_ON_NEW_LINE" value="true" />
5
+ </ScalaCodeStyleSettings>
6
+ </code_scheme>
7
+ </component>
@@ -0,0 +1,5 @@
1
+ <component name="ProjectCodeStyleConfiguration">
2
+ <state>
3
+ <option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
4
+ </state>
5
+ </component>
@@ -0,0 +1,9 @@
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>
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="JavaScriptLibraryMappings">
4
+ <file url="file://$PROJECT_DIR$" libraries="{Node.js Core}" />
5
+ </component>
6
+ </project>
package/.idea/misc.xml ADDED
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectRootManager">
4
+ <output url="file://$PROJECT_DIR$/out" />
5
+ </component>
6
+ </project>
@@ -0,0 +1,8 @@
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>
package/.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="" vcs="Git" />
5
+ </component>
6
+ </project>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fleetmap-reports",
3
- "version": "1.0.328",
3
+ "version": "1.0.329",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -13,6 +13,7 @@
13
13
  "axios": "^0.21.1",
14
14
  "axios-cookiejar-support": "^1.0.1",
15
15
  "docx": "^7.3.0",
16
+ "eslint": "^8.8.0",
16
17
  "file-saver": "^2.0.5",
17
18
  "fleetmap-partners": "^1.0.42",
18
19
  "json-as-xlsx": "^1.2.1",
@@ -87,11 +87,10 @@ async function createActivityReportByDevice(from, to, userData, traccarInstance)
87
87
 
88
88
  let summaries = []
89
89
  let routeData = []
90
- const allInOne = await traccar.getAllInOne(traccarInstance, from, to, devicesToProcess, userData.groupByDay && !userData.allWeek, true, false, !userData.groupByDay)
91
- const tripsData = allInOne.trips
90
+ const tripsData = await traccar.getTrips(traccarInstance, from, to, devicesToProcess)
92
91
 
93
92
  if(userData.groupByDay) {
94
- routeData = allInOne.route
93
+ routeData = userData.allWeek ? [] : await traccar.getRoute(traccarInstance, from, to, devicesToProcess)
95
94
  console.log('trips:' + tripsData.length)
96
95
 
97
96
  if (tripsData.length > 0) {
@@ -110,7 +109,7 @@ async function createActivityReportByDevice(from, to, userData, traccarInstance)
110
109
  }
111
110
  }
112
111
  } else {
113
- summaries = allInOne.summary
112
+ summaries = await traccar.getSummary(traccarInstance, from, to, devicesToProcess)
114
113
  }
115
114
 
116
115
  console.log('Summary:' + summaries.length)
@@ -129,9 +128,8 @@ async function createActivityReportByDriver(from, to, userData, traccarInstance)
129
128
  let tripsData = []
130
129
  let routeData = []
131
130
  if(devices.length > 0) {
132
- const allInOne = await traccar.getAllInOne(traccarInstance, from, to, devices, true, true, false, false)
133
- tripsData = allInOne.trips
134
- routeData = allInOne.route
131
+ tripsData = await traccar.getTrips(traccarInstance, from, to, devices)
132
+ routeData = await traccar.getRoute(traccarInstance, from, to, devices)
135
133
  }
136
134
 
137
135
  const allData = {
package/src/index.js CHANGED
@@ -7,8 +7,7 @@ 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),
11
- basic: {config:config, axios:axios}
10
+ geofences: new GeofencesApi(config, null, axios)
12
11
  }
13
12
  this.getUserData = async () => {
14
13
  return {
package/src/index.test.js CHANGED
@@ -17,24 +17,6 @@ describe('speedingReport', function() {
17
17
  const report = await reports.kmsReport(new Date(2021, 9, 30), new Date(2021, 10),
18
18
  userData)
19
19
  console.log('report', report)
20
- //console.log(reports.kmsReportToExcel(userData, report[0]))
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')
20
+ console.log(reports.kmsReportToExcel(userData, report[0]))
39
21
  })
40
22
  })
package/src/kms-report.js CHANGED
@@ -9,7 +9,6 @@ const {getDates, convertFromUTC} = require("./util/utils")
9
9
  const trips = require("./util/trips")
10
10
  const drivers = require("./util/driver")
11
11
  const { isInsideTimetable, isPartialInsideTimetable} = require("./util/trips")
12
- const word = require("./word");
13
12
 
14
13
  const fileName = 'KmsReport'
15
14
 
@@ -431,4 +430,3 @@ function exportKmsReportToExcel(userData, reportData) {
431
430
  exports.createKmsReport = createKmsReport
432
431
  exports.exportKmsReportToPDF = exportKmsReportToPDF
433
432
  exports.exportKmsReportToExcel = exportKmsReportToExcel
434
- exports.exportKmsReportToWord = word.exportKmsReportToWord
@@ -47,10 +47,9 @@ 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 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
50
+ const tripsData = await traccarHelper.getTrips(traccar, from, to, devicesToSlice)
51
+ const stopsData = await traccarHelper.getStops(traccar, from, to, devicesToSlice)
52
+ const routeData = await traccarHelper.getRoute(traccar, from, to, devicesToSlice)
54
53
 
55
54
  console.log('Trips:' + tripsData.length)
56
55
 
@@ -109,9 +108,8 @@ async function createTripReportByDriver(from, to, userData, traccar){
109
108
  return { drivers:[] }
110
109
  }
111
110
 
112
- const allInOne = await traccarHelper.getAllInOne(traccar, from, to, devices, true, true, false, false)
113
- const tripsData = allInOne.trips
114
- const routeData = allInOne.route
111
+ const tripsData = await traccarHelper.getTrips(traccar, from, to, devices)
112
+ const routeData = await traccarHelper.getRoute(traccar, from, to, devices)
115
113
 
116
114
  return { drivers: processDrivers(from, to, userData, {trips: tripsData, route: routeData})}
117
115
  }
@@ -11,7 +11,6 @@ async function getRoute(traccar, from, to, devices){
11
11
  }
12
12
 
13
13
  const result = await Promise.all(requests)
14
-
15
14
  return result.map(r => r.data).flat()
16
15
  }
17
16
 
@@ -66,49 +65,8 @@ async function getSummary(traccar, from, to, devices){
66
65
  return result.map(r => r.data).flat()
67
66
  }
68
67
 
69
- async function getAllInOne(traccar, from, to, devices, getRoutes, getTrips, getStops, getSummary){
70
-
71
- let url = `${traccar.basic.config.basePath}/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.basic.axios.get(sliceUrl, traccar.basic.config.baseOptions)
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
-
109
68
  exports.getRoute = getRoute
110
69
  exports.getTrips = getTrips
111
70
  exports.getStops = getStops
112
71
  exports.getEvents = getEvents
113
72
  exports.getSummary = getSummary
114
- exports.getAllInOne = getAllInOne