aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2017-06-20 17:07:37 +0500
committerAbyss777 <abyss@fox5.ru>2017-06-20 17:07:37 +0500
commitbc0c4319245de8e4ff62f005b22fc73350090d9e (patch)
tree93d4cd495a2eb8248bd4ca0759ead2c30241d55b
parent87d3a5d2a2782f57c3dfa50de64052697ca9250d (diff)
downloadtrackermap-server-bc0c4319245de8e4ff62f005b22fc73350090d9e.tar.gz
trackermap-server-bc0c4319245de8e4ff62f005b22fc73350090d9e.tar.bz2
trackermap-server-bc0c4319245de8e4ff62f005b22fc73350090d9e.zip
Change type of 'spentFuel' to double
-rw-r--r--src/org/traccar/reports/ReportUtils.java6
-rw-r--r--src/org/traccar/reports/model/BaseReport.java6
-rw-r--r--test/org/traccar/reports/ReportUtilsTest.java4
3 files changed, 8 insertions, 8 deletions
diff --git a/src/org/traccar/reports/ReportUtils.java b/src/org/traccar/reports/ReportUtils.java
index 705f11429..71c567c29 100644
--- a/src/org/traccar/reports/ReportUtils.java
+++ b/src/org/traccar/reports/ReportUtils.java
@@ -89,16 +89,16 @@ public final class ReportUtils {
return distance;
}
- public static String calculateFuel(Position firstPosition, Position lastPosition) {
+ public static double calculateFuel(Position firstPosition, Position lastPosition) {
if (firstPosition.getAttributes().get(Position.KEY_FUEL_LEVEL) != null
&& lastPosition.getAttributes().get(Position.KEY_FUEL_LEVEL) != null) {
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 value.setScale(1, RoundingMode.HALF_EVEN).doubleValue();
}
- return null;
+ return 0;
}
public static org.jxls.common.Context initializeContext(long userId) {
diff --git a/src/org/traccar/reports/model/BaseReport.java b/src/org/traccar/reports/model/BaseReport.java
index e1dec1407..941e2757f 100644
--- a/src/org/traccar/reports/model/BaseReport.java
+++ b/src/org/traccar/reports/model/BaseReport.java
@@ -74,13 +74,13 @@ public class BaseReport {
}
}
- private String spentFuel;
+ private double spentFuel;
- public String getSpentFuel() {
+ public double getSpentFuel() {
return spentFuel;
}
- public void setSpentFuel(String spentFuel) {
+ public void setSpentFuel(double spentFuel) {
this.spentFuel = spentFuel;
}
diff --git a/test/org/traccar/reports/ReportUtilsTest.java b/test/org/traccar/reports/ReportUtilsTest.java
index 2fe05e688..adcdf5875 100644
--- a/test/org/traccar/reports/ReportUtilsTest.java
+++ b/test/org/traccar/reports/ReportUtilsTest.java
@@ -60,10 +60,10 @@ public class ReportUtilsTest extends BaseTest {
public void testCalculateSpentFuel() {
Position startPosition = new Position();
Position endPosition = new Position();
- Assert.assertNull(ReportUtils.calculateFuel(startPosition, endPosition));
+ Assert.assertEquals(ReportUtils.calculateFuel(startPosition, endPosition), 0.0, 0.01);
startPosition.set(Position.KEY_FUEL_LEVEL, 0.7);
endPosition.set(Position.KEY_FUEL_LEVEL, 0.5);
- Assert.assertEquals(ReportUtils.calculateFuel(startPosition, endPosition), "0.2");
+ Assert.assertEquals(ReportUtils.calculateFuel(startPosition, endPosition), 0.2, 0.01);
}
@Test