|
|
@@ -3,16 +3,17 @@ package com.zd.laboratory.event;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.alibaba.fastjson.TypeReference;
|
|
|
import com.alibaba.fastjson.parser.Feature;
|
|
|
-import com.alibaba.nacos.shaded.org.checkerframework.checker.units.qual.A;
|
|
|
import com.zd.laboratory.domain.LabControl;
|
|
|
import com.zd.laboratory.domain.LabHardware;
|
|
|
import com.zd.laboratory.domain.vo.LabDealyNotifyVo;
|
|
|
import com.zd.laboratory.domain.vo.LabHardwareVO;
|
|
|
import com.zd.laboratory.mapper.LabHardwareMapper;
|
|
|
import com.zd.laboratory.service.ILabControlService;
|
|
|
-import com.zd.laboratory.service.impl.LabSubjectManagerService;
|
|
|
import com.zd.laboratory.socket.command.Symbol;
|
|
|
+import com.zd.laboratory.socket.service.SocketService;
|
|
|
import com.zd.model.constant.BaseConstants;
|
|
|
+import com.zd.model.constant.HttpStatus;
|
|
|
+import com.zd.model.domain.ResultData;
|
|
|
import com.zd.model.enums.HardwareTypeEnum;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.redis.connection.Message;
|
|
|
@@ -49,10 +50,10 @@ public class RedisExpiredAndWorkListener extends KeyExpirationEventMessageListen
|
|
|
private LabHardwareMapper labHardwareMapper;
|
|
|
|
|
|
@Autowired
|
|
|
- private LabSubjectManagerService subjectManagerService;
|
|
|
+ private ILabControlService labControlService;
|
|
|
|
|
|
@Autowired
|
|
|
- private ILabControlService labControlService;
|
|
|
+ private SocketService socketService;
|
|
|
|
|
|
public RedisExpiredAndWorkListener(RedisMessageListenerContainer listenerContainer)
|
|
|
{
|
|
|
@@ -79,13 +80,19 @@ public class RedisExpiredAndWorkListener extends KeyExpirationEventMessageListen
|
|
|
.stream()
|
|
|
.forEach(a->{
|
|
|
if(dealyNotifyVo.getOpenOrCloseType().intValue()==1){
|
|
|
- subjectManagerService.control(a.getId(), Symbol.command.open);
|
|
|
+ ResultData ResultData = socketService.sendMqttCommand(a.getId(), a.getRelayCode(), Symbol.command.open, a.getBit(),a.getSubjectId());
|
|
|
+ boolean equals = ResultData.getCode().equals(HttpStatus.SUCCESS);
|
|
|
//插入control 打开日志
|
|
|
- saveControl(a,1);
|
|
|
+ if (equals) {
|
|
|
+ saveControl(a, 1);
|
|
|
+ }
|
|
|
}else{
|
|
|
- subjectManagerService.control(a.getId(), Symbol.command.close);
|
|
|
+ ResultData ResultData = socketService.sendMqttCommand(a.getId(), a.getRelayCode(), Symbol.command.close, a.getBit(),a.getSubjectId());
|
|
|
+ boolean equals = ResultData.getCode().equals(HttpStatus.SUCCESS);
|
|
|
//插入control 关闭日志
|
|
|
- saveControl(a,0);
|
|
|
+ if (equals) {
|
|
|
+ saveControl(a,0);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
});
|