|
|
@ -20,7 +20,7 @@ import java.util.concurrent.*; |
|
|
|
@Slf4j |
|
|
|
@Component |
|
|
|
@RequiredArgsConstructor |
|
|
|
public class HumidityCollector { |
|
|
|
public class SensorCollector { |
|
|
|
private final WebSocketService webSocketService; |
|
|
|
private final DeviceCommandService deviceCommandService; |
|
|
|
|
|
|
@ -36,12 +36,12 @@ public class HumidityCollector { |
|
|
|
Double deviceHumidity = humidityGetCmdFutureResult.getDouble("humidity"); |
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
map.put("humidity", deviceHumidity); |
|
|
|
webSocketService.pushMsg(WebSocketMessageType.HUMIDITY, map); |
|
|
|
webSocketService.pushMsg(WebSocketMessageType.SENSOR, map); |
|
|
|
} catch (Exception e) { |
|
|
|
if (!executorService.isShutdown()) { |
|
|
|
executorService.shutdown(); // 关闭 ScheduledExecutorService |
|
|
|
} |
|
|
|
log.error("定时推送设备状态异常", e); |
|
|
|
log.error("定时推送传感器状态错误", e); |
|
|
|
} |
|
|
|
}, 10, 1000, TimeUnit.MILLISECONDS); |
|
|
|
} |