diff options
-rw-r--r-- | src/org/traccar/reports/Events.java | 2 | ||||
-rw-r--r-- | src/org/traccar/reports/ReportUtils.java | 24 | ||||
-rw-r--r-- | src/org/traccar/reports/Route.java | 2 | ||||
-rw-r--r-- | src/org/traccar/reports/Summary.java | 2 | ||||
-rw-r--r-- | src/org/traccar/reports/Trips.java | 2 | ||||
-rw-r--r-- | templates/export/events.xlsx | bin | 11211 -> 8020 bytes | |||
-rw-r--r-- | templates/export/route.xlsx | bin | 11707 -> 8508 bytes | |||
-rw-r--r-- | templates/export/summary.xlsx | bin | 11209 -> 8081 bytes | |||
-rw-r--r-- | templates/export/trips.xlsx | bin | 12124 -> 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 Binary files differindex 4f9569324..63c24d0ce 100644 --- a/templates/export/events.xlsx +++ b/templates/export/events.xlsx diff --git a/templates/export/route.xlsx b/templates/export/route.xlsx Binary files differindex efd659e64..fbddfd06d 100644 --- a/templates/export/route.xlsx +++ b/templates/export/route.xlsx diff --git a/templates/export/summary.xlsx b/templates/export/summary.xlsx Binary files differindex a989e0d19..c61258844 100644 --- a/templates/export/summary.xlsx +++ b/templates/export/summary.xlsx diff --git a/templates/export/trips.xlsx b/templates/export/trips.xlsx Binary files differindex 8e214a8a3..795189d16 100644 --- a/templates/export/trips.xlsx +++ b/templates/export/trips.xlsx |