fleetmap-reports 2.0.96 → 2.0.98
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
CHANGED
|
@@ -9,6 +9,65 @@ const { getStyle } = require('../reportStyle')
|
|
|
9
9
|
const { getUserPartner } = require('fleetmap-partners')
|
|
10
10
|
const { calculateConsumption } = require('../util/fuel')
|
|
11
11
|
|
|
12
|
+
async function createPerformanceReportSingle (from, to, userData, traccar) {
|
|
13
|
+
const reportData = []
|
|
14
|
+
|
|
15
|
+
const allInOne = await traccarHelper.getAllInOne(traccar, from, to, userData.devices.slice(0, 1), true, true, true, true)
|
|
16
|
+
|
|
17
|
+
const device = userData.devices[0]
|
|
18
|
+
|
|
19
|
+
if (!device) { return [] }
|
|
20
|
+
|
|
21
|
+
const {
|
|
22
|
+
drivingTime, idleTime, cruiseControlTime, economicTime, highEngineRPM, hardBraking, hardAcceleration, hardCornering,
|
|
23
|
+
drivingConsumption, idleConsumption, cruiseControlConsumption, economicConsumption, drivingDistance, cruiseControlDistance,
|
|
24
|
+
economicDistance
|
|
25
|
+
} = getDeviceData(allInOne, device)
|
|
26
|
+
|
|
27
|
+
const totalTime = drivingTime + idleTime
|
|
28
|
+
const totalConsumption = drivingConsumption + idleConsumption
|
|
29
|
+
|
|
30
|
+
const totalIndicator = (drivingDistance > 0 ? totalConsumption * 100 / drivingDistance : 0).toFixed(1) + ' L/100'
|
|
31
|
+
const drivingIndicator = (drivingDistance > 0 ? drivingConsumption * 100 / drivingDistance : 0).toFixed(1) + ' L/100'
|
|
32
|
+
const idleIndicator = (totalConsumption > 0 ? idleConsumption * 100 / totalConsumption : 0).toFixed(1) + ' %'
|
|
33
|
+
const economicIndicator = (totalTime > 0 ? economicTime * 100 / totalTime : 0).toFixed(1) + ' %'
|
|
34
|
+
const cruiseControlIndicator = (totalTime > 0 ? cruiseControlTime * 100 / totalTime : 0).toFixed(1) + ' %'
|
|
35
|
+
const highEngineRPMIndicator = (totalTime > 0 ? highEngineRPM * 100 / totalTime : 0).toFixed(1) + ' %'
|
|
36
|
+
const hardBrakingIndicator = (drivingDistance > 0 ? hardBraking * 100 / drivingDistance : 0).toFixed(0) + ' Freinage/100 Km'
|
|
37
|
+
const hardAccelerationIndicator = (drivingDistance > 0 ? hardAcceleration * 100 / drivingDistance : 0).toFixed(0) + ' Accélération/100 Km'
|
|
38
|
+
const hardCorneringIndicator = (drivingDistance > 0 ? hardCornering * 100 / drivingDistance : 0).toFixed(0) + ' Virages/100 Km'
|
|
39
|
+
|
|
40
|
+
const drivingUse = Math.round(totalTime > 0 ? drivingTime * 100 / totalTime : 0)
|
|
41
|
+
const idleUse = Math.round(totalTime > 0 ? idleTime * 100 / totalTime : 0)
|
|
42
|
+
|
|
43
|
+
const engineEconomicRPM = Math.round(totalTime > 0 ? economicTime * 100 / totalTime : 0)
|
|
44
|
+
const engineHighRPM = Math.round(totalTime > 0 ? highEngineRPM * 100 / totalTime : 0)
|
|
45
|
+
const engineOtherRPM = 100 - (engineEconomicRPM + engineHighRPM)
|
|
46
|
+
|
|
47
|
+
const cruiseControlOn = Math.round(totalTime > 0 ? cruiseControlTime * 100 / totalTime : 0)
|
|
48
|
+
const cruiseControlOff = 100 - cruiseControlOn
|
|
49
|
+
|
|
50
|
+
const totalData = getRowData(1, device, 'Totale', totalTime, totalConsumption, drivingDistance, totalIndicator, 0, 0, 0)
|
|
51
|
+
const drivingData = getRowData(2, device, 'Conduite', drivingTime, drivingConsumption, drivingDistance, drivingIndicator, drivingUse, engineOtherRPM, cruiseControlOff)
|
|
52
|
+
const idleData = getRowData(3, device, 'Ralenti', idleTime, idleConsumption, '', idleIndicator, idleUse, 0, 0)
|
|
53
|
+
const economicData = getRowData(4, device, 'Économique', economicTime, economicConsumption, economicDistance, economicIndicator, 0, engineEconomicRPM, 0)
|
|
54
|
+
const cruiseControlData = getRowData(5, device, 'Cruise Control', cruiseControlTime, cruiseControlConsumption, cruiseControlDistance, cruiseControlIndicator, 0, 0, cruiseControlOn)
|
|
55
|
+
const highEngineRPMData = getRowData(6, device, 'Tour moteur élevé', highEngineRPM, '', '', highEngineRPMIndicator, 0, engineHighRPM, 0)
|
|
56
|
+
const hardBrakingData = getRowData(7, device, 'Freinage brusque', hardBraking, '', '', hardBrakingIndicator, 0, 0, 0)
|
|
57
|
+
const hardAccelerationData = getRowData(8, device, 'Accéleration brusque', hardAcceleration, '', '', hardAccelerationIndicator, 0, 0, 0)
|
|
58
|
+
const hardCorneringData = getRowData(9, device, 'Virages brusque', hardCornering, '', '', hardCorneringIndicator, 0, 0, 0)
|
|
59
|
+
|
|
60
|
+
reportData.push(totalData)
|
|
61
|
+
reportData.push(drivingData)
|
|
62
|
+
reportData.push(idleData)
|
|
63
|
+
reportData.push(economicData)
|
|
64
|
+
reportData.push(cruiseControlData)
|
|
65
|
+
reportData.push(highEngineRPMData)
|
|
66
|
+
reportData.push(hardBrakingData)
|
|
67
|
+
reportData.push(hardAccelerationData)
|
|
68
|
+
reportData.push(hardCorneringData)
|
|
69
|
+
return reportData
|
|
70
|
+
}
|
|
12
71
|
async function createPerformanceReport (from, to, userData, traccar) {
|
|
13
72
|
const reportData = []
|
|
14
73
|
|
|
@@ -28,59 +87,6 @@ async function createPerformanceReport (from, to, userData, traccar) {
|
|
|
28
87
|
|
|
29
88
|
deviceCount = deviceCount + slice.length
|
|
30
89
|
}
|
|
31
|
-
} else {
|
|
32
|
-
const allInOne = await traccarHelper.getAllInOne(traccar, from, to, userData.devices, true, true, true, true)
|
|
33
|
-
|
|
34
|
-
const device = userData.devices[0]
|
|
35
|
-
|
|
36
|
-
const {
|
|
37
|
-
drivingTime, idleTime, cruiseControlTime, economicTime, highEngineRPM, hardBraking, hardAcceleration, hardCornering,
|
|
38
|
-
drivingConsumption, idleConsumption, cruiseControlConsumption, economicConsumption, drivingDistance, cruiseControlDistance,
|
|
39
|
-
economicDistance
|
|
40
|
-
} = getDeviceData(allInOne, device)
|
|
41
|
-
|
|
42
|
-
const totalTime = drivingTime + idleTime
|
|
43
|
-
const totalConsumption = drivingConsumption + idleConsumption
|
|
44
|
-
|
|
45
|
-
const totalIndicator = (drivingDistance > 0 ? totalConsumption * 100 / drivingDistance : 0).toFixed(1) + ' L/100'
|
|
46
|
-
const drivingIndicator = (drivingDistance > 0 ? drivingConsumption * 100 / drivingDistance : 0).toFixed(1) + ' L/100'
|
|
47
|
-
const idleIndicator = (totalConsumption > 0 ? idleConsumption * 100 / totalConsumption : 0).toFixed(1) + ' %'
|
|
48
|
-
const economicIndicator = (totalTime > 0 ? economicTime * 100 / totalTime : 0).toFixed(1) + ' %'
|
|
49
|
-
const cruiseControlIndicator = (totalTime > 0 ? cruiseControlTime * 100 / totalTime : 0).toFixed(1) + ' %'
|
|
50
|
-
const highEngineRPMIndicator = (totalTime > 0 ? highEngineRPM * 100 / totalTime : 0).toFixed(1) + ' %'
|
|
51
|
-
const hardBrakingIndicator = (drivingDistance > 0 ? hardBraking * 100 / drivingDistance : 0).toFixed(0) + ' Freinage/100 Km'
|
|
52
|
-
const hardAccelerationIndicator = (drivingDistance > 0 ? hardAcceleration * 100 / drivingDistance : 0).toFixed(0) + ' Accélération/100 Km'
|
|
53
|
-
const hardCorneringIndicator = (drivingDistance > 0 ? hardCornering * 100 / drivingDistance : 0).toFixed(0) + ' Virages/100 Km'
|
|
54
|
-
|
|
55
|
-
const drivingUse = Math.round(totalTime > 0 ? drivingTime * 100 / totalTime : 0)
|
|
56
|
-
const idleUse = Math.round(totalTime > 0 ? idleTime * 100 / totalTime : 0)
|
|
57
|
-
|
|
58
|
-
const engineEconomicRPM = Math.round(totalTime > 0 ? economicTime * 100 / totalTime : 0)
|
|
59
|
-
const engineHighRPM = Math.round(totalTime > 0 ? highEngineRPM * 100 / totalTime : 0)
|
|
60
|
-
const engineOtherRPM = 100 - (engineEconomicRPM + engineHighRPM)
|
|
61
|
-
|
|
62
|
-
const cruiseControlOn = Math.round(totalTime > 0 ? cruiseControlTime * 100 / totalTime : 0)
|
|
63
|
-
const cruiseControlOff = 100 - cruiseControlOn
|
|
64
|
-
|
|
65
|
-
const totalData = getRowData(1, device, 'Totale', totalTime, totalConsumption, drivingDistance, totalIndicator, 0, 0, 0)
|
|
66
|
-
const drivingData = getRowData(2, device, 'Conduite', drivingTime, drivingConsumption, drivingDistance, drivingIndicator, drivingUse, engineOtherRPM, cruiseControlOff)
|
|
67
|
-
const idleData = getRowData(3, device, 'Ralenti', idleTime, idleConsumption, '', idleIndicator, idleUse, 0, 0)
|
|
68
|
-
const economicData = getRowData(4, device, 'Économique', economicTime, economicConsumption, economicDistance, economicIndicator, 0, engineEconomicRPM, 0)
|
|
69
|
-
const cruiseControlData = getRowData(5, device, 'Cruise Control', cruiseControlTime, cruiseControlConsumption, cruiseControlDistance, cruiseControlIndicator, 0, 0, cruiseControlOn)
|
|
70
|
-
const highEngineRPMData = getRowData(6, device, 'Tour moteur élevé', highEngineRPM, '', '', highEngineRPMIndicator, 0, engineHighRPM, 0)
|
|
71
|
-
const hardBrakingData = getRowData(7, device, 'Freinage brusque', hardBraking, '', '', hardBrakingIndicator, 0, 0, 0)
|
|
72
|
-
const hardAccelerationData = getRowData(8, device, 'Accéleration brusque', hardAcceleration, '', '', hardAccelerationIndicator, 0, 0, 0)
|
|
73
|
-
const hardCorneringData = getRowData(9, device, 'Virages brusque', hardCornering, '', '', hardCorneringIndicator, 0, 0, 0)
|
|
74
|
-
|
|
75
|
-
reportData.push(totalData)
|
|
76
|
-
reportData.push(drivingData)
|
|
77
|
-
reportData.push(idleData)
|
|
78
|
-
reportData.push(economicData)
|
|
79
|
-
reportData.push(cruiseControlData)
|
|
80
|
-
reportData.push(highEngineRPMData)
|
|
81
|
-
reportData.push(hardBrakingData)
|
|
82
|
-
reportData.push(hardAccelerationData)
|
|
83
|
-
reportData.push(hardCorneringData)
|
|
84
90
|
}
|
|
85
91
|
return reportData
|
|
86
92
|
}
|
|
@@ -348,5 +354,6 @@ function exportPerformanceReportToExcel (userData, reportData) {
|
|
|
348
354
|
}
|
|
349
355
|
|
|
350
356
|
exports.createPerformanceReport = createPerformanceReport
|
|
357
|
+
exports.createPerformanceReportSingle = createPerformanceReportSingle
|
|
351
358
|
exports.exportPerformanceReportToPDF = exportPerformanceReportToPDF
|
|
352
359
|
exports.exportPerformanceReportToExcel = exportPerformanceReportToExcel
|