aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/reports
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2017-07-12 14:22:03 +0500
committerAbyss777 <abyss@fox5.ru>2017-07-12 15:20:07 +0500
commitb19f1a505f7088ff48f467b32b5f1c207aa3be01 (patch)
tree663ef14ec15af04e5d9062c2185cd020fb5b9e42 /src/org/traccar/reports
parent4f3830d844dd0542e9e7b09e7a6c17ffbb796264 (diff)
downloadtraccar-server-b19f1a505f7088ff48f467b32b5f1c207aa3be01.tar.gz
traccar-server-b19f1a505f7088ff48f467b32b5f1c207aa3be01.tar.bz2
traccar-server-b19f1a505f7088ff48f467b32b5f1c207aa3be01.zip
- Handle rfid attributes and populate driverUniqueId
- Add Driver Name to Trip report
Diffstat (limited to 'src/org/traccar/reports')
-rw-r--r--src/org/traccar/reports/ReportUtils.java16
-rw-r--r--src/org/traccar/reports/model/TripReport.java10
2 files changed, 26 insertions, 0 deletions
diff --git a/src/org/traccar/reports/ReportUtils.java b/src/org/traccar/reports/ReportUtils.java
index 71c567c29..92918b861 100644
--- a/src/org/traccar/reports/ReportUtils.java
+++ b/src/org/traccar/reports/ReportUtils.java
@@ -26,6 +26,7 @@ import org.jxls.transform.Transformer;
import org.jxls.transform.poi.PoiTransformer;
import org.jxls.util.TransformerFactory;
import org.traccar.Context;
+import org.traccar.model.Driver;
import org.traccar.model.Position;
import org.traccar.reports.model.BaseReport;
import org.traccar.reports.model.StopReport;
@@ -101,6 +102,20 @@ public final class ReportUtils {
return 0;
}
+ public static String findDriverName(Position firstPosition, Position lastPosition) {
+ String driverUniqueId = null;
+ if (firstPosition.getAttributes().containsKey(Position.KEY_DRIVER_UNIQUE_ID)) {
+ driverUniqueId = 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);
+ }
+ if (driverUniqueId != null && Context.getDriversManager() != null) {
+ Driver driver = Context.getDriversManager().getDriverByUniqueId(driverUniqueId);
+ return driver != null ? driver.getName() : null;
+ }
+ return null;
+ }
+
public static org.jxls.common.Context initializeContext(long userId) {
org.jxls.common.Context jxlsContext = PoiTransformer.createInitialContext();
jxlsContext.putVar("distanceUnit", getDistanceUnit(userId));
@@ -175,6 +190,7 @@ public final class ReportUtils {
trip.setAverageSpeed(speedSum / (endIndex - startIndex));
trip.setMaxSpeed(speedMax);
trip.setSpentFuel(calculateFuel(startTrip, endTrip));
+ trip.setDriverName(findDriverName(startTrip, endTrip));
return trip;
}
diff --git a/src/org/traccar/reports/model/TripReport.java b/src/org/traccar/reports/model/TripReport.java
index efe556f79..0f23581b2 100644
--- a/src/org/traccar/reports/model/TripReport.java
+++ b/src/org/traccar/reports/model/TripReport.java
@@ -145,4 +145,14 @@ public class TripReport extends BaseReport {
public void setDuration(long duration) {
this.duration = duration;
}
+
+ private String driverName;
+
+ public String getDriverName() {
+ return driverName;
+ }
+
+ public void setDriverName(String driverName) {
+ this.driverName = driverName;
+ }
}