|
@@ -40,16 +40,16 @@
|
|
|
|
|
|
|
|
<select id="selectByDevicesId" parameterType="java.lang.String" resultType="java.util.Map">
|
|
<select id="selectByDevicesId" parameterType="java.lang.String" resultType="java.util.Map">
|
|
|
<!--@mbg.generated-->
|
|
<!--@mbg.generated-->
|
|
|
- select count(id) as count,pid,type
|
|
|
|
|
|
|
+ select count(id) as count,device_id,type
|
|
|
from kws_alarm
|
|
from kws_alarm
|
|
|
where 1 = 1
|
|
where 1 = 1
|
|
|
<if test="devicesId != null and devicesId.size() > 0">
|
|
<if test="devicesId != null and devicesId.size() > 0">
|
|
|
- AND pid IN
|
|
|
|
|
|
|
+ AND device_id IN
|
|
|
<foreach collection="devicesId" open="(" close=")" item="item" separator=",">
|
|
<foreach collection="devicesId" open="(" close=")" item="item" separator=",">
|
|
|
#{item}
|
|
#{item}
|
|
|
</foreach>
|
|
</foreach>
|
|
|
</if>
|
|
</if>
|
|
|
- group by pid, type
|
|
|
|
|
|
|
+ group by device_id, type
|
|
|
</select>
|
|
</select>
|
|
|
|
|
|
|
|
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
|
|
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
|
|
@@ -191,39 +191,39 @@
|
|
|
<!--@mbg.generated-->
|
|
<!--@mbg.generated-->
|
|
|
update kws_alarm
|
|
update kws_alarm
|
|
|
set pid = #{pid,jdbcType=BIGINT},
|
|
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}
|
|
where id = #{id,jdbcType=BIGINT}
|
|
|
</update>
|
|
</update>
|
|
|
|
|
|
|
|
<select id="getDataAlarmToDay" resultType="java.util.Map">
|
|
<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
|
|
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 #{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,
|
|
(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
|
|
|
|
|
|
|
+ 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>
|
|
<where>
|
|
|
<if test="type != null and type != ''">
|
|
<if test="type != null and type != ''">
|
|
|
and b.type =#{type}
|
|
and b.type =#{type}
|
|
@@ -238,7 +238,7 @@
|
|
|
) t
|
|
) t
|
|
|
ON DATE_FORMAT(t.create_time, '%Y-%m-%d %H') = DATE_FORMAT(h.h, '%Y-%m-%d %H')
|
|
ON DATE_FORMAT(t.create_time, '%Y-%m-%d %H') = DATE_FORMAT(h.h, '%Y-%m-%d %H')
|
|
|
WHERE h.h BETWEEN #{startTime}
|
|
WHERE h.h BETWEEN #{startTime}
|
|
|
- AND #{endTime}
|
|
|
|
|
|
|
+ AND #{endTime}
|
|
|
GROUP BY dateTime
|
|
GROUP BY dateTime
|
|
|
ORDER BY dateTime ASC;
|
|
ORDER BY dateTime ASC;
|
|
|
</select>
|
|
</select>
|
|
@@ -246,27 +246,27 @@
|
|
|
<select id="getDataAlarmToWeek" resultType="java.util.Map">
|
|
<select id="getDataAlarmToWeek" resultType="java.util.Map">
|
|
|
SELECT a.date as dateTime, COALESCE(b.number, 0) as number
|
|
SELECT a.date as dateTime, COALESCE(b.number, 0) as number
|
|
|
from (select date_add(#{startTime}, interval row1 DAY) date
|
|
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
|
|
|
|
|
|
|
+ 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,
|
|
(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
|
|
|
|
|
|
|
+ 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>
|
|
<where>
|
|
|
<if test="type != null and type != ''">
|
|
<if test="type != null and type != ''">
|
|
|
and a.type =#{type}
|
|
and a.type =#{type}
|
|
@@ -286,16 +286,16 @@
|
|
|
|
|
|
|
|
<select id="getDataAlarmToYear" resultType="java.util.Map">
|
|
<select id="getDataAlarmToYear" resultType="java.util.Map">
|
|
|
SELECT a.dateTime AS dateTime,
|
|
SELECT a.dateTime AS dateTime,
|
|
|
- COALESCE(b.number, 0) AS num
|
|
|
|
|
|
|
+ COALESCE(b.number, 0) AS num
|
|
|
FROM (SELECT DATE_FORMAT(DATE_ADD(#{startTime}, INTERVAL ROW1 MONTH ), '%Y-%m') dateTime
|
|
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
|
|
|
|
|
|
|
+ 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>
|
|
<where>
|
|
|
<if test="type != null and type != ''">
|
|
<if test="type != null and type != ''">
|
|
|
and a.type =#{type}
|
|
and a.type =#{type}
|
|
@@ -315,15 +315,30 @@
|
|
|
|
|
|
|
|
<select id="getProjectAlarmList" resultType="java.util.Map">
|
|
<select id="getProjectAlarmList" resultType="java.util.Map">
|
|
|
SELECT
|
|
SELECT
|
|
|
- project_id as projectId,COUNT(DISTINCT a.id) as alarmTotal
|
|
|
|
|
|
|
+ project_id as projectId,COUNT(DISTINCT a.id) as alarmTotal
|
|
|
FROM
|
|
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>
|
|
|
|
|
|
|
+ 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
|
|
GROUP BY a.project_id
|
|
|
</select>
|
|
</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>
|
|
</mapper>
|