|
@@ -16,8 +16,8 @@
|
|
|
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
|
|
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
|
|
|
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
|
|
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
|
|
|
<result column="status" jdbcType="TINYINT" property="status"/>
|
|
<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>
|
|
</resultMap>
|
|
|
<sql id="Base_Column_List">
|
|
<sql id="Base_Column_List">
|
|
|
<!--@mbg.generated-->
|
|
<!--@mbg.generated-->
|
|
@@ -32,7 +32,9 @@
|
|
|
project_id,
|
|
project_id,
|
|
|
update_time,
|
|
update_time,
|
|
|
device_id,
|
|
device_id,
|
|
|
- trigger_times,is_history,del_flag
|
|
|
|
|
|
|
+ trigger_times,
|
|
|
|
|
+ is_history,
|
|
|
|
|
+ del_flag
|
|
|
</sql>
|
|
</sql>
|
|
|
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
|
|
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
|
|
|
<!--@mbg.generated-->
|
|
<!--@mbg.generated-->
|
|
@@ -44,7 +46,9 @@
|
|
|
|
|
|
|
|
<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(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
|
|
where 1 = 1
|
|
|
<if test="devicesId != null and devicesId.size() > 0">
|
|
<if test="devicesId != null and devicesId.size() > 0">
|
|
|
AND device_id IN
|
|
AND device_id IN
|
|
@@ -194,42 +198,42 @@
|
|
|
<!--@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 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>
|
|
<where>
|
|
|
<if test="type != null and type != ''">
|
|
<if test="type != null and type != ''">
|
|
|
- and b.type =#{type}
|
|
|
|
|
|
|
+ and b.type = #{type}
|
|
|
</if>
|
|
</if>
|
|
|
<if test="mountainId != null and mountainId != ''">
|
|
<if test="mountainId != null and mountainId != ''">
|
|
|
and b.mountain_id = #{mountainId}
|
|
and b.mountain_id = #{mountainId}
|
|
@@ -241,7 +245,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>
|
|
@@ -249,39 +253,39 @@
|
|
|
<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 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>
|
|
<where>
|
|
|
<if test="type != null and type != ''">
|
|
<if test="type != null and type != ''">
|
|
|
- and a.type =#{type}
|
|
|
|
|
|
|
+ and a.type = #{type}
|
|
|
</if>
|
|
</if>
|
|
|
<if test="mountainId != null and mountainId != ''">
|
|
<if test="mountainId != null and mountainId != ''">
|
|
|
- and a.mountain_id=#{mountainId}
|
|
|
|
|
|
|
+ and a.mountain_id = #{mountainId}
|
|
|
</if>
|
|
</if>
|
|
|
<if test="projectId != null and projectId != ''">
|
|
<if test="projectId != null and projectId != ''">
|
|
|
- and a.project_id=#{projectId}
|
|
|
|
|
|
|
+ and a.project_id = #{projectId}
|
|
|
</if>
|
|
</if>
|
|
|
<if test="level != null and level != ''">
|
|
<if test="level != null and level != ''">
|
|
|
- and a.level=#{level}
|
|
|
|
|
|
|
+ and a.level = #{level}
|
|
|
</if>
|
|
</if>
|
|
|
</where>
|
|
</where>
|
|
|
GROUP BY DATE_FORMAT(b.create_time, '%Y-%m-%d')) b ON a.date = b.date_time
|
|
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 id="getDataAlarmToYear" resultType="java.util.Map">
|
|
|
SELECT a.dateTime AS dateTime,
|
|
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 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 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 ) <= #{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>
|
|
<where>
|
|
|
<if test="type != null and type != ''">
|
|
<if test="type != null and type != ''">
|
|
|
- and a.type =#{type}
|
|
|
|
|
|
|
+ and a.type = #{type}
|
|
|
</if>
|
|
</if>
|
|
|
<if test="mountainId != null and mountainId != ''">
|
|
<if test="mountainId != null and mountainId != ''">
|
|
|
and a.mountain_id = #{mountainId}
|
|
and a.mountain_id = #{mountainId}
|
|
@@ -348,6 +352,80 @@
|
|
|
</select>
|
|
</select>
|
|
|
|
|
|
|
|
<select id="selectDetailCount" resultType="int">
|
|
<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>
|
|
</select>
|
|
|
</mapper>
|
|
</mapper>
|