Ver Fonte

网络监测设备接收增量代码提交

jingyuanchao há 11 meses atrás
pai
commit
719a66b442

+ 7 - 0
project_data/sql/1.0.11/soc.sql

@@ -254,6 +254,13 @@ INSERT INTO `sys_menu` VALUES (01747915341556742146, '视频诊断任务', 17479
 INSERT INTO `sys_menu` VALUES (01761830909641408513, '视频诊断阈值', 1747911340288892930, 2, 'diagnoseThreshold', 'iot/diagnoseThreshold', NULL, 1, 0, 'C', '0', '0', 'iot:diagnoseThreshold', '1', 'client', NULL, '超级管理员', '2024-11-18 09:37:19', '超级管理员', '2024-11-18 09:37:19', '');
 
 update sys_multi_layer_dictionary set is_system=1 where id in (1,2,3,4);
+-- 新增预置品牌
+delete from sys_multi_layer_dictionary where id in (1861655738759962626,1861655839484891137,1861655874030460930,1861656043241267202);
+INSERT INTO `sys_multi_layer_dictionary`(`id`, `code`, `name`, `parent_id`, `type`, `type_name`, `level`, `sort`, `status`, `is_system`, `path`, `remark`, `create_time`, `modified_name`, `update_time`, `modified_id`, `deleted`) VALUES (1861655738759962626, '1', '丽泽', -1, 'BrandModelType', '品牌型号类', 1, 0, '0', '1', '1861655738759962626-', NULL, '2024-11-27 14:18:10.665000', NULL, NULL, NULL, 0);
+INSERT INTO `sys_multi_layer_dictionary`(`id`, `code`, `name`, `parent_id`, `type`, `type_name`, `level`, `sort`, `status`, `is_system`, `path`, `remark`, `create_time`, `modified_name`, `update_time`, `modified_id`, `deleted`) VALUES (1861655839484891137, '1', '讯美', -1, 'BrandModelType', '品牌型号类', 1, 0, '0', '1', '1861655839484891137-', NULL, '2024-11-27 14:18:34.678000', NULL, NULL, NULL, 0);
+INSERT INTO `sys_multi_layer_dictionary`(`id`, `code`, `name`, `parent_id`, `type`, `type_name`, `level`, `sort`, `status`, `is_system`, `path`, `remark`, `create_time`, `modified_name`, `update_time`, `modified_id`, `deleted`) VALUES (1861655874030460930, '1', '其他', -1, 'BrandModelType', '品牌型号类', 1, 0, '0', '1', '1861655874030460930-', NULL, '2024-11-27 14:18:42.919000', NULL, NULL, NULL, 0);
+INSERT INTO `sys_multi_layer_dictionary`(`id`, `code`, `name`, `parent_id`, `type`, `type_name`, `level`, `sort`, `status`, `is_system`, `path`, `remark`, `create_time`, `modified_name`, `update_time`, `modified_id`, `deleted`) VALUES (1861656043241267202, '1', '世邦', -1, 'BrandModelType', '品牌型号类', 1, 0, '0', '1', '1861656043241267202-', NULL, '2024-11-27 14:19:23.262000', NULL, NULL, NULL, 0);
+
 
 
 

+ 2 - 0
soc-modules/soc-modules-host/src/main/java/com/xunmei/host/iot/mapper/IotDeviceInfoMapper.java

@@ -17,6 +17,8 @@ public interface IotDeviceInfoMapper extends BaseMapper<IotDeviceInfo> {
 
     SysMultiLayerDictionary selectSysMultiLayerDictionaryById(@Param("id") Long id);
 
+    SysMultiLayerDictionary selectDictionary(@Param("name") String name, @Param("type") String type);
+
     void updateDvsAndChannelDeleted(@Param("iotCode") String iotCode, @Param("deviceCode") String deviceCode);
 
     List<IotDeviceInfo> selectChannelList(@Param("iotToken") String iotToken, @Param("deviceCode") String deviceCode);

+ 84 - 6
soc-modules/soc-modules-host/src/main/java/com/xunmei/host/iot/service/impl/IotDeviceInfoServiceImpl.java

@@ -39,6 +39,7 @@ import com.xunmei.host.websocket.dto.DeviceStatusInfo;
 import com.xunmei.host.websocket.dto.WebsocketExecuteReq;
 import com.xunmei.host.websocket.dto.WebsocketResult;
 import com.xunmei.host.websocket.dto.alarmHost.AlarmHostIncrementVo;
+import com.xunmei.host.websocket.dto.alarmHost.NetDeviceIncrementVo;
 import com.xunmei.host.websocket.dto.dvs.DevicePushResult;
 import com.xunmei.host.websocket.dto.dvs.DvsBaseInfo;
 import com.xunmei.host.websocket.dto.dvs.SubDeviceInfo;
@@ -94,6 +95,7 @@ public class IotDeviceInfoServiceImpl extends ServiceImpl<IotDeviceInfoMapper, I
     @Autowired
     private WebsocketService websocketService;
 
+
     /**
      * 根据设备类型和设备编码,获取设备信息
      *
@@ -413,14 +415,78 @@ public class IotDeviceInfoServiceImpl extends ServiceImpl<IotDeviceInfoMapper, I
             case AlarmHost:
                 handleAlarmHostIncrement(data, serverInfo);
                 break;
+            case Host_Door:
+            case Host_Talk:
+                handleNetHostIncrement(data, serverInfo);
+                break;
+            default:
+                break;
         }
+    }
 
-
+    private void handleNetHostIncrement(String data, IotServerInfo serverInfo) {
+
+        final NetDeviceIncrementVo incrementVo = JSON.parseObject(data, NetDeviceIncrementVo.class);
+        final BaseDeviceTypeEnum typeEnum = BaseDeviceTypeEnum.valueOf(incrementVo.getDeviceType());
+        IotDeviceInfo device = selectByTypeAndCode(serverInfo.getIotCode(), typeEnum.getCode(), incrementVo.getDeviceProduct(), incrementVo.getDeviceCode());
+        final SysMultiLayerDictionary brandModelType = baseMapper.selectDictionary(incrementVo.getProducer(), "BrandModelType");
+        if (device == null) {
+            device = new IotDeviceInfo();
+            device.setId(IdWorker.getId());
+            device.setDeviceProduct(incrementVo.getDeviceProduct());
+            device.setDeviceCode(incrementVo.getDeviceCode());
+            device.setDeviceName(incrementVo.getDeviceName());
+            device.setDeviceType(typeEnum.getCode());
+            device.setOrgId(serverInfo.getOrgId());
+            device.setOrgName(serverInfo.getOrgName());
+            device.setOrgPath(serverInfo.getOrgPath());
+            device.setIotToken(serverInfo.getIotCode());
+            device.setNetStatus(DeviceNetStatusEnum.UNKNOWN.getValue());
+            device.setDeleted(0);
+            device.setEnable(incrementVo.getEnable());
+            device.setSyncStatus(DeviceSyncStatus.SYNC_SUCCESS.getCode());
+            device.setCreateBy("system");
+            device.setUpdateBy("system");
+            device.setCreateTime(new Date());
+            device.setUpdateTime(new Date());
+        } else {
+            device.setDeviceProduct(incrementVo.getDeviceProduct());
+            device.setDeviceCode(incrementVo.getDeviceCode());
+            device.setDeviceName(incrementVo.getDeviceName());
+            device.setDeviceType(typeEnum.getCode());
+            device.setDeleted(0);
+            device.setEnable(incrementVo.getEnable());
+            device.setUpdateBy("system");
+            device.setUpdateTime(new Date());
+        }
+        IotDeviceInfoExtend extend = iIotDeviceInfoExtendService.selectByDeviceId(device.getId());
+        if (extend == null) {
+            extend = new IotDeviceInfoExtend();
+            extend.setId(IdWorker.getId());
+            extend.setDeviceId(device.getId());
+            extend.setIotToken(serverInfo.getIotCode());
+            extend.setNetAddress(incrementVo.getNetAddress());
+            extend.setDeleted(0);
+            extend.setCreateBy("system");
+            extend.setUpdateBy("system");
+            extend.setCreateTime(new Date());
+            extend.setUpdateTime(new Date());
+        } else {
+            extend.setNetAddress(incrementVo.getNetAddress());
+            extend.setUpdateBy("system");
+            extend.setUpdateTime(new Date());
+            extend.setDeleted(0);
+        }
+        if (brandModelType != null) {
+            device.setDeviceBrand(brandModelType.getId());
+        }
+        saveOrUpdate(device);
+        iIotDeviceInfoExtendService.saveOrUpdate(extend);
     }
 
     private void handleAlarmHostIncrement(String data, IotServerInfo serverInfo) {
         AlarmHostIncrementVo baseDataInfo = JSON.parseObject(data, AlarmHostIncrementVo.class);
-        IotDeviceInfo deviceInfo = selectByTokenProductAndDeviceCode(serverInfo.getIotCode(), baseDataInfo.getProduct(), baseDataInfo.getName());
+        IotDeviceInfo deviceInfo = selectByTypeAndCode(serverInfo.getIotCode(), BaseDeviceTypeEnum.AlarmHost.getCode(), baseDataInfo.getProduct(), baseDataInfo.getName());
         if (ObjectUtil.isNull(deviceInfo)) {
             deviceInfo = handleAlarmHostAddHost(baseDataInfo, serverInfo);
         } else {
@@ -557,6 +623,8 @@ public class IotDeviceInfoServiceImpl extends ServiceImpl<IotDeviceInfoMapper, I
         alarmHost.setDeleted(0);
         alarmHost.setEnable(baseInfo.getStatus());
         alarmHost.setSyncStatus(DeviceSyncStatus.SYNC_SUCCESS.getCode());
+        alarmHost.setUpdateBy("system");
+        alarmHost.setUpdateTime(new Date());
         updateById(alarmHost);
     }
 
@@ -576,6 +644,10 @@ public class IotDeviceInfoServiceImpl extends ServiceImpl<IotDeviceInfoMapper, I
         alarmHost.setDeleted(0);
         alarmHost.setEnable(baseInfo.getStatus());
         alarmHost.setSyncStatus(DeviceSyncStatus.SYNC_SUCCESS.getCode());
+        alarmHost.setCreateBy("system");
+        alarmHost.setUpdateBy("system");
+        alarmHost.setCreateTime(new Date());
+        alarmHost.setUpdateTime(new Date());
         save(alarmHost);
         return alarmHost;
     }
@@ -1304,9 +1376,15 @@ public class IotDeviceInfoServiceImpl extends ServiceImpl<IotDeviceInfoMapper, I
 
     private JSONObject getNetDeviceJson(IotDeviceInfo deviceInfo, BaseDeviceTypeEnum deviceTypeEnum) {
         final IotDeviceInfoExtend extend = iIotDeviceInfoExtendService.selectByDeviceId(deviceInfo.getId());
-        final JSONObject obj = JSONObject.parseObject(JSON.toJSONString(deviceInfo));
-        obj.put("deviceType", deviceTypeEnum.name());
-        obj.put("extend", extend);
-        return obj;
+        final JSONObject object = new JSONObject();
+        object.put("deviceId", deviceInfo.getId());
+        object.put("name", deviceInfo.getDeviceName());
+        object.put("equipmentTypeId", deviceTypeEnum.getCode());
+        //object.put("producer", deviceInfo.getManufacturer());
+        object.put("netAddress", extend.getNetAddress());
+        object.put("deviceType", deviceTypeEnum.name());
+        object.put("enable", ObjectUtil.equal(0, deviceInfo.getEnable()));
+
+        return object;
     }
 }

+ 20 - 0
soc-modules/soc-modules-host/src/main/java/com/xunmei/host/websocket/dto/alarmHost/NetDeviceIncrementVo.java

@@ -0,0 +1,20 @@
+package com.xunmei.host.websocket.dto.alarmHost;
+
+import lombok.Data;
+
+/**
+ * @author jingyuanchao
+ * @date 2024/11/27 13:48
+ */
+
+
+@Data
+public class NetDeviceIncrementVo {
+    private String deviceType;
+    private String deviceProduct;
+    private String deviceCode;
+    private String producer;
+    private String deviceName;
+    private String netAddress;
+    private Integer enable;
+}

+ 61 - 20
soc-modules/soc-modules-host/src/main/resources/mapper/IotDeviceInfoMapper.xml

@@ -20,22 +20,54 @@
         <foreach collection="list" item="item" index="index" separator=";">
             UPDATE iot_device_info
             <set>
-                <if test="item.deviceType != null">device_type = #{item.deviceType},</if>
-                <if test="item.deviceProduct != null">device_product = #{item.deviceProduct},</if>
-                <if test="item.deviceModel != null">device_model = #{item.deviceModel},</if>
-                <if test="item.deviceCode != null">device_code = #{item.deviceCode},</if>
-                <if test="item.deviceName != null">device_name = #{item.deviceName},</if>
-                <if test="item.iotToken != null">iot_token = #{item.iotToken},</if>
-                <if test="item.orgId != null">org_id = #{item.orgId},</if>
-                <if test="item.orgName != null">org_name = #{item.orgName},</if>
-                <if test="item.orgPath != null">org_path = #{item.orgPath},</if>
-                <if test="item.netStatus != null">net_status = #{item.netStatus},</if>
-                <if test="item.hostCode != null">host_code = #{item.hostCode},</if>
-                <if test="item.deleted != null">deleted = #{item.deleted},</if>
-                <if test="item.createTime != null">create_time = #{item.createTime},</if>
-                <if test="item.updateTime != null">update_time = #{item.updateTime},</if>
-                <if test="item.createBy != null">create_by = #{item.createBy},</if>
-                <if test="item.updateBy != null">update_by = #{item.updateBy}</if>
+                <if test="item.deviceType != null">
+                    device_type = #{item.deviceType},
+                </if>
+                <if test="item.deviceProduct != null">
+                    device_product = #{item.deviceProduct},
+                </if>
+                <if test="item.deviceModel != null">
+                    device_model = #{item.deviceModel},
+                </if>
+                <if test="item.deviceCode != null">
+                    device_code = #{item.deviceCode},
+                </if>
+                <if test="item.deviceName != null">
+                    device_name = #{item.deviceName},
+                </if>
+                <if test="item.iotToken != null">
+                    iot_token = #{item.iotToken},
+                </if>
+                <if test="item.orgId != null">
+                    org_id = #{item.orgId},
+                </if>
+                <if test="item.orgName != null">
+                    org_name = #{item.orgName},
+                </if>
+                <if test="item.orgPath != null">
+                    org_path = #{item.orgPath},
+                </if>
+                <if test="item.netStatus != null">
+                    net_status = #{item.netStatus},
+                </if>
+                <if test="item.hostCode != null">
+                    host_code = #{item.hostCode},
+                </if>
+                <if test="item.deleted != null">
+                    deleted = #{item.deleted},
+                </if>
+                <if test="item.createTime != null">
+                    create_time = #{item.createTime},
+                </if>
+                <if test="item.updateTime != null">
+                    update_time = #{item.updateTime},
+                </if>
+                <if test="item.createBy != null">
+                    create_by = #{item.createBy},
+                </if>
+                <if test="item.updateBy != null">
+                    update_by = #{item.updateBy}
+                </if>
             </set>
             WHERE id = #{item.id}
         </foreach>
@@ -47,16 +79,18 @@
                  inner JOIN iot_device_status s ON d.device_product = s.device_product and d.device_code = s.device_code
         where d.device_product = 'FSU_DoPowerCollection'
           AND (d.`device_code` LIKE CONCAT('%', '41860001') OR d.`device_code` LIKE CONCAT('%', '41860002'))
-          and d.org_id=#{orgId}
+          and d.org_id = #{orgId}
           and d.deleted = 0
-          and s.org_id=#{orgId}
+          and s.org_id = #{orgId}
     </select>
 
     <select id="selectSysMultiLayerDictionaryById"
             resultType="com.xunmei.common.core.domain.device.domain.SysMultiLayerDictionary">
-        select * from sys_multi_layer_dictionary where id=#{id}
+        select *
+        from sys_multi_layer_dictionary
+        where id = #{id}
     </select>
-    <delete id="updateDvsAndChannelDeleted" >
+    <delete id="updateDvsAndChannelDeleted">
         update
             iot_device_info
         set deleted = 1
@@ -71,4 +105,11 @@
           and host_code = #{deviceCode}
           and deleted = 0
     </select>
+
+    <select id="selectDictionary" resultType="com.xunmei.common.core.domain.device.domain.SysMultiLayerDictionary">
+        select id,name
+        from sys_multi_layer_dictionary
+        where name = #{name}
+          and type = #{name}
+    </select>
 </mapper>