Browse Source

bug修改

jingyuanchao 1 year ago
parent
commit
2079b5d34d

+ 9 - 9
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/video/MediatorVideoDiagnosisRecord.java

@@ -64,35 +64,35 @@ public class MediatorVideoDiagnosisRecord extends BaseEntity implements Serializ
 
     @ApiModelProperty(value = "信号丢失  0: 正常 | 1:异常")
     @TableField("signal_lost")
-    private Integer signalLost;
+    private int signalLost;
 
     @ApiModelProperty(value = "遮挡  0: 正常 | 1:异常")
     @TableField("occlude")
-    private Integer occlude;
+    private int occlude;
 
     @ApiModelProperty(value = "亮度  0: 正常 | 1:异常")
     @TableField("brightness")
-    private Integer brightness;
+    private int brightness;
 
     @ApiModelProperty(value = "偏色  0: 正常 | 1:异常")
     @TableField("color_cast")
-    private Integer colorCast;
+    private int colorCast;
 
     @ApiModelProperty(value = "雪花  0: 正常 | 1:异常")
     @TableField("snowflake")
-    private Integer snowflake;
+    private int snowflake;
 
     @ApiModelProperty(value = "条纹  0: 正常 | 1:异常")
     @TableField("stripe")
-    private Integer stripe;
+    private int stripe;
 
     @ApiModelProperty(value = "对比度  0: 正常 | 1:异常")
     @TableField("contrast")
-    private Integer contrast;
+    private int contrast;
 
     @ApiModelProperty(value = "模糊  0: 正常 | 1:异常")
     @TableField("blurry")
-    private Integer blurry;
+    private int blurry;
 
     @TableField("equipment_name")
     private String equipmentName;
@@ -103,7 +103,7 @@ public class MediatorVideoDiagnosisRecord extends BaseEntity implements Serializ
 
     @ApiModelProperty(value = "报警状态标识",notes = " 0:正常 | 1:异常")
     @TableField("is_alarm")
-    private Integer isAlarm;
+    private int isAlarm;
 
     @ApiModelProperty(value = "质量当前状态详情",notes = " 0: 正常 | 1:异常")
     @TableField("detail_info")

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

@@ -88,4 +88,7 @@ public enum BaseDeviceTypeEnum {
         return e != null ? e.getDesc() : "";
     }
 
+    public static BaseDeviceTypeEnum getEnumByCode(String code) {
+        return enumMap.get(code);
+    }
 }

+ 15 - 13
soc-modules/soc-modules-host/src/main/java/com/xunmei/host/alarm/service/impl/IotAlarmDataServiceImpl.java

@@ -71,7 +71,8 @@ public class IotAlarmDataServiceImpl extends ServiceImpl<IotAlarmDataMapper, Iot
     private IotAlarmSystemFieldMapper iotAlarmSystemFieldMapper;
 
     @Autowired
-    private IotDeviceStatusMapper deviceStatusMapper;;
+    private IotDeviceStatusMapper deviceStatusMapper;
+    ;
 
     @Autowired
     private RemoteConfigService remoteConfigService;
