Kaynağa Gözat

soc-modules-host模块代码提交

jingyuanchao 1 yıl önce
ebeveyn
işleme
a2f81b0724

+ 3 - 0
soc-modules/soc-modules-host/src/main/java/com/xunmei/host/iot/service/impl/IotDeviceStatusServiceImpl.java

@@ -167,6 +167,9 @@ public class IotDeviceStatusServiceImpl extends ServiceImpl<IotDeviceStatusMappe
                     .findFirst()
                     .orElse(StringUtil.EMPTY_STRING);
             String val = DeviceTypeEnum.getStatusText(jsb.get("args"));
+            if (ObjectUtil.hasEmpty(name,val)) {
+                continue;
+            }
             object.put("name", name);
             object.put("val", val);
             final ElectricityMeterAttributes attributesEnum = ElectricityMeterAttributes.getEnumByName(name);

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

@@ -146,7 +146,7 @@ public class VideoIntegrityCheckServiceImpl extends ServiceImpl<VideoIntegrityCh
             object.put("recordDate", Arrays.asList(DateUtil.format(DateUtil.offsetDay(new Date(), -1), Constants.DAILY_FORMAT)));
             WebsocketResult websocketResult = IotServerUtils.invokeDownLinkServer(TopicTypeEnums.PRODUCT_SERVICE_INVOKE, iotDeviceInfo.getDeviceProduct(), iotDeviceInfo.getDeviceCode(), WebSocketConstants.GET_RECORD_INFOS_SERVICES, object);
             LogUtils.WEBSOCKET_MSG.info("获取录像完整性数据:{}", JacksonUtils.toJSONString(websocketResult));
