diff options
author | Abyss777 <abyss@fox5.ru> | 2018-04-11 14:55:11 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2018-04-11 14:55:31 +0500 |
commit | f7a4d1977e71797b231ebb9a55308fee7c2b64d7 (patch) | |
tree | 3b879aed22d40ebe405a792f7bdd3446d7b38aaa /src/org/traccar/reports | |
parent | bb071de84dd000ec3067991bb523fe5ef24b76e9 (diff) | |
download | trackermap-server-f7a4d1977e71797b231ebb9a55308fee7c2b64d7.tar.gz trackermap-server-f7a4d1977e71797b231ebb9a55308fee7c2b64d7.tar.bz2 trackermap-server-f7a4d1977e71797b231ebb9a55308fee7c2b64d7.zip |
Add support of multiple Maintenances
Diffstat (limited to 'src/org/traccar/reports')
-rw-r--r-- | src/org/traccar/reports/Events.java | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/org/traccar/reports/Events.java b/src/org/traccar/reports/Events.java index 7cb6ef6eb..66d9e708d 100644 --- a/src/org/traccar/reports/Events.java +++ b/src/org/traccar/reports/Events.java @@ -1,6 +1,6 @@ /* - * Copyright 2016 Anton Tananaev (anton@traccar.org) - * Copyright 2016 Andrey Kunitsyn (andrey@traccar.org) + * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2016 - 2018 Andrey Kunitsyn (andrey@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,6 +33,7 @@ import org.traccar.model.Device; import org.traccar.model.Event; import org.traccar.model.Geofence; import org.traccar.model.Group; +import org.traccar.model.Maintenance; import org.traccar.reports.model.DeviceReport; public final class Events { @@ -51,7 +52,10 @@ public final class Events { for (Event event : events) { if (all || types.contains(event.getType())) { long geofenceId = event.getGeofenceId(); - if (geofenceId == 0 || Context.getGeofenceManager().checkItemPermission(userId, geofenceId)) { + long maintenanceId = event.getMaintenanceId(); + if ((geofenceId == 0 || Context.getGeofenceManager().checkItemPermission(userId, geofenceId)) + && (maintenanceId == 0 + || Context.getMaintenancesManager().checkItemPermission(userId, maintenanceId))) { result.add(event); } } @@ -67,6 +71,7 @@ public final class Events { ArrayList<DeviceReport> devicesEvents = new ArrayList<>(); ArrayList<String> sheetNames = new ArrayList<>(); HashMap<Long, String> geofenceNames = new HashMap<>(); + HashMap<Long, String> maintenanceNames = new HashMap<>(); for (long deviceId: ReportUtils.getDeviceList(deviceIds, groupIds)) { Context.getPermissionsManager().checkDevice(userId, deviceId); Collection<Event> events = Context.getDataManager().getEvents(deviceId, from, to); @@ -75,6 +80,7 @@ public final class Events { Event event = iterator.next(); if (all || types.contains(event.getType())) { long geofenceId = event.getGeofenceId(); + long maintenanceId = event.getMaintenanceId(); if (geofenceId != 0) { if (Context.getGeofenceManager().checkItemPermission(userId, geofenceId)) { Geofence geofence = Context.getGeofenceManager().getById(geofenceId); @@ -84,6 +90,15 @@ public final class Events { } else { iterator.remove(); } + } else if (maintenanceId != 0) { + if (Context.getMaintenancesManager().checkItemPermission(userId, maintenanceId)) { + Maintenance maintenance = Context.getMaintenancesManager().getById(maintenanceId); + if (maintenance != null) { + maintenanceNames.put(maintenanceId, maintenance.getName()); + } + } else { + iterator.remove(); + } } } else { iterator.remove(); @@ -109,6 +124,7 @@ public final class Events { jxlsContext.putVar("devices", devicesEvents); jxlsContext.putVar("sheetNames", sheetNames); jxlsContext.putVar("geofenceNames", geofenceNames); + jxlsContext.putVar("maintenanceNames", maintenanceNames); jxlsContext.putVar("from", from); jxlsContext.putVar("to", to); ReportUtils.processTemplateWithSheets(inputStream, outputStream, jxlsContext); |