aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/traccar/reports/CombinedReportProvider.java18
-rw-r--r--src/main/java/org/traccar/reports/model/CombinedReportItem.java11
2 files changed, 24 insertions, 5 deletions
diff --git a/src/main/java/org/traccar/reports/CombinedReportProvider.java b/src/main/java/org/traccar/reports/CombinedReportProvider.java
index ca290f7db..d47a91bef 100644
--- a/src/main/java/org/traccar/reports/CombinedReportProvider.java
+++ b/src/main/java/org/traccar/reports/CombinedReportProvider.java
@@ -53,16 +53,24 @@ public class CombinedReportProvider {
for (Device device: reportUtils.getAccessibleDevices(userId, deviceIds, groupIds)) {
CombinedReportItem item = new CombinedReportItem();
item.setDeviceId(device.getId());
- item.setRoute(PositionUtil.getPositions(storage, device.getId(), from, to)
- .stream()
- .map(p -> new double[] { p.getLongitude(), p.getLatitude() })
+ var positions = PositionUtil.getPositions(storage, device.getId(), from, to);
+ item.setRoute(positions.stream()
+ .map(p -> new double[] {p.getLongitude(), p.getLatitude()})
.collect(Collectors.toList()));
- item.setEvents(storage.getObjects(Event.class, new Request(
+ var events = storage.getObjects(Event.class, new Request(
new Columns.All(),
new Condition.And(
new Condition.Equals("deviceId", device.getId()),
new Condition.Between("eventTime", "from", from, "to", to)),
- new Order("eventTime"))));
+ new Order("eventTime")));
+ item.setEvents(events);
+ var eventPositions = events.stream()
+ .map(Event::getPositionId)
+ .filter(positionId -> positionId > 0)
+ .collect(Collectors.toSet());
+ item.setPositions(positions.stream()
+ .filter(p -> eventPositions.contains(p.getId()))
+ .collect(Collectors.toList()));
result.add(item);
}
return result;
diff --git a/src/main/java/org/traccar/reports/model/CombinedReportItem.java b/src/main/java/org/traccar/reports/model/CombinedReportItem.java
index 00f2cc08e..810e00916 100644
--- a/src/main/java/org/traccar/reports/model/CombinedReportItem.java
+++ b/src/main/java/org/traccar/reports/model/CombinedReportItem.java
@@ -16,6 +16,7 @@
package org.traccar.reports.model;
import org.traccar.model.Event;
+import org.traccar.model.Position;
import java.util.List;
@@ -51,4 +52,14 @@ public class CombinedReportItem {
this.events = events;
}
+ private List<Position> positions;
+
+ public List<Position> getPositions() {
+ return positions;
+ }
+
+ public void setPositions(List<Position> positions) {
+ this.positions = positions;
+ }
+
}