diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2017-04-17 17:18:07 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2017-04-17 17:18:07 +1200 |
commit | 136a302846ad340f6babaa5f0f35018d867f73e8 (patch) | |
tree | ab3fb3c575a98e75f9a1d0a7d9a08c32358844b2 /src/org/traccar/reports/ReportUtils.java | |
parent | 57941c8095839951caf868368963ba13e8fc3da3 (diff) | |
download | trackermap-server-136a302846ad340f6babaa5f0f35018d867f73e8.tar.gz trackermap-server-136a302846ad340f6babaa5f0f35018d867f73e8.tar.bz2 trackermap-server-136a302846ad340f6babaa5f0f35018d867f73e8.zip |
Add spent fuel to summary report
Diffstat (limited to 'src/org/traccar/reports/ReportUtils.java')
-rw-r--r-- | src/org/traccar/reports/ReportUtils.java | 22 |
1 files changed, 5 insertions, 17 deletions
diff --git a/src/org/traccar/reports/ReportUtils.java b/src/org/traccar/reports/ReportUtils.java index 02e3764bc..acc8e4e3b 100644 --- a/src/org/traccar/reports/ReportUtils.java +++ b/src/org/traccar/reports/ReportUtils.java @@ -90,24 +90,12 @@ public final class ReportUtils { if (firstPosition.getAttributes().get(Position.KEY_FUEL_LEVEL) != null && lastPosition.getAttributes().get(Position.KEY_FUEL_LEVEL) != null) { - try { - switch (firstPosition.getProtocol()) { - case "meitrack": - case "galileo": - case "noran": - BigDecimal v = new BigDecimal( - firstPosition.getAttributes().get(Position.KEY_FUEL_LEVEL).toString()); - v = v.subtract(new BigDecimal( - lastPosition.getAttributes().get(Position.KEY_FUEL_LEVEL).toString())); - return v.setScale(2, RoundingMode.HALF_EVEN).toString() + " %"; - default: - break; - } - } catch (Exception error) { - Log.warning(error); - } + + BigDecimal value = new BigDecimal(firstPosition.getDouble(Position.KEY_FUEL_LEVEL) + - lastPosition.getDouble(Position.KEY_FUEL_LEVEL)); + return value.setScale(1, RoundingMode.HALF_EVEN).toString(); } - return "-"; + return null; } public static org.jxls.common.Context initializeContext(long userId) { |