aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2024-05-23 18:18:51 -0700
committerAnton Tananaev <anton@traccar.org>2024-05-23 18:18:51 -0700
commitbcbc08150700c2cc68d8b894bdd1dd38ad65ca62 (patch)
tree237ea3feafa6ee51d13dcc6deaf4fa946c28cfb6
parentb9445651c5b9803476d0f96702ff3a293a327e20 (diff)
downloadtrackermap-server-bcbc08150700c2cc68d8b894bdd1dd38ad65ca62.tar.gz
trackermap-server-bcbc08150700c2cc68d8b894bdd1dd38ad65ca62.tar.bz2
trackermap-server-bcbc08150700c2cc68d8b894bdd1dd38ad65ca62.zip
Summary report start and end hours
-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;
+ }
+
}