diff options
author | Anton Tananaev <anton@traccar.org> | 2022-06-09 08:53:26 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2022-06-09 08:53:26 -0700 |
commit | 6f163bdf3856323a5aa075f9a2e1aeb01b7bc598 (patch) | |
tree | 353177ec93bc4c28c40fbc72d060e671ed3733db /src/main/java/org/traccar/reports | |
parent | 4dbe47a2362bde8e2a8419b202a02e5e7fc16f87 (diff) | |
download | trackermap-server-6f163bdf3856323a5aa075f9a2e1aeb01b7bc598.tar.gz trackermap-server-6f163bdf3856323a5aa075f9a2e1aeb01b7bc598.tar.bz2 trackermap-server-6f163bdf3856323a5aa075f9a2e1aeb01b7bc598.zip |
Remove more from context
Diffstat (limited to 'src/main/java/org/traccar/reports')
3 files changed, 29 insertions, 5 deletions
diff --git a/src/main/java/org/traccar/reports/StopsReportProvider.java b/src/main/java/org/traccar/reports/StopsReportProvider.java index 8899dc42f..b7896c423 100644 --- a/src/main/java/org/traccar/reports/StopsReportProvider.java +++ b/src/main/java/org/traccar/reports/StopsReportProvider.java @@ -34,6 +34,7 @@ import org.traccar.database.IdentityManager; import org.traccar.model.Device; import org.traccar.model.Group; import org.traccar.reports.common.ReportUtils; +import org.traccar.reports.common.TripsConfig; import org.traccar.reports.model.DeviceReportSection; import org.traccar.reports.model.StopReportItem; import org.traccar.storage.Storage; @@ -45,11 +46,13 @@ public class StopsReportProvider { private final PermissionsService permissionsService; private final Storage storage; + private final TripsConfig tripsConfig; @Inject - public StopsReportProvider(PermissionsService permissionsService, Storage storage) { + public StopsReportProvider(PermissionsService permissionsService, Storage storage, TripsConfig tripsConfig) { this.permissionsService = permissionsService; this.storage = storage; + this.tripsConfig = tripsConfig; } private Collection<StopReportItem> detectStops(long deviceId, Date from, Date to) throws StorageException { @@ -61,7 +64,7 @@ public class StopsReportProvider { return ReportUtils.detectTripsAndStops( storage, identityManager, deviceManager, Context.getDataManager().getPositions(deviceId, from, to), - Context.getTripsConfig(), ignoreOdometer, StopReportItem.class); + tripsConfig, ignoreOdometer, StopReportItem.class); } public Collection<StopReportItem> getObjects( diff --git a/src/main/java/org/traccar/reports/TripsReportProvider.java b/src/main/java/org/traccar/reports/TripsReportProvider.java index bcd79ab25..0505baaa1 100644 --- a/src/main/java/org/traccar/reports/TripsReportProvider.java +++ b/src/main/java/org/traccar/reports/TripsReportProvider.java @@ -33,6 +33,7 @@ import org.traccar.database.IdentityManager; import org.traccar.model.Device; import org.traccar.model.Group; import org.traccar.reports.common.ReportUtils; +import org.traccar.reports.common.TripsConfig; import org.traccar.reports.model.DeviceReportSection; import org.traccar.reports.model.TripReportItem; import org.traccar.storage.Storage; @@ -44,11 +45,13 @@ public class TripsReportProvider { private final PermissionsService permissionsService; private final Storage storage; + private final TripsConfig tripsConfig; @Inject - public TripsReportProvider(PermissionsService permissionsService, Storage storage) { + public TripsReportProvider(PermissionsService permissionsService, Storage storage, TripsConfig tripsConfig) { this.permissionsService = permissionsService; this.storage = storage; + this.tripsConfig = tripsConfig; } private Collection<TripReportItem> detectTrips(long deviceId, Date from, Date to) throws StorageException { @@ -60,7 +63,7 @@ public class TripsReportProvider { return ReportUtils.detectTripsAndStops( storage, identityManager, deviceManager, Context.getDataManager().getPositions(deviceId, from, to), - Context.getTripsConfig(), ignoreOdometer, TripReportItem.class); + tripsConfig, ignoreOdometer, TripReportItem.class); } public Collection<TripReportItem> getObjects(long userId, Collection<Long> deviceIds, Collection<Long> groupIds, diff --git a/src/main/java/org/traccar/reports/common/TripsConfig.java b/src/main/java/org/traccar/reports/common/TripsConfig.java index 9a7cebafb..c28cbeed4 100644 --- a/src/main/java/org/traccar/reports/common/TripsConfig.java +++ b/src/main/java/org/traccar/reports/common/TripsConfig.java @@ -16,9 +16,27 @@ */ package org.traccar.reports.common; +import org.traccar.config.Config; +import org.traccar.config.Keys; + +import javax.inject.Inject; + public class TripsConfig { - public TripsConfig(double minimalTripDistance, long minimalTripDuration, long minimalParkingDuration, + @Inject + public TripsConfig(Config config) { + this( + config.getLong(Keys.REPORT_TRIP_MINIMAL_TRIP_DISTANCE), + config.getLong(Keys.REPORT_TRIP_MINIMAL_TRIP_DURATION) * 1000, + config.getLong(Keys.REPORT_TRIP_MINIMAL_PARKING_DURATION) * 1000, + config.getLong(Keys.REPORT_TRIP_MINIMAL_NO_DATA_DURATION) * 1000, + config.getBoolean(Keys.REPORT_TRIP_USE_IGNITION), + config.getBoolean(Keys.EVENT_MOTION_PROCESS_INVALID_POSITIONS), + config.getDouble(Keys.EVENT_MOTION_SPEED_THRESHOLD)); + } + + public TripsConfig( + double minimalTripDistance, long minimalTripDuration, long minimalParkingDuration, long minimalNoDataDuration, boolean useIgnition, boolean processInvalidPositions, double speedThreshold) { this.minimalTripDistance = minimalTripDistance; this.minimalTripDuration = minimalTripDuration; |