diff options
author | Abyss777 <abyss@fox5.ru> | 2017-07-12 14:22:03 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2017-07-12 15:20:07 +0500 |
commit | b19f1a505f7088ff48f467b32b5f1c207aa3be01 (patch) | |
tree | 663ef14ec15af04e5d9062c2185cd020fb5b9e42 /src/org/traccar/reports/ReportUtils.java | |
parent | 4f3830d844dd0542e9e7b09e7a6c17ffbb796264 (diff) | |
download | trackermap-server-b19f1a505f7088ff48f467b32b5f1c207aa3be01.tar.gz trackermap-server-b19f1a505f7088ff48f467b32b5f1c207aa3be01.tar.bz2 trackermap-server-b19f1a505f7088ff48f467b32b5f1c207aa3be01.zip |
- Handle rfid attributes and populate driverUniqueId
- Add Driver Name to Trip report
Diffstat (limited to 'src/org/traccar/reports/ReportUtils.java')
-rw-r--r-- | src/org/traccar/reports/ReportUtils.java | 16 |
1 files changed, 16 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; } |