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.java9
-rw-r--r--src/org/traccar/reports/Route.java10
-rw-r--r--src/org/traccar/reports/Summary.java9
-rw-r--r--src/org/traccar/reports/Trips.java9
4 files changed, 29 insertions, 8 deletions
diff --git a/src/org/traccar/reports/Events.java b/src/org/traccar/reports/Events.java
index 9d82b97a5..ada1580d9 100644
--- a/src/org/traccar/reports/Events.java
+++ b/src/org/traccar/reports/Events.java
@@ -28,6 +28,7 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
+import org.joda.time.DateTime;
import org.jxls.area.Area;
import org.jxls.builder.xls.XlsCommentAreaBuilder;
import org.jxls.common.CellRef;
@@ -36,6 +37,7 @@ import org.jxls.transform.Transformer;
import org.jxls.transform.poi.PoiTransformer;
import org.jxls.util.TransformerFactory;
import org.traccar.Context;
+import org.traccar.helper.DateUtil;
import org.traccar.model.Device;
import org.traccar.model.Event;
import org.traccar.model.Geofence;
@@ -68,13 +70,15 @@ public final class Events {
public static void getExcel(OutputStream outputStream,
long userId, Collection<Long> deviceIds, Collection<Long> groupIds,
- Collection<String> types, Date from, Date to) throws SQLException, IOException {
+ Collection<String> types, String fromString, String toString) throws SQLException, IOException {
ArrayList<DeviceReport> devicesEvents = new ArrayList<>();
ArrayList<String> sheetNames = new ArrayList<>();
+ DateTime from = DateUtil.parseDateTime(fromString);
+ DateTime to = DateUtil.parseDateTime(toString);
HashMap<Long, String> geofenceNames = new HashMap<>();
for (long deviceId: ReportUtils.getDeviceList(deviceIds, groupIds)) {
Context.getPermissionsManager().checkDevice(userId, deviceId);
- Collection<Event> events = Context.getDataManager().getEvents(deviceId, from, to);
+ Collection<Event> events = Context.getDataManager().getEvents(deviceId, from.toDate(), to.toDate());
boolean all = types.isEmpty() || types.contains(Event.ALL_EVENTS);
for (Iterator<Event> iterator = events.iterator(); iterator.hasNext();) {
Event event = iterator.next();
@@ -118,6 +122,7 @@ public final class Events {
jxlsContext.putVar("to", to);
jxlsContext.putVar("distanceUnit", ReportUtils.getDistanceUnit(userId));
jxlsContext.putVar("speedUnit", ReportUtils.getSpeedUnit(userId));
+ jxlsContext.putVar("timezone", from.getZone());
jxlsContext.putVar("bracketsRegex", "[\\{\\}\"]");
Transformer transformer = TransformerFactory.createTransformer(inputStream, outputStream);
List<Area> xlsAreas = new XlsCommentAreaBuilder(transformer).build();
diff --git a/src/org/traccar/reports/Route.java b/src/org/traccar/reports/Route.java
index b29e04b2e..f438c8f4d 100644
--- a/src/org/traccar/reports/Route.java
+++ b/src/org/traccar/reports/Route.java
@@ -26,6 +26,7 @@ import java.util.Collection;
import java.util.Date;
import java.util.List;
+import org.joda.time.DateTime;
import org.jxls.area.Area;
import org.jxls.builder.xls.XlsCommentAreaBuilder;
import org.jxls.common.CellRef;
@@ -34,6 +35,7 @@ import org.jxls.transform.Transformer;
import org.jxls.transform.poi.PoiTransformer;
import org.jxls.util.TransformerFactory;
import org.traccar.Context;
+import org.traccar.helper.DateUtil;
import org.traccar.model.Device;
import org.traccar.model.Group;
import org.traccar.model.Position;
@@ -56,12 +58,15 @@ public final class Route {
public static void getExcel(OutputStream outputStream,
long userId, Collection<Long> deviceIds, Collection<Long> groupIds,
- Date from, Date to) throws SQLException, IOException {
+ String fromString, String toString) throws SQLException, IOException {
ArrayList<DeviceReport> devicesRoutes = new ArrayList<>();
ArrayList<String> sheetNames = new ArrayList<>();
+ DateTime from = DateUtil.parseDateTime(fromString);
+ DateTime to = DateUtil.parseDateTime(toString);
for (long deviceId: ReportUtils.getDeviceList(deviceIds, groupIds)) {
Context.getPermissionsManager().checkDevice(userId, deviceId);
- Collection<Position> positions = Context.getDataManager().getPositions(deviceId, from, to);
+ Collection<Position> positions = Context.getDataManager()
+ .getPositions(deviceId, from.toDate(), to.toDate());
DeviceReport deviceRoutes = new DeviceReport();
Device device = Context.getIdentityManager().getDeviceById(deviceId);
deviceRoutes.setDeviceName(device.getName());
@@ -85,6 +90,7 @@ public final class Route {
jxlsContext.putVar("to", to);
jxlsContext.putVar("distanceUnit", ReportUtils.getDistanceUnit(userId));
jxlsContext.putVar("speedUnit", ReportUtils.getSpeedUnit(userId));
+ jxlsContext.putVar("timezone", from.getZone());
jxlsContext.putVar("bracketsRegex", "[\\{\\}\"]");
Transformer transformer = TransformerFactory.createTransformer(inputStream, outputStream);
List<Area> xlsAreas = new XlsCommentAreaBuilder(transformer).build();
diff --git a/src/org/traccar/reports/Summary.java b/src/org/traccar/reports/Summary.java
index 95a3737a1..d7d8ab417 100644
--- a/src/org/traccar/reports/Summary.java
+++ b/src/org/traccar/reports/Summary.java
@@ -25,9 +25,11 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
+import org.joda.time.DateTime;
import org.jxls.transform.poi.PoiTransformer;
import org.jxls.util.JxlsHelper;
import org.traccar.Context;
+import org.traccar.helper.DateUtil;
import org.traccar.model.Position;
import org.traccar.reports.model.SummaryReport;
@@ -82,8 +84,10 @@ public final class Summary {
public static void getExcel(OutputStream outputStream,
long userId, Collection<Long> deviceIds, Collection<Long> groupIds,
- Date from, Date to) throws SQLException, IOException {
- Collection<SummaryReport> summaries = getObjects(userId, deviceIds, groupIds, from, to);
+ String fromString, String toString) throws SQLException, IOException {
+ DateTime from = DateUtil.parseDateTime(fromString);
+ DateTime to = DateUtil.parseDateTime(toString);
+ Collection<SummaryReport> summaries = getObjects(userId, deviceIds, groupIds, from.toDate(), to.toDate());
String templatePath = Context.getConfig().getString("report.templatesPath",
"templates/export/");
try (InputStream inputStream = new FileInputStream(templatePath + "/summary.xlsx")) {
@@ -93,6 +97,7 @@ public final class Summary {
jxlsContext.putVar("to", to);
jxlsContext.putVar("distanceUnit", ReportUtils.getDistanceUnit(userId));
jxlsContext.putVar("speedUnit", ReportUtils.getSpeedUnit(userId));
+ jxlsContext.putVar("timezone", from.getZone());
JxlsHelper.getInstance().setUseFastFormulaProcessor(false)
.processTemplate(inputStream, outputStream, jxlsContext);
}
diff --git a/src/org/traccar/reports/Trips.java b/src/org/traccar/reports/Trips.java
index 91a080d45..c31eaac83 100644
--- a/src/org/traccar/reports/Trips.java
+++ b/src/org/traccar/reports/Trips.java
@@ -26,6 +26,7 @@ import java.util.Collection;
import java.util.Date;
import java.util.List;
+import org.joda.time.DateTime;
import org.jxls.area.Area;
import org.jxls.builder.xls.XlsCommentAreaBuilder;
import org.jxls.common.CellRef;
@@ -34,6 +35,7 @@ import org.jxls.transform.Transformer;
import org.jxls.transform.poi.PoiTransformer;
import org.jxls.util.TransformerFactory;
import org.traccar.Context;
+import org.traccar.helper.DateUtil;
import org.traccar.model.Device;
import org.traccar.model.Group;
import org.traccar.model.Position;
@@ -175,12 +177,14 @@ public final class Trips {
public static void getExcel(OutputStream outputStream,
long userId, Collection<Long> deviceIds, Collection<Long> groupIds,
- Date from, Date to) throws SQLException, IOException {
+ String fromString, String toString) throws SQLException, IOException {
ArrayList<DeviceReport> devicesTrips = new ArrayList<>();
ArrayList<String> sheetNames = new ArrayList<>();
+ DateTime from = DateUtil.parseDateTime(fromString);
+ DateTime to = DateUtil.parseDateTime(toString);
for (long deviceId: ReportUtils.getDeviceList(deviceIds, groupIds)) {
Context.getPermissionsManager().checkDevice(userId, deviceId);
- Collection<TripReport> trips = detectTrips(deviceId, from, to);
+ Collection<TripReport> trips = detectTrips(deviceId, from.toDate(), to.toDate());
DeviceReport deviceTrips = new DeviceReport();
Device device = Context.getIdentityManager().getDeviceById(deviceId);
deviceTrips.setDeviceName(device.getName());
@@ -204,6 +208,7 @@ public final class Trips {
jxlsContext.putVar("to", to);
jxlsContext.putVar("distanceUnit", ReportUtils.getDistanceUnit(userId));
jxlsContext.putVar("speedUnit", ReportUtils.getSpeedUnit(userId));
+ jxlsContext.putVar("timezone", from.getZone());
Transformer transformer = TransformerFactory.createTransformer(inputStream, outputStream);
List<Area> xlsAreas = new XlsCommentAreaBuilder(transformer).build();
for (Area xlsArea : xlsAreas) {