|
|
@@ -0,0 +1,32 @@
|
|
|
+package com.zhongshu.iot.server.core.timers;
|
|
|
+
|
|
|
+import com.zhongshu.iot.server.core.service.mqtt.DevicePingInfoService;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.scheduling.annotation.EnableScheduling;
|
|
|
+import org.springframework.scheduling.annotation.Scheduled;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 定时检查设备在线状态
|
|
|
+ *
|
|
|
+ * @author TRX
|
|
|
+ * @date 2024/7/3
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@EnableScheduling
|
|
|
+@Component
|
|
|
+public class CheckDeviceStateWork {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private DevicePingInfoService devicePingInfoService;
|
|
|
+
|
|
|
+ @Scheduled(fixedRate = 1000 * 15)
|
|
|
+ public void checkDeviceState() {
|
|
|
+ // 检测设备在线状态
|
|
|
+ devicePingInfoService.checkDeviceState();
|
|
|
+
|
|
|
+ // 检测网关在线状态
|
|
|
+ devicePingInfoService.checkGateWayState();
|
|
|
+ }
|
|
|
+}
|