Summary report start and end hours

This commit is contained in:
Anton Tananaev 2024-05-23 18:18:51 -07:00
parent b9445651c5
commit bcbc081507
2 changed files with 26 additions and 10 deletions

View File

@ -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

View File

@ -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;
}
public void setEngineHours(long engineHours) {
this.engineHours = engineHours;
private long startHours; // milliseconds
public long getStartHours() {
return startHours;
}
public void setStartHours(long startHours) {
this.startHours = startHours;
}
private long endHours; // milliseconds
public long getEndHours() {
return endHours;
}
public void setEndHours(long endHours) {
this.endHours = endHours;
}
}