aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2024-01-28 08:15:46 -0800
committerAnton Tananaev <anton@traccar.org>2024-01-28 08:15:46 -0800
commit52dcedfe60e5b9468db16e7d72048595bcdeb98f (patch)
tree837e49caa26dc9ac6391cef81d205a4f3020822f /src/main
parent34b507dbe268c6aec2f20e9ec3c3f9e243187c3e (diff)
downloadtrackermap-server-52dcedfe60e5b9468db16e7d72048595bcdeb98f.tar.gz
trackermap-server-52dcedfe60e5b9468db16e7d72048595bcdeb98f.tar.bz2
trackermap-server-52dcedfe60e5b9468db16e7d72048595bcdeb98f.zip
Support time maintenance
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/traccar/handler/events/MaintenanceEventHandler.java19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/main/java/org/traccar/handler/events/MaintenanceEventHandler.java b/src/main/java/org/traccar/handler/events/MaintenanceEventHandler.java
index 6c4271ce2..2fa2e8869 100644
--- a/src/main/java/org/traccar/handler/events/MaintenanceEventHandler.java
+++ b/src/main/java/org/traccar/handler/events/MaintenanceEventHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 - 2022 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2024 Anton Tananaev (anton@traccar.org)
* Copyright 2016 - 2018 Andrey Kunitsyn (andrey@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -49,8 +49,8 @@ public class MaintenanceEventHandler extends BaseEventHandler {
Map<Event, Position> events = new HashMap<>();
for (Maintenance maintenance : cacheManager.getDeviceObjects(position.getDeviceId(), Maintenance.class)) {
if (maintenance.getPeriod() != 0) {
- double oldValue = lastPosition.getDouble(maintenance.getType());
- double newValue = position.getDouble(maintenance.getType());
+ double oldValue = getValue(lastPosition, maintenance.getType());
+ double newValue = getValue(position, maintenance.getType());
if (oldValue != 0.0 && newValue != 0.0 && newValue >= maintenance.getStart()) {
if (oldValue < maintenance.getStart()
|| (long) ((oldValue - maintenance.getStart()) / maintenance.getPeriod())
@@ -67,4 +67,17 @@ public class MaintenanceEventHandler extends BaseEventHandler {
return events;
}
+ private double getValue(Position position, String type) {
+ switch (type) {
+ case "serverTime":
+ return position.getServerTime().getTime();
+ case "deviceTime":
+ return position.getDeviceTime().getTime();
+ case "fixTime":
+ return position.getFixTime().getTime();
+ default:
+ return position.getDouble(type);
+ }
+ }
+
}