|
|
@@ -13,11 +13,14 @@ import com.zd.laboratory.api.feign.RemoteLaboratoryService;
|
|
|
import com.zd.model.constant.CacheConstants;
|
|
|
import com.zd.model.constant.CacheDevice;
|
|
|
import com.zd.model.constant.MqttConstants;
|
|
|
+import com.zd.model.domain.ResultData;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
|
import java.util.List;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
@@ -28,7 +31,7 @@ import java.util.concurrent.TimeUnit;
|
|
|
* @Description:
|
|
|
*/
|
|
|
@Component
|
|
|
-
|
|
|
+@RequestMapping("/firedeviceTask")
|
|
|
public class FireDeviceStatusTask {
|
|
|
|
|
|
Logger logger = LoggerFactory.getLogger(FireDeviceStatusTask.class);
|
|
|
@@ -46,8 +49,9 @@ public class FireDeviceStatusTask {
|
|
|
/**
|
|
|
* 定时更新灭火装置状态
|
|
|
*/
|
|
|
- @Scheduled(cron = "0/20 * * * * ?")
|
|
|
- public void getFireDeviceStatus() {
|
|
|
+ //@Scheduled(cron = "0/20 * * * * ?")
|
|
|
+ @RequestMapping("/deviceStatus")
|
|
|
+ public ResultData getFireDeviceStatus() {
|
|
|
try {
|
|
|
//redis取值
|
|
|
List<HardwareFireDeviceVO> list = JSON.parseArray(redisService.getCacheObject(CacheConstants.FIRE_DEVICE_LIST) + "", HardwareFireDeviceVO.class);
|
|
|
@@ -67,8 +71,8 @@ public class FireDeviceStatusTask {
|
|
|
byte[] activeCodeByte = ReUtil.hexStringToByteArray(activeCode);
|
|
|
mqttSend.send(MqttConstants.TOPIC_FIRE_DEVICE + vo.getDeviceCode(), activeCodeByte);
|
|
|
//兼容指令无反应问题
|
|
|
- /*Thread.sleep(500);
|
|
|
- mqttSend.send(MqttConstants.TOPIC_FIRE_DEVICE + vo.getDeviceCode(), activeCodeByte);*/
|
|
|
+ Thread.sleep(500);
|
|
|
+ mqttSend.send(MqttConstants.TOPIC_FIRE_DEVICE + vo.getDeviceCode(), activeCodeByte);
|
|
|
logger.info("集合数量:" + list.size() + ",mqtt消息推送, 灭火装置状态请求,实验室id:" + vo.getSubjectId() + ",采集器编号:" + vo.getDeviceCode() + ",继电器编号" + vo.getRelayCode());
|
|
|
|
|
|
|
|
|
@@ -102,5 +106,6 @@ public class FireDeviceStatusTask {
|
|
|
} catch (Exception e) {
|
|
|
logger.info("一键灭火定时任务异常" + e);
|
|
|
}
|
|
|
+ return ResultData.success();
|
|
|
}
|
|
|
}
|