aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2023-05-24 15:37:04 -0700
committerAnton Tananaev <anton@traccar.org>2023-05-24 15:37:04 -0700
commit886efe231e79255aa86a0056e7bf912fff6069fb (patch)
tree74652c5077fa2849a08f8bc4569715c04fe96b36 /src/main/java
parentd304c74cfc870d23718cb7aabfd6038492aade8b (diff)
downloadtrackermap-server-886efe231e79255aa86a0056e7bf912fff6069fb.tar.gz
trackermap-server-886efe231e79255aa86a0056e7bf912fff6069fb.tar.bz2
trackermap-server-886efe231e79255aa86a0056e7bf912fff6069fb.zip
Query positions in report utils
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/traccar/reports/StopsReportProvider.java11
-rw-r--r--src/main/java/org/traccar/reports/TripsReportProvider.java11
-rw-r--r--src/main/java/org/traccar/reports/common/ReportUtils.java10
3 files changed, 9 insertions, 23 deletions
diff --git a/src/main/java/org/traccar/reports/StopsReportProvider.java b/src/main/java/org/traccar/reports/StopsReportProvider.java
index a23cee48b..57c57079d 100644
--- a/src/main/java/org/traccar/reports/StopsReportProvider.java
+++ b/src/main/java/org/traccar/reports/StopsReportProvider.java
@@ -20,7 +20,6 @@ import org.apache.poi.ss.util.WorkbookUtil;
import org.traccar.config.Config;
import org.traccar.config.Keys;
import org.traccar.helper.model.DeviceUtil;
-import org.traccar.helper.model.PositionUtil;
import org.traccar.model.Device;
import org.traccar.model.Group;
import org.traccar.reports.common.ReportUtils;
@@ -56,12 +55,6 @@ public class StopsReportProvider {
this.storage = storage;
}
- private Collection<StopReportItem> detectStops(Device device, Date from, Date to) throws StorageException {
- boolean ignoreOdometer = config.getBoolean(Keys.REPORT_IGNORE_ODOMETER);
- var positions = PositionUtil.getPositions(storage, device.getId(), from, to);
- return reportUtils.detectTripsAndStops(device, positions, ignoreOdometer, StopReportItem.class);
- }
-
public Collection<StopReportItem> getObjects(
long userId, Collection<Long> deviceIds, Collection<Long> groupIds,
Date from, Date to) throws StorageException {
@@ -69,7 +62,7 @@ public class StopsReportProvider {
ArrayList<StopReportItem> result = new ArrayList<>();
for (Device device: DeviceUtil.getAccessibleDevices(storage, userId, deviceIds, groupIds)) {
- result.addAll(detectStops(device, from, to));
+ result.addAll(reportUtils.detectTripsAndStops(device, from, to, StopReportItem.class));
}
return result;
}
@@ -82,7 +75,7 @@ public class StopsReportProvider {
ArrayList<DeviceReportSection> devicesStops = new ArrayList<>();
ArrayList<String> sheetNames = new ArrayList<>();
for (Device device: DeviceUtil.getAccessibleDevices(storage, userId, deviceIds, groupIds)) {
- Collection<StopReportItem> stops = detectStops(device, from, to);
+ Collection<StopReportItem> stops = reportUtils.detectTripsAndStops(device, from, to, StopReportItem.class);
DeviceReportSection deviceStops = new DeviceReportSection();
deviceStops.setDeviceName(device.getName());
sheetNames.add(WorkbookUtil.createSafeSheetName(deviceStops.getDeviceName()));
diff --git a/src/main/java/org/traccar/reports/TripsReportProvider.java b/src/main/java/org/traccar/reports/TripsReportProvider.java
index 2d8989b7a..e6c3e7ffd 100644
--- a/src/main/java/org/traccar/reports/TripsReportProvider.java
+++ b/src/main/java/org/traccar/reports/TripsReportProvider.java
@@ -20,7 +20,6 @@ import org.apache.poi.ss.util.WorkbookUtil;
import org.traccar.config.Config;
import org.traccar.config.Keys;
import org.traccar.helper.model.DeviceUtil;
-import org.traccar.helper.model.PositionUtil;
import org.traccar.model.Device;
import org.traccar.model.Group;
import org.traccar.reports.common.ReportUtils;
@@ -56,12 +55,6 @@ public class TripsReportProvider {
this.storage = storage;
}
- private Collection<TripReportItem> detectTrips(Device device, Date from, Date to) throws StorageException {
- boolean ignoreOdometer = config.getBoolean(Keys.REPORT_IGNORE_ODOMETER);
- var positions = PositionUtil.getPositions(storage, device.getId(), from, to);
- return reportUtils.detectTripsAndStops(device, positions, ignoreOdometer, TripReportItem.class);
- }
-
public Collection<TripReportItem> getObjects(
long userId, Collection<Long> deviceIds, Collection<Long> groupIds,
Date from, Date to) throws StorageException {
@@ -69,7 +62,7 @@ public class TripsReportProvider {
ArrayList<TripReportItem> result = new ArrayList<>();
for (Device device: DeviceUtil.getAccessibleDevices(storage, userId, deviceIds, groupIds)) {
- result.addAll(detectTrips(device, from, to));
+ result.addAll(reportUtils.detectTripsAndStops(device, from, to, TripReportItem.class));
}
return result;
}
@@ -82,7 +75,7 @@ public class TripsReportProvider {
ArrayList<DeviceReportSection> devicesTrips = new ArrayList<>();
ArrayList<String> sheetNames = new ArrayList<>();
for (Device device: DeviceUtil.getAccessibleDevices(storage, userId, deviceIds, groupIds)) {
- Collection<TripReportItem> trips = detectTrips(device, from, to);
+ Collection<TripReportItem> trips = reportUtils.detectTripsAndStops(device, from, to, TripReportItem.class);
DeviceReportSection deviceTrips = new DeviceReportSection();
deviceTrips.setDeviceName(device.getName());
sheetNames.add(WorkbookUtil.createSafeSheetName(deviceTrips.getDeviceName()));
diff --git a/src/main/java/org/traccar/reports/common/ReportUtils.java b/src/main/java/org/traccar/reports/common/ReportUtils.java
index 6c2d5cd72..a930f9439 100644
--- a/src/main/java/org/traccar/reports/common/ReportUtils.java
+++ b/src/main/java/org/traccar/reports/common/ReportUtils.java
@@ -58,7 +58,6 @@ import java.io.OutputStream;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Locale;
@@ -291,14 +290,15 @@ public class ReportUtils {
return positions.get(index).getBoolean(Position.KEY_MOTION);
}
- public <T extends BaseReportItem> Collection<T> detectTripsAndStops(
- Device device, List<Position> positions, boolean ignoreOdometer,
- Class<T> reportClass) throws StorageException {
+ public <T extends BaseReportItem> List<T> detectTripsAndStops(
+ Device device, Date from, Date to, Class<T> reportClass) throws StorageException {
- Collection<T> result = new ArrayList<>();
+ List<T> result = new ArrayList<>();
TripsConfig tripsConfig = new TripsConfig(
new AttributeUtil.StorageProvider(config, storage, permissionsService, device));
+ boolean ignoreOdometer = config.getBoolean(Keys.REPORT_IGNORE_ODOMETER);
+ var positions = PositionUtil.getPositions(storage, device.getId(), from, to);
if (!positions.isEmpty()) {
boolean trips = reportClass.equals(TripReportItem.class);