Преглед изворни кода

Merge branch 'V0.0.6-iot' of http://10.87.21.221:8000/jzyd_yyds/soc into V0.0.6-iot

jiawuxian пре 1 година
родитељ
комит
34b6583fac

+ 8 - 0
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/constant/DictConstants.java

@@ -283,4 +283,12 @@ public class DictConstants {
      * 安全检查-检查类型
      */
     public static final String CHECK_TYPE = "check_type";
+    /**
+     * 动环传感器告警状态
+     */
+    public static final String SENSOR_ALARM_STATUS = "sensor_alarm_status";
+    /**
+     * 动环传感器设备类型
+     */
+    public static final String SENSOR_DEVICE_TYPE = "sensor_device_type";
 }

+ 6 - 6
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/iot/domain/IotSensor.java

@@ -2,9 +2,13 @@ package com.xunmei.common.core.domain.iot.domain;
 
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.baomidou.mybatisplus.annotation.TableId;
+
 import java.time.LocalDateTime;
+
 import com.baomidou.mybatisplus.annotation.TableField;
+
 import java.io.Serializable;
+
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
@@ -12,7 +16,7 @@ import lombok.EqualsAndHashCode;
 
 /**
  * <p>
- * 
+ *
  * </p>
  *
  * @author oygj
@@ -21,7 +25,7 @@ import lombok.EqualsAndHashCode;
 @Data
 @EqualsAndHashCode(callSuper = false)
 @TableName("iot_sensor")
-@ApiModel(value="IotSensor对象", description="")
+@ApiModel(value = "IotSensor对象", description = "")
 public class IotSensor implements Serializable {
 
     private static final long serialVersionUID = 1L;
@@ -53,10 +57,6 @@ public class IotSensor implements Serializable {
     @TableField("device_code")
     private String deviceCode;
 
-    @ApiModelProperty(value = "传感器类型编码")
-    @TableField("category_id")
-    private Long categoryId;
-
     @ApiModelProperty(value = "设备类型编码")
     @TableField("device_type")
     private String deviceType;

+ 1 - 0
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/enums/CategoryDataEnum.java

@@ -29,6 +29,7 @@ public enum CategoryDataEnum {
     AMMETER_SENSOR(3712198166114160L, "智能电表"),
     GAS_ALARM(3712197694111744L, "燃气报警器"),
     DOOR_WINDOW_SENSOR(3712197092999168L, "门磁、窗磁传感器"),
+    IOT_DETECTION_DEVICE(3712197092999168L, "视频物联网检测主机"),
     ;
 
 

+ 11 - 1
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/dto/sensor/SensorPageDto.java

@@ -1,6 +1,7 @@
 package com.xunmei.iot.dto.sensor;
 
 import com.xunmei.common.core.web.domain.PageRequest;
+import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
 import java.util.Date;
@@ -11,16 +12,25 @@ import java.util.Date;
  */
 @Data
 public class SensorPageDto extends PageRequest {
-
+    @ApiModelProperty(value = "传感器设备名称")
     private String deviceName;
 
+    @ApiModelProperty(value = "传感器设备code")
     private String deviceCode;
 
+    @ApiModelProperty(value = "传感器设备类型")
+    private String deviceType;
+
+    @ApiModelProperty(value = "上报时间")
     private Date[] dateRange;
 
     private Date startTime;
 
     private Date endTime;
 
+    @ApiModelProperty(value = "告警状态,0:正常,1:告警")
+    private Integer state;
+
+
 
 }

+ 5 - 20
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/service/impl/IotCommonSensorServiceImpl.java

@@ -5,10 +5,13 @@ import cn.hutool.core.util.ObjectUtil;
 import com.alibaba.fastjson2.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.xunmei.common.core.constant.DictConstants;
 import com.xunmei.common.core.constant.SecurityConstants;
 import com.xunmei.common.core.domain.iot.domain.IotSensor;
 import com.xunmei.common.core.domain.mediator.domain.MediatorCategory;
 import com.xunmei.common.core.web.page.TableDataInfo;
+import com.xunmei.common.redis.utils.RedisUtils;
+import com.xunmei.common.security.utils.DictUtils;
 import com.xunmei.iot.dto.sensor.SensorPageDto;
 import com.xunmei.iot.mapper.IotCommonSensorMapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -51,11 +54,11 @@ public class IotCommonSensorServiceImpl extends ServiceImpl<IotCommonSensorMappe
         dealPageParam(request);
 
         Page<SensorPageVo> page = sensorMapper.selectPageData(request.getPageRequest(), request);
