aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-11-06 10:36:16 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2016-11-06 10:36:16 +1300
commit313a51dbf23ca3ee0d5ac1d1dc37d0ff05cb2abd (patch)
tree50d3fe461d4d9d26f3e730b255001208b0b4a959
parent395249ddf82bafec4ec1bf879a6d7282cbdc2ea9 (diff)
downloadtrackermap-server-313a51dbf23ca3ee0d5ac1d1dc37d0ff05cb2abd.tar.gz
trackermap-server-313a51dbf23ca3ee0d5ac1d1dc37d0ff05cb2abd.tar.bz2
trackermap-server-313a51dbf23ca3ee0d5ac1d1dc37d0ff05cb2abd.zip
Use distance units in Excel reports
-rw-r--r--src/org/traccar/reports/Events.java2
-rw-r--r--src/org/traccar/reports/ReportUtils.java24
-rw-r--r--src/org/traccar/reports/Route.java2
-rw-r--r--src/org/traccar/reports/Summary.java2
-rw-r--r--src/org/traccar/reports/Trips.java2
-rw-r--r--templates/export/events.xlsxbin11211 -> 8020 bytes
-rw-r--r--templates/export/route.xlsxbin11707 -> 8508 bytes
-rw-r--r--templates/export/summary.xlsxbin11209 -> 8081 bytes
-rw-r--r--templates/export/trips.xlsxbin12124 -> 8911 bytes
9 files changed, 28 insertions, 4 deletions
diff --git a/src/org/traccar/reports/Events.java b/src/org/traccar/reports/Events.java
index 0ad6ab309..9d82b97a5 100644
--- a/src/org/traccar/reports/Events.java
+++ b/src/org/traccar/reports/Events.java
@@ -116,6 +116,8 @@ public final class Events {
jxlsContext.putVar("geofenceNames", geofenceNames);
jxlsContext.putVar("from", from);
jxlsContext.putVar("to", to);
+ jxlsContext.putVar("distanceUnit", ReportUtils.getDistanceUnit(userId));
+ jxlsContext.putVar("speedUnit", ReportUtils.getSpeedUnit(userId));
jxlsContext.putVar("bracketsRegex", "[\\{\\}\"]");
Transformer transformer = TransformerFactory.createTransformer(inputStream, outputStream);
List<Area> xlsAreas = new XlsCommentAreaBuilder(transformer).build();
diff --git a/src/org/traccar/reports/ReportUtils.java b/src/org/traccar/reports/ReportUtils.java
index 6cbda0ede..7fcc767e9 100644
--- a/src/org/traccar/reports/ReportUtils.java
+++ b/src/org/traccar/reports/ReportUtils.java
@@ -16,20 +16,36 @@
*/
package org.traccar.reports;
+import org.traccar.Context;
+import org.traccar.helper.Log;
+import org.traccar.model.Position;
+
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Collection;
-import org.traccar.Context;
-import org.traccar.helper.Log;
-import org.traccar.model.Position;
-
public final class ReportUtils {
private ReportUtils() {
}
+ public static String getDistanceUnit(long userId) {
+ String unit = Context.getPermissionsManager().getUser(userId).getDistanceUnit();
+ if (unit == null) {
+ unit = Context.getPermissionsManager().getServer().getDistanceUnit();
+ }
+ return unit != null ? unit : "km";
+ }
+
+ public static String getSpeedUnit(long userId) {
+ String unit = Context.getPermissionsManager().getUser(userId).getSpeedUnit();
+ if (unit == null) {
+ unit = Context.getPermissionsManager().getServer().getSpeedUnit();
+ }
+ return unit != null ? unit : "kn";
+ }
+
public static Collection<Long> getDeviceList(Collection<Long> deviceIds, Collection<Long> groupIds) {
Collection<Long> result = new ArrayList<>();
result.addAll(deviceIds);
diff --git a/src/org/traccar/reports/Route.java b/src/org/traccar/reports/Route.java
index 9ac183aea..b29e04b2e 100644
--- a/src/org/traccar/reports/Route.java
+++ b/src/org/traccar/reports/Route.java
@@ -83,6 +83,8 @@ public final class Route {
jxlsContext.putVar("sheetNames", sheetNames);
jxlsContext.putVar("from", from);
jxlsContext.putVar("to", to);
+ jxlsContext.putVar("distanceUnit", ReportUtils.getDistanceUnit(userId));
+ jxlsContext.putVar("speedUnit", ReportUtils.getSpeedUnit(userId));
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 d008f5d88..95a3737a1 100644
--- a/src/org/traccar/reports/Summary.java
+++ b/src/org/traccar/reports/Summary.java
@@ -91,6 +91,8 @@ public final class Summary {
jxlsContext.putVar("summaries", summaries);
jxlsContext.putVar("from", from);
jxlsContext.putVar("to", to);
+ jxlsContext.putVar("distanceUnit", ReportUtils.getDistanceUnit(userId));
+ jxlsContext.putVar("speedUnit", ReportUtils.getSpeedUnit(userId));
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 5a3a9a355..91a080d45 100644
--- a/src/org/traccar/reports/Trips.java
+++ b/src/org/traccar/reports/Trips.java
@@ -202,6 +202,8 @@ public final class Trips {
jxlsContext.putVar("sheetNames", sheetNames);
jxlsContext.putVar("from", from);
jxlsContext.putVar("to", to);
+ jxlsContext.putVar("distanceUnit", ReportUtils.getDistanceUnit(userId));
+ jxlsContext.putVar("speedUnit", ReportUtils.getSpeedUnit(userId));
Transformer transformer = TransformerFactory.createTransformer(inputStream, outputStream);
List<Area> xlsAreas = new XlsCommentAreaBuilder(transformer).build();
for (Area xlsArea : xlsAreas) {
diff --git a/templates/export/events.xlsx b/templates/export/events.xlsx
index 4f9569324..63c24d0ce 100644
--- a/templates/export/events.xlsx
+++ b/templates/export/events.xlsx
Binary files differ
diff --git a/templates/export/route.xlsx b/templates/export/route.xlsx
index efd659e64..fbddfd06d 100644
--- a/templates/export/route.xlsx
+++ b/templates/export/route.xlsx
Binary files differ
diff --git a/templates/export/summary.xlsx b/templates/export/summary.xlsx
index a989e0d19..c61258844 100644
--- a/templates/export/summary.xlsx
+++ b/templates/export/summary.xlsx
Binary files differ
diff --git a/templates/export/trips.xlsx b/templates/export/trips.xlsx
index 8e214a8a3..795189d16 100644
--- a/templates/export/trips.xlsx
+++ b/templates/export/trips.xlsx
Binary files differ