From b6294bd36b3023e18606c77553fe136e6500a4b2 Mon Sep 17 00:00:00 2001
From: rain <167982779@qq.com>
Date: Wed, 17 Apr 2024 15:42:34 +0800
Subject: [PATCH] 完善DB数据配置

---
 src/main/java/com/dji/sample/component/GlobalScheduleService.java |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/main/java/com/dji/sample/component/GlobalScheduleService.java b/src/main/java/com/dji/sample/component/GlobalScheduleService.java
index e092ad4..7e77a34 100644
--- a/src/main/java/com/dji/sample/component/GlobalScheduleService.java
+++ b/src/main/java/com/dji/sample/component/GlobalScheduleService.java
@@ -7,6 +7,7 @@
 import com.dji.sample.manage.model.enums.DeviceDomainEnum;
 import com.dji.sample.manage.service.IDeviceService;
 import com.dji.sample.wayline.service.IWaylineJobService;
+import com.fasterxml.jackson.databind.ObjectMapper;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Scheduled;
@@ -32,11 +33,12 @@
 
     @Autowired
     private IWaylineJobService waylineJobService;
-
+    @Autowired
+    private ObjectMapper mapper;
     /**
      * Check the status of the devices every 30 seconds. It is recommended to use cache.
      */
-    @Scheduled(initialDelay = 30, fixedRate = 30, timeUnit = TimeUnit.SECONDS)
+    @Scheduled(initialDelay = 10, fixedRate = 30, timeUnit = TimeUnit.SECONDS)
     private void deviceStatusListen() {
         int start = RedisConst.DEVICE_ONLINE_PREFIX.length();
 
@@ -49,8 +51,9 @@
                 } else {
                     deviceService.unsubscribeTopicOffline(key.substring(start));
                     deviceService.pushDeviceOfflineTopo(device.getWorkspaceId(), device.getDeviceSn());
-                    RedisOpsUtils.hashDel(RedisConst.LIVE_CAPACITY, new String[]{key});
-                    RedisOpsUtils.del(RedisConst.HMS_PREFIX + key);
+                    RedisOpsUtils.hashDel(RedisConst.LIVE_CAPACITY, new String[]{device.getDeviceSn()});
+                    RedisOpsUtils.del(RedisConst.HMS_PREFIX + device.getDeviceSn());
+                    RedisOpsUtils.del(RedisConst.OSD_PREFIX + device.getDeviceSn());
                 }
                 RedisOpsUtils.del(key);
             }

--
Gitblit v1.9.3