Преглед изворни кода

2023-3-7 推送一体机消息延迟。

chaiyunlong пре 2 година
родитељ
комит
2959644386

+ 14 - 14
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/mqtt/service/impl/SubMessageSendManager.java

@@ -124,20 +124,20 @@ public class SubMessageSendManager {
         MessageBody messageBody = getMessageBody(subFunction);
         logger.error("消息推送一体机开始");
         //仅发送一次
-        commonSend.send(getFunctionSubTopic(subId), messageBody, SendMode.ONCE);
-//        int count = 0;
-//        List<SensorFunctionStatus> sensorFunctionStatusList = subFunction.getFunctionStatuses();
-//        for (SensorFunctionStatus sensorFunc : sensorFunctionStatusList) {
-//            if (redisService.getCacheObject(sensorFunc.getFunNum()+""+sensorFunc.getDescribe())==null){
-//                logger.error("消息推送funNum存入redis:::"+sensorFunc.getFunNum()+""+sensorFunc.getDescribe());
-//                redisService.setCacheObject(sensorFunc.getFunNum()+""+sensorFunc.getDescribe(),sensorFunc.getFunNum(),15L, TimeUnit.SECONDS);
-//                count++;
-//            }
-//        }
-//        if(count>0){
-//            logger.error("消息推送中.......");
-//            commonSend.send(getFunctionSubTopic(subId), messageBody, SendMode.ONCE);
-//        }
+//        commonSend.send(getFunctionSubTopic(subId), messageBody, SendMode.ONCE);
+        int count = 0;
+        List<SensorFunctionStatus> sensorFunctionStatusList = subFunction.getFunctionStatuses();
+        for (SensorFunctionStatus sensorFunc : sensorFunctionStatusList) {
+            if (redisService.getCacheObject(sensorFunc.getFunNum()+""+sensorFunc.getDescribe())==null){
+                logger.error("消息推送funNum存入redis:::"+sensorFunc.getFunNum()+""+sensorFunc.getDescribe());
+                redisService.setCacheObject(sensorFunc.getFunNum()+""+sensorFunc.getDescribe(),sensorFunc.getFunNum(),15L, TimeUnit.SECONDS);
+                count++;
+            }
+        }
+        if(count>0){
+            logger.error("消息推送中.......");
+            commonSend.send(getFunctionSubTopic(subId), messageBody, SendMode.ONCE);
+        }
     }
 
     /**