From 35ae557526d8613e9658375e7f846e644fca4d83 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sun, 21 Apr 2024 15:52:44 -0700 Subject: Hide missing values in reports --- .../java/org/traccar/reports/SummaryReportProvider.java | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'src/main') diff --git a/src/main/java/org/traccar/reports/SummaryReportProvider.java b/src/main/java/org/traccar/reports/SummaryReportProvider.java index ffde0b067..5f155552b 100644 --- a/src/main/java/org/traccar/reports/SummaryReportProvider.java +++ b/src/main/java/org/traccar/reports/SummaryReportProvider.java @@ -105,15 +105,9 @@ public class SummaryReportProvider { result.setDistance(PositionUtil.calculateDistance(first, last, !ignoreOdometer)); result.setSpentFuel(reportUtils.calculateFuel(first, last)); - long durationMilliseconds; if (first.hasAttribute(Position.KEY_HOURS) && last.hasAttribute(Position.KEY_HOURS)) { - durationMilliseconds = last.getLong(Position.KEY_HOURS) - first.getLong(Position.KEY_HOURS); + long durationMilliseconds = last.getLong(Position.KEY_HOURS) - first.getLong(Position.KEY_HOURS); result.setEngineHours(durationMilliseconds); - } else { - durationMilliseconds = last.getFixTime().getTime() - first.getFixTime().getTime(); - } - - if (durationMilliseconds > 0) { result.setAverageSpeed(UnitsConverter.knotsFromMps(result.getDistance() * 1000 / durationMilliseconds)); } @@ -142,15 +136,13 @@ public class SummaryReportProvider { if (daily) { while (from.truncatedTo(ChronoUnit.DAYS).isBefore(to.truncatedTo(ChronoUnit.DAYS))) { ZonedDateTime fromDay = from.truncatedTo(ChronoUnit.DAYS); - ZonedDateTime nextDay = fromDay.plus(1, ChronoUnit.DAYS); + ZonedDateTime nextDay = fromDay.plusDays(1); results.addAll(calculateDeviceResult( device, Date.from(from.toInstant()), Date.from(nextDay.toInstant()), fast)); from = nextDay; } - results.addAll(calculateDeviceResult(device, Date.from(from.toInstant()), Date.from(to.toInstant()), fast)); - } else { - results.addAll(calculateDeviceResult(device, Date.from(from.toInstant()), Date.from(to.toInstant()), fast)); } + results.addAll(calculateDeviceResult(device, Date.from(from.toInstant()), Date.from(to.toInstant()), fast)); return results; } -- cgit v1.2.3