<?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.tievd.jyz.mapper.OilEventMapper">
|
|
<select id="monthlyAlarmCount" parameterType="map" resultType="int">
|
select
|
count(1)
|
from
|
t_oil_event toe
|
where
|
toe.org_code like concat(#{orgCode}, '%')
|
and date_format(toe.event_time, '%Y-%m') = #{date}
|
</select>
|
|
<select id="alarmStat" parameterType="map" resultType="com.tievd.jyz.entity.vo.AlarmOverviewVO">
|
select
|
count(toe.id) alarmCount,
|
count(toe.audit_time) dealedAlarmCount,
|
count(if(toe.audit_result = 1, 1, null)) confirmedAlarmCount
|
from
|
t_oil_event toe
|
where
|
toe.org_code like concat(#{orgCode}, '%')
|
and date_format(toe.event_time, '%Y-%m-%d') = #{date}
|
</select>
|
|
<select id="alarmStatRange" parameterType="map" resultType="com.tievd.jyz.dto.AlarmStatDTO">
|
select
|
count(toe.id) alarmCount,
|
count(if(toe.audit_result = 1, 1, null)) confirmedAlarmCount,
|
a.date
|
from
|
(
|
select
|
date_format(date_add(#{endDay}, interval -t.help_topic_id day), '%Y-%m-%d') as 'date'
|
from
|
mysql.help_topic t
|
where t.help_topic_id <![CDATA[ < ]]> #{intervalDay}
|
) as a
|
left join t_oil_event toe on toe.event_day = a.date
|
and toe.org_code like concat(#{orgCode}, '%')
|
group by a.date
|
order by a.date asc
|
</select>
|
|
<select id="regionAlarmStat" parameterType="map" resultType="com.tievd.jyz.dto.AlarmStatDTO">
|
select
|
sum(b.alarmCount) alarmCount,
|
sum(b.confirmedAlarmCount) confirmedAlarmCount,
|
sum(b.dealedAlarmCount) dealedAlarmCount,
|
departName,
|
orgCode
|
from
|
(
|
select
|
count(toe.id) alarmCount,
|
count(if(toe.audit_result != 0, 1, null)) dealedAlarmCount,
|
count(if(toe.audit_result = 1, 1, null)) confirmedAlarmCount,
|
sd.depart_name departName,
|
sd.org_code orgCode
|
from
|
sys_depart sd
|
left join t_oil_event toe on
|
sd.org_code = toe.org_code
|
and toe.event_day = #{date}
|
where
|
sd.org_category = 3
|
and sd.org_code like concat(#{orgCode}, '%')
|
group by sd.org_code
|
union all
|
select
|
count(toe.id) alarmCount,
|
count(if(toe.audit_result != 0, 1, null)) dealedAlarmCount,
|
count(if(toe.audit_result = 1, 1, null)) confirmedAlarmCount,
|
sd.depart_name departName,
|
sd.org_code orgCode
|
from
|
sys_depart sd
|
left join t_oilout_event toe on
|
sd.org_code = toe.org_code
|
and toe.event_day = #{date}
|
and toe.event_type = 2
|
where
|
sd.org_category = 3
|
and sd.org_code like concat(#{orgCode}, '%')
|
group by sd.org_code
|
) b
|
group by orgCode
|
order by alarmCount desc, confirmedAlarmCount desc
|
limit #{limit}
|
</select>
|
|
<select id="alarmTypeStatByDay" parameterType="map" resultType="com.tievd.jyz.dto.AlarmTypeStatDTO">
|
select
|
toe.algorithm_name,
|
count(toe.id) alarmCount
|
from
|
t_oil_event toe
|
where
|
toe.org_code like concat(#{orgCode},'%')
|
and toe.event_day = #{date}
|
group by toe.algorithm_code
|
union all
|
select
|
toe.algorithm_name,
|
count(toe.id) alarmCount
|
from
|
t_oilout_event toe
|
where
|
toe.org_code like concat(#{orgCode},'%')
|
and toe.event_day = #{date}
|
and toe.event_type = 2
|
group by toe.algorithm_code
|
limit 6
|
</select>
|
|
<select id="alarmTypeStatByMonth" parameterType="map" resultType="com.tievd.jyz.dto.AlarmTypeStatDTO">
|
select
|
toe.algorithm_name,
|
count(toe.id) alarmCount
|
from
|
t_oil_event toe
|
where
|
toe.org_code like concat(#{orgCode},'%')
|
and date_format(toe.event_day, '%Y-%m') = #{date}
|
group by toe.algorithm_code
|
union all
|
select
|
toe.algorithm_name,
|
count(toe.id) alarmCount
|
from
|
t_oilout_event toe
|
where
|
toe.org_code like concat(#{orgCode},'%')
|
and date_format(toe.event_day, '%Y-%m') = #{date}
|
and toe.event_type = 2
|
group by toe.algorithm_code
|
limit 6
|
</select>
|
|
<select id="getLatestAlarm" parameterType="map" resultType="com.tievd.jyz.entity.vo.AlarmEventVO">
|
select
|
*
|
from
|
(
|
select
|
toe.org_name departName,
|
toe.camera_name cameraName,
|
toe.event_time alarmTime,
|
'异常事件' eventType,
|
toe.algorithm_name algorithmName
|
from
|
t_oil_event toe
|
where
|
toe.org_code like concat(#{orgCode},'%')
|
and toe.event_day = #{date}
|
union all
|
select
|
toe.org_name departName,
|
toe.camera_name cameraName,
|
toe.event_time alarmTime,
|
'异常告警' eventType,
|
toe.algorithm_name algorithmName
|
from
|
t_oilout_event toe
|
where
|
toe.org_code like concat(#{orgCode}, '%')
|
and toe.event_type = 2
|
and toe.event_day = #{date}
|
) a
|
order by alarmTime desc
|
limit #{limit}
|
</select>
|
|
<select id="alarmTrendStatRange" parameterType="map" resultType="com.tievd.jyz.dto.AlarmStatDTO">
|
select
|
count(toe.id) oilEventAlarmCount,
|
a.date
|
from
|
(
|
select
|
date_format(date_add(#{endDay}, interval -t.help_topic_id day), '%Y-%m-%d') as 'date'
|
from
|
mysql.help_topic t
|
where
|
t.help_topic_id <![CDATA[ < ]]> #{intervalDay}
|
) as a
|
left join t_oil_event toe on
|
toe.event_day = a.date
|
and toe.org_code like concat(#{orgCode}, '%')
|
group by a.date
|
order by a.date asc
|
</select>
|
|
<select id="getAlarmRankingByDay" parameterType="map" resultType="com.tievd.jyz.entity.vo.OrgAlarmCountVO">
|
select
|
cameraCode,
|
cameraName,
|
alarmCount
|
from
|
(
|
select
|
tc.code cameraCode,
|
tc.name cameraName,
|
count(toe.id) alarmCount
|
from
|
t_camera tc
|
left join t_oil_event toe on
|
toe.camera_code = tc.code
|
where
|
toe.event_day =
|
#{date} and toe.org_code like concat(#{orgCode}, '%') group by tc.code
|
union all
|
select
|
tc.code cameraCode,
|
tc.name cameraName,
|
count(toe.id) alarmCount
|
from
|
t_camera tc
|
left join t_oilout_event toe on
|
toe.camera_code = tc.code
|
where
|
toe.event_day =
|
#{date} and toe.event_type = 2 and toe.org_code like concat(#{orgCode}, '%') group by tc.code
|
) a
|
order by alarmCount desc
|
limit #{limit}
|
</select>
|
|
<select id="getAlarmRankingByMonth" parameterType="map" resultType="com.tievd.jyz.entity.vo.OrgAlarmCountVO">
|
select
|
cameraCode,
|
cameraName,
|
alarmCount
|
from
|
(
|
select
|
tc.code cameraCode,
|
tc.name cameraName,
|
count(toe.id) alarmCount
|
from
|
t_camera tc
|
left join t_oil_event toe on
|
toe.camera_code = tc.code
|
where
|
date_format(toe.event_day, '%Y-%m') = #{date}
|
and toe.org_code like concat(#{orgCode}, '%')
|
group by tc.code
|
union all
|
select
|
tc.code cameraCode,
|
tc.name cameraName,
|
count(toe.id) alarmCount
|
from t_camera tc
|
left join t_oilout_event toe on
|
toe.camera_code = tc.code
|
where
|
date_format(toe.event_day, '%Y-%m') = #{date}
|
and toe.event_type = 2
|
and toe.org_code like concat(#{orgCode}, '%')
|
group by tc.code
|
) a
|
order by alarmCount desc
|
limit #{limit}
|
</select>
|
|
<select id="getPartirionAlarmStat" parameterType="map" resultType="com.tievd.jyz.entity.vo.PartitionAlarmStatVO">
|
select
|
toe.event_address partitionName,
|
count(toe.id) alarmCount,
|
count(if(toe.audit_result = 1, 1, null)) confirmedAlarmCount
|
from
|
t_oil_event toe
|
where
|
toe.org_code like concat(#{orgCode}, '%')
|
and toe.event_day = #{date}
|
group by toe.event_address
|
union all
|
select
|
1 partitionName,
|
count(toe.id) alarmCount,
|
count(if(toe.audit_result = 1, 1, null)) confirmedAlarmCount
|
from
|
t_oilout_event toe
|
where
|
toe.org_code like concat(#{orgCode}, '%')
|
and toe.event_day = #{date}
|
and toe.event_type = 2
|
</select>
|
|
<select id="eventMergeList" parameterType="map" resultType="com.tievd.jyz.entity.vo.MergeEventVo">
|
select
|
id, event_time, algorithm_code, algorithm_name, camera_code, camera_name, device_id, device_name, org_code, org_name, img_uid, img_path, video_path, audit_user, audit_result, audit_comment, audit_time, create_time,
|
1 type,
|
event_address eventAddress,
|
null eventPhrase
|
from t_oil_event
|
where DATE(event_time) = CURRENT_DATE and img_path is not null and video_path is not null
|
<if test="current != null"> and create_time > #{current}</if>
|
<if test="cameraCode != null and cameraCode !=''"> and camera_code = #{cameraCode}</if>
|
union all
|
select
|
id, event_time, algorithm_code, algorithm_name, camera_code, camera_name, device_id, device_name, org_code, org_name, img_uid, img_path, video_path, audit_user, audit_result, audit_comment, audit_time, create_time,
|
2 type,
|
null eventAddress,
|
event_phrase eventPhrase
|
from t_oilout_event
|
where DATE(event_time) = CURRENT_DATE and event_type=2
|
<if test="current != null"> and create_time > #{current}</if>
|
<if test="cameraCode != null and cameraCode !=''"> and camera_code = #{cameraCode}</if>
|
ORDER BY event_time desc
|
<if test="limit != null">limit #{limit}</if>
|
</select>
|
</mapper>
|