@@ -141,7 +142,7 @@ public class IotAlarmDataServiceImpl extends ServiceImpl<IotAlarmDataMapper, Iot
             for (IotAlarmData alarm : list) {
                 if (alarm.getSmsType()) {
                     LogUtils.DIRECT_HOST_SENSOR_STATUS.info("传感器【 {} 】 发生报警需要发送短信提醒", deviceStatus.getDeviceName());
-                    CompletableFuture.runAsync(()->{
+                    CompletableFuture.runAsync(() -> {
                         try {
                             //需要发送短信
                             LocalDateTime time = alarm.getTime();
@@ -206,14 +207,16 @@ public class IotAlarmDataServiceImpl extends ServiceImpl<IotAlarmDataMapper, Iot
    /* @Transactional(rollbackFor = Exception.class)
     @Override
     public void dealSensorData(IotSensor iotSensor) throws Exception {
-        *//**
-         * 生成告警数据逻辑梳理
-         * 1.根据传入的设备数据,判断设备类型。
-         * 2.根据设备类型获取设备绑定规则。
-         * 3.根据绑定规则判断适用于星期几,时间段。
-         * 4.根据绑定的规则判断是否需要生成告警数据。
-         * 5.如果结果是告警,判断是否已有告警数据,如果有则不生成告警数据。如果是告警结束,则修改告警数据的结束时间。
-         *//*
+        */
+
+    /**
+     * 生成告警数据逻辑梳理
+     * 1.根据传入的设备数据,判断设备类型。
+     * 2.根据设备类型获取设备绑定规则。
+     * 3.根据绑定规则判断适用于星期几,时间段。
+     * 4.根据绑定的规则判断是否需要生成告警数据。
+     * 5.如果结果是告警,判断是否已有告警数据,如果有则不生成告警数据。如果是告警结束,则修改告警数据的结束时间。
+     *//*
         Date now = new Date();
         //判断是否有绑定规则
         QueryWrapper<IotAlarmRuleSource> qw = new QueryWrapper<>();
@@ -335,7 +338,6 @@ public class IotAlarmDataServiceImpl extends ServiceImpl<IotAlarmDataMapper, Iot
             }
         }
     }*/
-
     @Override
     @Transactional(rollbackFor = Exception.class)
     public void dealSensorListData(List<IotSensor> iotSensor) throws Exception {
@@ -493,7 +495,7 @@ public class IotAlarmDataServiceImpl extends ServiceImpl<IotAlarmDataMapper, Iot
                 .eq(IotAlarmData::getSourceType, diagnosisType).isNull(IotAlarmData::getEndTime);
         List<IotAlarmData> iots = baseMapper.selectList(qw);
         //对于未配置需要告警的视频质量类型,不产生告警,但是允许将设备恢复正常,结束告警时间
-        if (diagnosisValue == 1 && iots.isEmpty() && (sysConfig != null && "1".equals(sysConfig.getConfigValue()))) {
+        if (ObjectUtil.equal(diagnosisValue, 1) && iots.isEmpty() && (sysConfig != null && "1".equals(sysConfig.getConfigValue()))) {
             /**
              * 报警处理逻辑
              * 1、判断报警表中是否有该类报警的数据;
@@ -506,7 +508,7 @@ public class IotAlarmDataServiceImpl extends ServiceImpl<IotAlarmDataMapper, Iot
 
 
         }
-        if (diagnosisValue == 0 && !iots.isEmpty()) {
+        if (ObjectUtil.equal(diagnosisValue, 0)  && !iots.isEmpty()) {
             IotAlarmData iotAlarmData = iots.get(0);
             iotAlarmData.setEndTime(LocalDateTime.now());
             this.updateById(iotAlarmData);

+ 20 - 0
soc-modules/soc-modules-host/src/main/resources/logback.xml

@@ -171,6 +171,22 @@
             <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
         </encoder>
     </appender>
+    <!-- 主机上报一键上下班操作数据  -->
+    <appender name="videoDiagnosisLog" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
+            <maxFileSize>${max.file.size}</maxFileSize>
+            <!--日志文件输出的文件名-->
+            <FileNamePattern>${LOG_HOME}/socketVideoDiagnosisLog/%d{yyyy-MM-dd}-%i.log</FileNamePattern>
+            <!--日志文件保留天数-->
+            <maxHistory>${max.history}</maxHistory>
+            <totalSizeCap>${total.size.cap}</totalSizeCap>
+            <cleanHistoryOnStart>true</cleanHistoryOnStart>
+        </rollingPolicy>
+        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
+            <!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
+            <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
+        </encoder>
+    </appender>
 
 
     <logger name="websocketMsgLog" additivity="false" level="info">
@@ -206,6 +222,10 @@
         <!--上面appender元素的name值。为了和logger的name属性做区分,我故意写的不一样-->
         <appender-ref ref="socketWorkOperationData"/>
     </logger>
+    <logger name="videoDiagnosisLog" additivity="false" level="info">
+        <!--上面appender元素的name值。为了和logger的name属性做区分,我故意写的不一样-->
+        <appender-ref ref="videoDiagnosisLog"/>
+    </logger>
 
     <!-- 日志输出级别 -->
     <root level="INFO">

+ 10 - 9
soc-modules/soc-modules-iot/src/main/java/com/xunmei/iot/service/impl/IotAlarmDataServiceImpl.java

@@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.google.common.collect.Lists;
 import com.xunmei.common.core.constant.SecurityConstants;
 import com.xunmei.common.core.domain.mediator.domain.IotAlarmData;
+import com.xunmei.common.core.enums.iot.BaseDeviceTypeEnum;
 import com.xunmei.common.core.enums.iot.SensorType;
 import com.xunmei.common.core.utils.StringUtils;
 import com.xunmei.common.core.web.page.TableDataInfo;
@@ -200,33 +201,33 @@ public class IotAlarmDataServiceImpl extends ServiceImpl<IotAlarmDataMapper, Iot
         }
         List<DeviceTypeCountVo> list = baseMapper.selectDeviceTypeCount(requestDto);
         for (DeviceTypeCountVo vo : list) {
-            String deviceType = vo.getDeviceType();
-            switch (deviceType){
-                case "4181"://红外
+            final BaseDeviceTypeEnum typeEnum = BaseDeviceTypeEnum.getEnumByCode(vo.getDeviceType());
+            switch (typeEnum){
+                case FSU_Infrared://红外
                     sensorAlarmCountVo.setInfraredCount(vo.getDeviceTypeCount());
                     sensorAlarmCountVo.setInfraredAlarmCount(vo.getDeviceTypeAlarmCount());
                     break;
-                case "4182"://烟感
+                case FSU_Smoke://烟感
                     sensorAlarmCountVo.setSmokeCount(vo.getDeviceTypeCount());
                     sensorAlarmCountVo.setSmokeAlarmCount(vo.getDeviceTypeAlarmCount());
                     break;
-                case "4183"://温湿度
+                case FSU_TemperatureAndHumidity://温湿度
                     sensorAlarmCountVo.setTemperatureAndHumidityCount(vo.getDeviceTypeCount());
                     sensorAlarmCountVo.setTemperatureAndHumidityAlarmCount(vo.getDeviceTypeAlarmCount());
                     break;
-                case "4184"://水浸
+                case FSU_Water://水浸
                     sensorAlarmCountVo.setWaterCount(vo.getDeviceTypeCount());
                     sensorAlarmCountVo.setWaterAlarmCount(vo.getDeviceTypeAlarmCount());
                     break;
-                case "4188"://门磁
+                case FSU_DoorMagnetic://门磁
                     sensorAlarmCountVo.setDoorCount(vo.getDeviceTypeCount());
                     sensorAlarmCountVo.setDoorAlarmCount(vo.getDeviceTypeAlarmCount());
                     break;
-                case "41881"://防盗
+                case FSU_Theft://防盗
                     sensorAlarmCountVo.setThiefCount(vo.getDeviceTypeCount());
                     sensorAlarmCountVo.setThiefAlarmCount(vo.getDeviceTypeAlarmCount());
                     break;
-                case "41885"://燃气
+                case FSU_Gas://燃气
                     sensorAlarmCountVo.setGasCount(vo.getDeviceTypeCount());
                     sensorAlarmCountVo.setGasAlarmCount(vo.getDeviceTypeAlarmCount());
                     break;

+ 2 - 2
soc-modules/soc-modules-iot/src/main/resources/mapper/DvrDiskMapper.xml

@@ -15,7 +15,7 @@
         <!--        <result column="alarmTime" property="alarmTime"/>-->
         <!--        <result column="detailInfo" property="detailInfo"-->
         <!--                typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler"/>-->
-        <collection property="diskInfos" column="equipmentCode=equipmentCode,,orgId=orgId"
+        <collection property="diskInfos" column="equipmentCode=equipmentCode,orgId=orgId"
                     select="selectDiskInfo">
             <result column="id" property="id"/>
             <result column="org_id" property="orgId"/>
@@ -33,7 +33,7 @@
         <result column="orgName" property="orgName"/>
         <result column="orgId" property="orgId"/>
         <result column="state" property="state"/>
-        <collection property="diskInfos" column="equipmentCode=equipmentCode,state=state"
+        <collection property="diskInfos" column="equipmentCode=equipmentCode,state=state,orgId=orgId"
                     select="selectDiskInfo">
             <result column="id" property="id"/>
             <result column="org_id" property="orgId"/>

+ 47 - 58
soc-modules/soc-modules-iot/src/main/resources/mapper/IotAlarmDataMapper.xml

@@ -116,96 +116,85 @@
     <select id="appBadge" resultType="java.lang.Integer">
         SELECT count(0)
         FROM iot_alarm_data a
-        where a.org_id = #{orgId} and a.end_time is null
+        where a.org_id = #{orgId}
+          and a.end_time is null
     </select>
 
     <select id="selectAlarmDataListByOrgPath" resultType="com.xunmei.common.core.domain.mediator.domain.IotAlarmData">
-        select d.* from iot_alarm_data d inner join sys_org o on d.org_id = o.id where o.path like concat(#{orgPath},'%') and o.deleted = 0
+        select d.* from iot_alarm_data d inner join sys_org o on d.org_id = o.id where o.path like
+        concat(#{orgPath},'%') and o.deleted = 0
         <if test="dataType != null">
             and d.data_type = #{dataType}
         </if>
     </select>
 
     <select id="selectDeviceTypeCount" resultType="com.xunmei.iot.vo.alarmData.DeviceTypeCountVo">
-        SELECT
-            s.device_type AS deviceType,
-            count(*) AS deviceTypeCount,
-            (
-            SELECT
-                count(*)
-            FROM
-                iot_sensor a
-            WHERE
-                a.device_type = s.device_type
-                AND a.state = 1
-                <if test="  query.checkSub != null and query.checkSub == true">
-                    and a.org_path like concat(concat('%',#{query.orgPath}),'%')
-                </if>
-                <if test="  query.checkSub != null and query.checkSub == false">
-                    and a.org_id = #{query.orgId}
-                </if>
-            ) AS deviceTypeAlarmCount
-        FROM
-            iot_sensor s
-        WHERE
-            s.deleted = 0
+        SELECT a.device_type as deviceType ,count(1) as deviceTypeCount,t.alarmNums as deviceTypeAlarmCount
+        FROM iot_device_info a INNER JOIN (
+        SELECT s.device_id as deviceId,COUNT(1) as alarmNums from iot_device_info i INNER join iot_device_status s on
+        i.id = s.device_id and i.iot_token = s.iot_token
+        WHERE s.state=1
+        ) t on t.deviceId= a.id
+        <where>
             <if test="  query.checkSub != null and query.checkSub == true">
-                and s.org_path like concat(concat('%',#{query.orgPath}),'%')
+                and a.org_path like concat(concat('%',#{query.orgPath}),'%')
             </if>
             <if test="  query.checkSub != null and query.checkSub == false">
-                and s.org_id = #{query.orgId}
+                and a.org_id = #{query.orgId}
             </if>
-        GROUP BY
-            s.device_type
+        </where>
+        GROUP BY a.device_type;
     </select>
     <select id="selectSensorAlarmPageList" resultType="com.xunmei.iot.vo.alarm.IotAlarmDataVo">
         SELECT
-            a.*,
-            b.affiliated_area AS city,
-            b.affiliated_bank AS bank,
-            b.short_name AS org_name
+        a.*,
+        b.affiliated_area AS city,
+        b.affiliated_bank AS bank,
+        b.short_name AS org_name
         FROM
-            iot_alarm_data a
-            LEFT JOIN iot_sensor s ON a.device_id = s.device_code AND a.org_id = s.org_id
-            LEFT JOIN sys_org b ON a.org_id = b.id
+        iot_alarm_data a
+        LEFT JOIN iot_sensor s ON a.device_id = s.device_code AND a.org_id = s.org_id
+        LEFT JOIN sys_org b ON a.org_id = b.id
         WHERE
-            1=1
-            <if test="param.sensorId != null">
-                and s.id = #{param.sensorId}
-            </if>
-            <if test="param.deviceName != null and param.deviceName != ''">
-                and s.device_name like concat('%',#{param.deviceName},'%')
-            </if>
+        1=1
+        <if test="param.sensorId != null">
+            and s.id = #{param.sensorId}
+        </if>
+        <if test="param.deviceName != null and param.deviceName != ''">
+            and s.device_name like concat('%',#{param.deviceName},'%')
+        </if>
         ORDER BY
-            a.`time` DESC,
-            a.end_time DESC
+        a.`time` DESC,
+        a.end_time DESC
     </select>
 
     <select id="selectAlarmCount" resultType="java.util.Map">
         select CAST(d.source_type as CHAR) deviceType, CAST(SUM(1) AS CHAR) as nums
         from iot_alarm_data d
                  inner join sys_org o on o.id = d.org_id
-        where o.deleted = 0 and data_type=0
+        where o.deleted = 0
+          and data_type = 0
           and (
-            (
-                #{beginTime}   <![CDATA[<=]]> d.time
-                    and now()       <![CDATA[>=]]> d.time
-                )
+                (
+                            #{beginTime}   <![CDATA[<=]]> d.time
+                        and now()       <![CDATA[>=]]> d.time
+                    )
                 or
-            (
-                #{beginTime}   <![CDATA[<=]]> d.end_time
-                    and now()       <![CDATA[>=]]> d.end_time
-                )
+                (
+                            #{beginTime}   <![CDATA[<=]]> d.end_time
+                        and now()       <![CDATA[>=]]> d.end_time
+                    )
                 or (
-                #{beginTime}   <![CDATA[>=]]> d.time
-                    and now()     <![CDATA[<=]]> d.end_time
-                )
+                            #{beginTime}   <![CDATA[>=]]> d.time
+                        and now()     <![CDATA[<=]]> d.end_time
+                    )
             )
-          and o.path like concat(#{orgPath}, '%') and d.source_type is not null
+          and o.path like concat(#{orgPath}, '%')
+          and d.source_type is not null
         group by d.source_type
     </select>
 
-    <select id="selectAlarmTypeList"  resultType="com.xunmei.iot.vo.alarmData.AlarmTypeSelectedVO">
+    <select id="selectAlarmTypeList" resultType="com.xunmei.iot.vo.alarmData.AlarmTypeSelectedVO">
         select source_type as value,
         replace(source_type_des,'传感器','') as label
         from iot_alarm_system_field