|
@@ -17,12 +17,14 @@ import com.zd.laboratory.api.entity.*;
|
|
|
import com.zd.laboratory.api.vo.*;
|
|
import com.zd.laboratory.api.vo.*;
|
|
|
import com.zd.laboratory.config.HardwareFunctionStatusConfig;
|
|
import com.zd.laboratory.config.HardwareFunctionStatusConfig;
|
|
|
import com.zd.laboratory.config.TimeWaitConfigUtils;
|
|
import com.zd.laboratory.config.TimeWaitConfigUtils;
|
|
|
|
|
+import com.zd.laboratory.constant.RelayConstants;
|
|
|
import com.zd.laboratory.domain.*;
|
|
import com.zd.laboratory.domain.*;
|
|
|
import com.zd.laboratory.domain.dto.LabSubListQuery;
|
|
import com.zd.laboratory.domain.dto.LabSubListQuery;
|
|
|
import com.zd.laboratory.domain.vo.*;
|
|
import com.zd.laboratory.domain.vo.*;
|
|
|
import com.zd.laboratory.mapper.*;
|
|
import com.zd.laboratory.mapper.*;
|
|
|
import com.zd.laboratory.mqtt.entiy.EquipmentStatus;
|
|
import com.zd.laboratory.mqtt.entiy.EquipmentStatus;
|
|
|
import com.zd.laboratory.mqtt.service.impl.SubMessageSendManager;
|
|
import com.zd.laboratory.mqtt.service.impl.SubMessageSendManager;
|
|
|
|
|
+import com.zd.laboratory.netty.NettyPushMsgService;
|
|
|
import com.zd.laboratory.service.*;
|
|
import com.zd.laboratory.service.*;
|
|
|
import com.zd.laboratory.socket.command.Symbol;
|
|
import com.zd.laboratory.socket.command.Symbol;
|
|
|
import com.zd.laboratory.socket.service.SocketService;
|
|
import com.zd.laboratory.socket.service.SocketService;
|
|
@@ -48,6 +50,7 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
import java.util.concurrent.CompletableFuture;
|
|
import java.util.concurrent.CompletableFuture;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
import java.util.concurrent.TimeUnit;
|
|
@@ -246,21 +249,40 @@ public class LabSubjectManagerService {
|
|
|
logger.error("未关联继电器位!id:{},名称:{}", id, labHardwareVO.getName());
|
|
logger.error("未关联继电器位!id:{},名称:{}", id, labHardwareVO.getName());
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
- if (labHardwareVO.getHardwareType() == 2) {
|
|
|
|
|
- ResultData ResultData = socketService.sendMqttCommand(labHardwareVO.getId(), labHardwareVO.getRelayCode(), command, labHardwareVO.getBit(),labHardwareVO.getSubjectId());
|
|
|
|
|
|
|
+ if (labHardwareVO.getHardwareType() == 1) {
|
|
|
|
|
+ ResultData ResultData = socketService.sendCommand(Symbol.order.control, labHardwareVO.getRelayCode(), command, labHardwareVO.getBit());
|
|
|
boolean equals = ResultData.getCode().equals(HttpStatus.SUCCESS);
|
|
boolean equals = ResultData.getCode().equals(HttpStatus.SUCCESS);
|
|
|
if (equals) {
|
|
if (equals) {
|
|
|
//添加记录
|
|
//添加记录
|
|
|
labControlService.manualCreateLabControlAndSave(labHardwareVO, Symbol.order.control, command);
|
|
labControlService.manualCreateLabControlAndSave(labHardwareVO, Symbol.order.control, command);
|
|
|
}
|
|
}
|
|
|
- } else {
|
|
|
|
|
- ResultData ResultData = socketService.sendCommand(Symbol.order.control, labHardwareVO.getRelayCode(), command, labHardwareVO.getBit());
|
|
|
|
|
|
|
+ return equals;
|
|
|
|
|
+ } else if (labHardwareVO.getHardwareType() == 2) {
|
|
|
|
|
+ ResultData ResultData = socketService.sendMqttCommand(labHardwareVO.getId(), labHardwareVO.getRelayCode(), command, labHardwareVO.getBit(), labHardwareVO.getSubjectId());
|
|
|
boolean equals = ResultData.getCode().equals(HttpStatus.SUCCESS);
|
|
boolean equals = ResultData.getCode().equals(HttpStatus.SUCCESS);
|
|
|
if (equals) {
|
|
if (equals) {
|
|
|
//添加记录
|
|
//添加记录
|
|
|
labControlService.manualCreateLabControlAndSave(labHardwareVO, Symbol.order.control, command);
|
|
labControlService.manualCreateLabControlAndSave(labHardwareVO, Symbol.order.control, command);
|
|
|
}
|
|
}
|
|
|
- return equals;
|
|
|
|
|
|
|
+ } else if (labHardwareVO.getHardwareType() == 3) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ String relayCode = labHardwareVO.getRelayCode();
|
|
|
|
|
+ String type = command.getType();
|
|
|
|
|
+ if(RelayConstants.AT_OPEN_STR.equals(type)){
|
|
|
|
|
+ type=RelayConstants.AT_OPEN.toString();
|
|
|
|
|
+ }
|
|
|
|
|
+ if(RelayConstants.AT_CLOSE_STR.equals(type)){
|
|
|
|
|
+ type=RelayConstants.AT_CLOSE.toString();
|
|
|
|
|
+ }
|
|
|
|
|
+ String commandStr = RelayConstants.AT_STACH + labHardwareVO.getBit() + "=" + type + RelayConstants.SPACE_WRAP;
|
|
|
|
|
+ NettyPushMsgService.push(relayCode, commandStr.getBytes());
|
|
|
|
|
+ return true;
|
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
|
+ logger.error("泥人继电器调用成功" + e.getMessage());
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return false;
|
|
|
}
|
|
}
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
@@ -728,6 +750,8 @@ public class LabSubjectManagerService {
|
|
|
classifyVO.setId(xcf.getId());
|
|
classifyVO.setId(xcf.getId());
|
|
|
classifyVO.setClassifyName(xcf.getClassifyName());
|
|
classifyVO.setClassifyName(xcf.getClassifyName());
|
|
|
classifyVO.setClassifyType(xcf.getClassifyType());
|
|
classifyVO.setClassifyType(xcf.getClassifyType());
|
|
|
|
|
+ classifyVO.setShowColour(xcf.getShowColour());
|
|
|
|
|
+ classifyVO.setIsSpecial(xcf.getIsSpecial());
|
|
|
classifyVOList.add(classifyVO);
|
|
classifyVOList.add(classifyVO);
|
|
|
|
|
|
|
|
//查询公共配置
|
|
//查询公共配置
|
|
@@ -1615,7 +1639,15 @@ public class LabSubjectManagerService {
|
|
|
hardware.setIsPcfire(a.getIsPcfire());
|
|
hardware.setIsPcfire(a.getIsPcfire());
|
|
|
}
|
|
}
|
|
|
//初始化开关状态 (开关类型)
|
|
//初始化开关状态 (开关类型)
|
|
|
- if (a.getHardwareType() == 2) {
|
|
|
|
|
|
|
+ if(a.getHardwareType()==1){
|
|
|
|
|
+ if (StrUtil.isNotBlank(a.getRelayCode()) && a.getBit() != null) {
|
|
|
|
|
+ Map<Integer, ControlEntity.SwitchEnums> switchEnums = socketService.getSwitchEnums(a.getRelayCode());
|
|
|
|
|
+ if (switchEnums != null) {
|
|
|
|
|
+ ControlEntity.SwitchEnums switchEnums1 = switchEnums.get(a.getBit());
|
|
|
|
|
+ hardware.setSwitchEnums(switchEnums1);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } else if (a.getHardwareType() == 2) {
|
|
|
Integer code=redisService.getCacheObject(CacheConstants.RELAY_STATUS_KEY+a.getId());
|
|
Integer code=redisService.getCacheObject(CacheConstants.RELAY_STATUS_KEY+a.getId());
|
|
|
if(null==code){
|
|
if(null==code){
|
|
|
if(null!=a.getOperate() && a.getOperate().getCode()==3){
|
|
if(null!=a.getOperate() && a.getOperate().getCode()==3){
|
|
@@ -1635,13 +1667,12 @@ public class LabSubjectManagerService {
|
|
|
hardware.setState(HardwareOperate.CLOSE);
|
|
hardware.setState(HardwareOperate.CLOSE);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- } else {
|
|
|
|
|
- if (StrUtil.isNotBlank(a.getRelayCode()) && a.getBit() != null) {
|
|
|
|
|
- Map<Integer, ControlEntity.SwitchEnums> switchEnums = socketService.getSwitchEnums(a.getRelayCode());
|
|
|
|
|
- if (switchEnums != null) {
|
|
|
|
|
- ControlEntity.SwitchEnums switchEnums1 = switchEnums.get(a.getBit());
|
|
|
|
|
- hardware.setSwitchEnums(switchEnums1);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ } else if(a.getHardwareType() == 3){
|
|
|
|
|
+ if(null!=a.getOperate() && a.getOperate().getCode()==3){
|
|
|
|
|
+ hardware.setSwitchEnums(ControlEntity.SwitchEnums.ON);
|
|
|
|
|
+ }
|
|
|
|
|
+ if(null!=a.getOperate() && a.getOperate().getCode()==4){
|
|
|
|
|
+ hardware.setSwitchEnums(ControlEntity.SwitchEnums.OFF);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|