Browse Source

fix:设备反馈消息通过success true false来区分指令成功失败

tags/1.0
白凤吉 4 months ago
parent
commit
7e6512bd35
  1. 9
      src/main/java/com/qyft/ms/system/service/device/DeviceCommandService.java

9
src/main/java/com/qyft/ms/system/service/device/DeviceCommandService.java

@ -41,7 +41,6 @@ public class DeviceCommandService {
} }
cmdFuture.getResponseFuture().whenComplete((result, ex) -> { cmdFuture.getResponseFuture().whenComplete((result, ex) -> {
log.info("commandFutureMap 移除id:{} 剩余:{}", cmdToDevice.getCmdId(),commandFutureMap.size());
commandFutureMap.remove(cmdToDevice.getCmdId()); commandFutureMap.remove(cmdToDevice.getCmdId());
}); });
@ -76,8 +75,8 @@ public class DeviceCommandService {
CommandFuture commandFuture = executeCommand(deviceCommand); CommandFuture commandFuture = executeCommand(deviceCommand);
// webSocketService.pushDebugMsg(FrontResponseGenerator.generateJson(cmdId, cmdCode, CommandStatus.SEND, "已向设备发送了" + deviceCommand.getCmdName() + "指令", deviceCommand)); // webSocketService.pushDebugMsg(FrontResponseGenerator.generateJson(cmdId, cmdCode, CommandStatus.SEND, "已向设备发送了" + deviceCommand.getCmdName() + "指令", deviceCommand));
// commandFuture.getAckFuture().thenApply(result -> { // commandFuture.getAckFuture().thenApply(result -> {
// Boolean status = result.getBool("status");
// if (!status) { //ack失败
// Boolean success = result.getBool("success");
// if (success == null || !success) { //ack失败
// String message = deviceCommand.getCmdName() + "指令,设备ack错误"; // String message = deviceCommand.getCmdName() + "指令,设备ack错误";
// webSocketService.pushDebugMsg(FrontResponseGenerator.generateJson(cmdId, cmdCode, CommandStatus.SEND, message, result)); // webSocketService.pushDebugMsg(FrontResponseGenerator.generateJson(cmdId, cmdCode, CommandStatus.SEND, message, result));
// throw new RuntimeException(message); // throw new RuntimeException(message);
@ -87,8 +86,8 @@ public class DeviceCommandService {
// }); // });
commandFuture.getResponseFuture().thenApply(result -> { commandFuture.getResponseFuture().thenApply(result -> {
Boolean status = result.getBool("status");
if (!status) { //response失败
Boolean success = result.getBool("success");
if (success == null || !success) { //response失败
String message = deviceCommand.getCmdName() + "指令,设备response错误"; String message = deviceCommand.getCmdName() + "指令,设备response错误";
webSocketService.pushDebugMsg(FrontResponseGenerator.generateJson(cmdId, cmdCode, CommandStatus.SEND, message, result)); webSocketService.pushDebugMsg(FrontResponseGenerator.generateJson(cmdId, cmdCode, CommandStatus.SEND, message, result));
throw new RuntimeException(message); throw new RuntimeException(message);

Loading…
Cancel
Save