fleetmap-reports 2.0.43 → 2.0.45
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 +2 -2
- package/src/index.js +0 -21
- package/src/partnerReports/dailyuse-report.js +1 -73
- package/src/speeding-report.js +5 -2
- package/src/tests/kms.test.js +0 -9
- package/src/tests/zones.test.js +0 -17
- package/src/util/index.js +6 -0
- package/src/util/traccar.js +1 -1
- package/src/util/utils.js +4 -1
- package/src/zone-report.js +3 -7
- 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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fleetmap-reports",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.45",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"country-reverse-geocoding": "^0.2.2",
|
|
19
19
|
"docx": "^7.3.0",
|
|
20
20
|
"file-saver": "^2.0.5",
|
|
21
|
-
"fleetmap-partners": "1.0.
|
|
21
|
+
"fleetmap-partners": "1.0.164",
|
|
22
22
|
"json-as-xlsx": "2.5.6",
|
|
23
23
|
"jspdf": "^2.5.1",
|
|
24
24
|
"jspdf-autotable": "3.8.1",
|
package/src/index.js
CHANGED
|
@@ -18,7 +18,6 @@ function Reports (config, axios) {
|
|
|
18
18
|
drivers: await this.traccar.drivers.driversGet().then(d => d.data),
|
|
19
19
|
geofences: await this.traccar.geofences.geofencesGet().then(d => d.data),
|
|
20
20
|
byGroup: false,
|
|
21
|
-
allWeek: true,
|
|
22
21
|
dayHours: { startTime: '00:00', endTime: '23:59' }
|
|
23
22
|
}
|
|
24
23
|
}
|
|
@@ -183,25 +182,5 @@ function Reports (config, axios) {
|
|
|
183
182
|
this.stopReportToExcel = (userData, reportData) => {
|
|
184
183
|
return require('./stop-report').exportStopReportToExcel(userData, reportData)
|
|
185
184
|
}
|
|
186
|
-
|
|
187
|
-
this.performanceReport = (from, to, userData) => {
|
|
188
|
-
return require('./partnerReports/performance-report').createPerformanceReport(from, to, userData, this.traccar)
|
|
189
|
-
}
|
|
190
|
-
this.performanceReportToPDF = (userData, reportData) => {
|
|
191
|
-
return require('./partnerReports/performance-report').exportPerformanceReportToPDF(userData, reportData)
|
|
192
|
-
}
|
|
193
|
-
this.performanceReportToExcel = (userData, reportData) => {
|
|
194
|
-
return require('./partnerReports/performance-report').exportPerformanceReportToExcel(userData, reportData)
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
this.dailyUseReport = (from, to, userData) => {
|
|
198
|
-
return require('./partnerReports/dailyuse-report').createDailyUseReport(from, to, userData, this.traccar)
|
|
199
|
-
}
|
|
200
|
-
this.dailyUseReportToPDF = (userData, reportData) => {
|
|
201
|
-
return require('./partnerReports/dailyuse-report').exportDailyUseReportToPDF(userData, reportData)
|
|
202
|
-
}
|
|
203
|
-
this.dailyUseReportToExcel = (userData, reportData) => {
|
|
204
|
-
return require('./partnerReports/dailyuse-report').exportDailyUseReportToExcel(userData, reportData)
|
|
205
|
-
}
|
|
206
185
|
}
|
|
207
186
|
module.exports = Reports
|
|
@@ -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
|
@@ -8,7 +8,9 @@ require('jspdf-autotable')
|
|
|
8
8
|
const { getStyle } = require('./reportStyle')
|
|
9
9
|
const drivers = require('./util/driver')
|
|
10
10
|
const here = require('./here')
|
|
11
|
-
const {
|
|
11
|
+
const {
|
|
12
|
+
getUserPartner
|
|
13
|
+
} = require('fleetmap-partners')
|
|
12
14
|
const traccarHelper = require('./util/traccar')
|
|
13
15
|
const { devicesToProcess } = require('./util/device')
|
|
14
16
|
const { point } = require('@turf/helpers')
|
|
@@ -18,6 +20,7 @@ const booleanPointInPolygon = require('@turf/boolean-point-in-polygon')
|
|
|
18
20
|
const automaticReports = require('./automaticReports')
|
|
19
21
|
const { default: axios } = require('axios')
|
|
20
22
|
const { getDriverName, getDriverData } = require('./util/driver')
|
|
23
|
+
const { getServerHost } = require('./util')
|
|
21
24
|
|
|
22
25
|
const fileName = 'SpeedingReport'
|
|
23
26
|
const eventTypes = ['deviceOverspeed']
|
|
@@ -123,7 +126,7 @@ async function createSpeedingReportByDriver (from, to, userData, traccarInstance
|
|
|
123
126
|
|
|
124
127
|
async function getEvents (traccarInstance, from, to, devices, userData, deviceCount, totalDevices, sliceSize) {
|
|
125
128
|
if (processServerSide()) {
|
|
126
|
-
const url = `https://${
|
|
129
|
+
const url = `https://${getServerHost()}/reports/speeding-report/getEvents`
|
|
127
130
|
return axios.post(url, { from, to, devices, userData, deviceCount, totalDevices, sliceSize }, { withCredentials: true }).then(d => d.data)
|
|
128
131
|
} else {
|
|
129
132
|
const geofencesFeatures = userData.geofences.filter(g => g.area.startsWith('POLYGON') &&
|
package/src/tests/kms.test.js
CHANGED
|
@@ -52,13 +52,4 @@ describe('Kms_Reports', function () {
|
|
|
52
52
|
assert.equal(device.days.length, 30) // Total Kms
|
|
53
53
|
assert.equal(device.days[29].kms, 136174.93281451002) // Total Kms
|
|
54
54
|
}, 30000)
|
|
55
|
-
it('KmsReport by driver', async () => {
|
|
56
|
-
const reports = await getReports(process.env.USER_CTM_MOVIFLOTTE, process.env.PASS_CTM_MOVIFLOTTE)
|
|
57
|
-
const userData = await reports.getUserData()
|
|
58
|
-
userData.byDriver = true
|
|
59
|
-
console.log(userData.drivers)
|
|
60
|
-
const data = await reports.kmsReport(new Date(2024, 0, 1, 0, 0, 0), new Date(2024, 0, 31, 23, 59, 59),
|
|
61
|
-
userData)
|
|
62
|
-
assert.equal(data.length, 1)
|
|
63
|
-
}, 3000000)
|
|
64
55
|
})
|
package/src/tests/zones.test.js
CHANGED
|
@@ -159,21 +159,4 @@ describe('zones', function () {
|
|
|
159
159
|
console.log(first)
|
|
160
160
|
assert.equal(first.days[6].distanceOut, 867.0554430738234)
|
|
161
161
|
}, 4000000)
|
|
162
|
-
|
|
163
|
-
it('works with casais zones in columns 7', async () => {
|
|
164
|
-
const report = await getReports()
|
|
165
|
-
const userData = await report.getUserData()
|
|
166
|
-
userData.zonesByColumn = true
|
|
167
|
-
userData.devices = userData.devices.filter(d => d.id === 81166)
|
|
168
|
-
userData.geofences = userData.geofences.filter(g => g.name === 'baliza 1 - raio verde ' ||
|
|
169
|
-
g.name === 'baliza 2 - raio amarelo')
|
|
170
|
-
userData.onlyWithKmsOut = false
|
|
171
|
-
const result = await report.zoneReport(
|
|
172
|
-
new Date(Date.UTC(2023, 9, 9, 0, 0, 0, 0)),
|
|
173
|
-
new Date(Date.UTC(2023, 9, 31, 23, 59, 59, 0)),
|
|
174
|
-
userData)
|
|
175
|
-
const first = result[0].devices[0]
|
|
176
|
-
console.log(first)
|
|
177
|
-
assert.equal(first.days[17].distanceOut, 720.7985320478997)
|
|
178
|
-
}, 4000000)
|
|
179
162
|
})
|
package/src/util/index.js
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
const { devicesToProcess } = require('./device')
|
|
2
2
|
const { isClientSide } = require('./utils')
|
|
3
|
+
const { newDomains } = require('fleetmap-partners')
|
|
3
4
|
|
|
4
5
|
exports.processServerSide = (userData) => {
|
|
5
6
|
const devices = devicesToProcess(userData)
|
|
6
7
|
return devices.length > 100 && isClientSide()
|
|
7
8
|
}
|
|
9
|
+
|
|
10
|
+
exports.getServerHost = () =>
|
|
11
|
+
isClientSide() && newDomains.includes(window.location.hostname)
|
|
12
|
+
? `${window.location.hostname}/pinmeapi`
|
|
13
|
+
: process.env.SERVER_HOST
|
package/src/util/traccar.js
CHANGED
|
@@ -81,7 +81,7 @@ async function getAllInOne (
|
|
|
81
81
|
devicesPerRequest = 1,
|
|
82
82
|
counter = undefined,
|
|
83
83
|
ignorePercentage = false) {
|
|
84
|
-
let url = `/reports/
|
|
84
|
+
let url = `/reports/allinone?from=${from.toISOString()}&to=${to.toISOString()}`
|
|
85
85
|
if (getRoutes) url += '&type=route'
|
|
86
86
|
if (getTrips) url += '&type=trips'
|
|
87
87
|
if (getStops) url += '&type=stops'
|
package/src/util/utils.js
CHANGED
|
@@ -2,6 +2,7 @@ const turf = require('@turf/helpers')
|
|
|
2
2
|
const { getUserPartner } = require('fleetmap-partners')
|
|
3
3
|
const messages = require('../../lang')
|
|
4
4
|
const distance = require('@turf/distance')
|
|
5
|
+
const { getServerHost } = require('./index')
|
|
5
6
|
|
|
6
7
|
exports.getTranslations = (userData) => {
|
|
7
8
|
const lang = this.getLanguage(userData)
|
|
@@ -234,7 +235,7 @@ async function executeServerSide (type, sliced, from, to, userData, totalItems,
|
|
|
234
235
|
for (let i = 0; i < sliced.length; i += maxRequests) {
|
|
235
236
|
const _sliced = sliced.slice(i, i + maxRequests)
|
|
236
237
|
await Promise.all(_sliced.map(async items => {
|
|
237
|
-
const url = `https://${
|
|
238
|
+
const url = `https://${getServerHost()}/reports/${type}`
|
|
238
239
|
try {
|
|
239
240
|
const data = await axios.post(url, {
|
|
240
241
|
from,
|
|
@@ -315,3 +316,5 @@ exports.getCountry = (position) => {
|
|
|
315
316
|
}
|
|
316
317
|
return country && country.code
|
|
317
318
|
}
|
|
319
|
+
|
|
320
|
+
exports.isClientSide = isClientSide
|
package/src/zone-report.js
CHANGED
|
@@ -12,8 +12,7 @@ const traccarHelper = require('./util/traccar')
|
|
|
12
12
|
const { headerFromUser, addTable } = require('./util/pdfDocument')
|
|
13
13
|
const { getStyle } = require('./reportStyle')
|
|
14
14
|
const {
|
|
15
|
-
getUserPartner
|
|
16
|
-
newDomains
|
|
15
|
+
getUserPartner
|
|
17
16
|
} = require('fleetmap-partners')
|
|
18
17
|
const { devicesToProcess } = require('./util/device')
|
|
19
18
|
const {
|
|
@@ -23,6 +22,7 @@ const {
|
|
|
23
22
|
const { checkGeofenceIn } = require('./util/geofence')
|
|
24
23
|
const { parallel } = require('./util/parallel')
|
|
25
24
|
const { getDataByDay } = require('./util/trips')
|
|
25
|
+
const { getServerHost } = require('./util')
|
|
26
26
|
const sliceSize = 100
|
|
27
27
|
const deviceChunk = 5
|
|
28
28
|
const fileName = 'ZoneReport'
|
|
@@ -35,12 +35,8 @@ async function createZoneReport (from, to, userData, traccar) {
|
|
|
35
35
|
xpert: devices.filter(d => d.attributes.xpert).length > 0
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
const serverHost = isClientSide() && newDomains.includes(window.location.hostname)
|
|
39
|
-
? `${window.location.hostname}/pinmeapi`
|
|
40
|
-
: process.env.SERVER_HOST
|
|
41
|
-
|
|
42
38
|
if (isClientSide()) {
|
|
43
|
-
const url = `https://${
|
|
39
|
+
const url = `https://${getServerHost()}/reports/zone-report/`
|
|
44
40
|
return traccar.axios.post(url, { from, to, userData }, { withCredentials: true })
|
|
45
41
|
.then(d => d.data)
|
|
46
42
|
}
|
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
|
-
})
|