fleetmap-reports 1.0.326 → 1.0.331
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 -1
- package/src/activity-report.js +8 -6
- package/src/index.js +2 -1
- package/src/index.test.js +18 -0
- package/src/kms-report.js +13 -10
- package/src/speeding-report.js +6 -6
- package/src/trip-report.js +13 -10
- package/src/util/traccar.js +42 -0
- package/src/util/trips.js +22 -19
- package/src/util/utils.js +20 -0
- package/.idea/aws.xml +0 -17
- package/.idea/codeStyles/Project.xml +0 -7
- package/.idea/codeStyles/codeStyleConfig.xml +0 -5
- package/.idea/fleetmap-reports.iml +0 -9
- package/.idea/jsLibraryMappings.xml +0 -6
- package/.idea/misc.xml +0 -6
- package/.idea/modules.xml +0 -8
- package/.idea/vcs.xml +0 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fleetmap-reports",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.331",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"axios": "^0.21.1",
|
|
14
14
|
"axios-cookiejar-support": "^1.0.1",
|
|
15
15
|
"docx": "^7.3.0",
|
|
16
|
+
"eslint": "^8.8.0",
|
|
16
17
|
"file-saver": "^2.0.5",
|
|
17
18
|
"fleetmap-partners": "^1.0.42",
|
|
18
19
|
"json-as-xlsx": "^1.2.1",
|
package/src/activity-report.js
CHANGED
|
@@ -65,7 +65,7 @@ async function createActivityReportByGroup(from, to, userData, traccarInstance){
|
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
const withoutGroupDevices = await createActivityReportByDevice(from, to)
|
|
68
|
+
const withoutGroupDevices = await createActivityReportByDevice(from, to, userData, traccarInstance)
|
|
69
69
|
reportData.push(withoutGroupDevices)
|
|
70
70
|
|
|
71
71
|
return reportData
|
|
@@ -87,10 +87,11 @@ async function createActivityReportByDevice(from, to, userData, traccarInstance)
|
|
|
87
87
|
|
|
88
88
|
let summaries = []
|
|
89
89
|
let routeData = []
|
|
90
|
-
const
|
|
90
|
+
const allInOne = await traccar.getAllInOne(traccarInstance, from, to, devicesToProcess, userData.groupByDay && !userData.allWeek, true, false, !userData.groupByDay)
|
|
91
|
+
const tripsData = allInOne.trips
|
|
91
92
|
|
|
92
93
|
if(userData.groupByDay) {
|
|
93
|
-
routeData =
|
|
94
|
+
routeData = allInOne.route
|
|
94
95
|
console.log('trips:' + tripsData.length)
|
|
95
96
|
|
|
96
97
|
if (tripsData.length > 0) {
|
|
@@ -109,7 +110,7 @@ async function createActivityReportByDevice(from, to, userData, traccarInstance)
|
|
|
109
110
|
}
|
|
110
111
|
}
|
|
111
112
|
} else {
|
|
112
|
-
summaries =
|
|
113
|
+
summaries = allInOne.summary
|
|
113
114
|
}
|
|
114
115
|
|
|
115
116
|
console.log('Summary:' + summaries.length)
|
|
@@ -128,8 +129,9 @@ async function createActivityReportByDriver(from, to, userData, traccarInstance)
|
|
|
128
129
|
let tripsData = []
|
|
129
130
|
let routeData = []
|
|
130
131
|
if(devices.length > 0) {
|
|
131
|
-
|
|
132
|
-
|
|
132
|
+
const allInOne = await traccar.getAllInOne(traccarInstance, from, to, devices, true, true, false, false)
|
|
133
|
+
tripsData = allInOne.trips
|
|
134
|
+
routeData = allInOne.route
|
|
133
135
|
}
|
|
134
136
|
|
|
135
137
|
const allData = {
|
package/src/index.js
CHANGED
|
@@ -7,7 +7,8 @@ function Reports(config, axios) {
|
|
|
7
7
|
devices: new DevicesApi(config, null, axios),
|
|
8
8
|
groups: new GroupsApi(config, null, axios),
|
|
9
9
|
drivers: new DriversApi(config, null, axios),
|
|
10
|
-
geofences: new GeofencesApi(config, null, axios)
|
|
10
|
+
geofences: new GeofencesApi(config, null, axios),
|
|
11
|
+
axios: axios || require('axios').create(config.baseOptions)
|
|
11
12
|
}
|
|
12
13
|
this.getUserData = async () => {
|
|
13
14
|
return {
|
package/src/index.test.js
CHANGED
|
@@ -19,4 +19,22 @@ describe('speedingReport', function() {
|
|
|
19
19
|
console.log('report', report)
|
|
20
20
|
console.log(reports.kmsReportToExcel(userData, report[0]))
|
|
21
21
|
})
|
|
22
|
+
it('test allinone', async() => {
|
|
23
|
+
console.log('Start')
|
|
24
|
+
|
|
25
|
+
const reports = await getReports()
|
|
26
|
+
|
|
27
|
+
const r = await require("./util/traccar").getAllInOne(reports.traccar,
|
|
28
|
+
new Date(2022, 1, 2),
|
|
29
|
+
new Date(2022, 1, 3),
|
|
30
|
+
[{"id":22327}],
|
|
31
|
+
false,
|
|
32
|
+
true,
|
|
33
|
+
true,
|
|
34
|
+
false)
|
|
35
|
+
|
|
36
|
+
console.log(r)
|
|
37
|
+
|
|
38
|
+
console.log('End')
|
|
39
|
+
})
|
|
22
40
|
})
|
package/src/kms-report.js
CHANGED
|
@@ -5,11 +5,10 @@ const {getStyle} = require("./reportStyle")
|
|
|
5
5
|
const {headerFromUser,addTable} = require("./util/pdfDocument")
|
|
6
6
|
const {getUserPartner} = require("fleetmap-partners")
|
|
7
7
|
const traccar = require("./util/traccar")
|
|
8
|
-
const {getDates} = require("./util/utils")
|
|
8
|
+
const {getDates, convertFromUTC} = require("./util/utils")
|
|
9
9
|
const trips = require("./util/trips")
|
|
10
10
|
const drivers = require("./util/driver")
|
|
11
11
|
const { isInsideTimetable, isPartialInsideTimetable} = require("./util/trips")
|
|
12
|
-
const word = require("./word");
|
|
13
12
|
|
|
14
13
|
const fileName = 'KmsReport'
|
|
15
14
|
|
|
@@ -47,7 +46,7 @@ async function createKmsReportByDevice(from, to, userData, traccarInstance) {
|
|
|
47
46
|
}
|
|
48
47
|
|
|
49
48
|
devicesToProcess.sort((a, b) => (a.name > b.name) ? 1 : -1)
|
|
50
|
-
const route =
|
|
49
|
+
const route = await traccar.getRoute(traccarInstance, from, to, devicesToProcess)
|
|
51
50
|
const tripsData = await traccar.getTrips(traccarInstance, from, to, devicesToProcess)
|
|
52
51
|
|
|
53
52
|
console.log('trips:' + tripsData.length)
|
|
@@ -70,7 +69,7 @@ async function createKmsReportByDriver(from, to, userData, traccarInstance) {
|
|
|
70
69
|
}
|
|
71
70
|
|
|
72
71
|
const tripsData = await traccar.getTrips(traccarInstance, from, to, devices)
|
|
73
|
-
const routeData = await traccar.
|
|
72
|
+
const routeData = await traccar.getRoute(traccarInstance, from, to, devices)
|
|
74
73
|
|
|
75
74
|
return { drivers: processDrivers(from, to, userData, {trips: tripsData, route: routeData}) }
|
|
76
75
|
}
|
|
@@ -157,7 +156,7 @@ function processDevices(from, to, devices, data, userData) {
|
|
|
157
156
|
|
|
158
157
|
if (deviceTrips.length > 0) {
|
|
159
158
|
if(userData.groupByDay) {
|
|
160
|
-
deviceTrips.forEach(t => t.tripDay =
|
|
159
|
+
deviceTrips.forEach(t => t.tripDay = convertFromUTC(t.startTime, userData.user.attributes.timezone).toISOString().split('T')[0] + ' 12:00 PM')
|
|
161
160
|
const groupedTrips = deviceTrips.reduce(
|
|
162
161
|
(entryMap, e) => entryMap.set(e.tripDay, [...entryMap.get(e.tripDay)||[], e]),
|
|
163
162
|
new Map()
|
|
@@ -411,10 +410,15 @@ function exportKmsReportToExcel(userData, reportData) {
|
|
|
411
410
|
}
|
|
412
411
|
})
|
|
413
412
|
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
413
|
+
// add total
|
|
414
|
+
if (data.length) {
|
|
415
|
+
data = data.concat({
|
|
416
|
+
name: '',
|
|
417
|
+
group: '',
|
|
418
|
+
licenseplate: 'Total',
|
|
419
|
+
distance: data.reduce((prev, curr) => curr.distance ? {distance: (prev.distance || 0) + curr.distance} : prev).distance
|
|
420
|
+
})
|
|
421
|
+
}
|
|
418
422
|
|
|
419
423
|
return {
|
|
420
424
|
headers,
|
|
@@ -426,4 +430,3 @@ function exportKmsReportToExcel(userData, reportData) {
|
|
|
426
430
|
exports.createKmsReport = createKmsReport
|
|
427
431
|
exports.exportKmsReportToPDF = exportKmsReportToPDF
|
|
428
432
|
exports.exportKmsReportToExcel = exportKmsReportToExcel
|
|
429
|
-
exports.exportKmsReportToWord = word.exportKmsReportToWord
|
package/src/speeding-report.js
CHANGED
|
@@ -29,7 +29,7 @@ async function createSpeedingReport(from, to, userData, traccarInstance) {
|
|
|
29
29
|
reportData.push(...allData)
|
|
30
30
|
} else {
|
|
31
31
|
console.log("createSpeedingReportByDevice")
|
|
32
|
-
const allData = await createSpeedingReportByDevice(from, to, userData
|
|
32
|
+
const allData = await createSpeedingReportByDevice(from, to, userData, traccarInstance)
|
|
33
33
|
reportData.push(allData)
|
|
34
34
|
}
|
|
35
35
|
|
|
@@ -60,16 +60,16 @@ async function createSpeedingReportByGroup(from, to, userData, traccarInstance){
|
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
const
|
|
64
|
-
const withoutGroupDevices = userData.devices.filter(d => !groupIds.includes(d.groupId))
|
|
65
|
-
|
|
66
|
-
const withoutGroupData = await createSpeedingReportByDevice(from, to, withoutGroupDevices, userData, traccarInstance)
|
|
63
|
+
const withoutGroupData = await createSpeedingReportByDevice(from, to, userData, traccarInstance)
|
|
67
64
|
reportData.push(withoutGroupData)
|
|
68
65
|
|
|
69
66
|
return reportData
|
|
70
67
|
}
|
|
71
68
|
|
|
72
|
-
async function createSpeedingReportByDevice(from, to,
|
|
69
|
+
async function createSpeedingReportByDevice(from, to, userData, traccarInstance) {
|
|
70
|
+
const groupIds = userData.groups.map(g => g.id)
|
|
71
|
+
const devices = userData.devices.filter(d => !groupIds.includes(d.groupId))
|
|
72
|
+
|
|
73
73
|
devices.sort((a, b) => (a.name > b.name) ? 1 : -1)
|
|
74
74
|
|
|
75
75
|
const routes = await traccarHelper.getRoute(traccarInstance, from, to, devices)
|
package/src/trip-report.js
CHANGED
|
@@ -36,7 +36,9 @@ async function createTripReport(from, to, userData, traccar) {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
async function createTripReportByDevice(from, to, userData, traccar) {
|
|
39
|
-
const
|
|
39
|
+
const groupIds = userData.groups.map(g => g.id)
|
|
40
|
+
const devices = userData.byGroup ? userData.devices.filter(d => !groupIds.includes(d.groupId)) : userData.devices
|
|
41
|
+
|
|
40
42
|
const allData = {
|
|
41
43
|
devices: [],
|
|
42
44
|
xpert: devices.filter(d => d.attributes.xpert).length > 0
|
|
@@ -45,9 +47,10 @@ async function createTripReportByDevice(from, to, userData, traccar) {
|
|
|
45
47
|
devices.sort((a, b) => (a.name > b.name) ? 1 : -1)
|
|
46
48
|
|
|
47
49
|
const devicesToSlice = devices.slice()
|
|
48
|
-
const
|
|
49
|
-
const
|
|
50
|
-
const
|
|
50
|
+
const allInOne = await traccarHelper.getAllInOne(traccar, from, to, devicesToSlice, true, true, true, false)
|
|
51
|
+
const tripsData = allInOne.trips
|
|
52
|
+
const stopsData = allInOne.stops
|
|
53
|
+
const routeData = allInOne.route
|
|
51
54
|
|
|
52
55
|
console.log('Trips:' + tripsData.length)
|
|
53
56
|
|
|
@@ -91,10 +94,7 @@ async function createTripReportByGroup(from, to, userData, traccar) {
|
|
|
91
94
|
}
|
|
92
95
|
}
|
|
93
96
|
|
|
94
|
-
const
|
|
95
|
-
const withoutGroupDevices = userData.devices.filter(d => !groupIds.includes(d.groupId))
|
|
96
|
-
|
|
97
|
-
const allData = await createTripReportByDevice(from, to, withoutGroupDevices, userData)
|
|
97
|
+
const allData = await createTripReportByDevice(from, to, userData, traccar)
|
|
98
98
|
reportData.push(allData)
|
|
99
99
|
|
|
100
100
|
return reportData
|
|
@@ -109,8 +109,9 @@ async function createTripReportByDriver(from, to, userData, traccar){
|
|
|
109
109
|
return { drivers:[] }
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
const
|
|
113
|
-
const
|
|
112
|
+
const allInOne = await traccarHelper.getAllInOne(traccar, from, to, devices, true, true, false, false)
|
|
113
|
+
const tripsData = allInOne.trips
|
|
114
|
+
const routeData = allInOne.route
|
|
114
115
|
|
|
115
116
|
return { drivers: processDrivers(from, to, userData, {trips: tripsData, route: routeData})}
|
|
116
117
|
}
|
|
@@ -124,6 +125,8 @@ function processDevices(from, to, devices, data, userData) {
|
|
|
124
125
|
&& (userData.allWeek || !userData.weekDays || isInsideTimetable(t, userData) || isPartialInsideTimetable(t, userData, route)))
|
|
125
126
|
const stops = data.stops.filter(s => s.deviceId === d.id)
|
|
126
127
|
|
|
128
|
+
console.log(trips)
|
|
129
|
+
|
|
127
130
|
addNearestPOIs(trips, userData)
|
|
128
131
|
|
|
129
132
|
trips.forEach(trip => {
|
package/src/util/traccar.js
CHANGED
|
@@ -11,6 +11,7 @@ async function getRoute(traccar, from, to, devices){
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
const result = await Promise.all(requests)
|
|
14
|
+
|
|
14
15
|
return result.map(r => r.data).flat()
|
|
15
16
|
}
|
|
16
17
|
|
|
@@ -65,8 +66,49 @@ async function getSummary(traccar, from, to, devices){
|
|
|
65
66
|
return result.map(r => r.data).flat()
|
|
66
67
|
}
|
|
67
68
|
|
|
69
|
+
async function getAllInOne(traccar, from, to, devices, getRoutes, getTrips, getStops, getSummary){
|
|
70
|
+
|
|
71
|
+
let url = `/reports/allinone?&from=${from.toISOString()}&to=${to.toISOString()}`
|
|
72
|
+
if(getRoutes) url += `&type=route`
|
|
73
|
+
if(getTrips) url += `&type=trips`
|
|
74
|
+
if(getStops) url += `&type=stops`
|
|
75
|
+
if(getSummary) url += `&type=summary`
|
|
76
|
+
|
|
77
|
+
const devicesToSlice = devices.slice()
|
|
78
|
+
const arrayOfArrays = automaticReports.sliceArray(devicesToSlice)
|
|
79
|
+
let requests = []
|
|
80
|
+
|
|
81
|
+
for (const a of arrayOfArrays) {
|
|
82
|
+
let sliceUrl = url
|
|
83
|
+
for(const d of a){
|
|
84
|
+
sliceUrl += `&deviceId=${d.id}`
|
|
85
|
+
}
|
|
86
|
+
const promise = traccar.axios.get(sliceUrl)
|
|
87
|
+
requests = requests.concat(promise)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const resultList = await Promise.all(requests)
|
|
91
|
+
|
|
92
|
+
const result = {
|
|
93
|
+
route : [],
|
|
94
|
+
trips : [],
|
|
95
|
+
stops : [],
|
|
96
|
+
summary : []
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
for(const r of resultList){
|
|
100
|
+
if(getRoutes) result.route = result.route.concat(r.data.route)
|
|
101
|
+
if(getTrips) result.trips = result.trips.concat(r.data.trips)
|
|
102
|
+
if(getStops) result.stops = result.stops.concat(r.data.stops)
|
|
103
|
+
if(getSummary) result.summary = result.summary.concat(r.data.summary)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return result
|
|
107
|
+
}
|
|
108
|
+
|
|
68
109
|
exports.getRoute = getRoute
|
|
69
110
|
exports.getTrips = getTrips
|
|
70
111
|
exports.getStops = getStops
|
|
71
112
|
exports.getEvents = getEvents
|
|
72
113
|
exports.getSummary = getSummary
|
|
114
|
+
exports.getAllInOne = getAllInOne
|
package/src/util/trips.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const {coordsDistance} = require("./utils");
|
|
1
|
+
const {coordsDistance, convertFromUTC} = require("./utils");
|
|
2
2
|
|
|
3
3
|
const minDistance = 0
|
|
4
4
|
const minAvgSpeed = 0
|
|
@@ -41,7 +41,9 @@ function checkTripsKms(traccarInstance, from, to, devices, data) {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
function isPartialInsideTimetable(t, userData, route){
|
|
44
|
-
const tripStart
|
|
44
|
+
const tripStart = new Date(t.startTime)
|
|
45
|
+
const tripEnd = new Date(t.endTime)
|
|
46
|
+
|
|
45
47
|
let isPartialInside = false
|
|
46
48
|
|
|
47
49
|
if((tripStart.getDay() === 0 && userData.weekDays.sunday) ||
|
|
@@ -52,22 +54,22 @@ function isPartialInsideTimetable(t, userData, route){
|
|
|
52
54
|
(tripStart.getDay() === 5 && userData.weekDays.friday) ||
|
|
53
55
|
(tripStart.getDay() === 6 && userData.weekDays.saturday)) {
|
|
54
56
|
|
|
55
|
-
const startDate = new Date(
|
|
56
|
-
const endDate = new Date(
|
|
57
|
+
const startDate = new Date(convertFromUTC(t.startTime, userData.user.attributes.timezone).toISOString().split('T')[0] + ' '+userData.dayHours.startTime)
|
|
58
|
+
const endDate = new Date(convertFromUTC(t.startTime, userData.user.attributes.timezone).toISOString().split('T')[0] + ' '+userData.dayHours.endTime)
|
|
57
59
|
|
|
58
60
|
if(startDate.getTime() > endDate.getTime()){
|
|
59
61
|
//Trip starts outside time period and ends inside time period
|
|
60
|
-
if (
|
|
61
|
-
&&
|
|
62
|
+
if (tripStart.getTime() < endDate.getTime()
|
|
63
|
+
&& tripEnd.getTime() > endDate.getTime()) {
|
|
62
64
|
//Trip starts inside time period and ends outside time period
|
|
63
|
-
const routeInside = route.filter(p => new Date(p.fixTime).getTime() < endDate.getTime() && new Date(p.fixTime).getTime() > new Date(t.startTime).getTime() && t.deviceId === p.deviceId)
|
|
65
|
+
const routeInside = route.filter(p => new Date(p.fixTime).getTime() < new Date(endDate.toUTCString()).getTime() && new Date(p.fixTime).getTime() > new Date(t.startTime).getTime() && t.deviceId === p.deviceId)
|
|
64
66
|
updateTrip(t, routeInside)
|
|
65
67
|
t.endTime = endDate.toISOString()
|
|
66
68
|
t.endTimeIsOut = true
|
|
67
69
|
isPartialInside = true
|
|
68
70
|
}
|
|
69
71
|
|
|
70
|
-
if (
|
|
72
|
+
if (tripStart.getTime() < startDate.getTime()
|
|
71
73
|
&& new Date(t.endTime).getTime() > startDate.getTime()) {
|
|
72
74
|
|
|
73
75
|
//Trip starts outside time period and ends inside time period
|
|
@@ -79,18 +81,18 @@ function isPartialInsideTimetable(t, userData, route){
|
|
|
79
81
|
}
|
|
80
82
|
|
|
81
83
|
} else {
|
|
82
|
-
if (
|
|
83
|
-
&&
|
|
84
|
+
if (tripStart.getTime() < startDate.getTime()
|
|
85
|
+
&& tripEnd.getTime() > startDate.getTime()) {
|
|
84
86
|
//Trip starts outside time period and ends inside time period
|
|
85
|
-
const routeInside = route.filter(p => new Date(p.fixTime).getTime() > startDate.getTime() && new Date(p.fixTime).getTime() < new Date(t.endTime).getTime() && t.deviceId === p.deviceId)
|
|
87
|
+
const routeInside = route.filter(p => new Date(p.fixTime).getTime() > new Date(startDate.toUTCString()).getTime() && new Date(p.fixTime).getTime() < new Date(t.endTime).getTime() && t.deviceId === p.deviceId)
|
|
86
88
|
updateTrip(t, routeInside)
|
|
87
89
|
t.startTime = startDate.toISOString()
|
|
88
90
|
t.startTimeIsOut = true
|
|
89
91
|
isPartialInside = true
|
|
90
92
|
}
|
|
91
93
|
|
|
92
|
-
if (
|
|
93
|
-
&&
|
|
94
|
+
if (tripStart.getTime() < endDate.getTime()
|
|
95
|
+
&& tripEnd.getTime() > endDate.getTime()) {
|
|
94
96
|
//Trip starts inside time period and ends outside time period
|
|
95
97
|
const routeInside = route.filter(p => new Date(p.fixTime).getTime() < endDate.getTime() && new Date(p.fixTime).getTime() > new Date(t.startTime).getTime() && t.deviceId === p.deviceId)
|
|
96
98
|
updateTrip(t, routeInside)
|
|
@@ -104,9 +106,10 @@ function isPartialInsideTimetable(t, userData, route){
|
|
|
104
106
|
return isPartialInside
|
|
105
107
|
}
|
|
106
108
|
|
|
109
|
+
|
|
107
110
|
function isInsideTimetable(t, userData){
|
|
108
|
-
const tripStart
|
|
109
|
-
const tripEnd
|
|
111
|
+
const tripStart = new Date(t.startTime)
|
|
112
|
+
const tripEnd = new Date(t.endTime)
|
|
110
113
|
|
|
111
114
|
if((tripStart.getDay() === 0 && userData.weekDays.sunday) ||
|
|
112
115
|
(tripStart.getDay() === 1 && userData.weekDays.monday) ||
|
|
@@ -116,13 +119,12 @@ function isInsideTimetable(t, userData){
|
|
|
116
119
|
(tripStart.getDay() === 5 && userData.weekDays.friday) ||
|
|
117
120
|
(tripStart.getDay() === 6 && userData.weekDays.saturday)) {
|
|
118
121
|
|
|
119
|
-
const startDate = new Date(
|
|
120
|
-
const endDate = new Date(
|
|
121
|
-
|
|
122
|
-
console.log(tripStart, startDate, endDate)
|
|
122
|
+
const startDate = new Date(convertFromUTC(t.startTime, userData.user.attributes.timezone).toISOString().split('T')[0] + ' '+userData.dayHours.startTime)
|
|
123
|
+
const endDate = new Date(convertFromUTC(t.startTime, userData.user.attributes.timezone).toISOString().split('T')[0] + ' '+userData.dayHours.endTime)
|
|
123
124
|
|
|
124
125
|
//Trips inside time period
|
|
125
126
|
if(startDate.getTime() < endDate.getTime()) {
|
|
127
|
+
console.log((tripStart.getTime() > startDate.getTime() && tripEnd.getTime() < endDate.getTime()))
|
|
126
128
|
return tripStart.getTime() > startDate.getTime() && tripEnd.getTime() < endDate.getTime()
|
|
127
129
|
} else {
|
|
128
130
|
return (tripStart.getTime() < endDate.getTime() && tripEnd.getTime() < endDate.getTime()) ||
|
|
@@ -134,6 +136,7 @@ function isInsideTimetable(t, userData){
|
|
|
134
136
|
}
|
|
135
137
|
|
|
136
138
|
function updateTrip(t, route){
|
|
139
|
+
if (!route[route.length-1]) { return }
|
|
137
140
|
const distance = route[route.length-1].attributes.totalDistance - route[0].attributes.totalDistance
|
|
138
141
|
t.distance = distance
|
|
139
142
|
t.duration = new Date(route[route.length-1].fixTime).getTime() - new Date(route[0].fixTime).getTime()
|
package/src/util/utils.js
CHANGED
|
@@ -112,6 +112,24 @@ function convertToLocaleTimeString(value, lang, timezone){
|
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
+
function getTimezoneOffset(timezone){
|
|
116
|
+
if(isClientSide){
|
|
117
|
+
return new Date().getTimezoneOffset()
|
|
118
|
+
} else {
|
|
119
|
+
const utcDate = new Date(new Date().toLocaleString('en-US', { timeZone: 'UTC' }))
|
|
120
|
+
const tzDate = new Date(new Date().toLocaleString('en-US', { timeZone: timezone }))
|
|
121
|
+
return (utcDate.getTime() - tzDate.getTime()) / 6e4
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function convertFromUTC(value, timezone) {
|
|
126
|
+
const offset = getTimezoneOffset(timezone)
|
|
127
|
+
|
|
128
|
+
const valueDate = new Date(value)
|
|
129
|
+
valueDate.setTime(valueDate.getTime() - (offset * 60 * 1000))
|
|
130
|
+
return valueDate
|
|
131
|
+
}
|
|
132
|
+
|
|
115
133
|
exports.getImgFromUrl = getImgFromUrl
|
|
116
134
|
exports.convertMS = convertMS
|
|
117
135
|
exports.coordsDistance = coordsDistance
|
|
@@ -120,6 +138,8 @@ exports.convertToLocaleString = convertToLocaleString
|
|
|
120
138
|
exports.convertToLocaleDateString = convertToLocaleDateString
|
|
121
139
|
exports.convertToLocaleTimeString = convertToLocaleTimeString
|
|
122
140
|
exports.isClientSide = isClientSide
|
|
141
|
+
exports.getTimezoneOffset = getTimezoneOffset
|
|
142
|
+
exports.convertFromUTC = convertFromUTC
|
|
123
143
|
exports.getLogo = (user) => {
|
|
124
144
|
const host = window ? window.location.hostname : getUserPartner(user).host
|
|
125
145
|
return getImage(getLogoUrl(host))
|
package/.idea/aws.xml
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<project version="4">
|
|
3
|
-
<component name="accountSettings">
|
|
4
|
-
<option name="activeProfile" value="profile:default" />
|
|
5
|
-
<option name="activeRegion" value="us-east-1" />
|
|
6
|
-
<option name="recentlyUsedProfiles">
|
|
7
|
-
<list>
|
|
8
|
-
<option value="profile:default" />
|
|
9
|
-
</list>
|
|
10
|
-
</option>
|
|
11
|
-
<option name="recentlyUsedRegions">
|
|
12
|
-
<list>
|
|
13
|
-
<option value="us-east-1" />
|
|
14
|
-
</list>
|
|
15
|
-
</option>
|
|
16
|
-
</component>
|
|
17
|
-
</project>
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<module type="JAVA_MODULE" version="4">
|
|
3
|
-
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
|
4
|
-
<exclude-output />
|
|
5
|
-
<content url="file://$MODULE_DIR$" />
|
|
6
|
-
<orderEntry type="inheritedJdk" />
|
|
7
|
-
<orderEntry type="sourceFolder" forTests="false" />
|
|
8
|
-
</component>
|
|
9
|
-
</module>
|
package/.idea/misc.xml
DELETED
package/.idea/modules.xml
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<project version="4">
|
|
3
|
-
<component name="ProjectModuleManager">
|
|
4
|
-
<modules>
|
|
5
|
-
<module fileurl="file://$PROJECT_DIR$/.idea/fleetmap-reports.iml" filepath="$PROJECT_DIR$/.idea/fleetmap-reports.iml" />
|
|
6
|
-
</modules>
|
|
7
|
-
</component>
|
|
8
|
-
</project>
|