From 87d54329d8d6ba14f37e15967079bcfc7299228c Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Fri, 28 Oct 2022 06:08:10 -0700 Subject: Address in events report (fix #4761) --- .../org/traccar/reports/EventsReportProvider.java | 11 +++++++++++ templates/export/events.xlsx | Bin 8763 -> 9023 bytes 2 files changed, 11 insertions(+) diff --git a/src/main/java/org/traccar/reports/EventsReportProvider.java b/src/main/java/org/traccar/reports/EventsReportProvider.java index d0d4fe8bf..30f55ba80 100644 --- a/src/main/java/org/traccar/reports/EventsReportProvider.java +++ b/src/main/java/org/traccar/reports/EventsReportProvider.java @@ -24,6 +24,7 @@ import org.traccar.model.Event; import org.traccar.model.Geofence; import org.traccar.model.Group; import org.traccar.model.Maintenance; +import org.traccar.model.Position; import org.traccar.reports.common.ReportUtils; import org.traccar.reports.model.DeviceReportSection; import org.traccar.storage.Storage; @@ -102,6 +103,7 @@ public class EventsReportProvider { ArrayList sheetNames = new ArrayList<>(); HashMap geofenceNames = new HashMap<>(); HashMap maintenanceNames = new HashMap<>(); + HashMap positions = new HashMap<>(); for (Device device: reportUtils.getAccessibleDevices(userId, deviceIds, groupIds)) { Collection events = getEvents(device.getId(), from, to); boolean all = types.isEmpty() || types.contains(Event.ALL_EVENTS); @@ -129,6 +131,14 @@ public class EventsReportProvider { iterator.remove(); } } + for (Event event : events) { + long positionId = event.getPositionId(); + if (positionId > 0) { + Position position = storage.getObject(Position.class, new Request( + new Columns.All(), new Condition.Equals("id", positionId))); + positions.put(positionId, position); + } + } DeviceReportSection deviceEvents = new DeviceReportSection(); deviceEvents.setDeviceName(device.getName()); sheetNames.add(WorkbookUtil.createSafeSheetName(deviceEvents.getDeviceName())); @@ -150,6 +160,7 @@ public class EventsReportProvider { context.putVar("sheetNames", sheetNames); context.putVar("geofenceNames", geofenceNames); context.putVar("maintenanceNames", maintenanceNames); + context.putVar("positions", positions); context.putVar("from", from); context.putVar("to", to); reportUtils.processTemplateWithSheets(inputStream, outputStream, context); diff --git a/templates/export/events.xlsx b/templates/export/events.xlsx index a6366750c..d0120ab8e 100644 Binary files a/templates/export/events.xlsx and b/templates/export/events.xlsx differ -- cgit v1.2.3