From bcbc08150700c2cc68d8b894bdd1dd38ad65ca62 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Thu, 23 May 2024 18:18:51 -0700 Subject: Summary report start and end hours --- .../org/traccar/reports/SummaryReportProvider.java | 9 ++++---- .../traccar/reports/model/SummaryReportItem.java | 27 +++++++++++++++++----- 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; + } + } -- cgit v1.2.3