Quellcode durchsuchen

DVS基础信息同步修改

jingyuanchao vor 1 Jahr
Ursprung
Commit
da362a9dd0

+ 2 - 0
soc-modules/soc-modules-mediator/src/main/java/com/xunmei/mediator/iot/mapper/IotDeviceInfoExtendMapper.java

@@ -3,7 +3,9 @@ package com.xunmei.mediator.iot.mapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.xunmei.system.api.domain.iot.IotDeviceInfoExtend;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
 
 @Mapper
 public interface IotDeviceInfoExtendMapper extends BaseMapper<IotDeviceInfoExtend> {
+    IotDeviceInfoExtend selectByProductDeviceNameAndToken(@Param("token") String token, @Param("deviceTypeCode") String deviceTypeCode, @Param("deviceName") String deviceName);
 }

+ 2 - 0
soc-modules/soc-modules-mediator/src/main/java/com/xunmei/mediator/iot/service/IIotDeviceInfoExtendService.java

@@ -35,4 +35,6 @@ public interface IIotDeviceInfoExtendService extends IService<IotDeviceInfoExten
      */
     void deleteDeviceExtendByToken(String token);
 
+    IotDeviceInfoExtend selectByProductDeviceNameAndToken(String token, String deviceTypeCode, String deviceName);
+
 }

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

@@ -81,5 +81,8 @@ public class IotDeviceInfoExtendServiceImpl extends ServiceImpl<IotDeviceInfoExt
         update(uw);
     }
 
-
+    @Override
+    public IotDeviceInfoExtend selectByProductDeviceNameAndToken(String token, String deviceTypeCode, String deviceName) {
+        return baseMapper.selectByProductDeviceNameAndToken(token,deviceTypeCode,deviceName);
+    }
 }

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

@@ -123,4 +123,5 @@ public interface WebSocketConstants {
     String DVS="DVS";
 
     String ALARM_HOST="AlarmHost";
+    String FSU_GATEWAY="FSU_Gateway";
 }

+ 2 - 1
soc-modules/soc-modules-mediator/src/main/java/com/xunmei/mediator/websocket/dto/dvs/DvsBaseInfo.java

@@ -1,5 +1,6 @@
 package com.xunmei.mediator.websocket.dto.dvs;
 
+import com.xunmei.mediator.websocket.dto.alarmHost.CommunicationParameter;
 import lombok.AllArgsConstructor;
 import lombok.Data;
 import lombok.NoArgsConstructor;
@@ -12,7 +13,7 @@ import java.util.List;
 @NoArgsConstructor
 public class DvsBaseInfo implements Serializable {
     private static final long serialVersionUID = 1L;
-    private List<DvsInfo> dvsInfos;
     private List<ChannelInfo> channelInfos;
     private List<DiskInfo> diskInfos;
+    private List<CommunicationParameter> communicationParameters;
 }

+ 15 - 0
soc-modules/soc-modules-mediator/src/main/java/com/xunmei/mediator/websocket/enums/DeviceTypeEnum.java

