From 40d7ff2f9505150c85e87332fac9f67725beba8e Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Thu, 20 Oct 2016 09:55:49 +0500 Subject: - Fix export empty reports - Cleanup templates metadata --- src/org/traccar/reports/Events.java | 22 ++++++++++------------ src/org/traccar/reports/Route.java | 22 ++++++++++------------ src/org/traccar/reports/Trips.java | 22 ++++++++++------------ templates/export/events.xlsx | Bin 11830 -> 11211 bytes templates/export/route.xlsx | Bin 12398 -> 11707 bytes templates/export/summary.xlsx | Bin 11896 -> 11209 bytes templates/export/trips.xlsx | Bin 12811 -> 12124 bytes 7 files changed, 30 insertions(+), 36 deletions(-) diff --git a/src/org/traccar/reports/Events.java b/src/org/traccar/reports/Events.java index 37bf7b227..77d995f56 100644 --- a/src/org/traccar/reports/Events.java +++ b/src/org/traccar/reports/Events.java @@ -98,20 +98,18 @@ public final class Events { iterator.remove(); } } - if (!events.isEmpty()) { - DeviceReport deviceEvents = new DeviceReport(); - Device device = Context.getIdentityManager().getDeviceById(deviceId); - deviceEvents.setDeviceName(device.getName()); - sheetNames.add(deviceEvents.getDeviceName()); - if (device.getGroupId() != 0) { - Group group = Context.getDeviceManager().getGroupById(device.getGroupId()); - if (group != null) { - deviceEvents.setGroupName(group.getName()); - } + DeviceReport deviceEvents = new DeviceReport(); + Device device = Context.getIdentityManager().getDeviceById(deviceId); + deviceEvents.setDeviceName(device.getName()); + sheetNames.add(deviceEvents.getDeviceName()); + if (device.getGroupId() != 0) { + Group group = Context.getDeviceManager().getGroupById(device.getGroupId()); + if (group != null) { + deviceEvents.setGroupName(group.getName()); } - deviceEvents.setObjects(events); - devicesEvents.add(deviceEvents); } + deviceEvents.setObjects(events); + devicesEvents.add(deviceEvents); } String templatePath = Context.getConfig().getString("report.templatesPath", "templates/export/"); diff --git a/src/org/traccar/reports/Route.java b/src/org/traccar/reports/Route.java index 7cefe04a3..6992c89cc 100644 --- a/src/org/traccar/reports/Route.java +++ b/src/org/traccar/reports/Route.java @@ -68,20 +68,18 @@ public final class Route { for (long deviceId: ReportUtils.getDeviceList(deviceIds, groupIds)) { Context.getPermissionsManager().checkDevice(userId, deviceId); Collection positions = Context.getDataManager().getPositions(deviceId, from, to); - if (positions != null && !positions.isEmpty()) { - DeviceReport deviceRoutes = new DeviceReport(); - Device device = Context.getIdentityManager().getDeviceById(deviceId); - deviceRoutes.setDeviceName(device.getName()); - sheetNames.add(deviceRoutes.getDeviceName()); - if (device.getGroupId() != 0) { - Group group = Context.getDeviceManager().getGroupById(device.getGroupId()); - if (group != null) { - deviceRoutes.setGroupName(group.getName()); - } + DeviceReport deviceRoutes = new DeviceReport(); + Device device = Context.getIdentityManager().getDeviceById(deviceId); + deviceRoutes.setDeviceName(device.getName()); + sheetNames.add(deviceRoutes.getDeviceName()); + if (device.getGroupId() != 0) { + Group group = Context.getDeviceManager().getGroupById(device.getGroupId()); + if (group != null) { + deviceRoutes.setGroupName(group.getName()); } - deviceRoutes.setObjects(positions); - devicesRoutes.add(deviceRoutes); } + deviceRoutes.setObjects(positions); + devicesRoutes.add(deviceRoutes); } String templatePath = Context.getConfig().getString("report.templatesPath", "templates/export/"); diff --git a/src/org/traccar/reports/Trips.java b/src/org/traccar/reports/Trips.java index 27863d877..705644849 100644 --- a/src/org/traccar/reports/Trips.java +++ b/src/org/traccar/reports/Trips.java @@ -187,20 +187,18 @@ public final class Trips { for (long deviceId: ReportUtils.getDeviceList(deviceIds, groupIds)) { Context.getPermissionsManager().checkDevice(userId, deviceId); Collection trips = detectTrips(deviceId, from, to); - if (!trips.isEmpty()) { - DeviceReport deviceTrips = new DeviceReport(); - Device device = Context.getIdentityManager().getDeviceById(deviceId); - deviceTrips.setDeviceName(device.getName()); - sheetNames.add(deviceTrips.getDeviceName()); - if (device.getGroupId() != 0) { - Group group = Context.getDeviceManager().getGroupById(device.getGroupId()); - if (group != null) { - deviceTrips.setGroupName(group.getName()); - } + DeviceReport deviceTrips = new DeviceReport(); + Device device = Context.getIdentityManager().getDeviceById(deviceId); + deviceTrips.setDeviceName(device.getName()); + sheetNames.add(deviceTrips.getDeviceName()); + if (device.getGroupId() != 0) { + Group group = Context.getDeviceManager().getGroupById(device.getGroupId()); + if (group != null) { + deviceTrips.setGroupName(group.getName()); } - deviceTrips.setObjects(detectTrips(deviceId, from, to)); - devicesTrips.add(deviceTrips); } + deviceTrips.setObjects(trips); + devicesTrips.add(deviceTrips); } String templatePath = Context.getConfig().getString("report.templatesPath", "templates/export/"); diff --git a/templates/export/events.xlsx b/templates/export/events.xlsx index 99a3f7437..4f9569324 100644 Binary files a/templates/export/events.xlsx and b/templates/export/events.xlsx differ diff --git a/templates/export/route.xlsx b/templates/export/route.xlsx index 6f74cfb45..efd659e64 100644 Binary files a/templates/export/route.xlsx and b/templates/export/route.xlsx differ diff --git a/templates/export/summary.xlsx b/templates/export/summary.xlsx index a975c54fe..a989e0d19 100644 Binary files a/templates/export/summary.xlsx and b/templates/export/summary.xlsx differ diff --git a/templates/export/trips.xlsx b/templates/export/trips.xlsx index 8e13d5ff8..8e214a8a3 100644 Binary files a/templates/export/trips.xlsx and b/templates/export/trips.xlsx differ -- cgit v1.2.3