aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/reports/ReportUtils.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2018-04-16 20:54:39 +1200
committerGitHub <noreply@github.com>2018-04-16 20:54:39 +1200
commitcec76679d1128514691d643278ef66e13a58be6d (patch)
tree0342b16af8f8aa524b69e4a5b83476431a5e6dbc /src/org/traccar/reports/ReportUtils.java
parent6d4b8df25c7e942b9ad594db9444fe15bcb16be9 (diff)
parent7a0be25c49eebba92ab70c715faa987312950b7d (diff)
downloadtrackermap-server-cec76679d1128514691d643278ef66e13a58be6d.tar.gz
trackermap-server-cec76679d1128514691d643278ef66e13a58be6d.tar.bz2
trackermap-server-cec76679d1128514691d643278ef66e13a58be6d.zip
Merge pull request #3849 from ckrey/OdometerInReportsClean
Odometer in reports clean
Diffstat (limited to 'src/org/traccar/reports/ReportUtils.java')
-rw-r--r--src/org/traccar/reports/ReportUtils.java25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/org/traccar/reports/ReportUtils.java b/src/org/traccar/reports/ReportUtils.java
index e04f2f90c..e12968428 100644
--- a/src/org/traccar/reports/ReportUtils.java
+++ b/src/org/traccar/reports/ReportUtils.java
@@ -217,10 +217,21 @@ public final class ReportUtils {
trip.setDriverUniqueId(findDriver(startTrip, endTrip));
trip.setDriverName(findDriverName(trip.getDriverUniqueId()));
+ if (!ignoreOdometer
+ && startTrip.getDouble(Position.KEY_ODOMETER) != 0
+ && endTrip.getDouble(Position.KEY_ODOMETER) != 0) {
+ trip.setStartOdometer(startTrip.getDouble(Position.KEY_ODOMETER));
+ trip.setEndOdometer(endTrip.getDouble(Position.KEY_ODOMETER));
+ } else {
+ trip.setStartOdometer(startTrip.getDouble(Position.KEY_TOTAL_DISTANCE));
+ trip.setEndOdometer(endTrip.getDouble(Position.KEY_TOTAL_DISTANCE));
+ }
+
return trip;
}
- private static StopReport calculateStop(ArrayList<Position> positions, int startIndex, int endIndex) {
+ private static StopReport calculateStop(ArrayList<Position> positions, int startIndex, int endIndex,
+ boolean ignoreOdometer) {
Position startStop = positions.get(startIndex);
Position endStop = positions.get(endIndex);
@@ -256,6 +267,16 @@ public final class ReportUtils {
}
stop.setEngineHours(engineHours);
+ if (!ignoreOdometer
+ && startStop.getDouble(Position.KEY_ODOMETER) != 0
+ && endStop.getDouble(Position.KEY_ODOMETER) != 0) {
+ stop.setStartOdometer(startStop.getDouble(Position.KEY_ODOMETER));
+ stop.setEndOdometer(endStop.getDouble(Position.KEY_ODOMETER));
+ } else {
+ stop.setStartOdometer(startStop.getDouble(Position.KEY_TOTAL_DISTANCE));
+ stop.setEndOdometer(endStop.getDouble(Position.KEY_TOTAL_DISTANCE));
+ }
+
return stop;
}
@@ -265,7 +286,7 @@ public final class ReportUtils {
if (reportClass.equals(TripReport.class)) {
return (T) calculateTrip(positions, startIndex, endIndex, ignoreOdometer);
} else {
- return (T) calculateStop(positions, startIndex, endIndex);
+ return (T) calculateStop(positions, startIndex, endIndex, ignoreOdometer);
}
}