aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/reports
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/reports')
-rw-r--r--src/org/traccar/reports/ReportUtils.java17
-rw-r--r--src/org/traccar/reports/model/TripReport.java10
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() {