aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2022-10-26 09:28:03 -0700
committerGitHub <noreply@github.com>2022-10-26 09:28:03 -0700
commit7fa60c7f1fc743b90fa988943da28e48148d8b99 (patch)
tree4fb735b40033de8ae871eebf28a829c5fdf1b977 /src/main/java/org
parent78a0df7befc84b7d138b403b137f26f9df379c3d (diff)
parent907e5d1669c154e266383a275c1212baea1bda2a (diff)
downloadtrackermap-server-7fa60c7f1fc743b90fa988943da28e48148d8b99.tar.gz
trackermap-server-7fa60c7f1fc743b90fa988943da28e48148d8b99.tar.bz2
trackermap-server-7fa60c7f1fc743b90fa988943da28e48148d8b99.zip
Merge pull request #4970 from jcardus/patch-1
Fix maintenance bugs
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/traccar/handler/events/MaintenanceEventHandler.java14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/main/java/org/traccar/handler/events/MaintenanceEventHandler.java b/src/main/java/org/traccar/handler/events/MaintenanceEventHandler.java
index 4fcfcd079..909950acf 100644
--- a/src/main/java/org/traccar/handler/events/MaintenanceEventHandler.java
+++ b/src/main/java/org/traccar/handler/events/MaintenanceEventHandler.java
@@ -51,13 +51,15 @@ public class MaintenanceEventHandler extends BaseEventHandler {
if (maintenance.getPeriod() != 0) {
double oldValue = lastPosition.getDouble(maintenance.getType());
double newValue = position.getDouble(maintenance.getType());
- if (oldValue != 0.0 && newValue != 0.0
- && (long) ((oldValue - maintenance.getStart()) / maintenance.getPeriod())
+ if (oldValue != 0.0 && newValue != 0.0 && newValue >= maintenance.getStart()) {
+ if (oldValue < maintenance.getStart()
+ || (long) ((oldValue - maintenance.getStart()) / maintenance.getPeriod())
< (long) ((newValue - maintenance.getStart()) / maintenance.getPeriod())) {
- Event event = new Event(Event.TYPE_MAINTENANCE, position);
- event.setMaintenanceId(maintenance.getId());
- event.set(maintenance.getType(), newValue);
- events.put(event, position);
+ Event event = new Event(Event.TYPE_MAINTENANCE, position);
+ event.setMaintenanceId(maintenance.getId());
+ event.set(maintenance.getType(), newValue);
+ events.put(event, position);
+ }
}
}
}