|
|
@@ -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;
|
|
|
}
|
|
|
|
|
|
|