fleetmap-reports 2.0.96 → 2.0.97

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fleetmap-reports",
3
- "version": "2.0.96",
3
+ "version": "2.0.97",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -9,6 +9,63 @@ 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
+ const {
20
+ drivingTime, idleTime, cruiseControlTime, economicTime, highEngineRPM, hardBraking, hardAcceleration, hardCornering,
21
+ drivingConsumption, idleConsumption, cruiseControlConsumption, economicConsumption, drivingDistance, cruiseControlDistance,
22
+ economicDistance
23
+ } = getDeviceData(allInOne, device)
24
+
25
+ const totalTime = drivingTime + idleTime
26
+ const totalConsumption = drivingConsumption + idleConsumption
27
+
28
+ const totalIndicator = (drivingDistance > 0 ? totalConsumption * 100 / drivingDistance : 0).toFixed(1) + ' L/100'
29
+ const drivingIndicator = (drivingDistance > 0 ? drivingConsumption * 100 / drivingDistance : 0).toFixed(1) + ' L/100'
30
+ const idleIndicator = (totalConsumption > 0 ? idleConsumption * 100 / totalConsumption : 0).toFixed(1) + ' %'
31
+ const economicIndicator = (totalTime > 0 ? economicTime * 100 / totalTime : 0).toFixed(1) + ' %'
32
+ const cruiseControlIndicator = (totalTime > 0 ? cruiseControlTime * 100 / totalTime : 0).toFixed(1) + ' %'
33
+ const highEngineRPMIndicator = (totalTime > 0 ? highEngineRPM * 100 / totalTime : 0).toFixed(1) + ' %'
34
+ const hardBrakingIndicator = (drivingDistance > 0 ? hardBraking * 100 / drivingDistance : 0).toFixed(0) + ' Freinage/100 Km'
35
+ const hardAccelerationIndicator = (drivingDistance > 0 ? hardAcceleration * 100 / drivingDistance : 0).toFixed(0) + ' Accélération/100 Km'
36
+ const hardCorneringIndicator = (drivingDistance > 0 ? hardCornering * 100 / drivingDistance : 0).toFixed(0) + ' Virages/100 Km'
37
+
38
+ const drivingUse = Math.round(totalTime > 0 ? drivingTime * 100 / totalTime : 0)
39
+ const idleUse = Math.round(totalTime > 0 ? idleTime * 100 / totalTime : 0)
40
+
41
+ const engineEconomicRPM = Math.round(totalTime > 0 ? economicTime * 100 / totalTime : 0)
42
+ const engineHighRPM = Math.round(totalTime > 0 ? highEngineRPM * 100 / totalTime : 0)
43
+ const engineOtherRPM = 100 - (engineEconomicRPM + engineHighRPM)
44
+
45
+ const cruiseControlOn = Math.round(totalTime > 0 ? cruiseControlTime * 100 / totalTime : 0)
46
+ const cruiseControlOff = 100 - cruiseControlOn
47
+
48
+ const totalData = getRowData(1, device, 'Totale', totalTime, totalConsumption, drivingDistance, totalIndicator, 0, 0, 0)
49
+ const drivingData = getRowData(2, device, 'Conduite', drivingTime, drivingConsumption, drivingDistance, drivingIndicator, drivingUse, engineOtherRPM, cruiseControlOff)
50
+ const idleData = getRowData(3, device, 'Ralenti', idleTime, idleConsumption, '', idleIndicator, idleUse, 0, 0)
51
+ const economicData = getRowData(4, device, 'Économique', economicTime, economicConsumption, economicDistance, economicIndicator, 0, engineEconomicRPM, 0)
52
+ const cruiseControlData = getRowData(5, device, 'Cruise Control', cruiseControlTime, cruiseControlConsumption, cruiseControlDistance, cruiseControlIndicator, 0, 0, cruiseControlOn)
53
+ const highEngineRPMData = getRowData(6, device, 'Tour moteur élevé', highEngineRPM, '', '', highEngineRPMIndicator, 0, engineHighRPM, 0)
54
+ const hardBrakingData = getRowData(7, device, 'Freinage brusque', hardBraking, '', '', hardBrakingIndicator, 0, 0, 0)
55
+ const hardAccelerationData = getRowData(8, device, 'Accéleration brusque', hardAcceleration, '', '', hardAccelerationIndicator, 0, 0, 0)
56
+ const hardCorneringData = getRowData(9, device, 'Virages brusque', hardCornering, '', '', hardCorneringIndicator, 0, 0, 0)
57
+
58
+ reportData.push(totalData)
59
+ reportData.push(drivingData)
60
+ reportData.push(idleData)
61
+ reportData.push(economicData)
62
+ reportData.push(cruiseControlData)
63
+ reportData.push(highEngineRPMData)
64
+ reportData.push(hardBrakingData)
65
+ reportData.push(hardAccelerationData)
66
+ reportData.push(hardCorneringData)
67
+ return reportData
68
+ }
12
69
  async function createPerformanceReport (from, to, userData, traccar) {
13
70
  const reportData = []
14
71
 
@@ -28,59 +85,6 @@ async function createPerformanceReport (from, to, userData, traccar) {
28
85
 
29
86
  deviceCount = deviceCount + slice.length
30
87
  }
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
88
  }
85
89
  return reportData
86
90
  }
@@ -348,5 +352,6 @@ function exportPerformanceReportToExcel (userData, reportData) {
348
352
  }
349
353
 
350
354
  exports.createPerformanceReport = createPerformanceReport
355
+ exports.createPerformanceReportSingle = createPerformanceReportSingle
351
356
  exports.exportPerformanceReportToPDF = exportPerformanceReportToPDF
352
357
  exports.exportPerformanceReportToExcel = exportPerformanceReportToExcel