فهرست منبع

Merge branch 'dev' of http://git.sckaiwu.cn/17358629955/slope-manage-service into dev

15928045575 2 سال پیش
والد
کامیت
a7bc125dc8

+ 5 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/dao/mysql/KwsAlarmMapper.java

@@ -3,6 +3,8 @@ package com.sckw.slope.detection.dao.mysql;
 import com.baomidou.dynamic.datasource.annotation.DS;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.sckw.slope.detection.model.dos.mysql.KwsAlarm;
+import com.sckw.slope.detection.model.param.AlarmLogThresholdExport;
+import com.sckw.slope.detection.model.param.AlarmLogThresholdQuery;
 import com.sckw.slope.detection.model.vo.AlarmLogThresholdVO;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
@@ -52,4 +54,7 @@ public interface KwsAlarmMapper extends BaseMapper<KwsAlarm> {
     List<AlarmLogThresholdVO> selectDetailList(@Param("page") Integer page, @Param("pageSize") Integer pageSize);
 
     int  selectDetailCount();
+
+    List<KwsAlarm> selectListByQuery(@Param("query") AlarmLogThresholdQuery query, @Param("mountainId") String mountainId);
+    List<KwsAlarm> selectExportListByQuery(@Param("query") AlarmLogThresholdExport query, @Param("mountainId") String mountainId,@Param("idsList") List<Long> idsList);
 }

+ 5 - 3
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/KwsAlarmService.java

@@ -140,7 +140,8 @@ public class KwsAlarmService {
             wrapper.like(KwsAlarm::getDeviceId, query.getDeviceId());
         }
         wrapper.orderByDesc(KwsAlarm::getCreateTime);
