<?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.ruoyi.aibrain.mapper.AiAlarmInfoMapper">
|
|
<resultMap type="AiAlarmInfo" id="AiAlarmInfoResult">
|
<result property="id" column="id" />
|
<result property="cameraId" column="camera_id" />
|
<result property="region" column="region" />
|
<result property="ruleId" column="rule_id" />
|
<result property="content" column="content" />
|
<result property="smallClass" column="small_class" />
|
<result property="video" column="video" />
|
<result property="picture" column="picture" />
|
<result property="alarmTime" column="alarm_time" />
|
<result property="dealWith" column="deal_with" />
|
<result property="dealInfo" column="deal_info" />
|
<result property="result" column="result" />
|
<result property="time" column="time" />
|
<result property="handler" column="handler" />
|
<result property="grade" column="grade" />
|
<result property="linkage" column="linkage" />
|
<result property="cameraName" column="camera_name" />
|
<result property="ruleName" column="rule_name" />
|
<result property="regionName" column="region_name" />
|
</resultMap>
|
|
<sql id="selectAiAlarmInfoVo">
|
SELECT
|
a.id,
|
a.camera_id,
|
c.`name` as camera_name,
|
r.rule_name,
|
a.region,
|
( SELECT d.dict_label FROM sys_dict_data d WHERE d.dict_type = 'sys_mine_region' AND d.dict_value = a.region ) AS region_name,
|
a.rule_id,
|
a.content,
|
a.small_class,
|
a.video,
|
a.picture,
|
a.alarm_time,
|
a.deal_with,
|
a.deal_info,
|
a.result,
|
a.time,
|
a.HANDLER,
|
a.grade,
|
a.linkage
|
FROM
|
ai_alarm_info a LEFT JOIN ai_camera c ON a.camera_id = c.id
|
LEFT JOIN ai_rule r ON a.rule_id = r.id
|
</sql>
|
|
<select id="selectAiAlarmInfoList" parameterType="AiAlarmInfo" resultMap="AiAlarmInfoResult">
|
<include refid="selectAiAlarmInfoVo"/>
|
<where>
|
<if test="cameraId != null "> and a.camera_id = #{cameraId}</if>
|
<if test="region != null and region != ''"> and a.region = #{region}</if>
|
<if test="ruleId != null "> and a.rule_id = #{ruleId}</if>
|
<if test="content != null and content != ''"> and a.content like concat('%', #{content}, '%')</if>
|
<if test="smallClass != null and smallClass != ''"> and a.small_class = #{smallClass}</if>
|
<if test="video != null and video != ''"> and a.video = #{video}</if>
|
<if test="picture != null and picture != ''"> and a.picture = #{picture}</if>
|
<if test="params.beginAlarmTime != null and params.beginAlarmTime != '' and params.endAlarmTime != null and params.endAlarmTime != ''"> and a.alarm_time between #{params.beginAlarmTime} and #{params.endAlarmTime}</if>
|
<if test="dealWith != null and dealWith != ''"> and a.deal_with = #{dealWith}</if>
|
<if test="dealInfo != null and dealInfo != ''"> and a.deal_info = #{dealInfo}</if>
|
<if test="result != null and result != ''"> and result = #{result}</if>
|
<if test="params.beginTime != null and params.beginTime != '' and params.endTime != null and params.endTime != ''"> and a.time between #{params.beginTime} and #{params.endTime}</if>
|
<if test="handler != null and handler != ''"> and a.handler = #{handler}</if>
|
<if test="grade != null and grade != ''"> and a.grade = #{grade}</if>
|
<if test="linkage != null and linkage != ''"> and a.linkage = #{linkage}</if>
|
</where>
|
ORDER BY a.deal_with ASC, a.alarm_time DESC
|
</select>
|
|
<select id="selectAlarmInfoNew" parameterType="AiAlarmInfo" resultMap="AiAlarmInfoResult">
|
<include refid="selectAiAlarmInfoVo"/>
|
WHERE
|
a.deal_with = '0'
|
ORDER BY a.alarm_time DESC
|
LIMIT 10
|
</select>
|
|
<select id="selectAiAlarmInfoById" parameterType="Long" resultMap="AiAlarmInfoResult">
|
<include refid="selectAiAlarmInfoVo"/>
|
where a.id = #{id}
|
</select>
|
|
<select id="countSanWeiAlarm" parameterType="AiAlarmInfo" resultType="Integer">
|
SELECT
|
count(*)
|
FROM
|
ai_alarm_info a
|
WHERE
|
a.small_class IN (
|
SELECT
|
t.alarm_small_type
|
FROM
|
ai_alarm_type t
|
WHERE
|
t.alarm_big_type = '1')
|
<if test="params.beginTime != null and params.endTime != null "> and a.alarm_time between #{params.beginTime} and #{params.endTime}</if>
|
</select>
|
|
<select id="countYinHuanAlarm" parameterType="AiAlarmInfo" resultType="Integer">
|
SELECT
|
count(*)
|
FROM
|
ai_alarm_info a
|
WHERE
|
a.small_class IN (
|
SELECT
|
t.alarm_small_type
|
FROM
|
ai_alarm_type t
|
WHERE
|
t.alarm_big_type = '2')
|
<if test="params.beginTime != null and params.endTime != null "> and a.alarm_time between #{params.beginTime} and #{params.endTime}</if>
|
</select>
|
|
<select id="countAllAlarm" parameterType="AiAlarmInfo" resultType="Integer">
|
SELECT
|
count(*)
|
FROM
|
ai_alarm_info a
|
WHERE
|
a.small_class IN (
|
SELECT
|
t.alarm_small_type
|
FROM
|
ai_alarm_type t
|
WHERE
|
t.alarm_big_type = '3')
|
<if test="params.beginTime != null and params.endTime != null "> and a.alarm_time between #{params.beginTime} and #{params.endTime}</if>
|
</select>
|
|
<select id="countAlarmInYear" parameterType="AiAlarmInfo" resultType="Integer">
|
SELECT
|
count(*)
|
FROM
|
ai_alarm_info a
|
WHERE
|
DATE_FORMAT( a.alarm_time, '%Y' ) = DATE_FORMAT( CURDATE( ) , '%Y' );
|
</select>
|
|
<select id="countAlarmInMonth" parameterType="AiAlarmInfo" resultType="Integer">
|
SELECT
|
count(*)
|
FROM
|
ai_alarm_info a
|
WHERE
|
DATE_FORMAT( a.alarm_time, '%Y%m' ) = DATE_FORMAT( CURDATE( ) , '%Y%m' );
|
</select>
|
|
<select id="countAlarmByTimeAndType" parameterType="AiAlarmInfo" resultType="java.util.HashMap">
|
SELECT
|
DATE_FORMAT( c.alarm_time, '%Y-%m-%d' ) as days,
|
count(*) as count
|
FROM
|
( SELECT * FROM ai_alarm_info WHERE DATE_SUB( CURDATE( ), INTERVAL #{days} DAY ) <![CDATA[ <= ]]> date( alarm_time ) and small_class = #{smallClass} ) c
|
GROUP BY days asc
|
</select>
|
|
<select id="selectCountAlarmByRegion" resultType="java.util.HashMap">
|
SELECT
|
d.dict_label AS label,
|
IFNULL(b.VALUE,0) as value
|
FROM
|
sys_dict_data d
|
LEFT JOIN (
|
SELECT
|
a.region,
|
count( a.region ) AS VALUE
|
FROM
|
ai_alarm_info a
|
WHERE
|
DATE_FORMAT( a.alarm_time, '%Y' ) = DATE_FORMAT( CURDATE( ), '%Y' )
|
GROUP BY
|
a.region
|
) b ON b.region = d.dict_value
|
WHERE
|
d.dict_type = 'sys_mine_region'
|
ORDER BY b.VALUE DESC
|
</select>
|
|
<select id="selectCountAlarmBySmall" resultType="java.util.HashMap">
|
SELECT
|
d.dict_label AS label,
|
IFNULL(b.VALUE,0) as value
|
FROM
|
sys_dict_data d
|
LEFT JOIN (
|
SELECT
|
a.small_class,
|
count( a.small_class ) AS VALUE
|
FROM
|
ai_alarm_info a
|
WHERE
|
DATE_FORMAT( a.alarm_time, '%Y' ) = DATE_FORMAT( CURDATE( ), '%Y' )
|
GROUP BY
|
a.small_class
|
) b ON b.small_class = d.dict_value
|
WHERE
|
d.dict_type = 'sys_alarm_small_type'
|
ORDER BY b.VALUE DESC
|
</select>
|
|
<select id="selectAlarmInfo" parameterType="aiAlarmInfo" resultMap="AiAlarmInfoResult">
|
<include refid="selectAiAlarmInfoVo"/>
|
<where>
|
<if test="cameraId != null "> and a.camera_id = #{cameraId}</if>
|
<if test="region != null and region != ''"> and a.region = #{region}</if>
|
<if test="ruleId != null "> and a.rule_id = #{ruleId}</if>
|
<if test="content != null and content != ''"> and a.content like concat('%', #{content}, '%')</if>
|
<if test="smallClass != null and smallClass != ''"> and a.small_class = #{smallClass}</if>
|
</where>
|
ORDER BY a.alarm_time DESC limit 0,1
|
</select>
|
|
<insert id="insertAiAlarmInfo" parameterType="AiAlarmInfo" useGeneratedKeys="true" keyProperty="id">
|
insert into ai_alarm_info
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="cameraId != null">camera_id,</if>
|
<if test="region != null">region,</if>
|
<if test="ruleId != null">rule_id,</if>
|
<if test="content != null">content,</if>
|
<if test="smallClass != null">small_class,</if>
|
<if test="video != null">video,</if>
|
<if test="picture != null">picture,</if>
|
<if test="alarmTime != null">alarm_time,</if>
|
<if test="dealWith != null">deal_with,</if>
|
<if test="dealInfo != null">deal_info,</if>
|
<if test="result != null">result,</if>
|
<if test="time != null">time,</if>
|
<if test="handler != null">handler,</if>
|
<if test="grade != null">grade,</if>
|
<if test="linkage != null">linkage,</if>
|
</trim>
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<if test="cameraId != null">#{cameraId},</if>
|
<if test="region != null">#{region},</if>
|
<if test="ruleId != null">#{ruleId},</if>
|
<if test="content != null">#{content},</if>
|
<if test="smallClass != null">#{smallClass},</if>
|
<if test="video != null">#{video},</if>
|
<if test="picture != null">#{picture},</if>
|
<if test="alarmTime != null">#{alarmTime},</if>
|
<if test="dealWith != null">#{dealWith},</if>
|
<if test="dealInfo != null">#{dealInfo},</if>
|
<if test="result != null">#{result},</if>
|
<if test="time != null">#{time},</if>
|
<if test="handler != null">#{handler},</if>
|
<if test="grade != null">#{grade},</if>
|
<if test="linkage != null">#{linkage},</if>
|
</trim>
|
</insert>
|
|
<update id="updateAiAlarmInfo" parameterType="AiAlarmInfo">
|
update ai_alarm_info
|
<trim prefix="SET" suffixOverrides=",">
|
<if test="cameraId != null">camera_id = #{cameraId},</if>
|
<if test="region != null">region = #{region},</if>
|
<if test="ruleId != null">rule_id = #{ruleId},</if>
|
<if test="content != null">content = #{content},</if>
|
<if test="smallClass != null">small_class = #{smallClass},</if>
|
<if test="video != null">video = #{video},</if>
|
<if test="picture != null">picture = #{picture},</if>
|
<if test="alarmTime != null">alarm_time = #{alarmTime},</if>
|
<if test="dealWith != null">deal_with = #{dealWith},</if>
|
<if test="dealInfo != null">deal_info = #{dealInfo},</if>
|
<if test="result != null">result = #{result},</if>
|
<if test="time != null">time = #{time},</if>
|
<if test="handler != null">handler = #{handler},</if>
|
<if test="grade != null">grade = #{grade},</if>
|
<if test="linkage != null">linkage = #{linkage},</if>
|
</trim>
|
where id = #{id}
|
</update>
|
|
<delete id="deleteAiAlarmInfoById" parameterType="Long">
|
delete from ai_alarm_info where id = #{id}
|
</delete>
|
|
<delete id="deleteAiAlarmInfoByIds" parameterType="String">
|
delete from ai_alarm_info where id in
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</delete>
|
</mapper>
|