diff options
author | Abyss777 <abyss@fox5.ru> | 2017-07-13 10:05:57 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2017-07-13 10:05:57 +0500 |
commit | e776aa3351535f78c60ab9502dd1154e2b973227 (patch) | |
tree | b19a69b83975aceca5ffa854da5181e62221fc0e /src/org/traccar/reports | |
parent | 74471c1fbbb7e8a09a6958fa88930a2905b4a3eb (diff) | |
download | trackermap-server-e776aa3351535f78c60ab9502dd1154e2b973227.tar.gz trackermap-server-e776aa3351535f78c60ab9502dd1154e2b973227.tar.bz2 trackermap-server-e776aa3351535f78c60ab9502dd1154e2b973227.zip |
- Save both driver name and driver unique id in trip report
- Map user and driver objects to notification templates
- Add driverUnauthorized templates
Diffstat (limited to 'src/org/traccar/reports')
-rw-r--r-- | src/org/traccar/reports/ReportUtils.java | 17 | ||||
-rw-r--r-- | src/org/traccar/reports/model/TripReport.java | 10 |
2 files changed, 21 insertions, 6 deletions
diff --git a/src/org/traccar/reports/ReportUtils.java b/src/org/traccar/reports/ReportUtils.java index 92918b861..3a177300b 100644 --- a/src/org/traccar/reports/ReportUtils.java +++ b/src/org/traccar/reports/ReportUtils.java @@ -102,16 +102,19 @@ public final class ReportUtils { return 0; } - public static String findDriverName(Position firstPosition, Position lastPosition) { - String driverUniqueId = null; + public static String findDriver(Position firstPosition, Position lastPosition) { if (firstPosition.getAttributes().containsKey(Position.KEY_DRIVER_UNIQUE_ID)) { - driverUniqueId = firstPosition.getString(Position.KEY_DRIVER_UNIQUE_ID); + return firstPosition.getString(Position.KEY_DRIVER_UNIQUE_ID); } else if (lastPosition.getAttributes().containsKey(Position.KEY_DRIVER_UNIQUE_ID)) { - driverUniqueId = lastPosition.getString(Position.KEY_DRIVER_UNIQUE_ID); + return lastPosition.getString(Position.KEY_DRIVER_UNIQUE_ID); } + return null; + } + + public static String findDriverName(String driverUniqueId) { if (driverUniqueId != null && Context.getDriversManager() != null) { Driver driver = Context.getDriversManager().getDriverByUniqueId(driverUniqueId); - return driver != null ? driver.getName() : null; + return driver != null ? driver.getName() : driverUniqueId; } return null; } @@ -190,7 +193,9 @@ public final class ReportUtils { trip.setAverageSpeed(speedSum / (endIndex - startIndex)); trip.setMaxSpeed(speedMax); trip.setSpentFuel(calculateFuel(startTrip, endTrip)); - trip.setDriverName(findDriverName(startTrip, endTrip)); + + trip.setDriverUniqueId(findDriver(startTrip, endTrip)); + trip.setDriverName(findDriverName(trip.getDriverUniqueId())); return trip; } diff --git a/src/org/traccar/reports/model/TripReport.java b/src/org/traccar/reports/model/TripReport.java index 0f23581b2..42a4240b7 100644 --- a/src/org/traccar/reports/model/TripReport.java +++ b/src/org/traccar/reports/model/TripReport.java @@ -146,6 +146,16 @@ public class TripReport extends BaseReport { this.duration = duration; } + private String driverUniqueId; + + public String getDriverUniqueId() { + return driverUniqueId; + } + + public void setDriverUniqueId(String driverUniqueId) { + this.driverUniqueId = driverUniqueId; + } + private String driverName; public String getDriverName() { |