aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/reports/General.java
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2016-08-05 14:41:53 +0500
committerAbyss777 <abyss@fox5.ru>2016-08-05 14:41:53 +0500
commit5a6e7582a7978341f3a2de9a81cb63252bca0bb7 (patch)
tree585eab11bfd805b9de814324e5e892e854fc1c62 /src/org/traccar/reports/General.java
parent933247b3d2ec24d65203fae39dcafbe2c9afb87e (diff)
downloadtrackermap-server-5a6e7582a7978341f3a2de9a81cb63252bca0bb7.tar.gz
trackermap-server-5a6e7582a7978341f3a2de9a81cb63252bca0bb7.tar.bz2
trackermap-server-5a6e7582a7978341f3a2de9a81cb63252bca0bb7.zip
- Moved GeneralReport to separate file
- Removed unnecessary getOut function - Added methods sorting
Diffstat (limited to 'src/org/traccar/reports/General.java')
-rw-r--r--src/org/traccar/reports/General.java50
1 files changed, 5 insertions, 45 deletions
diff --git a/src/org/traccar/reports/General.java b/src/org/traccar/reports/General.java
index 75194bc13..595dd49f9 100644
--- a/src/org/traccar/reports/General.java
+++ b/src/org/traccar/reports/General.java
@@ -12,6 +12,7 @@ import javax.json.JsonObjectBuilder;
import org.traccar.Context;
import org.traccar.helper.DistanceCalculator;
import org.traccar.model.Position;
+import org.traccar.reports.model.GeneralReport;
import org.traccar.web.CsvBuilder;
import org.traccar.web.JsonConverter;
@@ -20,49 +21,8 @@ public final class General {
private General() {
}
- public static class GeneralResult {
-
- private String deviceName;
- public String getDeviceName() {
- return deviceName;
- }
- public void setDeviceName(String deviceName) {
- this.deviceName = deviceName;
- }
-
- private double distance = 0;
- public double getDistance() {
- return distance;
- }
- public void setDistance(double distance) {
- this.distance = distance;
- }
-
- public void addDistance(double distance) {
- this.distance += distance;
- }
-
- private double averageSpeed = 0;
- public double getAverageSpeed() {
- return averageSpeed;
- }
- public void setAverageSpeed(double averageSpeed) {
- this.averageSpeed = averageSpeed;
- }
-
- private double maxSpeed = 0;
- public double getMaxSpeed() {
- return maxSpeed;
- }
- public void setMaxSpeed(double maxSpeed) {
- if (maxSpeed > this.maxSpeed) {
- this.maxSpeed = maxSpeed;
- }
- }
- }
-
- private static GeneralResult calculateGeneralResult(long deviceId, Date from, Date to) throws SQLException {
- GeneralResult result = new GeneralResult();
+ private static GeneralReport calculateGeneralResult(long deviceId, Date from, Date to) throws SQLException {
+ GeneralReport result = new GeneralReport();
Collection<Position> positions = Context.getDataManager().getPositions(deviceId, from, to);
if (positions != null && !positions.isEmpty()) {
result.setDeviceName(Context.getDeviceManager().getDeviceById(deviceId).getName());
@@ -93,12 +53,12 @@ public final class General {
return json.build().toString();
}
- public static byte[] getCsv(long userId, Collection<Long> deviceIds, Collection<Long> groupIds,
+ public static String getCsv(long userId, Collection<Long> deviceIds, Collection<Long> groupIds,
Date from, Date to) throws SQLException {
CsvBuilder csv = new CsvBuilder();
for (long deviceId: ReportUtils.getReportedDevices(deviceIds, groupIds)) {
Context.getPermissionsManager().checkDevice(userId, deviceId);
- csv.addHeaderLine(new GeneralResult());
+ csv.addHeaderLine(new GeneralReport());
csv.addLine(calculateGeneralResult(deviceId, from, to));
}
return csv.get();