Showing
1 changed file
with
8 additions
and
5 deletions
... | ... | @@ -94,13 +94,16 @@ public abstract class AbstractRpcController extends BaseController { |
94 | 94 | if(!additional.has(FastIotConstants.Rpc.TARGET_ID)){ |
95 | 95 | additional.put(FastIotConstants.Rpc.TARGET_ID, deviceId.getId().toString()); |
96 | 96 | } |
97 | - String methodName = rpcRequestBody.get("method").asText(); | |
98 | - ObjectNode methodParams = (ObjectNode) rpcRequestBody.get("params"); | |
99 | - methodParams.put(FastIotConstants.Rpc.TARGET_NAME,targetDevice.getName()); | |
100 | - DeviceId realDevice = DeviceTypeEnum.SENSOR == targetDevice.getDeviceType()?new DeviceId(UUID.fromString(targetDevice.getGatewayId())):deviceId; | |
101 | 97 | String additionalInfo = JacksonUtil.toString(additional); |
98 | + String methodName = rpcRequestBody.get(FastIotConstants.Rpc.METHOD_NAME).asText(); | |
99 | + JsonNode params = rpcRequestBody.get(FastIotConstants.Rpc.PARAMS_NAME); | |
100 | + if(params!=null && !params.isTextual()){ | |
101 | + ObjectNode methodParams = (ObjectNode) rpcRequestBody.get(FastIotConstants.Rpc.PARAMS_NAME); | |
102 | + methodParams.put(FastIotConstants.Rpc.TARGET_NAME,targetDevice.getName()); | |
103 | + } | |
104 | + DeviceId realDevice = DeviceTypeEnum.SENSOR == targetDevice.getDeviceType()?new DeviceId(UUID.fromString(targetDevice.getGatewayId())):deviceId; | |
102 | 105 | |
103 | - ToDeviceRpcRequestBody body = new ToDeviceRpcRequestBody(methodName, JacksonUtil.toString(methodParams)); | |
106 | + ToDeviceRpcRequestBody body = new ToDeviceRpcRequestBody(methodName, JacksonUtil.toString(params)); | |
104 | 107 | TenantId tenantId = currentUser.getTenantId(); |
105 | 108 | final DeferredResult<ResponseEntity> response = new DeferredResult<>(); |
106 | 109 | long timeout = rpcRequestBody.has(DataConstants.TIMEOUT) ? rpcRequestBody.get(DataConstants.TIMEOUT).asLong() : defaultTimeout; | ... | ... |