aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2023-02-02 13:56:18 -0800
committerAnton Tananaev <anton@traccar.org>2023-02-02 13:56:18 -0800
commit47c9d9fb21e897733f7aaa29bb5797036ccc4476 (patch)
tree0423018c23d2a8119ec823df3a2d611700cce548 /src/main/java
parent707fccfa5b8d3afaff10f70a65e6d99ed0df6561 (diff)
downloadtrackermap-server-47c9d9fb21e897733f7aaa29bb5797036ccc4476.tar.gz
trackermap-server-47c9d9fb21e897733f7aaa29bb5797036ccc4476.tar.bz2
trackermap-server-47c9d9fb21e897733f7aaa29bb5797036ccc4476.zip
Add event positions
Diffstat (limited to 'src/main/java')
-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;
+ }
+
}