-        final List<MediatorCategory> categoryList = categoryMapper.selectList(new LambdaQueryWrapper<>());
         for (SensorPageVo record : page.getRecords()) {
             final String info = record.getInfo();
             record.setInfo(dealInfoData(info));
-            dealCategoryName(record, categoryList);
+            record.setDeviceType(DictUtils.getDictLabel(DictConstants.SENSOR_DEVICE_TYPE,Integer.parseInt(record.getDeviceType())));
+            record.setStateText(DictUtils.getDictLabel(DictConstants.SENSOR_ALARM_STATUS,record.getState()));
         }
         return TableDataInfo.build(page);
     }
@@ -106,22 +109,4 @@ public class IotCommonSensorServiceImpl extends ServiceImpl<IotCommonSensorMappe
         return String.join(";", dataList);
     }
 
-    private void dealCategoryName(SensorPageVo record, List<MediatorCategory> categoryList) {
-        if (ObjectUtil.isEmpty(record.getCategoryId())) {
-            return;
-        }
-        final Optional<MediatorCategory> optional = categoryList.stream().filter(c -> ObjectUtil.equal(c.getId(), record.getCategoryId())).findFirst();
-        if (!optional.isPresent()) {
-            return;
-        }
-        final MediatorCategory category = optional.get();
-        record.setCategoryType(category.getName());
-        final Optional<MediatorCategory> parentCategoryOptional = categoryList.stream().filter(c -> ObjectUtil.equal(c.getId(), category.getParentId())).findFirst();
-        if (!parentCategoryOptional.isPresent()) {
-            return;
-        }
-        final MediatorCategory parentCategory = parentCategoryOptional.get();
-        record.setAssetsType(parentCategory.getName());
-
-    }
 }

+ 6 - 4
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/vo/sensor/SensorPageVo.java

