aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/reports/ReportUtils.java
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2018-05-31 09:04:38 +0500
committerAbyss777 <abyss@fox5.ru>2018-05-31 09:04:38 +0500
commit3d14b6504b01b26e529717b88318be54094b8816 (patch)
tree2586ec5b6e0d0e28615a6caf7b7f69ce94f7573b /src/org/traccar/reports/ReportUtils.java
parent607123610018cdc1f0e391fec43e54e769d40a06 (diff)
downloadtrackermap-server-3d14b6504b01b26e529717b88318be54094b8816.tar.gz
trackermap-server-3d14b6504b01b26e529717b88318be54094b8816.tar.bz2
trackermap-server-3d14b6504b01b26e529717b88318be54094b8816.zip
Add engine hours handler
Diffstat (limited to 'src/org/traccar/reports/ReportUtils.java')
-rw-r--r--src/org/traccar/reports/ReportUtils.java14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/org/traccar/reports/ReportUtils.java b/src/org/traccar/reports/ReportUtils.java
index 010c88b22..94cc7664f 100644
--- a/src/org/traccar/reports/ReportUtils.java
+++ b/src/org/traccar/reports/ReportUtils.java
@@ -263,10 +263,16 @@ public final class ReportUtils {
stop.setSpentFuel(calculateFuel(startStop, endStop));
long engineHours = 0;
- for (int i = startIndex + 1; i <= endIndex; i++) {
- if (positions.get(i).getBoolean(Position.KEY_IGNITION)
- && positions.get(i - 1).getBoolean(Position.KEY_IGNITION)) {
- engineHours += positions.get(i).getFixTime().getTime() - positions.get(i - 1).getFixTime().getTime();
+ if (startStop.getAttributes().containsKey(Position.KEY_HOURS)
+ && endStop.getAttributes().containsKey(Position.KEY_HOURS)) {
+ engineHours = endStop.getLong(Position.KEY_HOURS) - startStop.getLong(Position.KEY_HOURS);
+ } else if (Context.getConfig().getBoolean("engineHours.enable")) {
+ for (int i = startIndex + 1; i <= endIndex; i++) {
+ if (positions.get(i).getBoolean(Position.KEY_IGNITION)
+ && positions.get(i - 1).getBoolean(Position.KEY_IGNITION)) {
+ engineHours += positions.get(i).getFixTime().getTime()
+ - positions.get(i - 1).getFixTime().getTime();
+ }
}
}
stop.setEngineHours(engineHours);