Showing
7 changed files
with
13 additions
and
11 deletions
... | ... | @@ -282,8 +282,6 @@ class DeviceActorMessageProcessor extends AbstractContextAwareMsgProcessor { |
282 | 282 | rpc.setExpirationTime(request.getExpirationTime()); |
283 | 283 | rpc.setRequest(JacksonUtil.valueToTree(request)); |
284 | 284 | rpc.setStatus(status); |
285 | - rpc.setAdditionalInfo(JacksonUtil.toJsonNode(request.getAdditionalInfo())); | |
286 | - | |
287 | 285 | rpc.setAdditionalInfo(additional); |
288 | 286 | |
289 | 287 | return systemContext.getTbRpcService().save(tenantId, rpc); | ... | ... |
... | ... | @@ -81,7 +81,12 @@ public abstract class AbstractRpcController extends BaseController { |
81 | 81 | protected DeferredResult<ResponseEntity> handleDeviceRPCRequest(boolean oneWay, DeviceId deviceId, String requestBody, HttpStatus timeoutStatus, HttpStatus noActiveConnectionStatus) throws ThingsboardException { |
82 | 82 | try { |
83 | 83 | JsonNode rpcRequestBody = JacksonUtil.toJsonNode(requestBody); |
84 | - ToDeviceRpcRequestBody body = new ToDeviceRpcRequestBody(rpcRequestBody.get("method").asText(), JacksonUtil.toString(rpcRequestBody.get("params"))); | |
84 | + | |
85 | + //Thingskit function | |
86 | + JsonNode paramJson = rpcRequestBody.get("params"); | |
87 | + String paramStr =paramJson.isTextual()?paramJson.asText():JacksonUtil.toString(paramJson); | |
88 | + | |
89 | + ToDeviceRpcRequestBody body = new ToDeviceRpcRequestBody(rpcRequestBody.get("method").asText(), paramStr); | |
85 | 90 | SecurityUser currentUser = getCurrentUser(); |
86 | 91 | TenantId tenantId = currentUser.getTenantId(); |
87 | 92 | final DeferredResult<ResponseEntity> response = new DeferredResult<>(); | ... | ... |
... | ... | @@ -173,8 +173,9 @@ public class RpcCommandTask { |
173 | 173 | SecurityUser securityUser, |
174 | 174 | String taskCenterId) { |
175 | 175 | JsonNode rpcCommand = cmdJsonNode.get(FastIotConstants.RPC_COMMAND); |
176 | + String paramStr =rpcCommand.isTextual()?rpcCommand.asText():JacksonUtil.toString(rpcCommand); | |
176 | 177 | ToDeviceRpcRequestBody body = |
177 | - new ToDeviceRpcRequestBody("methodThingskit", JacksonUtil.toString(rpcCommand)); | |
178 | + new ToDeviceRpcRequestBody(FastIotConstants.Rpc.METHOD_NAME_VALUE, paramStr); | |
178 | 179 | DeviceId deviceId = new DeviceId(UUID.fromString(originateId)); |
179 | 180 | ObjectNode objectNode = JacksonUtil.newObjectNode(); |
180 | 181 | objectNode.put( | ... | ... |
... | ... | @@ -165,6 +165,7 @@ public interface FastIotConstants { |
165 | 165 | |
166 | 166 | /**RPC方法名*/ |
167 | 167 | public static String METHOD_NAME = "method"; |
168 | + public static String METHOD_NAME_VALUE = "methodThingskit"; | |
168 | 169 | /**RPC参数*/ |
169 | 170 | public static String PARAMS_NAME = "params"; |
170 | 171 | /**实控设备*/ | ... | ... |
common/transport/tcp/src/main/java/org/thingsboard/server/transport/tcp/adaptors/JsonTcpAdaptor.java
... | ... | @@ -136,12 +136,8 @@ public class JsonTcpAdaptor implements TcpTransportAdaptor { |
136 | 136 | |
137 | 137 | @Override |
138 | 138 | public Optional<TcpDownEntry> convertToPublish(TcpDeviceWareSessionContext ctx, TransportProtos.ToDeviceRpcRequestMsg rpcRequest) throws ExecutionException, InterruptedException { |
139 | -// ListenableFuture<Object> result = ctx.getContext().getJsEngine().invokeFunction(ctx.getRpcScriptId(), rpcRequest.getParams()); | |
140 | -// return Optional.of(Futures.transform(result, t -> JacksonUtil.fromString(t.toString(), TcpDownEntry.class), MoreExecutors.directExecutor()).get()); | |
141 | 139 | String payload = rpcRequest.getParams();//methodThingskit |
142 | - if (!payload.startsWith("{") && !payload.endsWith("}")) { | |
143 | - payload = payload.replace("\"","").replace(" ",""); | |
144 | - } | |
140 | + | |
145 | 141 | TcpDownEntry data = new TcpDownEntry(); |
146 | 142 | data.setDatas(payload); |
147 | 143 | data.setIdentifier(payload); | ... | ... |
... | ... | @@ -21,6 +21,7 @@ import org.springframework.util.StringUtils; |
21 | 21 | import org.thingsboard.server.common.data.DataConstants; |
22 | 22 | import org.thingsboard.server.common.data.id.DeviceId; |
23 | 23 | import org.thingsboard.server.common.data.kv.*; |
24 | +import org.thingsboard.server.common.data.yunteng.constant.FastIotConstants; | |
24 | 25 | import org.thingsboard.server.gen.transport.TransportProtos; |
25 | 26 | import org.thingsboard.server.gen.transport.TransportProtos.*; |
26 | 27 | |
... | ... | @@ -136,7 +137,7 @@ public class JsonConverter { |
136 | 137 | public static JsonElement toJson(TransportProtos.ToDeviceRpcRequestMsg msg, boolean includeRequestId) { |
137 | 138 | //Thingskit function |
138 | 139 | JsonObject result = null; |
139 | - if("methodThingskit".equals(msg.getMethodName())){ | |
140 | + if(FastIotConstants.Rpc.METHOD_NAME_VALUE.equals(msg.getMethodName())){ | |
140 | 141 | result= JSON_PARSER.parse(msg.getParams()).getAsJsonObject(); |
141 | 142 | }else{ |
142 | 143 | result = new JsonObject(); | ... | ... |
... | ... | @@ -252,7 +252,7 @@ public class TkSceneLinkageServiceImpl |
252 | 252 | JsonNode inputContext = |
253 | 253 | doActionDTO.getDoContext().get(FastIotConstants.Rpc.PARAMS_NAME); |
254 | 254 | ObjectNode outputContext = JacksonUtil.newObjectNode(); |
255 | - outputContext.put(FastIotConstants.Rpc.METHOD_NAME, "methodThingskit"); | |
255 | + outputContext.put(FastIotConstants.Rpc.METHOD_NAME, FastIotConstants.Rpc.METHOD_NAME_VALUE); | |
256 | 256 | if (inputContext == null) { |
257 | 257 | outputContext.put(FastIotConstants.Rpc.PARAMS_NAME, ""); |
258 | 258 | } else if (inputContext.isTextual()) { | ... | ... |