Browse Source

代码提交

jingyuanchao 1 năm trước cách đây
mục cha
commit
4686d1d843

+ 6 - 1
soc-modules/soc-modules-mediator/src/main/java/com/xunmei/mediator/api/video/service/impl/VideoIntegrityCheckServiceImpl.java

@@ -31,8 +31,10 @@ import com.xunmei.mediator.websocket.dto.WebsocketExecuteReq;
 import com.xunmei.mediator.websocket.dto.WebsocketResult;
 import com.xunmei.mediator.websocket.enums.DeviceTypeEnum;
 import com.xunmei.mediator.websocket.enums.ProductEnums;
+import com.xunmei.mediator.websocket.enums.TopicTypeEnums;
 import com.xunmei.mediator.websocket.holder.WebSocketSessionHolder;
 import com.xunmei.mediator.websocket.service.RouterService;
+import com.xunmei.mediator.websocket.utils.WebSocketUtils;
 import com.xunmei.system.api.RemoteOrgService;
 import com.xunmei.system.api.domain.SysOrg;
 import com.xunmei.system.api.domain.iot.IotDeviceInfo;
@@ -105,7 +107,9 @@ public class VideoIntegrityCheckServiceImpl extends ServiceImpl<VideoIntegrityCh
         VideoIntegrityCheckDto checkDto = transform(checkReq);
         SysOrg sysOrg = iotServerInfoService.selectOrgByToken(req.getToken());
         checkDto.setOrganizationGuid(sysOrg.getCode());
-        return this.saveData(checkDto, "");
+        final ReceiveErrorDto dto = this.saveData(checkDto, req.getId());
+        String topic=req.getTopic()+"/reply";
+        return WebsocketResult.of(dto, topic, req.getId());
     }
 
     @Override
@@ -113,6 +117,7 @@ public class VideoIntegrityCheckServiceImpl extends ServiceImpl<VideoIntegrityCh
         WebsocketResult websocketResult = new WebsocketResult();
         websocketResult.setId(UUID.randomUUID().toString());
         websocketResult.setTimestamp(new Date());
+        //websocketResult.setTopic(String.format(TopicTypeEnums.PRODUCT_EVENT_NOTICE_REPLY.getUrl(),));
         HashMap<String, Object> hashMap = new HashMap<>();
         hashMap.put(WebSocketConstants.SERVICE, WebSocketConstants.GET_RECORD_INFOS_SERVICES);
         hashMap.put(WebSocketConstants.ARGS, new JSONObject());

+ 2 - 0
soc-modules/soc-modules-mediator/src/main/java/com/xunmei/mediator/websocket/dto/WebsocketExecuteReq.java

