|
@@ -326,23 +326,43 @@ 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());
|
|
|
|
|
- boolean equals = ResultData.getCode().equals(200);
|
|
|
|
|
|
|
+ if (labHardwareVO.getHardwareType() == 1) {
|
|
|
|
|
+ ResultData ResultData = socketService.sendCommand(Symbol.order.control, labHardwareVO.getRelayCode(), command, labHardwareVO.getBit());
|
|
|
|
|
+ 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());
|
|
|
|
|
- boolean equals = ResultData.getCode().equals(200);
|
|
|
|
|
|
|
+ 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);
|
|
|
if (equals) {
|
|
if (equals) {
|
|
|
//添加记录
|
|
//添加记录
|
|
|
labControlService.manualCreateLabControlAndSave(labHardwareVO, Symbol.order.control, command);
|
|
labControlService.manualCreateLabControlAndSave(labHardwareVO, Symbol.order.control, command);
|
|
|
}
|
|
}
|
|
|
return equals;
|
|
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());
|
|
|
|
|
+ logger.info("声光报警泥人继电器调用完成!");
|
|
|
|
|
+ return true;
|
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
|
+ logger.error("声光报警泥人继电器调用失败!" + e.getMessage());
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return false;
|
|
|
}
|
|
}
|
|
|
- return true;
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|