<?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="org.springblade.jfpt.alarm.mapper.AlarmMapper">
|
|
<!-- 通用查询映射结果 -->
|
<resultMap id="alarmResultMap" type="org.springblade.jfpt.alarm.vo.AlarmVO">
|
<id column="id" property="id"/>
|
<result column="alarmType" property="alarmType"/>
|
<result column="alarmPeople" property="alarmPeople"/>
|
<result column="alarmTime" property="alarmTime"/>
|
<result column="galarmPeople" property="galarmPeople"/>
|
<result column="sex" property="sex"/>
|
<result column="phoneNumber" property="phoneNumber"/>
|
<result column="place" property="place"/>
|
<result column="content" property="content"/>
|
<result column="waringType" property="waringType"/>
|
<result column="deviceNumber" property="deviceNumber"/>
|
<result column="region" property="region"/>
|
<result column="district" property="district"/>
|
<result column="alarmId" property="alarmId"/>
|
<result column="level" property="level"/>
|
<!--<result column="coordinate" property="coordinate"/>-->
|
<result column="jd" property="jd"/>
|
<result column="wd" property="wd"/>
|
<result column="jtype" property="jtype"/>
|
<result column="rname" property="rname"/>
|
<result column="serialNumber" property="serialNumber"/>
|
<result column="stype" property="stype"/>
|
<result column="channelNumber" property="channelNumber"/>
|
<result column="czTime" property="czTime"/>
|
<result column="bz" property="bz"/>
|
<result column="name" property="name"/>
|
<result column="cid" property="cid"/>
|
<result column="vaddress" property="vaddress"/>
|
<result column="aaddress" property="aaddress"/>
|
</resultMap>
|
|
|
<select id="selectAlarmPage" resultMap="alarmResultMap">
|
select
|
a.id,a.alarmType,a.alarmPeople,a.alarmTime,a.galarmPeople,a.sex,a.phoneNumber,a.place,a.content,a.waringType,a.bz,
|
a.deviceNumber,a.region,a.district,a.vaddress,a.aaddress,
|
a.alarmId,a.LEVEL,e.jd,e.wd,a.jtype,a.rname,a.jjTime,a.province,a.city,a.cid,
|
e.serialNumber,e.oneContacts,e.ThreeContacts,e.twoContacts,e.onePhone,e.twoPhone,e.ThreePhone,
|
e.stype,
|
e.oneId,
|
e.twoId,
|
e.threeId,
|
e.deptId,
|
e.channelNumber from sys_alarm a
|
LEFT JOIN sys_equipment e on e.deviceNumber=a.deviceNumber
|
where 1=1
|
<if test="alarm.jtype!=null">
|
and a.jtype like concat('%',#{alarm.jtype},'%')
|
</if>
|
<if test="alarm.deviceNumber!=null">
|
and a.deviceNumber like concat('%',#{alarm.deviceNumber},'%')
|
</if>
|
<if test="alarm.galarmPeople!=null">
|
and a.galarmPeople like concat('%',#{alarm.galarmPeople},'%')
|
</if>
|
<if test="alarm.district!=null">
|
and a.district like concat('%',#{alarm.district},'%')
|
</if>
|
<if test="alarm.province!=null">
|
and a.province like concat('%',#{alarm.province},'%')
|
</if>
|
<if test="alarm.city!=null">
|
and a.city like concat('%',#{alarm.city},'%')
|
</if>
|
<if test="alarm.level!=null">
|
and a.level like concat('%',#{alarm.level},'%')
|
</if>
|
<if test="alarm.waringType!=null">
|
and a.waringType like concat('%',#{alarm.waringType},'%')
|
</if>
|
<if test="alarm.beginTime!=null and alarm.beginTime!=''">
|
and a.alarmTime>=#{alarm.beginTime}
|
</if>
|
<if test="alarm.endTime!=null and alarm.endTime!=''">
|
and a.alarmTime<=#{alarm.endTime}
|
</if>
|
<if test="alarm.timeDesc!=null and alarm.timeDesc!=''">
|
<if test="alarm.timeDesc=='30分钟以上'">
|
and czTime-alarmTime>1800
|
</if>
|
<if test="alarm.timeDesc=='10-30分钟'">
|
and czTime-alarmTime>600 and czTime-alarmTime <1800
|
</if>
|
<if test="alarm.timeDesc=='5-10分钟'">
|
and czTime-alarmTime>300 and czTime-alarmTime <600
|
</if>
|
<if test="alarm.timeDesc=='小于5分钟'">
|
and czTime-alarmTime>0 and czTime-alarmTime <300
|
</if>
|
</if>
|
|
and a.waringType IN("紧急求救")
|
|
ORDER BY
|
a.jtype ASC,
|
a.alarmTime DESC
|
</select>
|
|
<select id="listAll" resultMap="alarmResultMap">
|
select a.id,a.alarmType,a.alarmPeople,a.alarmTime,a.galarmPeople,a.sex,a.phoneNumber,a.place,a.content,a.waringType,
|
a.deviceNumber,a.region,a.district, a.alarmId,a.LEVEL,e.jd,e.wd,a.jtype,a.rname,a.jjTime,a.province,a.city,a.cid,a.vaddress
|
from sys_alarm a LEFT JOIN sys_equipment e on e.deviceNumber=a.deviceNumber
|
|
</select>
|
|
<select id="selectList" resultMap="alarmResultMap">
|
SELECT
|
a.id,
|
a.alarmType,
|
a.alarmPeople,
|
a.alarmTime,
|
a.galarmPeople,
|
a.sex,
|
a.phoneNumber,
|
a.place,
|
a.content,
|
a.waringType,
|
a.deviceNumber,
|
a.vaddress,
|
a.region,
|
a.district,
|
a.alarmId,
|
a.czTime,
|
a.bz,
|
a.LEVEL,
|
a.jd,
|
a.wd,
|
a.jtype,
|
a.cid,
|
a.rname,
|
jfpth.blade_region.name as addvnm,
|
e.serialNumber,
|
e.stype,
|
e.channelNumber
|
FROM
|
sys_alarm a LEFT JOIN sys_equipment e on e.deviceNumber=a.deviceNumber LEFT JOIN jfpth.blade_region on
|
jfpth.blade_region.`code`=a.district where 1=1
|
<if test="jtype!=null and jtype!=''">
|
and a.jtype=#{jtype}
|
</if>
|
<if test="district!=null and district!=''">
|
and a.district=#{district}
|
</if>
|
<if test="waringType!=null and waringType!=''">
|
and a.waringType=#{waringType}
|
</if>
|
<if test="beginTime!=null and beginTime!=''">
|
and a.alarmTime>=#{beginTime}
|
</if>
|
<if test="endTime!=null and endTime!=''">
|
and a.alarmTime<=#{endTime}
|
</if>
|
ORDER BY id ASC
|
</select>
|
|
<select id="getLimit" resultMap="alarmResultMap">
|
select a.id,a.alarmType,a.alarmPeople,a.alarmTime,a.galarmPeople,a.sex,a.phoneNumber,a.place,a.content,a.waringType,a.vaddress,
|
a.deviceNumber,a.region,a.district, a.alarmId,a.LEVEL,a.jd,a.wd,a.jtype,a.rname,a.jjTime,a.province,a.city,a.cid from sys_alarm a ORDER BY id DESC LIMIT 1
|
</select>
|
|
<select id="selectInfo" resultMap="alarmResultMap">
|
SELECT
|
a.id,
|
a.alarmType,
|
a.alarmPeople,
|
a.alarmTime,
|
a.galarmPeople,
|
a.sex,
|
a.phoneNumber,
|
a.place,
|
a.czTime,
|
a.bz,
|
a.content,
|
a.waringType,
|
a.deviceNumber,
|
a.region,
|
a.district,
|
a.alarmId,
|
a.vaddress,
|
a.rname,
|
a.LEVEL,
|
a.cid,
|
a.jd,
|
a.wd,
|
a.jtype,
|
d.addvnm
|
FROM
|
sys_alarm a LEFT JOIN sys_district d on d.addvcds=a.district where 1=1
|
<if test="id!=null and id!=''">
|
and a.id=#{id}
|
</if>
|
</select>
|
|
<!--实时提醒-->
|
<select id="selecttx" resultMap="alarmResultMap">
|
SELECT
|
a.id,
|
a.alarmType,
|
a.alarmPeople,
|
a.alarmTime,
|
a.galarmPeople,
|
a.sex,
|
a.phoneNumber,
|
a.place,
|
a.content,
|
a.waringType,
|
a.deviceNumber,
|
a.region,
|
a.district,
|
a.province,
|
a.city,
|
a.alarmId,
|
a.rname,
|
a.LEVEL,
|
a.cid,
|
a.jd,
|
a.wd,
|
a.jtype,
|
d.addvnm,
|
e.serialNumber,
|
e.stype,
|
e.channelNumber,
|
e.oneContacts,
|
e.ThreeContacts,
|
e.twoContacts,
|
e.onePhone,
|
e.twoPhone,
|
e.ThreePhone
|
FROM
|
sys_alarm a LEFT JOIN sys_district d on d.addvcds=a.district LEFT JOIN sys_equipment e on
|
e.deviceNumber=a.deviceNumber where 1=1
|
<if test="id!=null and id!=''">
|
and a.id >#{id}
|
</if>
|
</select>
|
|
<delete id="deletejj">
|
delete from sys_alarm where id=#{id}
|
</delete>
|
|
<!--新增-->
|
<insert id="s" parameterType="org.springblade.jfpt.alarm.entity.Alarm" useGeneratedKeys="true" keyProperty="id">
|
INSERT INTO sys_alarm (alarmType,jjTime,alarmPeople,alarmTime,galarmPeople,sex,phoneNumber,place,content,waringType,deviceNumber,
|
region,district,alarmId,level,rname,coordinate,jd,wd,jtype,province,city,cid) VALUES
|
(#{alarmType},#{jjTime},#{alarmPeople},#{alarmTime},#{galarmPeople},#{sex},#{phoneNumber},#{place},#{content},#{waringType},
|
#{deviceNumber},#{region},#{district},#{alarmId},#{level},#{rname},POINT(#{jd},#{wd}),
|
#{jd},#{wd},#{jtype},#{province},#{city},#{cid})
|
</insert>
|
|
<update id="updateOne" parameterType="org.springblade.jfpt.alarm.entity.Alarm">
|
update sys_alarm SET alarmType=#{alarmType},alarmPeople=#{alarmPeople},alarmTime=#{alarmTime},
|
galarmPeople=#{galarmPeople},sex=#{sex},phoneNumber=#{phoneNumber},place=#{place},
|
content=#{content},waringType=#{waringType},deviceNumber=#{deviceNumber},region=#{region},district=#{district},alarmId=#{alarmId},level=#{level},rname=#{rname},jd=#{jd},wd=#{wd},
|
coordinate=POINT(#{jd},#{wd}),jtype=#{jtype},province=#{province},city=#{city},cid=#{cid} where id=#{id}
|
</update>
|
|
|
<select id="selectScount" resultType="java.util.HashMap">
|
SELECT COUNT(*) as cou,waringType FROM `sys_alarm` WHERE alarmTime like concat(concat('%', #{time}), '%') GROUP BY waringType
|
</select>
|
|
|
<select id="selectListSe" resultMap="alarmResultMap">
|
|
SELECT
|
a.id,
|
a.alarmType,
|
a.alarmPeople,
|
a.alarmTime,
|
a.galarmPeople,
|
a.sex,
|
a.phoneNumber,
|
a.place,
|
a.content,
|
a.waringType,
|
a.deviceNumber,
|
a.region,
|
a.district,
|
a.alarmId,
|
a.LEVEL,
|
a.jd,
|
a.cid,
|
a.wd,
|
a.jtype,
|
a.rname,
|
e.serialNumber,
|
e.stype,
|
e.channelNumber,
|
jfpth.blade_region.`name` as addvnm
|
FROM
|
sys_alarm a LEFT JOIN sys_equipment e on e.deviceNumber=a.deviceNumber LEFT JOIN jfpth.blade_region on jfpth.blade_region.`code`=a.district where
|
DATE_FORMAT(alarmTime,'%Y-%m-%d') >=#{beginTime} and DATE_FORMAT(alarmTime,'%Y-%m-%d') <=#{endTime} and a.waringType NOT IN("系统测试","主机重新上电") ORDER BY alarmTime desc
|
</select>
|
|
|
<update id="updateJtype">
|
update sys_alarm SET jtype=#{jtype},bz=#{bz} where id=#{id}
|
</update>
|
|
<update id="updatePoliceStatus">
|
update jfpth.blade_user SET work_status=#{status} where id=#{id}
|
</update>
|
|
<!--查询当天警情总数-->
|
<select id="selectAlarmCount" resultType="java.lang.Integer">
|
SELECT count(*) FROM `sys_alarm`
|
where
|
waringType = '紧急求救'
|
<if test="conditionVo.status==0">
|
and to_days(alarmTime) = to_days(curdate())
|
</if>
|
<if test="conditionVo.startTime!=null and conditionVo.startTime!='' and conditionVo.endTime!=null and conditionVo.endTime!=''">
|
and alarmTime between #{conditionVo.startTime} and #{conditionVo.endTime}
|
</if>
|
</select>
|
|
|
<!--查询警情7天内每天的数据-->
|
<select id="selectAlarmData" resultType="java.lang.Integer">
|
select ifnull(b.count,0) as count from
|
(
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 6 day),'%Y-%m-%d') as click_date
|
union all
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 5 day),'%Y-%m-%d') as click_date
|
union all
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 4 day),'%Y-%m-%d') as click_date
|
union all
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 3 day),'%Y-%m-%d') as click_date
|
union all
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 2 day),'%Y-%m-%d') as click_date
|
union all
|
SELECT DATE_FORMAT(date_sub(curdate(), interval 1 day),'%Y-%m-%d') as click_date
|
union all
|
SELECT DATE_FORMAT(curdate(),'%Y-%m-%d') as click_date
|
) a
|
left join
|
(
|
select DATE_FORMAT(alarmTime,'%Y-%m-%d') as datetime, count(*) as count from sys_alarm
|
where waringType = '紧急求救'
|
group by DATE_FORMAT(alarmTime,'%Y-%m-%d')
|
) b
|
on
|
a.click_date = b.datetime
|
order by a.click_date asc
|
</select>
|
|
<!-- <!–查询本日,本周,本月 主动报警的数量–>-->
|
<!-- <select id="selectAlarmSum" resultType="java.util.HashMap">-->
|
<!-- select sa.alarmType name,IFNULL(sb.count, 0) value from (select alarmType from sys_alarm GROUP BY alarmType) sa-->
|
<!-- left join-->
|
<!-- ( select alarmType,count(*) count from sys_alarm-->
|
<!-- where 1=1-->
|
<!-- <if test="conditionVo.status==0">-->
|
<!-- and to_days(alarmTime) = to_days(now())-->
|
<!-- </if>-->
|
<!-- <if test="conditionVo.status==1">-->
|
<!-- and YEARWEEK(date_format(alarmTime,'%Y-%m-%d'),1) = YEARWEEK(now(),1)-->
|
<!-- </if>-->
|
<!-- <if test="conditionVo.status==2">-->
|
<!-- and date_format(alarmTime,'%Y%m') = date_format(now(),'%Y%m')-->
|
<!-- </if>-->
|
<!-- group by alarmType-->
|
<!-- ) sb-->
|
<!-- on-->
|
<!-- sa.alarmType = sb.alarmType-->
|
<!-- </select>-->
|
|
<!--查询本日,本周,本月 主动报警的数量-->
|
<select id="selectAlarmSum" resultType="java.util.HashMap">
|
select '一键求助' name,ifnull(count(*),0 ) value from sys_alarm
|
where waringType = '紧急求救'
|
<if test="conditionVo.status==0">
|
and to_days(alarmTime) = to_days(now())
|
</if>
|
<if test="conditionVo.status==1">
|
and YEARWEEK(date_format(alarmTime,'%Y-%m-%d'),1) = YEARWEEK(now(),1)
|
</if>
|
<if test="conditionVo.status==2">
|
and date_format(alarmTime,'%Y%m') = date_format(now(),'%Y%m')
|
</if>
|
union all
|
select '电话报警' name,ifnull(count(*),0 ) value from sys_alarm
|
where waringType = '电话报警'
|
<if test="conditionVo.status==0">
|
and to_days(alarmTime) = to_days(now())
|
</if>
|
<if test="conditionVo.status==1">
|
and YEARWEEK(date_format(alarmTime,'%Y-%m-%d'),1) = YEARWEEK(now(),1)
|
</if>
|
<if test="conditionVo.status==2">
|
and date_format(alarmTime,'%Y%m') = date_format(now(),'%Y%m')
|
</if>
|
|
</select>
|
|
<select id="queryPolice" resultType="java.util.HashMap">
|
SELECT * FROM jfpth.blade_user WHERE is_deleted != '1' and role_id ="1372092102682521602"
|
</select>
|
|
|
<select id="queryPoliceTime" resultType="java.util.HashMap">
|
|
SELECT
|
a.alarmPeople,
|
a.alarmId,
|
max( a.jjTime ) AS jjTime
|
FROM
|
sys_alarm a
|
WHERE
|
1 =1
|
|
<if test="policeIdArr!=null and policeIdArr.size>0">
|
and alarmId in
|
<foreach collection="policeIdArr" index="index" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
GROUP BY
|
a.alarmPeople,
|
a.alarmId
|
ORDER BY
|
jjTime
|
LIMIT 1
|
|
</select>
|
|
<select id="queryBa" resultType="java.util.HashMap">
|
SELECT
|
s.id,
|
s.CODE,
|
s.NAME,
|
s.real_name,
|
s.phone,
|
p.jd,
|
p.wd,
|
ST_ASTEXT ( e.coordinate )
|
FROM
|
jfpth.blade_user s
|
LEFT JOIN sys_position p ON p.snumber = s.
|
CODE LEFT JOIN sys_enclosure e ON e.anumber = s.CODE
|
WHERE
|
is_deleted != '1'
|
AND role_id = "1370562810882502657"
|
</select>
|
|
<update id="updateVaddress">
|
update sys_alarm SET vaddress=#{vaddress} where id=#{jid}
|
</update>
|
|
|
<select id="selectEq" resultType="java.util.HashMap">
|
SELECT COUNT(deviceNumber) as cou,deviceNumber FROM `sys_alarm` WHERE alarmTime like concat(concat('%', #{time}), '%') and waringType NOT IN("系统测试","主机重新上电") group by deviceNumber
|
</select>
|
|
<select id="selAlarmTimeCount" resultType="java.lang.Integer">
|
select count(*) from sys_alarm
|
where waringType = '紧急求救'
|
<if test="conditionVo.startTime!=null and conditionVo.startTime!='' and conditionVo.endTime!=null and conditionVo.endTime!=''">
|
and alarmTime between #{conditionVo.startTime} and #{conditionVo.endTime}
|
</if>
|
</select>
|
|
<!--查询当前时间段内一键求助报警的数据集合-->
|
<select id="selectAlarmList" resultType="org.springblade.jfpt.alarm.entity.Alarm">
|
SELECT waringType,alarmTime,alarmId,alarmPeople,jtype,czTime FROM `sys_alarm`
|
where waringType='紧急求救'
|
and alarmTime between #{conditionVo.startTime} and #{conditionVo.endTime}
|
</select>
|
|
<!--统计时间段内一键求助警情数量数据-->
|
<select id="selectAlarmTimeData" resultType="java.lang.Integer">
|
select ifnull(count,0) count from
|
(
|
SELECT @date := DATE_ADD( @date, INTERVAL + 1 DAY ) days FROM
|
(
|
SELECT @date := DATE_ADD( #{conditionVo.startTime}, INTERVAL - 1 DAY ) FROM sys_date
|
) time
|
WHERE to_days( @date ) < to_days( #{conditionVo.endTime} )
|
) a
|
left join
|
(
|
select DATE_FORMAT(alarmTime,'%Y-%m-%d') as datetime, count(*) as count from sys_alarm
|
where waringType = '紧急求救'
|
group by DATE_FORMAT(alarmTime,'%Y-%m-%d')
|
) b
|
on
|
a.days = b.datetime
|
</select>
|
|
|
<!--查询本年所有月份的预警数量-->
|
<select id="queryYearAlarm" resultType="java.util.HashMap">
|
|
<if test="childList!=null and childList.size>0">
|
|
<foreach collection="childList" index="index" item="item" open="" separator="union all" close="">
|
SELECT
|
#{item} as month,count(ce.id) as count
|
FROM
|
sys_alarm as ce
|
WHERE
|
YEAR ( alarmTime ) = date_format(now(),'%Y%')
|
AND MONTH ( alarmTime ) = #{item}
|
|
AND waringType = "紧急求救"
|
AND deviceNumber = #{deviceNumber}
|
|
</foreach>
|
</if>
|
|
</select>
|
|
</mapper>
|