aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/org/traccar/reports/ReportUtils.java22
-rw-r--r--src/org/traccar/reports/Summary.java1
-rw-r--r--src/org/traccar/reports/model/BaseReport.java16
-rw-r--r--src/org/traccar/reports/model/DeviceReport.java6
-rw-r--r--src/org/traccar/reports/model/SummaryReport.java14
-rw-r--r--src/org/traccar/reports/model/TripReport.java24
-rw-r--r--templates/export/summary.xlsxbin12350 -> 8735 bytes
7 files changed, 63 insertions, 20 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) {
diff --git a/src/org/traccar/reports/Summary.java b/src/org/traccar/reports/Summary.java
index abe0277da..5aaf33fae 100644
--- a/src/org/traccar/reports/Summary.java
+++ b/src/org/traccar/reports/Summary.java
@@ -61,6 +61,7 @@ public final class Summary {
.lookupAttributeBoolean(deviceId, "report.ignoreOdometer", false, true);
result.setDistance(ReportUtils.calculateDistance(firstPosition, previousPosition, !ignoreOdometer));
result.setAverageSpeed(speedSum / positions.size());
+ result.setSpentFuel(ReportUtils.calculateFuel(firstPosition, previousPosition));
}
return result;
}
diff --git a/src/org/traccar/reports/model/BaseReport.java b/src/org/traccar/reports/model/BaseReport.java
index c33b9a8dd..13c67cbb7 100644
--- a/src/org/traccar/reports/model/BaseReport.java
+++ b/src/org/traccar/reports/model/BaseReport.java
@@ -19,25 +19,31 @@ package org.traccar.reports.model;
public class BaseReport {
private long deviceId;
+
public long getDeviceId() {
return deviceId;
}
+
public void setDeviceId(long deviceId) {
this.deviceId = deviceId;
}
private String deviceName;
+
public String getDeviceName() {
return deviceName;
}
+
public void setDeviceName(String deviceName) {
this.deviceName = deviceName;
}
- private double distance; // meters
+ private double distance;
+
public double getDistance() {
return distance;
}
+
public void setDistance(double distance) {
this.distance = distance;
}
@@ -46,18 +52,22 @@ public class BaseReport {
this.distance += distance;
}
- private double averageSpeed; // knots
+ private double averageSpeed;
+
public double getAverageSpeed() {
return averageSpeed;
}
+
public void setAverageSpeed(Double averageSpeed) {
this.averageSpeed = averageSpeed;
}
- private double maxSpeed; // knots
+ private double maxSpeed;
+
public double getMaxSpeed() {
return maxSpeed;
}
+
public void setMaxSpeed(double maxSpeed) {
if (maxSpeed > this.maxSpeed) {
this.maxSpeed = maxSpeed;
diff --git a/src/org/traccar/reports/model/DeviceReport.java b/src/org/traccar/reports/model/DeviceReport.java
index 58caa809b..932753d15 100644
--- a/src/org/traccar/reports/model/DeviceReport.java
+++ b/src/org/traccar/reports/model/DeviceReport.java
@@ -23,25 +23,31 @@ import java.util.List;
public class DeviceReport {
private String deviceName;
+
public String getDeviceName() {
return deviceName;
}
+
public void setDeviceName(String deviceName) {
this.deviceName = deviceName;
}
private String groupName = "";
+
public String getGroupName() {
return groupName;
}
+
public void setGroupName(String groupName) {
this.groupName = groupName;
}
private List<?> objects;
+
public Collection<?> getObjects() {
return objects;
}
+
public void setObjects(Collection<?> objects) {
this.objects = new ArrayList<>(objects);
}
diff --git a/src/org/traccar/reports/model/SummaryReport.java b/src/org/traccar/reports/model/SummaryReport.java
index 2d650381d..85ba6bc54 100644
--- a/src/org/traccar/reports/model/SummaryReport.java
+++ b/src/org/traccar/reports/model/SummaryReport.java
@@ -19,13 +19,27 @@ package org.traccar.reports.model;
public class SummaryReport extends BaseReport {
private long engineHours; // milliseconds
+
public long getEngineHours() {
return engineHours;
}
+
public void setEngineHours(long engineHours) {
this.engineHours = engineHours;
}
+
public void addEngineHours(long engineHours) {
this.engineHours += engineHours;
}
+
+ private String spentFuel;
+
+ public String getSpentFuel() {
+ return spentFuel;
+ }
+
+ public void setSpentFuel(String spentFuel) {
+ this.spentFuel = spentFuel;
+ }
+
}
diff --git a/src/org/traccar/reports/model/TripReport.java b/src/org/traccar/reports/model/TripReport.java
index b28793e44..fce805ad6 100644
--- a/src/org/traccar/reports/model/TripReport.java
+++ b/src/org/traccar/reports/model/TripReport.java
@@ -21,54 +21,67 @@ import java.util.Date;
public class TripReport extends BaseReport {
private long startPositionId;
+
public long getStartPositionId() {
return startPositionId;
}
+
public void setStartPositionId(long startPositionId) {
this.startPositionId = startPositionId;
}
private long endPositionId;
+
public long getEndPositionId() {
return endPositionId;
}
+
public void setEndPositionId(long endPositionId) {
this.endPositionId = endPositionId;
}
private double startLat;
+
public double getStartLat() {
return startLat;
}
+
public void setStartLat(double startLat) {
this.startLat = startLat;
}
private double startLon;
+
public double getStartLon() {
return startLon;
}
+
public void setStartLon(double startLon) {
this.startLon = startLon;
}
private double endLat;
+
public double getEndLat() {
return endLat;
}
+
public void setEndLat(double endLat) {
this.endLat = endLat;
}
private double endLon;
+
public double getEndLon() {
return endLon;
}
+
public void setEndLon(double endLon) {
this.endLon = endLon;
}
private Date startTime;
+
public Date getStartTime() {
if (startTime != null) {
return new Date(startTime.getTime());
@@ -76,6 +89,7 @@ public class TripReport extends BaseReport {
return null;
}
}
+
public void setStartTime(Date startTime) {
if (startTime != null) {
this.startTime = new Date(startTime.getTime());
@@ -85,14 +99,17 @@ public class TripReport extends BaseReport {
}
private String startAddress;
+
public String getStartAddress() {
return startAddress;
}
+
public void setStartAddress(String address) {
this.startAddress = address;
}
private Date endTime;
+
public Date getEndTime() {
if (endTime != null) {
return new Date(endTime.getTime());
@@ -100,6 +117,7 @@ public class TripReport extends BaseReport {
return null;
}
}
+
public void setEndTime(Date endTime) {
if (endTime != null) {
this.endTime = new Date(endTime.getTime());
@@ -109,25 +127,31 @@ public class TripReport extends BaseReport {
}
private String endAddress;
+
public String getEndAddress() {
return endAddress;
}
+
public void setEndAddress(String address) {
this.endAddress = address;
}
private long duration;
+
public long getDuration() {
return duration;
}
+
public void setDuration(long duration) {
this.duration = duration;
}
private String spentFuel;
+
public String getSpentFuel() {
return spentFuel;
}
+
public void setSpentFuel(String spentFuel) {
this.spentFuel = spentFuel;
}
diff --git a/templates/export/summary.xlsx b/templates/export/summary.xlsx
index db32d077a..73e702a70 100644
--- a/templates/export/summary.xlsx
+++ b/templates/export/summary.xlsx
Binary files differ