|
|
@ -1,6 +1,7 @@ |
|
|
|
package com.qyft.ms.system.service.device; |
|
|
|
|
|
|
|
import cn.hutool.json.JSONObject; |
|
|
|
import cn.hutool.json.JSONUtil; |
|
|
|
import com.qyft.ms.app.device.status.DeviceStatus; |
|
|
|
import com.qyft.ms.system.common.constant.CommandStatus; |
|
|
|
import com.qyft.ms.system.common.device.command.CommandFuture; |
|
|
@ -78,7 +79,7 @@ public class DeviceCommandService { |
|
|
|
// Boolean success = result.getBool("success"); |
|
|
|
// if (success == null || !success) { //ack失败 |
|
|
|
// String message = deviceCommand.getCmdName() + "指令,设备ack错误"; |
|
|
|
// webSocketService.pushDebugMsg(FrontResponseGenerator.generateJson(cmdId, cmdCode, CommandStatus.SEND, message, result)); |
|
|
|
// webSocketService.pushDebugMsg(FrontResponseGenerator.generateJson(cmdId, cmdCode, CommandStatus.DEVICE_ERROR, message, result)); |
|
|
|
// throw new RuntimeException(message); |
|
|
|
// } |
|
|
|
// webSocketService.pushDebugMsg(FrontResponseGenerator.generateJson(cmdId, cmdCode, CommandStatus.RESULT, deviceCommand.getCmdName() + "指令,设备ack正常", result)); |
|
|
@ -89,7 +90,7 @@ public class DeviceCommandService { |
|
|
|
Boolean success = result.getBool("success"); |
|
|
|
if (success == null || !success) { //response失败 |
|
|
|
String message = deviceCommand.getCmdName() + "指令,设备response错误"; |
|
|
|
webSocketService.pushDebugMsg(FrontResponseGenerator.generateJson(cmdId, cmdCode, CommandStatus.SEND, message, result)); |
|
|
|
webSocketService.pushDebugMsg(FrontResponseGenerator.generateJson(cmdId, cmdCode, CommandStatus.DEVICE_ERROR, message, result)); |
|
|
|
throw new RuntimeException(message); |
|
|
|
} |
|
|
|
webSocketService.pushDebugMsg(FrontResponseGenerator.generateJson(cmdId, cmdCode, CommandStatus.DEVICE_RESULT, deviceCommand.getCmdName() + "指令,设备response正常,耗时:" + (commandFuture.getEndSendTime() - commandFuture.getStartSendTime()), result)); |
|
|
@ -103,8 +104,10 @@ public class DeviceCommandService { |
|
|
|
public void handleDeviceResult(JSONObject deviceResult) { |
|
|
|
String tag = deviceResult.getStr("tag"); |
|
|
|
if ("ACK".equals(tag)) { |
|
|
|
log.info("ACK {}", JSONUtil.toJsonStr(deviceResult)); |
|
|
|
completeCommandAck(deviceResult); |
|
|
|
} else if ("RESPONSE".equals(tag)) { |
|
|
|
log.info("RESPONSE {}", JSONUtil.toJsonStr(deviceResult)); |
|
|
|
completeCommandResponse(deviceResult); |
|
|
|
} else if ("EVENT".equals(tag)) { |
|
|
|
String eventType = deviceResult.getStr("event_type"); |
|
|
|