فهرست منبع

Merge remote-tracking branch 'origin/V0.1.1' into V0.1.1

# Conflicts:
#	soc-modules/soc-modules-mediator/src/main/java/com/xunmei/mediator/websocket/utils/IotServerUtils.java
jingyuanchao 1 سال پیش
والد
کامیت
17f724198a

+ 4 - 1
soc-modules/soc-modules-mediator/src/main/java/com/xunmei/mediator/api/protection/service/impl/IotAlarmHostServiceImpl.java

@@ -136,8 +136,11 @@ public class IotAlarmHostServiceImpl implements IIotAlarmHostService, RouterServ
                     args.put("id",Integer.valueOf(subsystem.getCode()));
                     args.put("isArm",isArm);
                     String topic = "/things/" + deviceInfo.getDeviceProduct() + "/" + deviceInfo.getDeviceCode() + "/service/invoke";
+                    JSONObject headers = new JSONObject();
+                    headers.put("productName", deviceInfo.getDeviceProduct());
+                    headers.put("deviceName", deviceInfo.getDeviceCode());
                     LogUtils.DEVICE_CONTROL_LOG.info("报警主机布撤防控制topic:{},控制参数:{}",topic,args.toJSONString());
-                    WebsocketResult websocketResult = IotServerUtils.invokeIotServer(topic, WebSocketConstants.SUB_SYSTEM_CONTROL, args);
+                    WebsocketResult websocketResult = IotServerUtils.invokeIotServer(topic, headers, WebSocketConstants.SUB_SYSTEM_CONTROL, args);
                     LogUtils.WEBSOCKET_MSG.info("布撤防控制指令:{}", JacksonUtils.toJSONString(websocketResult));
                     boolean invoked = WebSocketSessionHolder.sendMessage(subsystem.getIotToken(), JacksonUtils.toJSONString(websocketResult));
                     if (!invoked){

+ 3 - 3
soc-modules/soc-modules-mediator/src/main/java/com/xunmei/mediator/websocket/service/impl/WebsocketServiceImpl.java

@@ -90,7 +90,7 @@ public class WebsocketServiceImpl implements WebsocketService, RouterService {
         List<String> categories = Arrays.asList(WebSocketConstants.DVS, WebSocketConstants.ALARM_HOST);
         JSONObject args = new JSONObject();
         args.put("categories", categories);
-        WebsocketResult websocketResult = IotServerUtils.invokeIotServer(iotServerDeviceTopic, WebSocketConstants.GET_DEVICE_BASE_INFOS, args);
+        WebsocketResult websocketResult = IotServerUtils.invokeIotServer(iotServerDeviceTopic, new JSONObject(), WebSocketConstants.GET_DEVICE_BASE_INFOS, args);
         LogUtils.WEBSOCKET_MSG.info("获取设备基础数据:{}", JacksonUtils.toJSONString(websocketResult));
         WebSocketSessionHolder.sendAll(JacksonUtils.toJSONString(websocketResult));
     }
@@ -100,7 +100,7 @@ public class WebsocketServiceImpl implements WebsocketService, RouterService {
         String[] productNames = ProductEnums.DVS.getProductName();
         JSONObject args = new JSONObject();
         args.put("productNames", productNames);
-        WebsocketResult websocketResult = IotServerUtils.invokeIotServer(iotServerDeviceTopic, WebSocketConstants.GET_DVS_DEVICE_INFOS, args);
+        WebsocketResult websocketResult = IotServerUtils.invokeIotServer(iotServerDeviceTopic, new JSONObject(), WebSocketConstants.GET_DVS_DEVICE_INFOS, args);
         LogUtils.WEBSOCKET_MSG.info("获取dvs下基础数据:{}", JacksonUtils.toJSONString(websocketResult));
         WebSocketSessionHolder.sendAll(JacksonUtils.toJSONString(websocketResult));
     }
@@ -110,7 +110,7 @@ public class WebsocketServiceImpl implements WebsocketService, RouterService {
         String[] productNames = ProductEnums.ALARM_HOST.getProductName();
         JSONObject args = new JSONObject();
         args.put("productNames", productNames);
-        WebsocketResult websocketResult = IotServerUtils.invokeIotServer(iotServerDeviceTopic, WebSocketConstants.GET_ALARM_HOST_DEVICE_INFOS, args);
+        WebsocketResult websocketResult = IotServerUtils.invokeIotServer(iotServerDeviceTopic, new JSONObject(), WebSocketConstants.GET_ALARM_HOST_DEVICE_INFOS, args);
         LogUtils.WEBSOCKET_MSG.info("获取报警主机下数据:{}", JacksonUtils.toJSONString(websocketResult));
         WebSocketSessionHolder.sendAll(JacksonUtils.toJSONString(websocketResult));
     }

+ 2 - 2
soc-modules/soc-modules-mediator/src/main/java/com/xunmei/mediator/websocket/utils/IotServerUtils.java

@@ -21,12 +21,12 @@ import java.util.UUID;
 @NoArgsConstructor(access = AccessLevel.PRIVATE)
 public class IotServerUtils {
 
-    public static WebsocketResult invokeIotServer(String topic, String service, Object args) {
+    public static WebsocketResult invokeIotServer(String topic,JSONObject headers, String service, Object args){
         WebsocketResult websocketResult = new WebsocketResult();
         websocketResult.setId(UUID.randomUUID().toString());
         websocketResult.setTimestamp(DateUtil.format(new Date(), Constants.UTC_FORMAT));
         websocketResult.setTopic(topic);
-        websocketResult.setHeaders(new JSONObject());
+        websocketResult.setHeaders(headers);
         HashMap<String, Object> hashMap = new HashMap<>();
         hashMap.put(WebSocketConstants.SERVICE, service);
         hashMap.put(WebSocketConstants.ARGS, args);