fleetmap-reports 1.0.982 → 1.0.984
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/index.js +0 -21
- package/src/kms-report.js +30 -15
- package/src/partnerReports/dailyuse-report.js +1 -73
- package/src/speeding-report.js +4 -7
- package/src/tests/speeding.test.js +46 -0
- package/src/tests/zones.test.js +0 -11
- package/src/util/utils.js +11 -0
- package/RapportPerformance.xlsx +0 -0
- package/src/partnerReports/delayedstart-report.js +0 -69
- package/src/partnerReports/passenger-report.js +0 -46
- package/src/temperature-report.js +0 -11
- package/src/tests/dailyuse.test.js +0 -19
- package/src/tests/gpsjump.test.js +0 -23
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -19,7 +19,6 @@ function Reports (config, axios, cookieJar) {
|
|
|
19
19
|
drivers: await this.traccar.drivers.driversGet().then(d => d.data),
|
|
20
20
|
geofences: await this.traccar.geofences.geofencesGet().then(d => d.data),
|
|
21
21
|
byGroup: false,
|
|
22
|
-
allWeek: true,
|
|
23
22
|
dayHours: { startTime: '00:00', endTime: '23:59' }
|
|
24
23
|
}
|
|
25
24
|
}
|
|
@@ -184,25 +183,5 @@ function Reports (config, axios, cookieJar) {
|
|
|
184
183
|
this.stopReportToExcel = (userData, reportData) => {
|
|
185
184
|
return require('./stop-report').exportStopReportToExcel(userData, reportData)
|
|
186
185
|
}
|
|
187
|
-
|
|
188
|
-
this.performanceReport = (from, to, userData) => {
|
|
189
|
-
return require('./partnerReports/performance-report').createPerformanceReport(from, to, userData, this.traccar)
|
|
190
|
-
}
|
|
191
|
-
this.performanceReportToPDF = (userData, reportData) => {
|
|
192
|
-
return require('./partnerReports/performance-report').exportPerformanceReportToPDF(userData, reportData)
|
|
193
|
-
}
|
|
194
|
-
this.performanceReportToExcel = (userData, reportData) => {
|
|
195
|
-
return require('./partnerReports/performance-report').exportPerformanceReportToExcel(userData, reportData)
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
this.dailyUseReport = (from, to, userData) => {
|
|
199
|
-
return require('./partnerReports/dailyuse-report').createDailyUseReport(from, to, userData, this.traccar)
|
|
200
|
-
}
|
|
201
|
-
this.dailyUseReportToPDF = (userData, reportData) => {
|
|
202
|
-
return require('./partnerReports/dailyuse-report').exportDailyUseReportToPDF(userData, reportData)
|
|
203
|
-
}
|
|
204
|
-
this.dailyUseReportToExcel = (userData, reportData) => {
|
|
205
|
-
return require('./partnerReports/dailyuse-report').exportDailyUseReportToExcel(userData, reportData)
|
|
206
|
-
}
|
|
207
186
|
}
|
|
208
187
|
module.exports = Reports
|
package/src/kms-report.js
CHANGED
|
@@ -10,9 +10,8 @@ const traccar = require('./util/traccar')
|
|
|
10
10
|
const { getDates, getTranslations, isClientSide, executeServerSide } = require('./util/utils')
|
|
11
11
|
const drivers = require('./util/driver')
|
|
12
12
|
const { isInsideTimetable, isPartialInsideTimetable, calculateTrip, getDataByDay, checkTripsKms, getKms } = require('./util/trips')
|
|
13
|
-
const traccarHelper = require('./util/traccar')
|
|
14
13
|
const { devicesToProcess } = require('./util/device')
|
|
15
|
-
const { getDriverData } = require('./util/driver')
|
|
14
|
+
const { getDriverData, reportByDriver } = require('./util/driver')
|
|
16
15
|
const automaticReports = require('./automaticReports')
|
|
17
16
|
const { getSummaryByDay } = require('./util/traccar')
|
|
18
17
|
|
|
@@ -56,12 +55,14 @@ async function createKmsReportByDevice (from, to, userData, traccarInstance) {
|
|
|
56
55
|
dates.forEach(date => {
|
|
57
56
|
const summaryByDay = summary.find(a => a.date === date).summary
|
|
58
57
|
const summaryByDevice = summaryByDay.find(a => a.deviceId === device.id)
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
58
|
+
if (summaryByDevice) {
|
|
59
|
+
days.push({
|
|
60
|
+
date,
|
|
61
|
+
kms: summaryByDevice.distance,
|
|
62
|
+
startOdometer: summaryByDevice.startOdometer,
|
|
63
|
+
endOdometer: summaryByDevice.endOdometer
|
|
64
|
+
})
|
|
65
|
+
}
|
|
65
66
|
})
|
|
66
67
|
const daysWithOdometer = days.filter(a => a.startOdometer > 0)
|
|
67
68
|
allData.devices.push({
|
|
@@ -100,16 +101,30 @@ async function createKmsReportByDevice (from, to, userData, traccarInstance) {
|
|
|
100
101
|
|
|
101
102
|
async function createKmsReportByDriver (from, to, userData, traccarInstance) {
|
|
102
103
|
const devices = await drivers.devicesByDriver(traccarInstance, from, to, userData.drivers, userData.devices)
|
|
103
|
-
console.log(devices.length)
|
|
104
104
|
|
|
105
|
-
|
|
106
|
-
// empty report
|
|
107
|
-
return { drivers: [] }
|
|
108
|
-
}
|
|
105
|
+
const results = await reportByDriver(devices, traccarInstance, from, to, userData, processDrivers)
|
|
109
106
|
|
|
110
|
-
const
|
|
107
|
+
const report = { drivers: [] }
|
|
108
|
+
|
|
109
|
+
results.drivers.forEach(result => {
|
|
110
|
+
const driver = report.drivers.find(d => d.driver.id === result.driver.id)
|
|
111
|
+
if (driver) {
|
|
112
|
+
if (userData.groupByDay) {
|
|
113
|
+
driver.days.forEach(day => {
|
|
114
|
+
const resultDay = result.days.find(d => d.date === day.date)
|
|
115
|
+
if (resultDay) {
|
|
116
|
+
day.kms = day.kms + resultDay.kms
|
|
117
|
+
}
|
|
118
|
+
})
|
|
119
|
+
} else {
|
|
120
|
+
driver.summary.distance = driver.summary.distance + result.summary.distance
|
|
121
|
+
}
|
|
122
|
+
} else {
|
|
123
|
+
report.drivers.push(result)
|
|
124
|
+
}
|
|
125
|
+
})
|
|
111
126
|
|
|
112
|
-
return
|
|
127
|
+
return report
|
|
113
128
|
}
|
|
114
129
|
|
|
115
130
|
async function createKmsReportByGroup (from, to, userData, traccarInstance) {
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
const traccarHelper = require('../util/traccar')
|
|
2
2
|
const { isInsideTimetable } = require('../util/trips')
|
|
3
|
-
const { convertFromUTCDate
|
|
3
|
+
const { convertFromUTCDate } = require('../util/utils')
|
|
4
4
|
const automaticReports = require('../automaticReports')
|
|
5
|
-
const jsPDF = require('jspdf')
|
|
6
|
-
const { getStyle } = require('../reportStyle')
|
|
7
|
-
const { getUserPartner } = require('fleetmap-partners')
|
|
8
|
-
const { addTable, headerFromUser } = require('../util/pdfDocument')
|
|
9
5
|
|
|
10
6
|
async function createDailyUseReport (from, to, userData, traccar) {
|
|
11
7
|
const reportData = []
|
|
@@ -81,72 +77,4 @@ function processDeviceData (allInOne, d, userData) {
|
|
|
81
77
|
}
|
|
82
78
|
}
|
|
83
79
|
|
|
84
|
-
async function exportDailyUseReportToPDF (userData, reportData) {
|
|
85
|
-
const translations = getTranslations(userData)
|
|
86
|
-
const timezone = userData.user.attributes.timezone
|
|
87
|
-
const lang = userData.user.attributes.lang || (isClientSide() && navigator.language)
|
|
88
|
-
|
|
89
|
-
const headers = [
|
|
90
|
-
translations.report.vehicle,
|
|
91
|
-
'Immatriculation',
|
|
92
|
-
'Groupe',
|
|
93
|
-
'Matin départ',
|
|
94
|
-
'Matin arrêt',
|
|
95
|
-
'Matin temps',
|
|
96
|
-
'Déjeuner',
|
|
97
|
-
'Après-midi départ',
|
|
98
|
-
'Après-midi arrêt',
|
|
99
|
-
'Après-midi temps',
|
|
100
|
-
'Total temps',
|
|
101
|
-
'Total conduit',
|
|
102
|
-
'Total arrêts',
|
|
103
|
-
'Total kms'
|
|
104
|
-
]
|
|
105
|
-
|
|
106
|
-
const data = []
|
|
107
|
-
reportData.forEach(d => {
|
|
108
|
-
const row = [
|
|
109
|
-
d.device,
|
|
110
|
-
d.licensePlate,
|
|
111
|
-
d.group,
|
|
112
|
-
convertToLocaleTimeString(d.morningStart, lang, timezone, userData.user),
|
|
113
|
-
convertToLocaleTimeString(d.morningEnd, lang, timezone, userData.user),
|
|
114
|
-
convertMS(d.morningTime),
|
|
115
|
-
convertMS(d.lunch),
|
|
116
|
-
convertToLocaleTimeString(d.afternoonStart, lang, timezone, userData.user),
|
|
117
|
-
convertToLocaleTimeString(d.afternoonEnd, lang, timezone, userData.user),
|
|
118
|
-
convertMS(d.afternoonTime),
|
|
119
|
-
convertMS(d.totalTime),
|
|
120
|
-
convertMS(d.totalDrivingTime),
|
|
121
|
-
d.totalStops,
|
|
122
|
-
(d.totalDistance / 100).toFixed(1)
|
|
123
|
-
]
|
|
124
|
-
data.push(row)
|
|
125
|
-
})
|
|
126
|
-
|
|
127
|
-
const doc = new jsPDF.jsPDF('l')
|
|
128
|
-
await headerFromUser(doc, 'Rapport de Performance', userData.user)
|
|
129
|
-
const style = getStyle(getUserPartner(userData.user))
|
|
130
|
-
|
|
131
|
-
const footValues = []
|
|
132
|
-
|
|
133
|
-
doc.setFontSize(11)
|
|
134
|
-
doc.text(new Date(userData.from).toLocaleString() + ' - ' + new Date(userData.to).toLocaleString(), 20, 33)
|
|
135
|
-
|
|
136
|
-
style.headerFontSize = 8
|
|
137
|
-
style.bodyFontSize = 7
|
|
138
|
-
const columnStyles = {}
|
|
139
|
-
for (let i = 3; i < 14; i++) {
|
|
140
|
-
columnStyles[i] = { halign: 'right' }
|
|
141
|
-
}
|
|
142
|
-
addTable(doc, headers, data, footValues, style, 40, columnStyles)
|
|
143
|
-
return doc
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
function exportDailyUseReportToExcel (userData, reportData) {
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
|
|
150
80
|
exports.createDailyUseReport = createDailyUseReport
|
|
151
|
-
exports.exportDailyUseReportToPDF = exportDailyUseReportToPDF
|
|
152
|
-
exports.exportDailyUseReportToExcel = exportDailyUseReportToExcel
|
package/src/speeding-report.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
const jsPDF = require('jspdf')
|
|
2
|
-
const {
|
|
2
|
+
const {
|
|
3
|
+
convertMS, convertToLocaleString, convertToFeature, convertPositionToFeature, getTranslations, getLanguage,
|
|
4
|
+
getCountry
|
|
5
|
+
} = require('./util/utils')
|
|
3
6
|
const { headerFromUser, AmiriRegular } = require('./util/pdfDocument')
|
|
4
7
|
require('jspdf-autotable')
|
|
5
8
|
const { getStyle } = require('./reportStyle')
|
|
@@ -15,7 +18,6 @@ const booleanPointInPolygon = require('@turf/boolean-point-in-polygon')
|
|
|
15
18
|
const automaticReports = require('./automaticReports')
|
|
16
19
|
const { default: axios } = require('axios')
|
|
17
20
|
const { getDriverName, getDriverData } = require('./util/driver')
|
|
18
|
-
const crg = require('country-reverse-geocoding').country_reverse_geocoding()
|
|
19
21
|
|
|
20
22
|
const fileName = 'SpeedingReport'
|
|
21
23
|
const eventTypes = ['deviceOverspeed']
|
|
@@ -299,11 +301,6 @@ async function getCustomSpeedLimitEvents (devices, routes, customSpeed) {
|
|
|
299
301
|
return events
|
|
300
302
|
}
|
|
301
303
|
|
|
302
|
-
function getCountry (position) {
|
|
303
|
-
const country = crg.get_country(position.latitude, position.longitude)
|
|
304
|
-
return country && country.code
|
|
305
|
-
}
|
|
306
|
-
|
|
307
304
|
async function getRoadSpeedLimits (devices, routes, threshold, minimumMinutes = 0) {
|
|
308
305
|
const position = routes.find(p => getCountry(p))
|
|
309
306
|
const country = position && getCountry(position)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const { getReports } = require('./index')
|
|
2
2
|
const assert = require('assert')
|
|
3
|
+
const { getCountry } = require('../util/utils')
|
|
3
4
|
|
|
4
5
|
async function getSpeedingReport (report, userData) {
|
|
5
6
|
const data = await report.speedingReport(
|
|
@@ -61,4 +62,49 @@ describe('speeding tests', function () {
|
|
|
61
62
|
assert.equal(totalDistance, 46.64576895855739) // Total Kms
|
|
62
63
|
assert.equal(totalEventTime, 1402000) // Total Duration
|
|
63
64
|
}, 999990000)
|
|
65
|
+
|
|
66
|
+
// eslint-disable-next-line no-undef
|
|
67
|
+
it('detects brazil', () => {
|
|
68
|
+
const p = {
|
|
69
|
+
id: 24088423790,
|
|
70
|
+
attributes: {
|
|
71
|
+
door: false,
|
|
72
|
+
hours: 2520745000,
|
|
73
|
+
motion: false,
|
|
74
|
+
distance: 0,
|
|
75
|
+
odometer: 5973617,
|
|
76
|
+
sat: 17,
|
|
77
|
+
battery: 4.03,
|
|
78
|
+
hdop: 0.7,
|
|
79
|
+
idleTime: 0,
|
|
80
|
+
output: 0,
|
|
81
|
+
input: 0,
|
|
82
|
+
driverUniqueId: '',
|
|
83
|
+
power: 12.61,
|
|
84
|
+
event: 0,
|
|
85
|
+
totalDistance: 31419705.27,
|
|
86
|
+
ignition: false,
|
|
87
|
+
adc3: 0,
|
|
88
|
+
adc2: 0,
|
|
89
|
+
status: 61,
|
|
90
|
+
tripTime: 0
|
|
91
|
+
},
|
|
92
|
+
deviceId: 28097,
|
|
93
|
+
type: null,
|
|
94
|
+
protocol: 'startek',
|
|
95
|
+
serverTime: '2024-01-20T03:01:50.000+00:00',
|
|
96
|
+
deviceTime: '2024-01-20T03:01:50.000+00:00',
|
|
97
|
+
fixTime: '2024-01-20T03:01:50.000+00:00',
|
|
98
|
+
outdated: false,
|
|
99
|
+
valid: true,
|
|
100
|
+
latitude: -22.295906,
|
|
101
|
+
longitude: -48.576135,
|
|
102
|
+
altitude: 579,
|
|
103
|
+
speed: 0,
|
|
104
|
+
course: 80,
|
|
105
|
+
address: 'Avenida Deputado Zien Nassif, 938, Vila Industrial, Jaú - SP, 17204-212, Brazil',
|
|
106
|
+
accuracy: 0
|
|
107
|
+
}
|
|
108
|
+
assert.equal('BRA', getCountry(p))
|
|
109
|
+
})
|
|
64
110
|
})
|
package/src/tests/zones.test.js
CHANGED
|
@@ -27,17 +27,6 @@ describe('zones', function () {
|
|
|
27
27
|
console.log('result', result)
|
|
28
28
|
}, 4000000)
|
|
29
29
|
|
|
30
|
-
it('trips between geofences', async () => {
|
|
31
|
-
const report = await getReports(process.env.USER_MOVIFLOTTE, process.env.PASS_MOVIFLOTTE)
|
|
32
|
-
const userData = await report.getUserData()
|
|
33
|
-
userData.tripsBetweenZones = true
|
|
34
|
-
const result = await report.zoneReport(
|
|
35
|
-
new Date(Date.UTC(2024, 0, 8, 0, 0, 0, 0)),
|
|
36
|
-
new Date(Date.UTC(2024, 0, 8, 23, 59, 59, 0)),
|
|
37
|
-
userData)
|
|
38
|
-
console.log('result', result)
|
|
39
|
-
}, 4000000)
|
|
40
|
-
|
|
41
30
|
// eslint-disable-next-line no-undef
|
|
42
31
|
it('works with casais', async () => {
|
|
43
32
|
const report = await getReports(process.env.USER_CASAIS, process.env.PASS_CASAIS)
|
package/src/util/utils.js
CHANGED
|
@@ -298,3 +298,14 @@ exports.getLogoUrl = getLogoUrl
|
|
|
298
298
|
exports.convertFromUTCDate = (value, user) => {
|
|
299
299
|
return convertFromUTC(value, user.attributes.timezone || getUserPartner(user).timezone)
|
|
300
300
|
}
|
|
301
|
+
|
|
302
|
+
const crg = require('country-reverse-geocoding').country_reverse_geocoding()
|
|
303
|
+
|
|
304
|
+
exports.getCountry = (position) => {
|
|
305
|
+
const country = crg.get_country(position.latitude, position.longitude)
|
|
306
|
+
if (!country) {
|
|
307
|
+
const country = position && position.attributes.address && position.attributes.address.split(',').slice(-1)[0].trim()
|
|
308
|
+
return { Brazil: 'BRA' }[country]
|
|
309
|
+
}
|
|
310
|
+
return country && country.code
|
|
311
|
+
}
|
package/RapportPerformance.xlsx
DELETED
|
Binary file
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
const automaticReports = require('../automaticReports')
|
|
2
|
-
const traccarHelper = require('../util/traccar')
|
|
3
|
-
const { getDates, getTranslations } = require('../util/utils')
|
|
4
|
-
const { getUserPartner } = require('fleetmap-partners')
|
|
5
|
-
const { getDataByDay } = require('../util/trips')
|
|
6
|
-
|
|
7
|
-
async function createDelayedStartReport (from, to, userData, traccar) {
|
|
8
|
-
const reportData = []
|
|
9
|
-
|
|
10
|
-
const devices = userData.devices
|
|
11
|
-
|
|
12
|
-
const sliced = automaticReports.sliceArray(devices, 5)
|
|
13
|
-
let deviceCount = 0
|
|
14
|
-
for (const slice of sliced) {
|
|
15
|
-
const allInOne = await traccarHelper.getAllInOne(traccar, from, to, slice, false, true, true, false, deviceCount, devices.length)
|
|
16
|
-
|
|
17
|
-
for (const d of slice) {
|
|
18
|
-
const deviceData = await processDeviceData(from, to, allInOne, d, userData, traccar)
|
|
19
|
-
reportData.push(deviceData)
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
deviceCount = deviceCount + slice.length
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return reportData
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
async function processDeviceData (from, to, allInOne, d, userData, traccar) {
|
|
29
|
-
const group = userData.groups.find(g => g.id === d.groupId)
|
|
30
|
-
const trips = allInOne.trips.filter(t => t.deviceId === d.id)
|
|
31
|
-
const translations = getTranslations(userData)
|
|
32
|
-
|
|
33
|
-
const weekDays = [
|
|
34
|
-
translations.report.sunday,
|
|
35
|
-
translations.report.monday,
|
|
36
|
-
translations.report.tuesday,
|
|
37
|
-
translations.report.wednesday,
|
|
38
|
-
translations.report.thursday,
|
|
39
|
-
translations.report.friday,
|
|
40
|
-
translations.report.saturday
|
|
41
|
-
]
|
|
42
|
-
|
|
43
|
-
const dates = getDates(from, to, userData.user.attributes.timezone || getUserPartner(userData.user).timezone)
|
|
44
|
-
|
|
45
|
-
const deviceData = {
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
for (const date of dates) {
|
|
50
|
-
const { tripsByDay } = await getDataByDay(d, date, { trips }, userData, traccar)
|
|
51
|
-
|
|
52
|
-
if (tripsByDay.length > 0) {
|
|
53
|
-
const startTime = tripsByDay[0].startTime
|
|
54
|
-
const stopTime = tripsByDay[tripsByDay.length].endTime
|
|
55
|
-
|
|
56
|
-
const deviceDayData = {
|
|
57
|
-
device: d.name,
|
|
58
|
-
licensePlate: d.attributes.license_plate,
|
|
59
|
-
group: group ? group.name : '',
|
|
60
|
-
driver: '',
|
|
61
|
-
weekDay: weekDays[new Date(date).getDay()],
|
|
62
|
-
startDate: '',
|
|
63
|
-
startTime: '',
|
|
64
|
-
delayDescription: '',
|
|
65
|
-
stopTime: ''
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
async function createPassengerReport (from, to, userData, traccar) {
|
|
2
|
-
//const allDevices = await traccar.axios.get('/devices').then(d => d.data)
|
|
3
|
-
const devices = userData.devices
|
|
4
|
-
const drivers = await traccar.axios.get('/drivers').then(d => d.data)
|
|
5
|
-
const groups = await traccar.axios.get('/groups').then(d => d.data)
|
|
6
|
-
await Promise.all(groups.map(async g => {
|
|
7
|
-
const driversByGroup = await traccar.axios.get(`/drivers?groupId=${g.id}`).then(d => d.data)
|
|
8
|
-
driversByGroup.forEach(d => {
|
|
9
|
-
const _driver = drivers.find(a => a.id === d.id)
|
|
10
|
-
if (_driver) {
|
|
11
|
-
_driver.groupName = g.name
|
|
12
|
-
}
|
|
13
|
-
})
|
|
14
|
-
}))
|
|
15
|
-
const eventsUrl = `/reports/events?${devices.map(d => 'deviceId=' + d.id).join('&')
|
|
16
|
-
}&from=${from.toISOString()
|
|
17
|
-
}&to=${to.toISOString()
|
|
18
|
-
}`
|
|
19
|
-
const positionsUrl = `/reports/route?${devices.map(d => 'deviceId=' + d.id).join('&')
|
|
20
|
-
}&from=${from.toISOString()
|
|
21
|
-
}&to=${to.toISOString()
|
|
22
|
-
}`
|
|
23
|
-
const events = await traccar.axios.get(eventsUrl).then(d => d.data)
|
|
24
|
-
const positions = await traccar.axios.get(positionsUrl).then(d => d.data)
|
|
25
|
-
events.forEach(e => {
|
|
26
|
-
delete e.attributes
|
|
27
|
-
const driver = getDriver(e, positions, drivers)
|
|
28
|
-
const position = positions.find(p => p.id === e.positionId)
|
|
29
|
-
e.deviceName = devices.find(d => d.id === e.deviceId).name
|
|
30
|
-
e.groupName = driver.groupName || ''
|
|
31
|
-
e.fixtime = position && new Date(position.fixTime)
|
|
32
|
-
e.notes = driver && driver.attributes.notes
|
|
33
|
-
e.driverName = (driver && driver.name) || (position && position.attributes.driverUniqueId)
|
|
34
|
-
})
|
|
35
|
-
return events
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function getDriver (event, positions, drivers) {
|
|
39
|
-
const p = positions.find(p => p.id === event.positionId)
|
|
40
|
-
if (!p) { return '' }
|
|
41
|
-
const d = drivers.find(d => d.uniqueId === p.attributes.driverUniqueId)
|
|
42
|
-
if (!d) { return '' }
|
|
43
|
-
return d
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
exports.createPassengerReport = createPassengerReport
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
const traccarHelper = require('./util/traccar')
|
|
2
|
-
const { devicesToProcess } = require('./util/device')
|
|
3
|
-
|
|
4
|
-
async function createTemperatureReport (from, to, userData, traccar) {
|
|
5
|
-
const devices = devicesToProcess(userData)
|
|
6
|
-
|
|
7
|
-
const allInOne = await traccarHelper.getAllInOne(traccar, from, to, devices, true, false, false, false)
|
|
8
|
-
const routeData = allInOne.route
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
const { getReports } = require('./index')
|
|
2
|
-
const assert = require('assert')
|
|
3
|
-
const { createDailyUseReport } = require('../partnerReports/dailyuse-report')
|
|
4
|
-
|
|
5
|
-
describe('dailyuse', function () {
|
|
6
|
-
// eslint-disable-next-line no-undef
|
|
7
|
-
it('dailyuse report', async () => {
|
|
8
|
-
const report = await getReports()
|
|
9
|
-
const userData = await report.getUserData()
|
|
10
|
-
|
|
11
|
-
const data = await createDailyUseReport(
|
|
12
|
-
new Date(Date.UTC(2023, 10, 1, 0, 0, 0, 0)),
|
|
13
|
-
new Date(Date.UTC(2023, 10, 6, 23, 59, 59, 0)),
|
|
14
|
-
userData,
|
|
15
|
-
report.traccar)
|
|
16
|
-
console.log(data)
|
|
17
|
-
assert.equal(data[0].consumption, 19.799999999999997)
|
|
18
|
-
}, 8000000)
|
|
19
|
-
})
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
const { getReports } = require('./index')
|
|
2
|
-
const assert = require('assert')
|
|
3
|
-
const { convertMS } = require('../util/utils')
|
|
4
|
-
const { createGPSJumpReport } = require('../partnerReports/gpsjump-report')
|
|
5
|
-
|
|
6
|
-
// eslint-disable-next-line no-undef
|
|
7
|
-
describe('gpsjump', function () {
|
|
8
|
-
// eslint-disable-next-line no-undef
|
|
9
|
-
it('gpsjump report', async () => {
|
|
10
|
-
const report = await getReports()
|
|
11
|
-
const userData = await report.getUserData()
|
|
12
|
-
userData.devices = userData.devices.filter(d => d.id === 22326)
|
|
13
|
-
const data = await createGPSJumpReport(
|
|
14
|
-
new Date(Date.UTC(2023, 6, 1, 0, 0, 0, 0)),
|
|
15
|
-
new Date(Date.UTC(2023, 6, 17, 23, 59, 59, 0)),
|
|
16
|
-
userData,
|
|
17
|
-
report.traccar)
|
|
18
|
-
console.log(data)
|
|
19
|
-
assert.equal(data[0].consumption, 19.799999999999997)
|
|
20
|
-
assert.equal(data[0].distance, 326.7657)
|
|
21
|
-
assert.equal(convertMS(data[1].time * 1000, false), '08:19')
|
|
22
|
-
}, 8000000)
|
|
23
|
-
})
|