Просмотр исходного кода

2023-4-6 定时排风排除通风处的数据。

chaiyunlong лет назад: 2
Родитель
Сommit
81f2ff2dd8

+ 24 - 8
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/event/RedisExpiredAndWorkListener.java

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.TypeReference;
 import com.alibaba.fastjson.parser.Feature;
 import com.zd.common.core.redis.RedisService;
+import com.zd.laboratory.config.TimeWaitConfigUtils;
 import com.zd.laboratory.domain.LabControl;
 import com.zd.laboratory.domain.LabHardware;
 import com.zd.laboratory.domain.vo.LabDealyNotifyVo;
@@ -61,6 +62,9 @@ public class RedisExpiredAndWorkListener extends KeyExpirationEventMessageListen
     @Autowired
     private RedisService redisService;
 
+    @Autowired
+    private TimeWaitConfigUtils timeWaitConfigUtils;
+
     private static final Logger log = LoggerFactory.getLogger(RedisExpiredAndWorkListener.class);
 
     public RedisExpiredAndWorkListener(RedisMessageListenerContainer listenerContainer)
@@ -84,6 +88,7 @@ public class RedisExpiredAndWorkListener extends KeyExpirationEventMessageListen
                 LabHardwareVO labHardwareVO = new LabHardwareVO();
                 labHardwareVO.setIds(ids);
                 labHardwareVO.setSubjectId(dealyNotifyVo.getSubId());
+                labHardwareVO.setPcType(0);
                 List<LabHardware> hardwareList = labHardwareMapper.selectNewLabHardwareByTypes(labHardwareVO);
                 log.info("定时排风根据条件查询硬件列表数量------------------"+hardwareList.size());
                 Optional.ofNullable(hardwareList).orElseGet(Collections::emptyList)
@@ -109,16 +114,27 @@ public class RedisExpiredAndWorkListener extends KeyExpirationEventMessageListen
 
     public Boolean relayControl(LabHardware labHardwareVO,Symbol.command command){
         if (labHardwareVO.getHardwareType() == 2) {
-            log.info("定时排风执行对应的继电器------------------RelayCode="+labHardwareVO.getRelayCode()+",Bit="+labHardwareVO.getBit()+",HardwareId="+labHardwareVO.getId()+",SubjectId="+labHardwareVO.getSubjectId());
-            ResultData ResultData = socketService.sendMqttCommand(labHardwareVO.getId(), labHardwareVO.getRelayCode(), command, labHardwareVO.getBit(),labHardwareVO.getSubjectId());
-            boolean equals = ResultData.getCode().equals(HttpStatus.SUCCESS);
-            return equals;
+            try {
+                log.info("定时排风执行对应的继电器------------------RelayCode="+labHardwareVO.getRelayCode()+",Bit="+labHardwareVO.getBit()+",HardwareId="+labHardwareVO.getId()+",SubjectId="+labHardwareVO.getSubjectId());
+                ResultData ResultData = socketService.sendMqttCommand(labHardwareVO.getId(), labHardwareVO.getRelayCode(), command, labHardwareVO.getBit(),labHardwareVO.getSubjectId());
+                boolean equals = ResultData.getCode().equals(HttpStatus.SUCCESS);
+                Thread.sleep(timeWaitConfigUtils.getWaitTime());
+                return equals;
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
         }else{
-            log.info("定时排风执行对应的继电器------------------RelayCode="+labHardwareVO.getRelayCode()+",Bit="+labHardwareVO.getBit());
-            ResultData ResultData = socketService.sendCommand(Symbol.order.control, labHardwareVO.getRelayCode(), command, labHardwareVO.getBit());
-            boolean equals = ResultData.getCode().equals(HttpStatus.SUCCESS);
-            return equals;
+            try {
+                log.info("定时排风执行对应的继电器------------------RelayCode="+labHardwareVO.getRelayCode()+",Bit="+labHardwareVO.getBit());
+                ResultData ResultData = socketService.sendCommand(Symbol.order.control, labHardwareVO.getRelayCode(), command, labHardwareVO.getBit());
+                boolean equals = ResultData.getCode().equals(HttpStatus.SUCCESS);
+                Thread.sleep(timeWaitConfigUtils.getWaitTime());
+                return equals;
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
         }
+        return false;
     }
 
 

+ 1 - 0
zd-modules/zd-modules-laboratory/src/main/resources/mapper/laboratory/LabHardwareMapper.xml

@@ -560,6 +560,7 @@
             #{id}
         </foreach>
         <if test="subjectId != null ">and subject_id = #{subjectId}</if>
+        <if test="pcType != null ">and  xx.pc_type = #{pcType}</if>
         order by create_time
     </select>