瀏覽代碼

一键灭火逻辑修改

xuxiaofei 3 年之前
父節點
當前提交
a1ed2cb847

+ 9 - 7
zd-modules/zd-algorithm/src/main/java/com/zd/alg/fire/controller/FireDeviceController.java

@@ -42,7 +42,6 @@ import java.util.concurrent.TimeUnit;
  * @Description:
  */
 @RestController
-@Component
 @RequestMapping("/firedevice")
 public class FireDeviceController extends BaseController {
 
@@ -125,6 +124,7 @@ public class FireDeviceController extends BaseController {
         HardwareFireDeviceVO vo = new HardwareFireDeviceVO();
         vo.setSubjectId(subjectId);
         List<HardwareFireDeviceVO> list = fireDeviceService.selectHardwareFireDeviceList(vo);
+        logger.info("是否配置灭火设备:"+list.size());
         if (list.size() == 0) {
             map.put("smoke", smoke);
             map.put("temperature", temperature);
@@ -135,8 +135,10 @@ public class FireDeviceController extends BaseController {
             isexist = true;
             //获取灭火主机最后一次响应时间,判断响应是否超时
             Long timeJson = redisService.getCacheObject(CacheConstants.FIRE_DEVICE_RESPOND_TIME+list.get(0).getDeviceCode());
+            logger.info("灭火主机最后一次响应时间:"+timeJson);
             if (StringUtils.isNotNull(timeJson)) {
                 Long timeDiff = (System.currentTimeMillis() - timeJson) / 1000;
+                logger.info("灭火主机最后一次响应时间差值:"+timeDiff+" 超时响应时间:"+onlineTime);
                 //时间差 在设置时间内
                 if (timeDiff < onlineTime) {
                     online = true;
@@ -149,9 +151,9 @@ public class FireDeviceController extends BaseController {
             JSONObject strJson = redisService.getCacheObject(list.get(0).getDeviceCode());
             if (StringUtils.isNotNull(strJson)) {
                 Integer fireNumber = (Integer) strJson.get("fireNumber");
-                if (fireNumber == 1) {
-                    temperature = true;
-                } else if (fireNumber == 2) {
+                if (fireNumber > 0) {
+                    smoke = true;
+                } else if (fireNumber >3) {
                     smoke = true;
                     temperature = true;
                 }
@@ -224,9 +226,9 @@ public class FireDeviceController extends BaseController {
         JSONObject strJson = redisService.getCacheObject(deviceCode);
         if (StringUtils.isNotNull(strJson)) {
             Integer fireNumber = (Integer) strJson.get("fireNumber");
-            if (fireNumber == 1) {
-                temperature = true;
-            } else if (fireNumber == 2) {
+            if (fireNumber >0) {
+                smoke = true;
+            } else if (fireNumber >3) {
                 smoke = true;
                 temperature = true;
             }

+ 2 - 1
zd-modules/zd-algorithm/src/main/java/com/zd/alg/fire/utils/FireDeviceStatusTask.java

@@ -21,6 +21,7 @@ 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 org.springframework.web.bind.annotation.RestController;
 
 import java.util.List;
 import java.util.concurrent.TimeUnit;
@@ -30,7 +31,7 @@ import java.util.concurrent.TimeUnit;
  * @Date: 2022/11/25/14:58
  * @Description:
  */
-@Component
+@RestController
 @RequestMapping("/firedeviceTask")
 public class FireDeviceStatusTask {