-            WebSocketUtils.sendAll(JacksonUtils.toJSONString(websocketResult));
+            WebSocketUtils.sendMessage(iotDeviceInfo.getIotToken(),JacksonUtils.toJSONString(websocketResult));
         }
        /* String str = "{\"id\":\"fe48fd03-d3eb-4999-9180-02005c863333\",\"topic\":\"/things/IoTServer/IoTServerDevice/service/invoke\",\"timestamp\":\"2024-07-26T17:44:32.062+08:00\",\"headers\":{\"deviceName\":\"IoTServerDevice\",\"productName\":\"IoTServer\"},\"payload\":{\"args\":{\"id\":\"fe48fd03-d3eb-4999-9180-02005c863333\",\"topic\":\"/things/VGSII_Hik/33/service/invoke\",\"timestamp\":\"2024-07-26T17:44:32.062+08:00\",\"headers\":{\"deviceName\":\"33\",\"productName\":\"VGSII_Hik\"},\"payload\":{\"args\":{\"dvsCode\":\"ZM_20240726141823051\",\"index\":\"33\",\"recordDate\":[\"2024-07-25\"]},\"service\":\"getRecordInfos\"}},\"service\":\"downlinkServicePassthrough\"}}";
         final WebsocketResult result = JSON.parseObject(str, WebsocketResult.class);

+ 1 - 1
soc-modules/soc-modules-host/src/main/java/com/xunmei/host/websocket/constant/WebSocketConstants.java

@@ -167,7 +167,7 @@ public interface WebSocketConstants {
 
     String ALARM_HOST="AlarmHost";
 
-    String FSU_GATEWAY="FSU_Gateway";
+    String FSU="FSU";
 
     String IOT_SERVER="IoTServer";
 

+ 2 - 0
soc-modules/soc-modules-host/src/main/java/com/xunmei/host/websocket/dto/DeviceBaseInfo.java

@@ -27,4 +27,6 @@ public class DeviceBaseInfo implements Serializable {
     private String sourceName;
 
     private String description;
+
+    private String parentName;
 }

+ 9 - 0
soc-modules/soc-modules-host/src/main/java/com/xunmei/host/websocket/dto/WebsocketPayloadResolve.java

@@ -1,6 +1,7 @@
 package com.xunmei.host.websocket.dto;
 
 import cn.hutool.core.util.ObjectUtil;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.xunmei.host.websocket.constant.WebSocketConstants;
 import com.xunmei.host.websocket.enums.TopicTypeEnums;
@@ -22,6 +23,14 @@ public class WebsocketPayloadResolve {
 
 
     public WebsocketPayloadResolve(WebsocketResult result) {
+        final Object payload = result.getPayload();
+        if (payload instanceof JSONArray) {
+            this.data = payload;
+            this.topic = result.getTopic();
+            this.header = result.getHeaders();
+            return;
+
+        }
         JSONObject parentPayload = (JSONObject) result.getPayload();
         String serviceName = parentPayload.getString(WebSocketConstants.SERVICE);
         //是否透穿的数据,是的话,取里面那层payload的数据,不是的话就去第一层的数据

+ 9 - 9
soc-modules/soc-modules-host/src/main/java/com/xunmei/host/websocket/service/impl/WebsocketServiceImpl.java

@@ -653,7 +653,7 @@ public class WebsocketServiceImpl implements WebsocketService, RouterService {
             log.error("同步主机基础信息,获取主机信息为空");
         } else {
             for (DeviceBaseInfo deviceBaseInfo : deviceBaseInfos) {
-                IotDeviceInfo info = iIotDeviceInfoService.selectByTypeAndCode(token, getDeviceType(deviceBaseInfo.getCategories()), deviceBaseInfo.getProductName(), deviceBaseInfo.getDeviceName());
+                IotDeviceInfo info = iIotDeviceInfoService.selectByTypeAndCode(token, getDeviceType(deviceBaseInfo), deviceBaseInfo.getProductName(), deviceBaseInfo.getDeviceName());
                 if (info == null) {
                     info = createHostInfo(deviceBaseInfo, serverInfo);
                     addList.add(info);
@@ -677,9 +677,10 @@ public class WebsocketServiceImpl implements WebsocketService, RouterService {
         long id = IdWorker.getId(info);
         info.setDeleted(0);
         info.setDeviceCode(baseInfo.getDeviceName());
+        info.setHostCode(baseInfo.getParentName());
         info.setDeviceProduct(baseInfo.getProductName());
         //info.setDeviceModel(alarmHostInfos.getModel());
-        info.setDeviceType(getDeviceType(baseInfo.getCategories()));
+        info.setDeviceType(getDeviceType(baseInfo));
         info.setNetStatus("0");
         info.setIotToken(serverInfo.getIotCode());
         info.setDeviceName(baseInfo.getDisplayName());
@@ -695,16 +696,14 @@ public class WebsocketServiceImpl implements WebsocketService, RouterService {
     }
 
 
-    private String getDeviceType(String categories) {
-        if (ObjectUtil.isEmpty(categories)) {
+    private String getDeviceType(DeviceBaseInfo baseInfo) {
+        if (ObjectUtil.isEmpty(baseInfo.getCategories())) {
             return null;
         }
+        String categories = baseInfo.getCategories();
         String[] split = categories.split(";");
-        if (categories.contains(WebSocketConstants.FSU_GATEWAY)) {
-            if (split.length == 1) {
-                return DeviceTypeEnum.FSU_Gateway.getCode();
-            }
-            DeviceTypeEnum typeEnum = DeviceTypeEnum.valueOf(split[1]);
+        if (categories.contains(WebSocketConstants.FSU)) {
+            DeviceTypeEnum typeEnum = DeviceTypeEnum.valueOf(baseInfo.getProductName());
             return typeEnum.getCode();
         }
 
@@ -727,6 +726,7 @@ public class WebsocketServiceImpl implements WebsocketService, RouterService {
     private void dealHostInfo(DeviceBaseInfo baseInfo, IotDeviceInfo info, IotServerInfo serverInfo) {
         info.setDeleted(0);
         info.setDeviceName(baseInfo.getDisplayName());
+        info.setHostCode(baseInfo.getParentName());
         //info.setDeviceModel(alarmHostInfos.getModel());
         info.setOrgId(serverInfo.getOrgId());
         info.setOrgName(serverInfo.getOrgName());