@@ -28,11 +28,8 @@ public class SensorPageVo {
     @ApiModelProperty("设备名称")
     private String deviceName;
 
-    @ApiModelProperty("资产类别")
-    private String assetsType;
-
     @ApiModelProperty("设备类型")
-    private String categoryType;
+    private String deviceType;
 
     @ApiModelProperty("设备code")
     private String deviceCode;
@@ -44,4 +41,9 @@ public class SensorPageVo {
     @ApiModelProperty("上报时间")
     private LocalDateTime updateTime;
 
+    @ApiModelProperty(value = "告警状态,0:正常,1:告警")
+    private Integer state;
+
+    @ApiModelProperty(value = "告警状态")
+    private String stateText;
 }

+ 17 - 11
soc-modules/soc-modules-iot/src/main/resources/mapper/IotSensorMapper.xml

@@ -1,9 +1,8 @@
 <?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.iot.mapper.IotCommonSensorMapper">
-
     <select id="selectPageData" resultType="com.xunmei.iot.vo.sensor.SensorPageVo">
-        select s.id, org_id, org_name, device_name, category_id, infos as info,device_code, update_time
+        select s.id, org_id, org_name, device_name, device_type, infos as info,device_code, update_time,state
         from iot_sensor s
         where s.deleted=0
         <if test="request.orgId!= null">
@@ -15,6 +14,12 @@
         <if test="request.deviceName != null and request.deviceName!= ''">
             and s.device_name like CONCAT('%',#{request.deviceName},'%')
         </if>
+        <if test="request.state!= null">
+            and s.state = #{request.state}
+        </if>
+        <if test="request.deviceType!= null">
+            and s.device_type = #{request.deviceType}
+        </if>
         <if test="request.startTime!= null">
             and s.state_update_time >=#{request.startTime}
         </if>
@@ -24,7 +29,8 @@
     </select>
 
     <select id="selectSensorLogDataPage" resultType="com.xunmei.iot.vo.sensor.SensorPageVo">
-        select s.id, org_id, org_name, device_name, category_id, infos as info,device_code, update_time from iot_sensor_log s
+        select s.id, org_id, org_name, device_name, category_id, infos as info,device_code, update_time from
+        iot_sensor_log s
         <where>
             <if test="request.orgId!= null">
                 and s.org_id=#{request.orgId}
@@ -47,16 +53,16 @@
         </where>
         order by s.state_update_time desc
     </select>
-    <select id="selectByIds"  resultType="com.xunmei.common.core.domain.iot.domain.IotSensor">
+    <select id="selectByIds" resultType="com.xunmei.common.core.domain.iot.domain.IotSensor">
         SELECT
-            org_id,
-            CONCAT(b.affiliated_area,'-',b.affiliated_bank,'-',b.short_name) as org_name,
-            device_name,
-            category_id,
-            infos AS info,
-            device_code
+        org_id,
+        CONCAT(b.affiliated_area,'-',b.affiliated_bank,'-',b.short_name) as org_name,
+        device_name,
+        category_id,
+        infos AS info,
+        device_code
         FROM
-            iot_sensor a
+        iot_sensor a
         LEFT JOIN sys_org b ON a.org_id = b.id
         where device_code in
         <foreach collection="deviceIds" index="index" item="item" open="(" separator="," close=")">

+ 5 - 60
soc-modules/soc-modules-mediator/src/main/java/com/xunmei/mediator/api/service/EquipmentSyncService.java

@@ -241,87 +241,32 @@ public class EquipmentSyncService {
         device.setCameraPassword(datum.getCameraPassword());
         device.setEquipmentAddr(datum.getEquipmentAddr());
         device.setCameraCode(datum.getCameraCode());
+        device.setDeviceType(datum.getDeviceType());
         device.setDeleted(0);
         device.setSource(1);
-        String categoryCode = null;
         switch (datum.getEquipmentType()) {
             case 1:
                 //监控主机
-                device.setDeviceType(String.valueOf(DeviceType.Dvs.ordinal()));
-                categoryCode = "14";
                 device.setCategoryId(CategoryDataEnum.MONITOR_HOST_DEVICE.getId());
                 break;
             case 2:
                 //对讲主机
-                device.setDeviceType(String.valueOf(DeviceType.Intercom_Equipment.ordinal()));
-                categoryCode = "16";
                 device.setCategoryId(CategoryDataEnum.TALK_HOST_DEVICE.getId());
                 break;
             case 3:
                 //报警主机
-                device.setDeviceType(String.valueOf(DeviceType.Alarm_Equipment.ordinal()));
-                categoryCode = "15";
                 device.setCategoryId(CategoryDataEnum.ALARM_HOST_DEVICE.getId());
                 break;
             case 4:
                 //门禁主机
-                device.setDeviceType(String.valueOf(DeviceType.Guard_Equipment.ordinal()));
-                categoryCode = "17";
                 device.setCategoryId(CategoryDataEnum.DOOR_HOST_DEVICE.getId());
+                break;
+            case 5:
+                //报警主机传感器
+                device.setCategoryId(CategoryDataEnum.IOT_DETECTION_DEVICE.getId());
             default:
                 break;
         }
-
-        /**
-         * 此处因为是统一处理,所以如果存在新的brand,就会存放一样的品牌到数据库多条记录
-         * 所以存储brand应该是个单独的事务
-         */
-        //处理设备品牌
-       /* if(datum.getEquipmentCode().contains("GXX")||datum.getEquipmentCode().contains("gxx")){
-            datum.setProducer("高新兴");
-        }
-        if (datum.getEquipmentType() == 5) {
-            if (datum.getEquipmentCode().contains("XSD") || datum.getEquipmentCode().contains("xsd")) {
-                datum.setProducer("新世电");
-            } else {
-                datum.setProducer("高新兴");
-            }
-        }
-        Brand brand = brands.get(datum.getProducer());
-        if (brand == null) {
-            if (StringUtils.isNotEmpty(datum.getProducer())) {
-                //不存在该品牌则新建该品牌
-                brand = new Brand();
-                brand.setName(datum.getProducer());
-                brand.setCreateTime(new Date());
-                baseInfoService.saveBrandInfo(brand);
-                brands.put(datum.getProducer(), brand);
-                device.setBrandId(brand.getId());
-            }
-        } else {
-            device.setBrandId(brand.getId());
-        }*/
-
-        //处理设备分类,视频物联网监控主机由于清楚DeviceType暂定14写死,和固定写死categoryId
-        if (datum.getEquipmentType() == 5) {
-            if (datum.getEquipmentCode().contains("XSD") || datum.getEquipmentCode().contains("xsd")) {
-                device.setCategoryId(3712199107215361L);
-            } else {
-                device.setCategoryId(3712199107215360L);
-            }
-            device.setDeviceType(String.valueOf(DeviceType.Spwlw_Jczj.ordinal()));
-        } else {
-            MediatorCategory cate = categorys.get(categoryCode);
-            if (cate == null) {
-                MediatorCategory category = categoryService.findCategoryByCodeAndParentId(categoryCode, -1L);
-                if (category != null) {
-                    device.setCategoryId(category.getId());
-                    categorys.put(categoryCode, category);
-                }
-            } else {
-                device.setCategoryId(cate.getId());
-            }
-        }
         device.setCreateTime(LocalDateTime.now());
         device.setUpdateTime(LocalDateTime.now());
         map.put("device", device);

+ 7 - 29
soc-modules/soc-modules-mediator/src/main/java/com/xunmei/mediator/api/service/impl/IotSensorServiceImpl.java

@@ -6,12 +6,14 @@ import com.alibaba.fastjson2.JSONArray;
 import com.alibaba.fastjson2.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.xunmei.common.core.constant.DictConstants;
 import com.xunmei.common.core.constant.SecurityConstants;
 import com.xunmei.common.core.domain.iot.domain.IotSensor;
 import com.xunmei.common.core.domain.iot.domain.IotSensorLog;
 import com.xunmei.common.core.enums.CategoryDataEnum;
 import com.xunmei.common.core.utils.DateUtils;
 import com.xunmei.common.core.utils.IDHelper;
+import com.xunmei.common.security.utils.DictUtils;
 import com.xunmei.mediator.api.mapper.IotSensorMapper;
 import com.xunmei.mediator.api.service.*;
 import com.xunmei.mediator.util.CheckDataUtil;
@@ -223,7 +225,7 @@ public class IotSensorServiceImpl extends ServiceImpl<IotSensorMapper, IotSensor
                         , sensorDto, "数据来源中,同机构中设备编号重复。"));
                 continue;
             }
