Explorar el Código

2023-3-7 优化一体机消息推送

chaiyunlong hace 2 años
padre
commit
42fe7d73a9

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

@@ -126,18 +126,27 @@ public class SubMessageSendManager {
         //仅发送一次
 //        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){
+
+//        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);
+//        }
+
+
+        if (redisService.getCacheObject("onePcSub"+subId)==null){
             logger.error("消息推送中.......");
+            redisService.setCacheObject("onePcSub"+subId,subId,15L, TimeUnit.SECONDS);
             commonSend.send(getFunctionSubTopic(subId), messageBody, SendMode.ONCE);
         }
+
     }
 
     /**