Commit eb458c5da5d65ff3c474a2c1409dc8c8f2df801b
Merge branch '20220426' into 'master'
20220426 See merge request huang/thingsboard3.3.2!86
Showing
4 changed files
with
52 additions
and
14 deletions
... | ... | @@ -36,6 +36,7 @@ import org.thingsboard.server.actors.shared.AbstractContextAwareMsgProcessor; |
36 | 36 | import org.thingsboard.server.actors.stats.StatsPersistTick; |
37 | 37 | import org.thingsboard.server.common.data.DataConstants; |
38 | 38 | import org.thingsboard.server.common.data.Device; |
39 | +import org.thingsboard.server.common.data.DeviceTransportType; | |
39 | 40 | import org.thingsboard.server.common.data.StringUtils; |
40 | 41 | import org.thingsboard.server.common.data.edge.EdgeEvent; |
41 | 42 | import org.thingsboard.server.common.data.edge.EdgeEventActionType; |
... | ... | @@ -245,7 +246,15 @@ class DeviceActorMessageProcessor extends AbstractContextAwareMsgProcessor { |
245 | 246 | rpc.setExpirationTime(request.getExpirationTime()); |
246 | 247 | rpc.setRequest(JacksonUtil.valueToTree(request)); |
247 | 248 | rpc.setStatus(status); |
248 | - rpc.setAdditionalInfo(JacksonUtil.toJsonNode(request.getAdditionalInfo())); | |
249 | + | |
250 | + //Thingskit function | |
251 | + JsonNode old = JacksonUtil.toJsonNode(request.getAdditionalInfo()); | |
252 | + ObjectNode additional = old.isEmpty() ?mapper.createObjectNode():(ObjectNode)old; | |
253 | + if(!additional.has("cmdType")){ | |
254 | + additional.put("cmdType", DeviceTransportType.MQTT.name()); | |
255 | + } | |
256 | + rpc.setAdditionalInfo(additional); | |
257 | + | |
249 | 258 | return systemContext.getTbRpcService().save(tenantId, rpc); |
250 | 259 | } |
251 | 260 | ... | ... |
1 | 1 | package org.thingsboard.server.common.data.yunteng.dto; |
2 | 2 | |
3 | -import com.fasterxml.jackson.annotation.JsonFormat; | |
4 | 3 | import com.fasterxml.jackson.databind.JsonNode; |
5 | -import com.fasterxml.jackson.databind.annotation.JsonSerialize; | |
6 | -import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; | |
7 | 4 | import io.swagger.annotations.ApiModelProperty; |
8 | 5 | import lombok.Data; |
9 | -import lombok.EqualsAndHashCode; | |
10 | -import org.thingsboard.server.common.data.TenantProfile; | |
11 | -import org.thingsboard.server.common.data.rpc.RpcStatus; | |
12 | 6 | import org.thingsboard.server.common.data.yunteng.enums.DeviceTypeEnum; |
13 | -import org.thingsboard.server.common.data.yunteng.enums.LoginMethodEnum; | |
14 | -import org.thingsboard.server.common.data.yunteng.enums.ThirdPlatformEnum; | |
15 | - | |
16 | -import javax.validation.constraints.NotEmpty; | |
17 | -import java.time.LocalDateTime; | |
7 | +import org.thingsboard.server.common.data.yunteng.enums.YtRpcStatus; | |
18 | 8 | |
19 | 9 | /** |
20 | 10 | * @author Administrator |
... | ... | @@ -54,9 +44,12 @@ public class YtRpcRecordDTO { |
54 | 44 | @ApiModelProperty(value = "RPC扩展信息") |
55 | 45 | private JsonNode additionalInfo; |
56 | 46 | @ApiModelProperty(value = "RPC状态") |
57 | - private RpcStatus status; | |
58 | - | |
47 | + private YtRpcStatus status; | |
59 | 48 | |
60 | 49 | |
50 | + private String statusName; | |
61 | 51 | |
52 | + public String getStatusName() { | |
53 | + return YtRpcStatus.getLabel(status.name()); | |
54 | + } | |
62 | 55 | } | ... | ... |
common/data/src/main/java/org/thingsboard/server/common/data/yunteng/enums/YtRpcStatus.java
0 → 100644
1 | +/** | |
2 | + * Copyright © 2016-2021 The Thingsboard Authors | |
3 | + * | |
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | + * you may not use this file except in compliance with the License. | |
6 | + * You may obtain a copy of the License at | |
7 | + * | |
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | + * | |
10 | + * Unless required by applicable law or agreed to in writing, software | |
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | + * See the License for the specific language governing permissions and | |
14 | + * limitations under the License. | |
15 | + */ | |
16 | +package org.thingsboard.server.common.data.yunteng.enums; | |
17 | + | |
18 | +public enum YtRpcStatus { | |
19 | + QUEUED("队列中"), SENT("已发送"), DELIVERED("处理中"), SUCCESSFUL("成功"), TIMEOUT("超时"), EXPIRED("过期"), FAILED("失败"); | |
20 | + | |
21 | + String label; | |
22 | + YtRpcStatus(String label){ | |
23 | + this.label= label; | |
24 | + } | |
25 | + public static String getLabel(String name){ | |
26 | + for(YtRpcStatus type:values()){ | |
27 | + if(type.name().equals(name)){ | |
28 | + return type.label; | |
29 | + } | |
30 | + } | |
31 | + return null; | |
32 | + } | |
33 | +} | ... | ... |
... | ... | @@ -155,6 +155,7 @@ public class JsonConverter { |
155 | 155 | } |
156 | 156 | |
157 | 157 | public static JsonElement toJson(TransportProtos.ToDeviceRpcRequestMsg msg, boolean includeRequestId) { |
158 | + //Thingskit function | |
158 | 159 | JsonObject result = null; |
159 | 160 | if("methodThingskit".equals(msg.getMethodName())){ |
160 | 161 | result= JSON_PARSER.parse(msg.getParams()).getAsJsonObject(); |
... | ... | @@ -163,6 +164,8 @@ public class JsonConverter { |
163 | 164 | result.addProperty("method", msg.getMethodName()); |
164 | 165 | result.add("params", JSON_PARSER.parse(msg.getParams())); |
165 | 166 | } |
167 | + | |
168 | + | |
166 | 169 | if (includeRequestId) { |
167 | 170 | result.addProperty("id", msg.getRequestId()); |
168 | 171 | } | ... | ... |