@@ -22,6 +22,8 @@ public class WebsocketExecuteReq {
     @ApiModelProperty(value = "消息中的id,以此作为msgId")
     private String id;
 
+    private String topic;
+
     @ApiModelProperty(value = "topic中的productName")
     private String productName;
     @ApiModelProperty(value = "topic中的deviceName")

+ 5 - 0
soc-modules/soc-modules-mediator/src/main/java/com/xunmei/mediator/websocket/dto/WebsocketResult.java

@@ -38,6 +38,11 @@ public class WebsocketResult implements Serializable {
      * 消息请求时间
      */
     private String timestamp;
+
+    /**
+     * 消息头
+     */
+    private String headers;
     /**
      * 消息内容
      */

+ 20 - 9
soc-modules/soc-modules-mediator/src/main/java/com/xunmei/mediator/websocket/enums/TopicTypeEnums.java

@@ -1,6 +1,7 @@
 package com.xunmei.mediator.websocket.enums;
 
 
+import io.netty.util.internal.StringUtil;
 import lombok.AllArgsConstructor;
 import lombok.Getter;
 import lombok.Setter;
@@ -15,22 +16,29 @@ public enum TopicTypeEnums {
 
 
     //系统通知
-    SYS_NOTICE("/sys/notification","",""),
+    SYS_NOTICE("/sys/notification", StringUtil.EMPTY_STRING, StringUtil.EMPTY_STRING, StringUtil.EMPTY_STRING),
     //设备状态通知
-    DEVICE_STATUS("^/device/status/([^/]+)/([^/]+)$","",""),
+    DEVICE_STATUS("^/device/status/([^/]+)/([^/]+)$", StringUtil.EMPTY_STRING, StringUtil.EMPTY_STRING, "/device/status/%s/%s"),
     //产品事件通知消息
-    PRODUCT_EVENT_NOTICE("^/things/([^/]+)/([^/]+)/event/post$","",""),
+    PRODUCT_EVENT_NOTICE("^/things/([^/]+)/([^/]+)/event/post$", StringUtil.EMPTY_STRING, StringUtil.EMPTY_STRING,"/things/%s/%s/event/post"),
+    //产品事件通知返回发给IOT消息
+    PRODUCT_EVENT_NOTICE_REPLY("^/things/([^/]+)/([^/]+)/event/post/reply$", StringUtil.EMPTY_STRING, StringUtil.EMPTY_STRING,"/things/%s/%s/event/post/reply"),
     //应用方调用IoT产品服务消息
-    PRODUCT_SERVICE_INVOKE("^/things/([^/]+)/([^/]+)/service/invoke$","",""),
+    PRODUCT_SERVICE_INVOKE("^/things/([^/]+)/([^/]+)/service/invoke$", StringUtil.EMPTY_STRING, StringUtil.EMPTY_STRING,"/things/%s/%s/service/invoke"),
     //IoT返回服务调用消息
-    PRODUCT_SERVICE_REPLY("^/things/([^/]+)/([^/]+)/service/invoke/reply$","",""),
+    PRODUCT_SERVICE_REPLY("^/things/([^/]+)/([^/]+)/service/invoke/reply$", StringUtil.EMPTY_STRING, StringUtil.EMPTY_STRING, "/things/%s/%s/service/invoke/reply"),
     //应用方读取属性
-    PRODUCT_PROPERTY_GET("^/things/([^/]+)/([^/]+)/property/get$","",""),
+    PRODUCT_PROPERTY_GET("^/things/([^/]+)/([^/]+)/property/get$", StringUtil.EMPTY_STRING, StringUtil.EMPTY_STRING, "/things/%s/%s/property/get"),
     //IoT返回属性
-    PRODUCT_PROPERTY_REPLY("^/things/([^/]+)/([^/]+)/property/get/reply$","",""),
+    PRODUCT_PROPERTY_GET_REPLY("^/things/([^/]+)/([^/]+)/property/get/reply$", StringUtil.EMPTY_STRING, StringUtil.EMPTY_STRING, "/things/%s/%s/property/get/reply"),
     //应用方设置属性
-    PRODUCT_PROPERTY_SET("^/things/([^/]+)/([^/]+)/property/set$","",""),
-
+    PRODUCT_PROPERTY_SET("^/things/([^/]+)/([^/]+)/property/set$", StringUtil.EMPTY_STRING, StringUtil.EMPTY_STRING, "/things/%s/%s/property/set"),
+    //应用方设置属性
+    PRODUCT_PROPERTY_SET_REPLY("^/things/([^/]+)/([^/]+)/property/set$", StringUtil.EMPTY_STRING, StringUtil.EMPTY_STRING, "/things/%s/%s/property/set/reply"),
+    //IoT上报属性
+    PRODUCT_PROPERTY_POST("^/things/([^/]+)/([^/]+)/property/post", StringUtil.EMPTY_STRING, StringUtil.EMPTY_STRING, "/things/%s/%s/property/post"),
+    //IoT上报属性返回消息
+    PRODUCT_PROPERTY_POST_REPLY("^/things/([^/]+)/([^/]+)/property/post/reply$", StringUtil.EMPTY_STRING, StringUtil.EMPTY_STRING, "/things/%s/%s/property/post/reply"),
     ;
 
     private final String topic;
@@ -39,6 +47,8 @@ public enum TopicTypeEnums {
     @Setter
     private String deviceName;
 
+    private String url;
+
 
 
 
@@ -46,6 +56,7 @@ public enum TopicTypeEnums {
         TopicTypeEnums[] typeEnums = TopicTypeEnums.values();
         for (TopicTypeEnums regex : typeEnums) {
             Pattern pattern = Pattern.compile(regex.getTopic());
+
             // 创建Matcher对象
             Matcher matcher = pattern.matcher(topic);
             // 检查是否匹配成功

+ 3 - 3
soc-modules/soc-modules-mediator/src/main/java/com/xunmei/mediator/websocket/handler/SocWebSocketHandler.java

@@ -186,13 +186,13 @@ public class SocWebSocketHandler extends AbstractWebSocketHandler {
                         //IoT返回服务调用消息
                     case PRODUCT_SERVICE_REPLY:
                         RouterService routeService = RouterServiceHandler.getRouteService(typeEnums.getProductName(), routingKey);
-                        ReceiveErrorDto dto = (ReceiveErrorDto) routeService.execute(new WebsocketExecuteReq(event, args, token, websocketResult.getId(), typeEnums.getProductName(), typeEnums.getDeviceName()));
-                        WebSocketUtils.sendMessage(session, WebsocketResult.of(dto, topic, websocketResult.getId()));
+                        WebsocketResult result = (WebsocketResult) routeService.execute(new WebsocketExecuteReq(event, args, token, websocketResult.getId(),topic, typeEnums.getProductName(), typeEnums.getDeviceName()));
+                        WebSocketUtils.sendMessage(session,result);
                        /* DvsBaseInfo javaObject = JSON.toJavaObject(args, DvsBaseInfo.class);
                         websocketService.dealDvsBaseInfo(javaObject, token);*/
                         break;
                     //IoT返回属性
-                    case PRODUCT_PROPERTY_REPLY:
+                    case PRODUCT_PROPERTY_GET_REPLY:
                         break;
                     default:
                         break;