fleetmap-reports 1.0.284 → 1.0.288
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/jsLibraryMappings.xml +1 -1
- package/.idea/modules.xml +1 -1
- package/.idea/vcs.xml +1 -1
- package/{.idea/fleetmap-reports.iml → fleetmap-reports.iml} +1 -2
- package/lang/enGB.js +1 -11
- package/lang/esCL.js +1 -10
- package/lang/index.js +1 -4
- package/lang/ptBR.js +1 -11
- package/lang/ptPT.js +1 -11
- package/package.json +1 -2
- package/src/activity-report.js +206 -542
- package/src/automaticReports.js +1 -1
- package/src/events-report.js +21 -25
- package/src/here.js +1 -1
- package/src/index.js +2 -12
- package/src/index.test.js +25 -18
- package/src/kms-report.js +103 -409
- package/src/location-report.js +18 -22
- package/src/refueling-report.js +1 -11
- package/src/reportStyle.js +0 -26
- package/src/speeding-report.js +180 -239
- package/src/trip-report.js +159 -152
- package/src/util/driver.js +13 -5
- package/src/util/utils.js +1 -67
- package/src/zone-report.js +23 -22
- package/.idea/aws.xml +0 -17
- package/.idea/codeStyles/Project.xml +0 -7
- package/src/idle-report.js +0 -285
- package/src/tests/index.js +0 -22
- package/src/util/pdfDocument.js +0 -58
- package/src/util/traccar.js +0 -72
- package/src/util/trips.js +0 -76
package/src/automaticReports.js
CHANGED
|
@@ -3,7 +3,7 @@ const moment = require('moment')
|
|
|
3
3
|
function sliceArray(longArray) {
|
|
4
4
|
const arrayToSlice = longArray.slice()
|
|
5
5
|
|
|
6
|
-
const size =
|
|
6
|
+
const size = 200
|
|
7
7
|
const arrayOfArrays = []
|
|
8
8
|
for (let i=0; i<arrayToSlice.length; i+=size) {
|
|
9
9
|
arrayOfArrays.push(arrayToSlice.slice(i,i+size));
|
package/src/events-report.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
const automaticReports = require("./automaticReports")
|
|
2
2
|
const messages = require('../lang')
|
|
3
3
|
const jsPDF = require('jspdf')
|
|
4
|
-
require('jspdf-autotable')
|
|
5
|
-
const
|
|
6
|
-
const {headerFromUser} = require("./util/pdfDocument");
|
|
7
|
-
const {getUserPartner} = require("fleetmap-partners");
|
|
8
|
-
const {convertToLocaleString} = require("./util/utils");
|
|
4
|
+
const autotable = require('jspdf-autotable')
|
|
5
|
+
const reportStyle = require("./reportStyle")
|
|
9
6
|
|
|
10
7
|
const fileName = 'EventReport'
|
|
11
8
|
|
|
@@ -117,11 +114,10 @@ async function processDevices(from, to, devices, geofences, drivers, data) {
|
|
|
117
114
|
return devicesResult
|
|
118
115
|
}
|
|
119
116
|
|
|
120
|
-
|
|
117
|
+
function exportSpeedingReportToPDF(userData, reportData) {
|
|
121
118
|
console.log('Export to PDF')
|
|
122
119
|
|
|
123
120
|
const lang = userData.user.attributes.lang
|
|
124
|
-
const timezone = userData.user.attributes.timezone
|
|
125
121
|
const translations = messages[lang] ? messages[lang] : messages['en-GB']
|
|
126
122
|
|
|
127
123
|
const headers = [
|
|
@@ -133,7 +129,8 @@ async function exportSpeedingReportToPDF(userData, reportData) {
|
|
|
133
129
|
if (reportData.devices) {
|
|
134
130
|
let first = true
|
|
135
131
|
const doc = new jsPDF.jsPDF('l');
|
|
136
|
-
|
|
132
|
+
doc.setFontSize(14)
|
|
133
|
+
doc.text(translations.report.titleEventsReport, 15, 15 )
|
|
137
134
|
|
|
138
135
|
reportData.devices.forEach(d => {
|
|
139
136
|
let data = []
|
|
@@ -147,11 +144,12 @@ async function exportSpeedingReportToPDF(userData, reportData) {
|
|
|
147
144
|
first = false
|
|
148
145
|
space = 10
|
|
149
146
|
}
|
|
150
|
-
doc.setFontSize(
|
|
147
|
+
doc.setFontSize(12)
|
|
148
|
+
|
|
151
149
|
doc.text(name, 20, space+20 )
|
|
152
|
-
doc.setFontSize(
|
|
150
|
+
doc.setFontSize(10)
|
|
153
151
|
doc.text(group, 200, space+20 )
|
|
154
|
-
doc.text(
|
|
152
|
+
doc.text(new Date(d.from).toLocaleString() + ' - ' + new Date(d.to).toLocaleString(), 20, space+25 )
|
|
155
153
|
|
|
156
154
|
doc.autoTable(['','','','',''], [
|
|
157
155
|
[translations.report.event_ignitionOn,translations.report.event_ignitionOff, translations.report.event_geofenceEnter,
|
|
@@ -160,10 +158,9 @@ async function exportSpeedingReportToPDF(userData, reportData) {
|
|
|
160
158
|
d.alerts.filter(a => a.type === 'geofenceEnter').length,d.alerts.filter(a => a.type === 'geofenceExit').length,
|
|
161
159
|
d.alerts.filter(a => a.type === 'deviceOverspeed').length],
|
|
162
160
|
[translations.report.event_driverChanged,translations.report.event_powerOn, translations.report.event_sos,
|
|
163
|
-
translations.report.event_deviceFuelDrop
|
|
161
|
+
translations.report.event_deviceFuelDrop],
|
|
164
162
|
[d.alerts.filter(a => a.type === 'driverChanged').length,d.alerts.filter(a => a.type === 'powerOn').length,
|
|
165
|
-
d.alerts.filter(a => a.type === 'sos').length,d.alerts.filter(a => a.type === 'deviceFuelDrop').length
|
|
166
|
-
d.alerts.filter(a => a.type === 'powerCut').length]
|
|
163
|
+
d.alerts.filter(a => a.type === 'sos').length,d.alerts.filter(a => a.type === 'deviceFuelDrop').length]
|
|
167
164
|
], { startY: space+30 , showHead: false, bodyStyles: { fillColor: [256, 256, 256], textColor: [30, 30, 30], halign: 'center', valign: 'middle' } , alternateRowStyles: {fillColor: [256, 256, 256], valign: 'bottom'}});
|
|
168
165
|
|
|
169
166
|
d.alerts.map(a => {
|
|
@@ -181,26 +178,22 @@ async function exportSpeedingReportToPDF(userData, reportData) {
|
|
|
181
178
|
'','',''
|
|
182
179
|
]
|
|
183
180
|
|
|
184
|
-
const style = getStyle(getUserPartner(userData.user))
|
|
185
181
|
doc.autoTable({
|
|
186
182
|
head: [headers],
|
|
187
183
|
body: data,
|
|
188
184
|
foot: [footValues],
|
|
189
185
|
showFoot: 'lastPage',
|
|
190
186
|
headStyles: {
|
|
191
|
-
fillColor:
|
|
192
|
-
textColor:
|
|
193
|
-
fontSize: 10
|
|
187
|
+
fillColor: reportStyle.pdfHeaderColor,
|
|
188
|
+
textColor: reportStyle.pdfHeaderTextColor
|
|
194
189
|
},
|
|
195
190
|
bodyStyles: {
|
|
196
|
-
fillColor:
|
|
197
|
-
textColor:
|
|
198
|
-
fontSize: 8
|
|
191
|
+
fillColor: reportStyle.pdfBodyColor,
|
|
192
|
+
textColor: reportStyle.pdfBodyTextColor
|
|
199
193
|
},
|
|
200
194
|
footStyles: {
|
|
201
|
-
fillColor:
|
|
202
|
-
textColor:
|
|
203
|
-
fontSize: 9
|
|
195
|
+
fillColor: reportStyle.pdfFooterColor,
|
|
196
|
+
textColor: reportStyle.pdfFooterTextColor
|
|
204
197
|
},
|
|
205
198
|
startY: space + 65
|
|
206
199
|
})
|
|
@@ -272,7 +265,10 @@ function getAlertInfo(drivers, alert) {
|
|
|
272
265
|
|
|
273
266
|
function getAlertDate(user, alert) {
|
|
274
267
|
if(alert.position) {
|
|
275
|
-
return
|
|
268
|
+
return new Date(alert.position.fixTime).toLocaleString(user.attributes.lang, {
|
|
269
|
+
timeZone: user.attributes.timezone,
|
|
270
|
+
hour12: false
|
|
271
|
+
})
|
|
276
272
|
}
|
|
277
273
|
}
|
|
278
274
|
|
package/src/here.js
CHANGED
|
@@ -97,10 +97,10 @@ function fillGeocoding(rows) {
|
|
|
97
97
|
}*/
|
|
98
98
|
|
|
99
99
|
exports.routeMatch = async (rows) => {
|
|
100
|
-
console.log('here sending', rows.length)
|
|
101
100
|
const csv = generateCSV(rows)
|
|
102
101
|
const response = await axios.post(calcRoute, csv, { headers: { 'Content-Type': 'application/binary' }})
|
|
103
102
|
const hereData = response.data
|
|
103
|
+
console.dir(hereData, {depth: null})
|
|
104
104
|
const route = hereData.response.route[0]
|
|
105
105
|
const results = []
|
|
106
106
|
const wayPoints = route.waypoint
|
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, roadSpeedLimits) => {
|
|
23
|
+
return require('./speeding-report').createSpeedingReport(from, to, userData, this.traccar, roadSpeedLimits)
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
this.speedingReportToPDF = (userData, reportData) => {
|
|
@@ -124,16 +124,6 @@ function Reports(config, axios) {
|
|
|
124
124
|
this.vistaWasteActivityReportToExcel = (userData, reportData) => {
|
|
125
125
|
return require('./custom/vistawasteActivity-report').exportVistaWasteActivityReportToExcel(userData, reportData)
|
|
126
126
|
}
|
|
127
|
-
|
|
128
|
-
this.idleReport = (from, to, userData) => {
|
|
129
|
-
return require('./idle-report').createIdleReport(from, to, userData, this.traccar)
|
|
130
|
-
}
|
|
131
|
-
this.idleReportToPDF = (userData, reportData) => {
|
|
132
|
-
return require('./idle-report').exportIdleReportToPDF(userData, reportData)
|
|
133
|
-
}
|
|
134
|
-
this.idleReportToExcel = (userData, reportData) => {
|
|
135
|
-
return require('./idle-report').exportIdleReportToExcel(userData, reportData)
|
|
136
|
-
}
|
|
137
127
|
}
|
|
138
128
|
module.exports = Reports
|
|
139
129
|
|
package/src/index.test.js
CHANGED
|
@@ -1,20 +1,27 @@
|
|
|
1
|
-
const
|
|
1
|
+
const Index = require('./index')
|
|
2
|
+
const {SessionApi} = require("traccar-api");
|
|
3
|
+
const axios = require('axios')
|
|
4
|
+
const axiosCookieJarSupport = require('axios-cookiejar-support').default;
|
|
5
|
+
const tough = require('tough-cookie');
|
|
6
|
+
const cookieJar = new tough.CookieJar();
|
|
2
7
|
|
|
3
|
-
|
|
4
|
-
this.timeout(500000)
|
|
5
|
-
it('test speeding', async () => {
|
|
6
|
-
const report = await getReports()
|
|
7
|
-
const userData = await report.getUserData()
|
|
8
|
+
axiosCookieJarSupport(axios)
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
10
|
+
test('speedingReport', async () => {
|
|
11
|
+
const traccarConfig = {
|
|
12
|
+
basePath: 'https://api.pinme.io/api',
|
|
13
|
+
baseOptions: {
|
|
14
|
+
withCredentials: true,
|
|
15
|
+
jar: cookieJar
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
await new SessionApi(traccarConfig, null, axios).sessionPost('-','-')
|
|
20
|
+
const report = new Index(traccarConfig, axios)
|
|
21
|
+
const userData = await report.getUserData()
|
|
22
|
+
|
|
23
|
+
await report.speedingReport(new Date(2021, 2, 30, 0, 0, 0, 0),
|
|
24
|
+
new Date(2021, 2, 30, 23, 59, 59, 0),
|
|
25
|
+
userData)
|
|
26
|
+
|
|
27
|
+
}, 10000)
|