@@ -1,10 +1,25 @@
 package com.xunmei.mediator.websocket.enums;
 
 public enum DeviceTypeEnum {
+
     DVS("1", "DVS监控主机"),
     MONITOR_CAMERA("2", "模拟摄像头"),
     NUMBER_CAMERA("3", "数字摄像头"),
     ALARM_HOST("4", "报警主机"),
+    FSU_GATEWAY("5", "动环主机"),
+    FSU_Smoke("6", "烟雾传感器"),
+    FSU_Infrared("7", "红外传感器"),
+    FSU_TemperatureAndHumidity("8", "温湿度传感器"),
+    FSU_DoorMagnetic("9", "门磁传感器"),
+    FSU_Gas("10", "燃气传感器"),
+    FSU_RollingShutterDoor("11", "卷帘门传感器"),
+    FSU_Water("12", "水浸传感器"),
+    FSU_SmartMeter("13", "智能电表"),
+    FSU_AirConditioner("14", "空调"),
+    FSU_Ups("15", "UPS"),
+    FSU_DoPowerControl("16", "DO8小时控电"),
+    FSU_ThreePhaseACVoltage("17", "三相电电压传感器");
+
     ;
     private String code;
     private String desc;

+ 1 - 0
soc-modules/soc-modules-mediator/src/main/java/com/xunmei/mediator/websocket/enums/ProductEnums.java

@@ -15,6 +15,7 @@ public enum ProductEnums {
     ALARM_HOST(new String[]{"InAnter_BM1600NTSmall", "Hik_DS19A", "HikModule", "FengYe_H402", "HengTong_CKWU01C", "MtaOCX", "CrossProcessDemo", "HoneywellOCX_IPM", "DaHuaAlarmHost", "BOSCH_CMS"}),
 
     IOT_SERVER(new String[]{"IoTServer"}),
+    FSU_GATEWAY(new String[]{"FSU_Gateway"}),
     ;
 
     private String[] productName;

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

@@ -22,6 +22,7 @@ import com.xunmei.mediator.websocket.dto.WebsocketExecuteReq;
 import com.xunmei.mediator.websocket.dto.WebsocketResult;
 import com.xunmei.mediator.websocket.dto.alarmHost.AlarmHostBaseInfo;
 import com.xunmei.mediator.websocket.dto.alarmHost.AlarmInputInfo;
+import com.xunmei.mediator.websocket.dto.alarmHost.CommunicationParameter;
 import com.xunmei.mediator.websocket.dto.alarmHost.SubSystemInfo;
 import com.xunmei.mediator.websocket.dto.dvs.ChannelInfo;
 import com.xunmei.mediator.websocket.dto.dvs.DiskInfo;
@@ -188,7 +189,6 @@ public class WebsocketServiceImpl implements WebsocketService, RouterService {
                 List<IotDvrDisk> addDiskList = new ArrayList<>();
                 //更新磁盘信息集合
                 List<IotDvrDisk> updateDiskList = new ArrayList<>();
-
                 //逻辑删除视频设备
                 iIotDeviceInfoService.deleteDeviceByToken(token);
                 //逻辑删除扩展信息
@@ -198,15 +198,11 @@ public class WebsocketServiceImpl implements WebsocketService, RouterService {
                 /**
                  * 逻辑处理
                  */
-                processDvsDevices(dvsBaseInfo.getDvsInfos(), serverInfo, token, addDvsList, updateDvsList, addListExtend, updateListExtend);
+                processDvsExtendInfo(dvsBaseInfo.getCommunicationParameters(), serverInfo, token, addDvsList, updateDvsList, addListExtend, updateListExtend);
                 processChannelDevices(dvsBaseInfo.getChannelInfos(), serverInfo, token, addChnnelList, updateChnnelList);
                 processDiskDevices(dvsBaseInfo.getDiskInfos(), serverInfo, token, addDiskList, updateDiskList);
-
-
                 // 批量保存和更新设备信息
                 saveOrUpdateDeviceBatches(addDvsList, updateDvsList, addChnnelList, updateChnnelList, addListExtend, updateListExtend, addDiskList, updateDiskList);
-
-
             } catch (Exception var8) {
                 log.error("同步视频类基础信息过程中出现异常", var8);
                 throw new RuntimeException(var8);
@@ -240,9 +236,9 @@ public class WebsocketServiceImpl implements WebsocketService, RouterService {
                 //逻辑删除主机
                 iIotDeviceInfoService.deleteAlarmHostAndDvsByToken(token);
 
-                //添加报警主机集合
+                //添加主机集合
                 List<IotDeviceInfo> addHostList = new ArrayList();
-                //更新报警主机集合
+                //更新主机集合
                 List<IotDeviceInfo> updateHostList = new ArrayList();
 
                 processHostDevices(alarmHostInfos, serverInfo, token, addHostList, updateHostList);
@@ -351,7 +347,7 @@ public class WebsocketServiceImpl implements WebsocketService, RouterService {
     /**
      * 处理dvs数据
      *
-     * @param dvsInfos
+     * @param communicationParameterList
      * @param serverInfo
      * @param token
      * @param addList
@@ -359,33 +355,32 @@ public class WebsocketServiceImpl implements WebsocketService, RouterService {
      * @param addListExtend
      * @param updateListExtend
      */
-    private void processDvsDevices(List<DvsInfo> dvsInfos, IotServerInfo serverInfo, String token, List<IotDeviceInfo> addList, List<IotDeviceInfo> updateList, List<IotDeviceInfoExtend> addListExtend, List<IotDeviceInfoExtend> updateListExtend) {
-        if (ObjectUtil.isEmpty(dvsInfos)) {
-            log.error("同步视频类基础信息,获取DVS信息为空");
+    private void processDvsExtendInfo(List<CommunicationParameter> communicationParameterList, IotServerInfo serverInfo, String token, List<IotDeviceInfo> addList, List<IotDeviceInfo> updateList, List<IotDeviceInfoExtend> addListExtend, List<IotDeviceInfoExtend> updateListExtend) {
+        if (ObjectUtil.isEmpty(communicationParameterList)) {
+            log.error("同步视频类基础信息,获取DVS扩展信息为空");
         } else {
-            for (DvsInfo dvsInfo : dvsInfos) {
-                IotDeviceInfo info = iIotDeviceInfoService.selectByTypeAndCode(token, DeviceTypeEnum.DVS.getCode(), dvsInfo.getDeviceName());
+            for (CommunicationParameter parameter : communicationParameterList) {
+                IotDeviceInfo info = iIotDeviceInfoService.selectByTypeAndCode(token, DeviceTypeEnum.DVS.getCode(), parameter.getDeviceName());
+                IotDeviceInfoExtend extend = iIotDeviceInfoExtendService.selectByProductDeviceNameAndToken(token, DeviceTypeEnum.DVS.getCode(), parameter.getDeviceName());
                 if (info == null) {
-                    info = createIotDeviceInfo(dvsInfo, serverInfo);
-                    addList.add(info);
-                    addListExtend.add(createIotDeviceInfoExtend(dvsInfo, info.getId(), token));
+                    continue;
+                }
+                if (extend == null) {
+                    addListExtend.add(createIotDeviceInfoExtend(parameter, info.getId(), token));
                 } else {
-                    dealDvsInfo(dvsInfo, info, serverInfo);
-                    updateList.add(info);
-                    IotDeviceInfoExtend extend = iIotDeviceInfoExtendService.selectByDeviceId(info.getId());
-                    dealDvsExtend(dvsInfo, extend);
+                    dealDvsExtend(parameter, extend);
                     updateListExtend.add(extend);
                 }
             }
         }
     }
 
-    private void dealDvsExtend(DvsInfo dvsInfo, IotDeviceInfoExtend extend) {
+    private void dealDvsExtend(CommunicationParameter dvsInfo, IotDeviceInfoExtend extend) {
         extend.setDeleted(0);
-        extend.setPort(dvsInfo.getPort());
-        extend.setPassword(dvsInfo.getPassword());
-        extend.setUserName(dvsInfo.getUserName());
-        extend.setNetAddress(dvsInfo.getNetAddress());
+        extend.setPort(dvsInfo.getDevicePort());
+        extend.setPassword(dvsInfo.getDevicePassword());
+        extend.setUserName(dvsInfo.getDeviceAccount());
+        extend.setNetAddress(dvsInfo.getDeviceAddress());
         extend.setUpdateBy("system");
         extend.setUpdateTime(new Date());
     }
@@ -414,13 +409,13 @@ public class WebsocketServiceImpl implements WebsocketService, RouterService {
      * @param deviceId
      * @return
      */
-    private IotDeviceInfoExtend createIotDeviceInfoExtend(DvsInfo dvsInfo, Long deviceId, String token) {
+    private IotDeviceInfoExtend createIotDeviceInfoExtend(CommunicationParameter dvsInfo, Long deviceId, String token) {
         IotDeviceInfoExtend extend = new IotDeviceInfoExtend();
         extend.setDeviceId(deviceId);
-        extend.setPort(dvsInfo.getPort());
-        extend.setPassword(dvsInfo.getPassword());
-        extend.setUserName(dvsInfo.getUserName());
-        extend.setNetAddress(dvsInfo.getNetAddress());
+        extend.setPort(dvsInfo.getDevicePort());
+        extend.setPassword(dvsInfo.getDevicePassword());
+        extend.setUserName(dvsInfo.getDeviceAccount());
+        extend.setNetAddress(dvsInfo.getDeviceAddress());
         extend.setIotToken(token);
         extend.setDeleted(0);
         extend.setCreateBy("system");
@@ -656,11 +651,19 @@ public class WebsocketServiceImpl implements WebsocketService, RouterService {
         if (ObjectUtil.isEmpty(categories)) {
             return null;
         }
-        String string = categories.split(":")[0];
-        if (WebSocketConstants.DVS.equals(string)) {
+        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]);
+            return typeEnum.getCode();
+        }
+
+        if (WebSocketConstants.DVS.equals(split[0])) {
             return DeviceTypeEnum.DVS.getCode();
         }
-        if (WebSocketConstants.ALARM_HOST.equals(string)) {
+        if (WebSocketConstants.ALARM_HOST.equals(split[0])) {
             return DeviceTypeEnum.ALARM_HOST.getCode();
         }
         return null;

+ 10 - 0
soc-modules/soc-modules-mediator/src/main/resources/mapper/IotDeviceInfoExtendmapper.xml

@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.xunmei.mediator.iot.mapper.IotDeviceInfoExtendMapper">
+
+
+    <select id="selectByProductDeviceNameAndToken" resultType="com.xunmei.system.api.domain.iot.IotDeviceInfoExtend">
+        select e.* from iot_device_info i inner join iot_device_info_extend e on i.id=e.device_id
+        where i.iot_token=#{token} and i.device_code=#{deviceName} and i.device_type=#{deviceTypeCode} limit 1
+    </select>
+</mapper>