aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/reports
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/reports')
-rw-r--r--src/org/traccar/reports/Events.java24
-rw-r--r--src/org/traccar/reports/Stops.java4
-rw-r--r--src/org/traccar/reports/Trips.java4
-rw-r--r--src/org/traccar/reports/model/StopReport.java24
-rw-r--r--src/org/traccar/reports/model/TripReport.java24
5 files changed, 30 insertions, 50 deletions
diff --git a/src/org/traccar/reports/Events.java b/src/org/traccar/reports/Events.java
index a13aeeeb4..66d9e708d 100644
--- a/src/org/traccar/reports/Events.java
+++ b/src/org/traccar/reports/Events.java
@@ -1,6 +1,6 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
- * Copyright 2016 Andrey Kunitsyn (andrey@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Andrey Kunitsyn (andrey@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,6 +33,7 @@ import org.traccar.model.Device;
import org.traccar.model.Event;
import org.traccar.model.Geofence;
import org.traccar.model.Group;
+import org.traccar.model.Maintenance;
import org.traccar.reports.model.DeviceReport;
public final class Events {
@@ -51,7 +52,10 @@ public final class Events {
for (Event event : events) {
if (all || types.contains(event.getType())) {
long geofenceId = event.getGeofenceId();
- if (geofenceId == 0 || Context.getGeofenceManager().checkItemPermission(userId, geofenceId)) {
+ long maintenanceId = event.getMaintenanceId();
+ if ((geofenceId == 0 || Context.getGeofenceManager().checkItemPermission(userId, geofenceId))
+ && (maintenanceId == 0
+ || Context.getMaintenancesManager().checkItemPermission(userId, maintenanceId))) {
result.add(event);
}
}
@@ -67,6 +71,7 @@ public final class Events {
ArrayList<DeviceReport> devicesEvents = new ArrayList<>();
ArrayList<String> sheetNames = new ArrayList<>();
HashMap<Long, String> geofenceNames = new HashMap<>();
+ HashMap<Long, String> maintenanceNames = new HashMap<>();
for (long deviceId: ReportUtils.getDeviceList(deviceIds, groupIds)) {
Context.getPermissionsManager().checkDevice(userId, deviceId);
Collection<Event> events = Context.getDataManager().getEvents(deviceId, from, to);
@@ -75,15 +80,25 @@ public final class Events {
Event event = iterator.next();
if (all || types.contains(event.getType())) {
long geofenceId = event.getGeofenceId();
+ long maintenanceId = event.getMaintenanceId();
if (geofenceId != 0) {
if (Context.getGeofenceManager().checkItemPermission(userId, geofenceId)) {
- Geofence geofence = (Geofence) Context.getGeofenceManager().getById(geofenceId);
+ Geofence geofence = Context.getGeofenceManager().getById(geofenceId);
if (geofence != null) {
geofenceNames.put(geofenceId, geofence.getName());
}
} else {
iterator.remove();
}
+ } else if (maintenanceId != 0) {
+ if (Context.getMaintenancesManager().checkItemPermission(userId, maintenanceId)) {
+ Maintenance maintenance = Context.getMaintenancesManager().getById(maintenanceId);
+ if (maintenance != null) {
+ maintenanceNames.put(maintenanceId, maintenance.getName());
+ }
+ } else {
+ iterator.remove();
+ }
}
} else {
iterator.remove();
@@ -109,6 +124,7 @@ public final class Events {
jxlsContext.putVar("devices", devicesEvents);
jxlsContext.putVar("sheetNames", sheetNames);
jxlsContext.putVar("geofenceNames", geofenceNames);
+ jxlsContext.putVar("maintenanceNames", maintenanceNames);
jxlsContext.putVar("from", from);
jxlsContext.putVar("to", to);
ReportUtils.processTemplateWithSheets(inputStream, outputStream, jxlsContext);
diff --git a/src/org/traccar/reports/Stops.java b/src/org/traccar/reports/Stops.java
index 14b3a2437..aa7a1ef20 100644
--- a/src/org/traccar/reports/Stops.java
+++ b/src/org/traccar/reports/Stops.java
@@ -42,11 +42,9 @@ public final class Stops {
boolean ignoreOdometer = Context.getDeviceManager()
.lookupAttributeBoolean(deviceId, "report.ignoreOdometer", false, true);
- Collection<StopReport> result = ReportUtils.detectTripsAndStops(
+ return ReportUtils.detectTripsAndStops(
Context.getDataManager().getPositions(deviceId, from, to),
Context.getTripsConfig(), ignoreOdometer, StopReport.class);
-
- return result;
}
public static Collection<StopReport> getObjects(
diff --git a/src/org/traccar/reports/Trips.java b/src/org/traccar/reports/Trips.java
index 696defa94..792833c27 100644
--- a/src/org/traccar/reports/Trips.java
+++ b/src/org/traccar/reports/Trips.java
@@ -41,11 +41,9 @@ public final class Trips {
boolean ignoreOdometer = Context.getDeviceManager()
.lookupAttributeBoolean(deviceId, "report.ignoreOdometer", false, true);
- Collection<TripReport> result = ReportUtils.detectTripsAndStops(
+ return ReportUtils.detectTripsAndStops(
Context.getDataManager().getPositions(deviceId, from, to),
Context.getTripsConfig(), ignoreOdometer, TripReport.class);
-
- return result;
}
public static Collection<TripReport> getObjects(long userId, Collection<Long> deviceIds, Collection<Long> groupIds,
diff --git a/src/org/traccar/reports/model/StopReport.java b/src/org/traccar/reports/model/StopReport.java
index 6b2e86299..245292b63 100644
--- a/src/org/traccar/reports/model/StopReport.java
+++ b/src/org/traccar/reports/model/StopReport.java
@@ -53,37 +53,21 @@ public class StopReport extends BaseReport {
private Date startTime;
public Date getStartTime() {
- if (startTime != null) {
- return new Date(startTime.getTime());
- } else {
- return null;
- }
+ return startTime;
}
public void setStartTime(Date startTime) {
- if (startTime != null) {
- this.startTime = new Date(startTime.getTime());
- } else {
- this.startTime = null;
- }
+ this.startTime = startTime;
}
private Date endTime;
public Date getEndTime() {
- if (endTime != null) {
- return new Date(endTime.getTime());
- } else {
- return null;
- }
+ return endTime;
}
public void setEndTime(Date endTime) {
- if (endTime != null) {
- this.endTime = new Date(endTime.getTime());
- } else {
- this.endTime = null;
- }
+ this.endTime = endTime;
}
private String address;
diff --git a/src/org/traccar/reports/model/TripReport.java b/src/org/traccar/reports/model/TripReport.java
index 42a4240b7..3140f3019 100644
--- a/src/org/traccar/reports/model/TripReport.java
+++ b/src/org/traccar/reports/model/TripReport.java
@@ -83,19 +83,11 @@ public class TripReport extends BaseReport {
private Date startTime;
public Date getStartTime() {
- if (startTime != null) {
- return new Date(startTime.getTime());
- } else {
- return null;
- }
+ return startTime;
}
public void setStartTime(Date startTime) {
- if (startTime != null) {
- this.startTime = new Date(startTime.getTime());
- } else {
- this.startTime = null;
- }
+ this.startTime = startTime;
}
private String startAddress;
@@ -111,19 +103,11 @@ public class TripReport extends BaseReport {
private Date endTime;
public Date getEndTime() {
- if (endTime != null) {
- return new Date(endTime.getTime());
- } else {
- return null;
- }
+ return endTime;
}
public void setEndTime(Date endTime) {
- if (endTime != null) {
- this.endTime = new Date(endTime.getTime());
- } else {
- this.endTime = null;
- }
+ this.endTime = endTime;
}
private String endAddress;