|
|
@@ -1,210 +1,344 @@
|
|
|
<?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.sckw.slope.detection.dao.mysql.KwsAlarmMapper">
|
|
|
- <resultMap id="BaseResultMap" type="com.sckw.slope.detection.model.dos.mysql.KwsAlarm">
|
|
|
- <!--@mbg.generated-->
|
|
|
- <!--@Table kws_alarm-->
|
|
|
- <id column="id" jdbcType="BIGINT" property="id" />
|
|
|
- <result column="title" jdbcType="VARCHAR" property="title" />
|
|
|
- <result column="company_id" jdbcType="VARCHAR" property="companyId" />
|
|
|
- <result column="mountain_id" jdbcType="VARCHAR" property="mountainId" />
|
|
|
- <result column="project_id" jdbcType="VARCHAR" property="projectId" />
|
|
|
- <result column="device_id" jdbcType="VARCHAR" property="deviceId" />
|
|
|
- <result column="level" jdbcType="INTEGER" property="level" />
|
|
|
- <result column="type" jdbcType="INTEGER" property="type" />
|
|
|
- <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
|
|
|
- <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
|
|
|
- <result column="status" jdbcType="TINYINT" property="status" />
|
|
|
- </resultMap>
|
|
|
- <sql id="Base_Column_List">
|
|
|
- <!--@mbg.generated-->
|
|
|
- id, title,`level`, `type`, create_time,
|
|
|
- `status`,company_id,mountain_id,project_id,update_time,device_id
|
|
|
- </sql>
|
|
|
- <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
|
|
|
- <!--@mbg.generated-->
|
|
|
- select
|
|
|
- <include refid="Base_Column_List" />
|
|
|
- from kws_alarm
|
|
|
- where id = #{id,jdbcType=BIGINT}
|
|
|
- </select>
|
|
|
-
|
|
|
- <select id="selectByDevicesId" parameterType="java.lang.String" resultType="java.util.Map">
|
|
|
- <!--@mbg.generated-->
|
|
|
- select count(id) as count,device_id,type
|
|
|
- from kws_alarm
|
|
|
- where 1 = 1
|
|
|
- <if test="devicesId != null and devicesId.size()>0">
|
|
|
- AND device_id IN
|
|
|
- <foreach collection="devicesId" open="(" close=")" item="item" separator=",">
|
|
|
- #{item}
|
|
|
- </foreach>
|
|
|
- </if>
|
|
|
- group by device_id,type
|
|
|
- </select>
|
|
|
-
|
|
|
- <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
|
|
|
- <!--@mbg.generated-->
|
|
|
- delete from kws_alarm
|
|
|
- where id = #{id,jdbcType=BIGINT}
|
|
|
- </delete>
|
|
|
- <insert id="insert" parameterType="com.sckw.slope.detection.model.dos.mysql.KwsAlarm">
|
|
|
- <!--@mbg.generated-->
|
|
|
- insert into kws_alarm (id, pid, title,
|
|
|
- val, content, `level`,
|
|
|
- `type`, lat, lng, alt,
|
|
|
- create_time, trigger_times, `status`
|
|
|
- )
|
|
|
- values (#{id,jdbcType=BIGINT}, #{pid,jdbcType=BIGINT}, #{title,jdbcType=VARCHAR},
|
|
|
- #{val,jdbcType=VARCHAR}, #{content,jdbcType=VARCHAR}, #{level,jdbcType=INTEGER},
|
|
|
- #{type,jdbcType=INTEGER}, #{lat,jdbcType=VARCHAR}, #{lng,jdbcType=VARCHAR}, #{alt,jdbcType=VARCHAR},
|
|
|
- #{createTime,jdbcType=TIMESTAMP}, #{triggerTimes,jdbcType=INTEGER}, #{status,jdbcType=TINYINT}
|
|
|
- )
|
|
|
- </insert>
|
|
|
- <insert id="insertSelective" parameterType="com.sckw.slope.detection.model.dos.mysql.KwsAlarm">
|
|
|
- <!--@mbg.generated-->
|
|
|
- insert into kws_alarm
|
|
|
- <trim prefix="(" suffix=")" suffixOverrides=",">
|
|
|
- <if test="id != null">
|
|
|
+ <resultMap id="BaseResultMap" type="com.sckw.slope.detection.model.dos.mysql.KwsAlarm">
|
|
|
+ <!--@mbg.generated-->
|
|
|
+ <!--@Table kws_alarm-->
|
|
|
+ <id column="id" jdbcType="BIGINT" property="id"/>
|
|
|
+ <result column="title" jdbcType="VARCHAR" property="title"/>
|
|
|
+ <result column="company_id" jdbcType="VARCHAR" property="companyId"/>
|
|
|
+ <result column="mountain_id" jdbcType="VARCHAR" property="mountainId"/>
|
|
|
+ <result column="project_id" jdbcType="VARCHAR" property="projectId"/>
|
|
|
+ <result column="device_id" jdbcType="VARCHAR" property="deviceId"/>
|
|
|
+ <result column="level" jdbcType="INTEGER" property="level"/>
|
|
|
+ <result column="type" jdbcType="INTEGER" property="type"/>
|
|
|
+ <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
|
|
|
+ <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
|
|
|
+ <result column="status" jdbcType="TINYINT" property="status"/>
|
|
|
+ </resultMap>
|
|
|
+ <sql id="Base_Column_List">
|
|
|
+ <!--@mbg.generated-->
|
|
|
id,
|
|
|
- </if>
|
|
|
- <if test="pid != null">
|
|
|
- pid,
|
|
|
- </if>
|
|
|
- <if test="title != null">
|
|
|
title,
|
|
|
- </if>
|
|
|
- <if test="val != null">
|
|
|
- val,
|
|
|
- </if>
|
|
|
- <if test="content != null">
|
|
|
- content,
|
|
|
- </if>
|
|
|
- <if test="level != null">
|
|
|
`level`,
|
|
|
- </if>
|
|
|
- <if test="type != null">
|
|
|
`type`,
|
|
|
- </if>
|
|
|
- <if test="lat != null">
|
|
|
- lat,
|
|
|
- </if>
|
|
|
- <if test="lng != null">
|
|
|
- lng,
|
|
|
- </if>
|
|
|
- <if test="alt != null">
|
|
|
- alt,
|
|
|
- </if>
|
|
|
- <if test="createTime != null">
|
|
|
create_time,
|
|
|
- </if>
|
|
|
- <if test="triggerTimes != null">
|
|
|
- trigger_times,
|
|
|
- </if>
|
|
|
- <if test="status != null">
|
|
|
`status`,
|
|
|
- </if>
|
|
|
- </trim>
|
|
|
- <trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
|
- <if test="id != null">
|
|
|
- #{id,jdbcType=BIGINT},
|
|
|
- </if>
|
|
|
- <if test="pid != null">
|
|
|
- #{pid,jdbcType=BIGINT},
|
|
|
- </if>
|
|
|
- <if test="title != null">
|
|
|
- #{title,jdbcType=VARCHAR},
|
|
|
- </if>
|
|
|
- <if test="val != null">
|
|
|
- #{val,jdbcType=VARCHAR},
|
|
|
- </if>
|
|
|
- <if test="content != null">
|
|
|
- #{content,jdbcType=VARCHAR},
|
|
|
- </if>
|
|
|
- <if test="level != null">
|
|
|
- #{level,jdbcType=INTEGER},
|
|
|
- </if>
|
|
|
- <if test="type != null">
|
|
|
- #{type,jdbcType=INTEGER},
|
|
|
- </if>
|
|
|
- <if test="lat != null">
|
|
|
- #{lat,jdbcType=VARCHAR},
|
|
|
- </if>
|
|
|
- <if test="lng != null">
|
|
|
- #{lng,jdbcType=VARCHAR},
|
|
|
- </if>
|
|
|
- <if test="alt != null">
|
|
|
- #{alt,jdbcType=VARCHAR},
|
|
|
- </if>
|
|
|
- <if test="createTime != null">
|
|
|
- #{createTime,jdbcType=TIMESTAMP},
|
|
|
- </if>
|
|
|
- <if test="triggerTimes != null">
|
|
|
- #{triggerTimes,jdbcType=INTEGER},
|
|
|
- </if>
|
|
|
- <if test="status != null">
|
|
|
- #{status,jdbcType=TINYINT},
|
|
|
- </if>
|
|
|
- </trim>
|
|
|
- </insert>
|
|
|
- <update id="updateByPrimaryKeySelective" parameterType="com.sckw.slope.detection.model.dos.mysql.KwsAlarm">
|
|
|
- <!--@mbg.generated-->
|
|
|
- update kws_alarm
|
|
|
- <set>
|
|
|
- <if test="pid != null">
|
|
|
- pid = #{pid,jdbcType=BIGINT},
|
|
|
- </if>
|
|
|
- <if test="title != null">
|
|
|
- title = #{title,jdbcType=VARCHAR},
|
|
|
- </if>
|
|
|
- <if test="val != null">
|
|
|
- val = #{val,jdbcType=VARCHAR},
|
|
|
- </if>
|
|
|
- <if test="content != null">
|
|
|
- content = #{content,jdbcType=VARCHAR},
|
|
|
- </if>
|
|
|
- <if test="level != null">
|
|
|
- `level` = #{level,jdbcType=INTEGER},
|
|
|
- </if>
|
|
|
- <if test="type != null">
|
|
|
- `type` = #{type,jdbcType=INTEGER},
|
|
|
- </if>
|
|
|
- <if test="lat != null">
|
|
|
- lat = #{lat,jdbcType=VARCHAR},
|
|
|
- </if>
|
|
|
- <if test="lng != null">
|
|
|
- lng = #{lng,jdbcType=VARCHAR},
|
|
|
- </if>
|
|
|
- <if test="alt != null">
|
|
|
- alt = #{alt,jdbcType=VARCHAR},
|
|
|
- </if>
|
|
|
- <if test="createTime != null">
|
|
|
- create_time = #{createTime,jdbcType=TIMESTAMP},
|
|
|
- </if>
|
|
|
- <if test="triggerTimes != null">
|
|
|
+ company_id,
|
|
|
+ mountain_id,
|
|
|
+ project_id,
|
|
|
+ update_time,
|
|
|
+ device_id
|
|
|
+ </sql>
|
|
|
+ <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
|
|
|
+ <!--@mbg.generated-->
|
|
|
+ select
|
|
|
+ <include refid="Base_Column_List"/>
|
|
|
+ from kws_alarm
|
|
|
+ where id = #{id,jdbcType=BIGINT}
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="selectByDevicesId" parameterType="java.lang.String" resultType="java.util.Map">
|
|
|
+ <!--@mbg.generated-->
|
|
|
+ select count(id) as count,device_id,type
|
|
|
+ from kws_alarm
|
|
|
+ where 1 = 1
|
|
|
+ <if test="devicesId != null and devicesId.size() > 0">
|
|
|
+ AND device_id IN
|
|
|
+ <foreach collection="devicesId" open="(" close=")" item="item" separator=",">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ group by device_id, type
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
|
|
|
+ <!--@mbg.generated-->
|
|
|
+ delete
|
|
|
+ from kws_alarm
|
|
|
+ where id = #{id,jdbcType=BIGINT}
|
|
|
+ </delete>
|
|
|
+ <insert id="insertSelective" parameterType="com.sckw.slope.detection.model.dos.mysql.KwsAlarm">
|
|
|
+ <!--@mbg.generated-->
|
|
|
+ insert into kws_alarm
|
|
|
+ <trim prefix="(" suffix=")" suffixOverrides=",">
|
|
|
+ <if test="id != null">
|
|
|
+ id,
|
|
|
+ </if>
|
|
|
+ <if test="pid != null">
|
|
|
+ pid,
|
|
|
+ </if>
|
|
|
+ <if test="title != null">
|
|
|
+ title,
|
|
|
+ </if>
|
|
|
+ <if test="val != null">
|
|
|
+ val,
|
|
|
+ </if>
|
|
|
+ <if test="content != null">
|
|
|
+ content,
|
|
|
+ </if>
|
|
|
+ <if test="level != null">
|
|
|
+ `level`,
|
|
|
+ </if>
|
|
|
+ <if test="type != null">
|
|
|
+ `type`,
|
|
|
+ </if>
|
|
|
+ <if test="lat != null">
|
|
|
+ lat,
|
|
|
+ </if>
|
|
|
+ <if test="lng != null">
|
|
|
+ lng,
|
|
|
+ </if>
|
|
|
+ <if test="alt != null">
|
|
|
+ alt,
|
|
|
+ </if>
|
|
|
+ <if test="createTime != null">
|
|
|
+ create_time,
|
|
|
+ </if>
|
|
|
+ <if test="triggerTimes != null">
|
|
|
+ trigger_times,
|
|
|
+ </if>
|
|
|
+ <if test="status != null">
|
|
|
+ `status`,
|
|
|
+ </if>
|
|
|
+ </trim>
|
|
|
+ <trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
|
+ <if test="id != null">
|
|
|
+ #{id,jdbcType=BIGINT},
|
|
|
+ </if>
|
|
|
+ <if test="pid != null">
|
|
|
+ #{pid,jdbcType=BIGINT},
|
|
|
+ </if>
|
|
|
+ <if test="title != null">
|
|
|
+ #{title,jdbcType=VARCHAR},
|
|
|
+ </if>
|
|
|
+ <if test="val != null">
|
|
|
+ #{val,jdbcType=VARCHAR},
|
|
|
+ </if>
|
|
|
+ <if test="content != null">
|
|
|
+ #{content,jdbcType=VARCHAR},
|
|
|
+ </if>
|
|
|
+ <if test="level != null">
|
|
|
+ #{level,jdbcType=INTEGER},
|
|
|
+ </if>
|
|
|
+ <if test="type != null">
|
|
|
+ #{type,jdbcType=INTEGER},
|
|
|
+ </if>
|
|
|
+ <if test="lat != null">
|
|
|
+ #{lat,jdbcType=VARCHAR},
|
|
|
+ </if>
|
|
|
+ <if test="lng != null">
|
|
|
+ #{lng,jdbcType=VARCHAR},
|
|
|
+ </if>
|
|
|
+ <if test="alt != null">
|
|
|
+ #{alt,jdbcType=VARCHAR},
|
|
|
+ </if>
|
|
|
+ <if test="createTime != null">
|
|
|
+ #{createTime,jdbcType=TIMESTAMP},
|
|
|
+ </if>
|
|
|
+ <if test="triggerTimes != null">
|
|
|
+ #{triggerTimes,jdbcType=INTEGER},
|
|
|
+ </if>
|
|
|
+ <if test="status != null">
|
|
|
+ #{status,jdbcType=TINYINT},
|
|
|
+ </if>
|
|
|
+ </trim>
|
|
|
+ </insert>
|
|
|
+ <update id="updateByPrimaryKeySelective" parameterType="com.sckw.slope.detection.model.dos.mysql.KwsAlarm">
|
|
|
+ <!--@mbg.generated-->
|
|
|
+ update kws_alarm
|
|
|
+ <set>
|
|
|
+ <if test="pid != null">
|
|
|
+ pid = #{pid,jdbcType=BIGINT},
|
|
|
+ </if>
|
|
|
+ <if test="title != null">
|
|
|
+ title = #{title,jdbcType=VARCHAR},
|
|
|
+ </if>
|
|
|
+ <if test="val != null">
|
|
|
+ val = #{val,jdbcType=VARCHAR},
|
|
|
+ </if>
|
|
|
+ <if test="content != null">
|
|
|
+ content = #{content,jdbcType=VARCHAR},
|
|
|
+ </if>
|
|
|
+ <if test="level != null">
|
|
|
+ `level` = #{level,jdbcType=INTEGER},
|
|
|
+ </if>
|
|
|
+ <if test="type != null">
|
|
|
+ `type` = #{type,jdbcType=INTEGER},
|
|
|
+ </if>
|
|
|
+ <if test="lat != null">
|
|
|
+ lat = #{lat,jdbcType=VARCHAR},
|
|
|
+ </if>
|
|
|
+ <if test="lng != null">
|
|
|
+ lng = #{lng,jdbcType=VARCHAR},
|
|
|
+ </if>
|
|
|
+ <if test="alt != null">
|
|
|
+ alt = #{alt,jdbcType=VARCHAR},
|
|
|
+ </if>
|
|
|
+ <if test="createTime != null">
|
|
|
+ create_time = #{createTime,jdbcType=TIMESTAMP},
|
|
|
+ </if>
|
|
|
+ <if test="triggerTimes != null">
|
|
|
+ trigger_times = #{triggerTimes,jdbcType=INTEGER},
|
|
|
+ </if>
|
|
|
+ <if test="status != null">
|
|
|
+ `status` = #{status,jdbcType=TINYINT},
|
|
|
+ </if>
|
|
|
+ </set>
|
|
|
+ where id = #{id,jdbcType=BIGINT}
|
|
|
+ </update>
|
|
|
+ <update id="updateByPrimaryKey" parameterType="com.sckw.slope.detection.model.dos.mysql.KwsAlarm">
|
|
|
+ <!--@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},
|
|
|
- </if>
|
|
|
- <if test="status != null">
|
|
|
- `status` = #{status,jdbcType=TINYINT},
|
|
|
- </if>
|
|
|
- </set>
|
|
|
- where id = #{id,jdbcType=BIGINT}
|
|
|
- </update>
|
|
|
- <update id="updateByPrimaryKey" parameterType="com.sckw.slope.detection.model.dos.mysql.KwsAlarm">
|
|
|
- <!--@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}
|
|
|
- where id = #{id,jdbcType=BIGINT}
|
|
|
- </update>
|
|
|
+ `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
|
|
|
+ (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
|
|
|
+ <where>
|
|
|
+ <if test="type != null and type != ''">
|
|
|
+ and b.type =#{type}
|
|
|
+ </if>
|
|
|
+ <if test="mountainId != null and mountainId != ''">
|
|
|
+ and b.mountain_id = #{mountainId}
|
|
|
+ </if>
|
|
|
+ <if test="level != null and level != ''">
|
|
|
+ and a.level = #{level}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ ) 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}
|
|
|
+ GROUP BY dateTime
|
|
|
+ ORDER BY dateTime ASC;
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <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) <= #{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
|
|
|
+ <where>
|
|
|
+ <if test="type != null and type != ''">
|
|
|
+ and a.type =#{type}
|
|
|
+ </if>
|
|
|
+ <if test="mountainId != null and mountainId != ''">
|
|
|
+ and a.mountain_id=#{mountainId}
|
|
|
+ </if>
|
|
|
+ <if test="projectId != null and projectId != ''">
|
|
|
+ and a.project_id=#{projectId}
|
|
|
+ </if>
|
|
|
+ <if test="level != null and level != ''">
|
|
|
+ and a.level=#{level}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ GROUP BY DATE_FORMAT(b.create_time, '%Y-%m-%d')) b ON a.date = b.date_time
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="getDataAlarmToYear" resultType="java.util.Map">
|
|
|
+ SELECT a.dateTime AS dateTime,
|
|
|
+ COALESCE(b.number, 0) AS num
|
|
|
+ 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 ) <= #{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
|
|
|
+ <where>
|
|
|
+ <if test="type != null and type != ''">
|
|
|
+ and a.type =#{type}
|
|
|
+ </if>
|
|
|
+ <if test="mountainId != null and mountainId != ''">
|
|
|
+ and a.mountain_id = #{mountainId}
|
|
|
+ </if>
|
|
|
+ <if test="projectId != null and projectId != ''">
|
|
|
+ and a.project_id = #{projectId}
|
|
|
+ </if>
|
|
|
+ <if test="level != null and level != ''">
|
|
|
+ and a.level = #{level}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ GROUP BY DATE_FORMAT(b.create_time, '%Y-%m')) b ON a.dateTime = b.dateTime
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="getProjectAlarmList" resultType="java.util.Map">
|
|
|
+ SELECT
|
|
|
+ project_id as projectId,COUNT(DISTINCT a.id) as alarmTotal
|
|
|
+ FROM
|
|
|
+ kws_alarm a
|
|
|
+ LEFT JOIN kws_alarm_detail b ON a.id = b.alarm_id
|
|
|
+ <where>
|
|
|
+ <if test="type != null and type != ''">
|
|
|
+ and a.type =#{type}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ GROUP BY a.project_id
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="selectDetailList" resultType="com.sckw.slope.detection.model.vo.AlarmLogThresholdVO">
|
|
|
+ SELECT a.id AS id,
|
|
|
+ b.project_id AS projectId,
|
|
|
+ b.mountain_id AS mountainId,
|
|
|
+ b.title AS title,
|
|
|
+ a.val AS val,
|
|
|
+ b.`level` AS LEVEL,
|
|
|
+ a.create_time AS createTime
|
|
|
+ FROM kws_alarm_detail a
|
|
|
+ LEFT JOIN kws_alarm b ON a.alarm_id = b.id
|
|
|
+ WHERE a.mountain_id = b.mountain_id
|
|
|
+ and b.`status` = 0
|
|
|
+ ORDER BY a.create_time DESC
|
|
|
+ </select>
|
|
|
</mapper>
|