diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2019-03-09 15:01:08 -0800 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2019-03-09 15:01:08 -0800 |
commit | e3668177e4cb989b596ed7b2eef71eb348860736 (patch) | |
tree | 7c5a0f131471ce8a3b5206a42fb44bb310d6ccf5 /src/org/traccar/reports | |
parent | 2af6e4cc6255f59acaa17e6763063b775d7ba1ea (diff) | |
download | trackermap-server-e3668177e4cb989b596ed7b2eef71eb348860736.tar.gz trackermap-server-e3668177e4cb989b596ed7b2eef71eb348860736.tar.bz2 trackermap-server-e3668177e4cb989b596ed7b2eef71eb348860736.zip |
Refactor motion event handler
Diffstat (limited to 'src/org/traccar/reports')
-rw-r--r-- | src/org/traccar/reports/ReportUtils.java | 5 | ||||
-rw-r--r-- | src/org/traccar/reports/Stops.java | 8 | ||||
-rw-r--r-- | src/org/traccar/reports/Trips.java | 8 |
3 files changed, 18 insertions, 3 deletions
diff --git a/src/org/traccar/reports/ReportUtils.java b/src/org/traccar/reports/ReportUtils.java index 5e02afb64..3a631e0d9 100644 --- a/src/org/traccar/reports/ReportUtils.java +++ b/src/org/traccar/reports/ReportUtils.java @@ -26,6 +26,8 @@ import org.jxls.transform.Transformer; import org.jxls.transform.poi.PoiTransformer; import org.jxls.util.TransformerFactory; import org.traccar.Context; +import org.traccar.database.DeviceManager; +import org.traccar.database.IdentityManager; import org.traccar.handler.events.MotionEventHandler; import org.traccar.model.DeviceState; import org.traccar.model.Driver; @@ -323,6 +325,7 @@ public final class ReportUtils { } public static <T extends BaseReport> Collection<T> detectTripsAndStops( + IdentityManager identityManager, DeviceManager deviceManager, Collection<Position> positionCollection, TripsConfig tripsConfig, boolean ignoreOdometer, Class<T> reportClass) { @@ -331,7 +334,7 @@ public final class ReportUtils { ArrayList<Position> positions = new ArrayList<>(positionCollection); if (!positions.isEmpty()) { boolean trips = reportClass.equals(TripReport.class); - MotionEventHandler motionHandler = new MotionEventHandler(tripsConfig); + MotionEventHandler motionHandler = new MotionEventHandler(identityManager, deviceManager, tripsConfig); DeviceState deviceState = new DeviceState(); deviceState.setMotionState(isMoving(positions, 0, tripsConfig)); int startEventIndex = trips == deviceState.getMotionState() ? 0 : -1; diff --git a/src/org/traccar/reports/Stops.java b/src/org/traccar/reports/Stops.java index aa7a1ef20..98c9cef00 100644 --- a/src/org/traccar/reports/Stops.java +++ b/src/org/traccar/reports/Stops.java @@ -28,6 +28,9 @@ import java.util.Date; import org.apache.poi.ss.util.WorkbookUtil; import org.traccar.Context; +import org.traccar.Main; +import org.traccar.database.DeviceManager; +import org.traccar.database.IdentityManager; import org.traccar.model.Device; import org.traccar.model.Group; import org.traccar.reports.model.DeviceReport; @@ -42,8 +45,11 @@ public final class Stops { boolean ignoreOdometer = Context.getDeviceManager() .lookupAttributeBoolean(deviceId, "report.ignoreOdometer", false, true); + IdentityManager identityManager = Main.getInjector().getInstance(IdentityManager.class); + DeviceManager deviceManager = Main.getInjector().getInstance(DeviceManager.class); + return ReportUtils.detectTripsAndStops( - Context.getDataManager().getPositions(deviceId, from, to), + identityManager, deviceManager, Context.getDataManager().getPositions(deviceId, from, to), Context.getTripsConfig(), ignoreOdometer, StopReport.class); } diff --git a/src/org/traccar/reports/Trips.java b/src/org/traccar/reports/Trips.java index 792833c27..3cda65553 100644 --- a/src/org/traccar/reports/Trips.java +++ b/src/org/traccar/reports/Trips.java @@ -27,6 +27,9 @@ import java.util.Date; import org.apache.poi.ss.util.WorkbookUtil; import org.traccar.Context; +import org.traccar.Main; +import org.traccar.database.DeviceManager; +import org.traccar.database.IdentityManager; import org.traccar.model.Device; import org.traccar.model.Group; import org.traccar.reports.model.DeviceReport; @@ -41,8 +44,11 @@ public final class Trips { boolean ignoreOdometer = Context.getDeviceManager() .lookupAttributeBoolean(deviceId, "report.ignoreOdometer", false, true); + IdentityManager identityManager = Main.getInjector().getInstance(IdentityManager.class); + DeviceManager deviceManager = Main.getInjector().getInstance(DeviceManager.class); + return ReportUtils.detectTripsAndStops( - Context.getDataManager().getPositions(deviceId, from, to), + identityManager, deviceManager, Context.getDataManager().getPositions(deviceId, from, to), Context.getTripsConfig(), ignoreOdometer, TripReport.class); } |