-            Long deviceType = convertDeviceType(sensorDto.getDeviceType());
+            String deviceType = convertDeviceType(sensorDto.getDeviceType());
             if (ObjectUtil.isNull(deviceType)) {
                 errors.add(new NorthError(msgId, path
                         , sensorDto, "无法识别的设备类型"));
@@ -244,7 +246,6 @@ public class IotSensorServiceImpl extends ServiceImpl<IotSensorMapper, IotSensor
             }
             domain.setUpdateTime(LocalDateTime.now());
             domain.setDeviceName(sensorDto.getDeviceName().replace("机房/基站环境", "物联环境"));
-            domain.setCategoryId(deviceType);
             domain.setHostCode(sensorDto.getHostCode());
             domain.setDeviceCode(sensorDto.getDeviceCode());
             domain.setOrgId(org.getId());
@@ -269,33 +270,10 @@ public class IotSensorServiceImpl extends ServiceImpl<IotSensorMapper, IotSensor
                 .collect(Collectors.groupingBy(c -> String.valueOf(c.getOrgId())));
     }
 
-    private Long convertDeviceType(String deviceCode) {
-        Long type = null;
-        switch (deviceCode) {
-            case "4183"://温湿度
-                type = CategoryDataEnum.HUMITURE_SENSOR.getId(); //todo
-                break;
-            case "4181"://红外
-                type = CategoryDataEnum.INFRARED_SENSOR.getId();
-                break;
-            case "4182": //烟感
-                type = CategoryDataEnum.SMOKE_SENSOR.getId();
-                break;
-            case "4184": //水浸
-                type = CategoryDataEnum.WATER_SENSOR.getId();
-                break;
-            case "4160"://智能电表
-                type = CategoryDataEnum.AMMETER_SENSOR.getId();
-                break;
-            case "4188"://门窗磁
-                type = CategoryDataEnum.DOOR_WINDOW_SENSOR.getId();
-                break;
-            case "41885"://燃气报警器
-                type = CategoryDataEnum.GAS_ALARM.getId();
-            default:
-                break;
+    private String convertDeviceType(String deviceType) {
+        if (ObjectUtil.isNotNull(deviceType)){
+            return null;
         }
-
-        return type;
+        return DictUtils.getDictLabel(DictConstants.SENSOR_DEVICE_TYPE, Integer.parseInt(deviceType));
     }
 }