aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/org/traccar/reports/SummaryReportProvider.java9
-rw-r--r--src/main/java/org/traccar/reports/model/SummaryReportItem.java27
2 files changed, 26 insertions, 10 deletions
diff --git a/src/main/java/org/traccar/reports/SummaryReportProvider.java b/src/main/java/org/traccar/reports/SummaryReportProvider.java
index 5f155552b..5bd7e51b3 100644
--- a/src/main/java/org/traccar/reports/SummaryReportProvider.java
+++ b/src/main/java/org/traccar/reports/SummaryReportProvider.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 - 2023 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2024 Anton Tananaev (anton@traccar.org)
* Copyright 2016 Andrey Kunitsyn (andrey@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -106,9 +106,10 @@ public class SummaryReportProvider {
result.setSpentFuel(reportUtils.calculateFuel(first, last));
if (first.hasAttribute(Position.KEY_HOURS) && last.hasAttribute(Position.KEY_HOURS)) {
- long durationMilliseconds = last.getLong(Position.KEY_HOURS) - first.getLong(Position.KEY_HOURS);
- result.setEngineHours(durationMilliseconds);
- result.setAverageSpeed(UnitsConverter.knotsFromMps(result.getDistance() * 1000 / durationMilliseconds));
+ result.setStartHours(first.getLong(Position.KEY_HOURS));
+ result.setEndHours(last.getLong(Position.KEY_HOURS));
+ result.setAverageSpeed(UnitsConverter.knotsFromMps(
+ result.getDistance() * 1000 / result.getEngineHours()));
}
if (!ignoreOdometer
diff --git a/src/main/java/org/traccar/reports/model/SummaryReportItem.java b/src/main/java/org/traccar/reports/model/SummaryReportItem.java
index 44a15cf1d..b88cabe49 100644
--- a/src/main/java/org/traccar/reports/model/SummaryReportItem.java
+++ b/src/main/java/org/traccar/reports/model/SummaryReportItem.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 - 2020 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2024 Anton Tananaev (anton@traccar.org)
* Copyright 2016 - 2017 Andrey Kunitsyn (andrey@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,13 +18,28 @@ package org.traccar.reports.model;
public class SummaryReportItem extends BaseReportItem {
- private long engineHours; // milliseconds
-
public long getEngineHours() {
- return engineHours;
+ return endHours - startHours;
+ }
+
+ private long startHours; // milliseconds
+
+ public long getStartHours() {
+ return startHours;
+ }
+
+ public void setStartHours(long startHours) {
+ this.startHours = startHours;
}
- public void setEngineHours(long engineHours) {
- this.engineHours = engineHours;
+ private long endHours; // milliseconds
+
+ public long getEndHours() {
+ return endHours;
}
+
+ public void setEndHours(long endHours) {
+ this.endHours = endHours;
+ }
+
}