-        List<KwsAlarm> list = alarmMapper.selectList(wrapper);
+        List<KwsAlarm> list = alarmMapper.selectListByQuery(query, headerData.getMountainId());
+//        List<KwsAlarm> list = alarmMapper.selectList(wrapper);
         List<KwsAlarmVO> alarmVOS = new ArrayList<>();
         PageInfo<KwsAlarm> info = new PageInfo<KwsAlarm>(list);
         if (CollectionUtils.isEmpty(list)) {
@@ -335,7 +336,8 @@ public class KwsAlarmService {
         if (!CollectionUtils.isEmpty(idsList) && idsList.size() > 0) {
             wrapper.in(KwsAlarm::getId, idsList);
         }
-        List<KwsAlarm> list = alarmMapper.selectList(wrapper);
+        List<KwsAlarm> list = alarmMapper.selectExportListByQuery(query, headerData.getMountainId(),idsList);
+//        List<KwsAlarm> list = alarmMapper.selectList(wrapper);
         List<KwsAlarmExportVO> alarmVOS = new ArrayList<>();
         if (CollectionUtils.isEmpty(list)) {
             return alarmVOS;
@@ -359,7 +361,7 @@ public class KwsAlarmService {
             vo.setEndTime(kwsAlarm.getUpdateTime());
             LocalDateTime now = LocalDateTime.now();
             System.out.println(now);
-            Long count = alarmDetailMapper.selectCount(new LambdaQueryWrapper<KwsAlarmDetail>().eq(KwsAlarmDetail::getAlarmId, kwsAlarm.getId()));
+//            Long count = alarmDetailMapper.selectCount(new LambdaQueryWrapper<KwsAlarmDetail>().eq(KwsAlarmDetail::getAlarmId, kwsAlarm.getId()));
             LocalDateTime now1 = LocalDateTime.now();
             System.out.println(now1);
             //todo 不使用缓存  使用新字段处理

+ 2 - 2
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/ThresholdService.java

@@ -228,8 +228,8 @@ public class ThresholdService {
             //集成要素
             List<DeviceElementDTO> integratedElementList = deviceIntegrationMapper.selectIntegratedElement(thresholdQuery.getProjectId(),
                     headerData.getMountainId(), status, deviceId);
-            List<String> collect1 = integratedElementList.stream().map(DeviceElementDTO::getIntegrationElement).collect(Collectors.toList());
-            if (!CollectionUtils.isEmpty(collect1)) {
+            List<String> collect1 = integratedElementList.stream().map(DeviceElementDTO::getIntegrationElement).filter(s -> s != null).collect(Collectors.toList());
+            if (!CollectionUtils.isEmpty(collect1) && collect1.size() > 0) {
                 itemNameList.addAll(collect1);
             }
             dto.setItemName(JSONObject.toJSONString(itemNameList));

+ 0 - 29
slope-modules/slope-detection/src/main/resources/bootstrap-xcq.yml

@@ -1,29 +0,0 @@
-spring:
-  cloud:
-    nacos:
-      discovery:
-        # 服务注册地址
-        server-addr: @nacos.server@
-        # 命名空间
-        namespace: @nacos.namespace@
-        # 共享配置
-        group: sckw-service-platform
-      config:
-        # 配置中心地址
-        server-addr: @nacos.server@
-        # 命名空间
-        namespace: @nacos.namespace@
-        # 共享配置
-        group: sckw-service-platform
-        # 配置文件格式
-        file-extension: yaml
-        shared-configs:
-          - data-id: sckw-common.yml
-            group: sckw-common
-            refresh: true
-
-        #可以读多个配置文件  需要在同一个命名空间下面可以是不同的组
-        extension-configs:
-          - dataId: sckw-common.yml
-            group: sckw-service-platform
-            refresh: true

+ 144 - 66
slope-modules/slope-detection/src/main/resources/mapper/mysql/KwsAlarmMapper.xml

@@ -16,8 +16,8 @@
         <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
         <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
         <result column="status" jdbcType="TINYINT" property="status"/>
-        <result column="is_history" jdbcType="TINYINT" property="isHistory" />
-        <result column="del_flag" jdbcType="TINYINT" property="delFlag" />
+        <result column="is_history" jdbcType="TINYINT" property="isHistory"/>
+        <result column="del_flag" jdbcType="TINYINT" property="delFlag"/>
     </resultMap>
     <sql id="Base_Column_List">
         <!--@mbg.generated-->
@@ -32,7 +32,9 @@
         project_id,
         update_time,
         device_id,
-        trigger_times,is_history,del_flag
+        trigger_times,
+        is_history,
+        del_flag
     </sql>
     <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
         <!--@mbg.generated-->
@@ -44,7 +46,9 @@
 
     <select id="selectByDevicesId" parameterType="java.lang.String" resultType="java.util.Map">
         <!--@mbg.generated-->
-        select count(d.id) as count,a.device_id,type from kws_alarm as a inner join kws_alarm_detail as d on a.id=d.alarm_id
+        select count(d.id) as count,a.device_id,type
+        from kws_alarm as a inner join kws_alarm_detail as d
+        on a.id=d.alarm_id
         where 1 = 1
         <if test="devicesId != null and devicesId.size() > 0">
             AND device_id IN
@@ -194,42 +198,42 @@
         <!--@mbg.generated-->
         update kws_alarm
         set pid           = #{pid,jdbcType=BIGINT},
-        title         = #{title,jdbcType=VARCHAR},
-        val           = #{val,jdbcType=VARCHAR},
-        content       = #{content,jdbcType=VARCHAR},
-        `level`       = #{level,jdbcType=INTEGER},
-        `type`        = #{type,jdbcType=INTEGER},
-        lat           = #{lat,jdbcType=VARCHAR},
-        lng           = #{lng,jdbcType=VARCHAR},
-        alt           = #{alt,jdbcType=VARCHAR},
-        create_time   = #{createTime,jdbcType=TIMESTAMP},
-        trigger_times = #{triggerTimes,jdbcType=INTEGER},
-        `status`      = #{status,jdbcType=TINYINT}
+            title         = #{title,jdbcType=VARCHAR},
+            val           = #{val,jdbcType=VARCHAR},
+            content       = #{content,jdbcType=VARCHAR},
+            `level`       = #{level,jdbcType=INTEGER},
+            `type`        = #{type,jdbcType=INTEGER},
+            lat           = #{lat,jdbcType=VARCHAR},
+            lng           = #{lng,jdbcType=VARCHAR},
+            alt           = #{alt,jdbcType=VARCHAR},
+            create_time   = #{createTime,jdbcType=TIMESTAMP},
+            trigger_times = #{triggerTimes,jdbcType=INTEGER},
+            `status`      = #{status,jdbcType=TINYINT}
         where id = #{id,jdbcType=BIGINT}
     </update>
 
     <select id="getDataAlarmToDay" resultType="java.util.Map">
         SELECT DATE_FORMAT(h.h, '%Y-%m-%d %H:00:00') AS dateTime, COUNT(t.id) AS number
         FROM (SELECT #{startTime} + INTERVAL n HOUR AS h
-        FROM (
-        SELECT 0 AS n
-        UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5
-        UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9 UNION ALL SELECT 10
-        UNION ALL SELECT 11 UNION ALL SELECT 12 UNION ALL SELECT 13 UNION ALL SELECT 14 UNION ALL SELECT 15
-        UNION ALL SELECT 16 UNION ALL SELECT 17 UNION ALL SELECT 18 UNION ALL SELECT 19 UNION ALL SELECT 20
-        UNION ALL SELECT 21 UNION ALL SELECT 22 UNION ALL SELECT 23
-        ) hours) h
-        LEFT JOIN
+              FROM (
+                  SELECT 0 AS n
+                  UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5
+                  UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9 UNION ALL SELECT 10
+                  UNION ALL SELECT 11 UNION ALL SELECT 12 UNION ALL SELECT 13 UNION ALL SELECT 14 UNION ALL SELECT 15
+                  UNION ALL SELECT 16 UNION ALL SELECT 17 UNION ALL SELECT 18 UNION ALL SELECT 19 UNION ALL SELECT 20
+                  UNION ALL SELECT 21 UNION ALL SELECT 22 UNION ALL SELECT 23
+                  ) hours) h
+            LEFT JOIN
         (SELECT a.id,
-        a.create_time,
-        b.project_id  as projectId,
-        b.company_id  as companyId,
-        b.mountain_id as mountainId
-        FROM kws_alarm_detail a
-        LEFT JOIN kws_alarm b ON a.alarm_id = b.id and a.del_flag = 0
+                a.create_time,
+                b.project_id  as projectId,
+                b.company_id  as companyId,
+                b.mountain_id as mountainId
+         FROM kws_alarm_detail a
+                  LEFT JOIN kws_alarm b ON a.alarm_id = b.id and a.del_flag = 0
         <where>
             <if test="type != null and type != ''">
-                and b.type =#{type}
+                and b.type = #{type}
             </if>
             <if test="mountainId != null and mountainId != ''">
                 and b.mountain_id = #{mountainId}
@@ -241,7 +245,7 @@
         ) t
         ON DATE_FORMAT(t.create_time, '%Y-%m-%d %H') = DATE_FORMAT(h.h, '%Y-%m-%d %H')
         WHERE h.h BETWEEN #{startTime}
-        AND #{endTime}
+                  AND #{endTime}
         GROUP BY dateTime
         ORDER BY dateTime ASC;
     </select>
@@ -249,39 +253,39 @@
     <select id="getDataAlarmToWeek" resultType="java.util.Map">
         SELECT a.date as dateTime, COALESCE(b.number, 0) as number
         from (select date_add(#{startTime}, interval row1 DAY) date
-        from
-        (
-        SELECT @row := @row + 1 as row1 FROM
-        (select 0 union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union
-        all select 6 union all select 7 union all select 8 union all select 9) t, (select 0 union all select 1 union all
-        select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union
-        all select 8 union all select 9) t2, (select 0 union all select 1 union all select 2 union all select 3 union
-        all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) t3, (select 0 union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union
-        all select 6 union all select 7 union all select 8 union all select 9) t4, (SELECT @row := -1) r
-        ) se
-        where date_add(#{startTime}
-        , interval row1 DAY) &lt;= #{endTime}) a
-        LEFT JOIN
+              from
+                  (
+                  SELECT @row := @row + 1 as row1 FROM
+                  (select 0 union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union
+                  all select 6 union all select 7 union all select 8 union all select 9) t, (select 0 union all select 1 union all
+                  select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union
+                  all select 8 union all select 9) t2, (select 0 union all select 1 union all select 2 union all select 3 union
+                  all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) t3, (select 0 union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union
+                  all select 6 union all select 7 union all select 8 union all select 9) t4, (SELECT @row := -1) r
+                  ) se
+              where date_add(#{startTime}
+                  , interval row1 DAY) &lt;= #{endTime}) a
+            LEFT JOIN
         (SELECT count(b.id)   as                       number,
-        DATE_FORMAT(b.create_time, '%Y-%m-%d') date_time,
-        a.project_id  as                       projectId,
-        a.company_id  as                       companyId,
-        a.mountain_id as                       mountainId
-        FROM kws_alarm a
-        LEFT JOIN
-        kws_alarm_detail b on a.id = b.alarm_id and b.del_flag = 0
+                DATE_FORMAT(b.create_time, '%Y-%m-%d') date_time,
+                a.project_id  as                       projectId,
+                a.company_id  as                       companyId,
+                a.mountain_id as                       mountainId
+         FROM kws_alarm a
+                  LEFT JOIN
+              kws_alarm_detail b on a.id = b.alarm_id and b.del_flag = 0
         <where>
             <if test="type != null and type != ''">
-                and a.type =#{type}
+                and a.type = #{type}
             </if>
             <if test="mountainId != null and mountainId != ''">
-                and a.mountain_id=#{mountainId}
+                and a.mountain_id = #{mountainId}
             </if>
             <if test="projectId != null and projectId != ''">
-                and a.project_id=#{projectId}
+                and a.project_id = #{projectId}
             </if>
             <if test="level != null and level != ''">
-                and a.level=#{level}
+                and a.level = #{level}
             </if>
         </where>
         GROUP BY DATE_FORMAT(b.create_time, '%Y-%m-%d')) b ON a.date = b.date_time
@@ -289,19 +293,19 @@
 
     <select id="getDataAlarmToYear" resultType="java.util.Map">
         SELECT a.dateTime            AS dateTime,
-        COALESCE(b.number, 0) AS number
+               COALESCE(b.number, 0) AS number
         FROM (SELECT DATE_FORMAT(DATE_ADD(#{startTime}, INTERVAL ROW1 MONTH ), '%Y-%m') dateTime
-        FROM (SELECT @ROW := @ROW + 1 AS row1
-        FROM
-        (select 0 union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) t, (select 0 union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) t2, (select 0 union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) t3, (select 0 union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) t4, ( SELECT @ROW := - 1 ) r) se
-        WHERE date_add(#{startTime}, INTERVAL row1 MONTH ) &lt;= #{endTime}) a
-        LEFT JOIN (SELECT count(b.id) AS                      number,
-        DATE_FORMAT(b.create_time, '%Y-%m') dateTime
-        FROM kws_alarm a
-        LEFT JOIN kws_alarm_detail b ON a.id = b.alarm_id and b.del_flag = 0
+              FROM (SELECT @ROW := @ROW + 1 AS row1
+                    FROM
+                        (select 0 union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) t, (select 0 union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) t2, (select 0 union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) t3, (select 0 union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) t4, ( SELECT @ROW := - 1 ) r) se
+              WHERE date_add(#{startTime}, INTERVAL row1 MONTH ) &lt;= #{endTime}) a
+            LEFT JOIN (SELECT count(b.id) AS                      number,
+                              DATE_FORMAT(b.create_time, '%Y-%m') dateTime
+                       FROM kws_alarm a
+                                LEFT JOIN kws_alarm_detail b ON a.id = b.alarm_id and b.del_flag = 0
         <where>
             <if test="type != null and type != ''">
-                and a.type =#{type}
+                and a.type = #{type}
             </if>
             <if test="mountainId != null and mountainId != ''">
                 and a.mountain_id = #{mountainId}
@@ -348,6 +352,80 @@
     </select>
 
     <select id="selectDetailCount" resultType="int">
+    </select>
+
+    <select id="selectListByQuery" resultMap="BaseResultMap">
+        select
+        <include refid="Base_Column_List">
+        </include>
+        from kws_alarm
+        <where>
+            del_flag = 0
+            <if test="mountainId != null and mountainId != ''">
+                and mountain_id = #{mountainId}
+            </if>
+            <if test="query.projectId != null and query.projectId != ''">
+                and project_id = #{query.projectId}
+            </if>
+            <if test="query.alarmInfo != null and query.alarmInfo != ''">
+                and title = #{query.alarmInfo}
+            </if>
+            <if test="query.status != null and query.status != ''">
+                and status = #{query.status}
+            </if>
+            <if test="query.status != null and query.status != ''">
+                and is_history = #{query.status}
+            </if>
+            <if test="query.alarmLevel != null and query.alarmLevel != ''">
+                and level = #{query.alarmLevel}
+            </if>
+            <if test="query.deviceName != null and query.deviceName != ''">
+                and device_id in
+                    (SELECT id FROM kws_device WHERE del_flag = 0 and name like concat('%', #{query.deviceName}, '%'))
+            </if>
+        </where>
+    </select>
 
+    <select id="selectExportListByQuery" resultMap="BaseResultMap">
+        select
+        <include refid="Base_Column_List">
+        </include>
+        from kws_alarm
+        <where>
+            del_flag = 0
+            <if test="idsList != null and idsList.size() > 0">
+                and id in
+                <foreach collection="idsList" item="item" open="(" close=")" separator=",">
+                    #{item}
+                </foreach>
+            </if>
+            <if test="mountainId != null and mountainId != ''">
+                and mountain_id = #{mountainId}
+            </if>
+            <if test="query.projectId != null and query.projectId != ''">
+                and project_id = #{query.projectId}
+            </if>
+            <if test="query.alarmInfo != null and query.alarmInfo != ''">
+                and title = #{query.alarmInfo}
+            </if>
+            <if test="query.status != null and query.status != ''">
+                and status = #{query.status}
+            </if>
+            <if test="query.status != null and query.status != ''">
+                and is_history = #{query.status}
+            </if>
+            <if test="query.alarmLevel != null and query.alarmLevel != ''">
+                and level = #{query.alarmLevel}
+            </if>
+            <if test="query.deviceName != null and query.deviceName != ''">
+                and device_id in
+                    (SELECT id
+                     FROM kws_device
+                     WHERE del_flag = 0
+                       and name like concat('%'
+                         , #{query.deviceName}
+                         , '%'))
+            </if>
+        </where>
     </select>
 </mapper>