Przeglądaj źródła

北向 FSU联调代码提交

jingyuanchao 1 rok temu
rodzic
commit
4856c9d98b

+ 3 - 0
project_data/sql/0.1.1/soc/soc.sql

@@ -850,6 +850,7 @@ CREATE TABLE `iot_device_status` (
                                      `device_id` bigint DEFAULT NULL COMMENT '设备id',
                                      `device_product` varchar(62) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '设备品牌',
                                      `device_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '设备编码',
+                                     `device_type` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '设备类型',
                                      `device_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '设备名称',
                                      `iot_token` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT 'iot服务唯一编码',
                                      `unique_code` varchar(225) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '设备编码',
@@ -857,6 +858,8 @@ CREATE TABLE `iot_device_status` (
                                      `org_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '机构名称',
                                      `org_path` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '机构路径',
                                      `info` text COLLATE utf8mb4_general_ci COMMENT '设备状态数据',
+                                     `state_update_time` datetime DEFAULT NULL COMMENT '最后一次状态更新时间',
+                                     `state_start_time` datetime DEFAULT NULL COMMENT '状态更新开始时间',
                                      `create_time` datetime DEFAULT NULL COMMENT '创建时间',
                                      `update_time` datetime DEFAULT NULL COMMENT '修改时间',
                                      `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建人',

+ 1 - 1
project_data/sql/0.1.1/升级文档.txt

@@ -84,4 +84,4 @@ security:
             multipart:
               max-file-size: 2048MB
 
-5.nacos新增配置:soc-host-dev.yml,配置内容可复制mediator配置文件
+5.nacos新增配置:soc-host-dev.yml,配置内容可复制mediator配置文件,若配置文件中有配置服务名称,则修改为soc-host,若无则不修改

+ 3 - 3
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/enums/iot/DeviceTypeEnum.java

@@ -1,6 +1,5 @@
 package com.xunmei.common.core.enums.iot;
 
-import com.xunmei.common.core.utils.StringUtils;
 import io.netty.util.internal.StringUtil;
 import lombok.AllArgsConstructor;
 import lombok.Getter;
@@ -18,7 +17,7 @@ public enum DeviceTypeEnum {
     MONITOR_CAMERA("2", "模拟摄像头"),
     NUMBER_CAMERA("3", "数字摄像头"),
     ALARM_HOST("4", "报警主机"),
-    FSU_GATEWAY("5", "动环主机"),
+    FSU_Gateway("5", "动环主机"),
     FSU_Smoke("6", "烟雾传感器"),
     FSU_Infrared("7", "红外传感器"),
     FSU_TemperatureAndHumidity("8", "温湿度传感器"),
@@ -30,7 +29,8 @@ public enum DeviceTypeEnum {
     FSU_AirConditioner("14", "空调"),
     FSU_Ups("15", "UPS"),
     FSU_DoPowerControl("16", "DO8小时控电"),
-    FSU_ThreePhaseACVoltage("17", "三相电电压传感器");
+    FSU_ThreePhaseACVoltage("17", "三相电电压传感器"),
+    FSU_Theft("18", "盗情传感器"),
 
     ;
     private String code;

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

@@ -702,7 +702,7 @@ public class WebsocketServiceImpl implements WebsocketService, RouterService {
         String[] split = categories.split(";");
         if (categories.contains(WebSocketConstants.FSU_GATEWAY)) {
             if (split.length == 1) {
-                return DeviceTypeEnum.FSU_GATEWAY.getCode();
+                return DeviceTypeEnum.FSU_Gateway.getCode();
             }
             DeviceTypeEnum typeEnum = DeviceTypeEnum.valueOf(split[1]);
             return typeEnum.getCode();

+ 1 - 1
soc-modules/soc-modules-mediator/src/main/java/com/xunmei/mediator/api/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);

+ 4 - 1
soc-modules/soc-modules-mediator/src/main/java/com/xunmei/mediator/iot/service/impl/IotDeviceStatusServiceImpl.java

@@ -166,7 +166,10 @@ public class IotDeviceStatusServiceImpl extends ServiceImpl<IotDeviceStatusMappe
                     .map(IotAlarmSystemField::getName)
                     .findFirst()
                     .orElse(StringUtil.EMPTY_STRING);
-            String val = DeviceTypeEnum.getStatusText(jsb.get("args"));
+            String val = DeviceTypeEnum.getStatusText(jsb.get("propertyValue"));
+            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-mediator/src/main/java/com/xunmei/mediator/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";
 

+ 4 - 0
soc-modules/soc-modules-mediator/src/main/java/com/xunmei/mediator/websocket/dto/DeviceBaseInfo.java

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

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

@@ -1,6 +1,7 @@
 package com.xunmei.mediator.websocket.dto;
 
 import cn.hutool.core.util.ObjectUtil;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.xunmei.mediator.websocket.constant.WebSocketConstants;
 import com.xunmei.mediator.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的数据,不是的话就去第一层的数据

+ 1 - 1
soc-modules/soc-modules-mediator/src/main/java/com/xunmei/mediator/websocket/service/RouterServiceHandler.java

@@ -47,7 +47,7 @@ public class RouterServiceHandler {
         if (first.isPresent()) {
             return first.get();
         }
-        LogUtils.WEBSOCKET_MSG.error("不支持的事件或服务:{}", routerKey);
+        LogUtils.WEBSOCKET_MSG.error("未找到合适处理类,不支持的事件或服务:{}", routerKey);
         return null;
     }
 }

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

@@ -86,7 +86,7 @@ public class WebsocketServiceImpl implements WebsocketService, RouterService {
 
     @Override
     public void invokeBaseDeviceInfoForSchedule() {
-        List<String> categories = Arrays.asList(WebSocketConstants.DVS, WebSocketConstants.ALARM_HOST);
+        List<String> categories = Arrays.asList(WebSocketConstants.FSU);
         JSONObject args = new JSONObject();
         args.put("categories", categories);
         WebsocketResult websocketResult = IotServerUtils.invokeIotServer(iotServerDeviceTopic, new JSONObject(), WebSocketConstants.GET_DEVICE_BASE_INFOS, args);
@@ -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);
@@ -678,8 +678,9 @@ public class WebsocketServiceImpl implements WebsocketService, RouterService {
         info.setDeleted(0);
         info.setDeviceCode(baseInfo.getDeviceName());
         info.setDeviceProduct(baseInfo.getProductName());
+        info.setHostCode(baseInfo.getParentName());
         //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());