123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- <?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.gyee.wisdom.alarm.schedule.mapper.AlarmCountMapper">
- <resultMap type="com.gyee.wisdom.alarm.schedule.entity.AlarmCount" id="myAlarmCount">
- <result property="id" column="id"/>
- <result property="alarmDate" column="alarmDate"/>
- <result property="snapId" column="snapId"/>
- <result property="count" column="count"/>
- <result property="time" column="time"/>
- <result property="alertValue" column="alertValue"/>
- <result property="windturbineId" column="windturbineId"/>
- </resultMap>
- <insert id="singleInsert" >
- insert into alarmcount (id, alarmdate, snapid, count)
- values
- (#{item.id}, cast(#{item.alarmDate} as timestamp), #{item.snapId}, #{item.count})
- </insert>
- <insert id="batchInsert" parameterType="java.util.List" useGeneratedKeys="false">
- insert into alarmcount ( ID, alarmdate, snapid, count,time )
- <foreach collection="list" item="item" index="index" separator="union all" >
- ( select
- #{item.id}, cast(#{item.alarmDate} as timestamp), #{item.snapId}, #{item.count} ,#{item.time}
- )
- </foreach>
- </insert>
- <select id="selectAlarmHistoryBySnapid" parameterType="java.util.Map" resultType="com.gyee.wisdom.alarm.schedule.entity.AlarmHistory" >
- select * from ${alarmhistory} where snapid = #{snapid}
- and alerttime >= #{startdate,jdbcType=DATE} and alerttime < #{enddate,jdbcType=DATE} order by alerttime asc
- </select>
- <select id="statAlarmCount1" parameterType="java.util.Map" resultType="com.gyee.wisdom.alarm.schedule.entity.AlarmStat1" >
- select t.*, s.stationid, s.windturbineid, s.alerttext from (
- select snapid, sum(count) as count,sum(time) time from alarmcount a
- left join alarmsnap ss on a.snapid = ss.id
- where ss.stationid = #{stationid} and ss.windturbineid is not null
- and alarmdate >= #{startdate,jdbcType=DATE} and alarmdate < #{enddate,jdbcType=DATE}
- group by snapid ) t
- left join alarmsnap s on t.snapid = s.id
- order by s.windturbineid
- </select>
- <select id="statAlarmCount5" parameterType="java.util.Map" resultType="com.gyee.wisdom.alarm.schedule.entity.AlarmStat1" >
- select * from alarmcount a
- LEFT JOIN alarmsnap s on a.snapid = s.id
- <where>
- 1=1
- <if test="startdate !=null and enddate !=null">
- and a.alarmdate >= #{startdate,jdbcType=DATE} and a.alarmdate <= #{enddate,jdbcType=DATE}
- </if>
- <if test="stationid !=null and stationid !=''">
- and s.stationid=#{stationid}
- </if>
- <if test="windturbineid !=null and windturbineid !=''">
- and s.windturbineid=#{windturbineid}
- </if>
- </where>
- </select>
- <select id="statAlarmCount" parameterType="java.util.Map" resultType="com.gyee.wisdom.alarm.schedule.entity.AlarmStat" >
- select t.snapid, t.count as sum, t.times as times, s.windturbineid as wtnum, s.alerttext as text from (
- select snapid, sum(count) as count, sum(time) as times from alarmcount a
- left join alarmsnap ss on a.snapid = ss.id
- where ss.stationid = #{stationid} and ss.windturbineid is not null
- and alarmdate >= #{startdate,jdbcType=DATE} and alarmdate <= #{enddate,jdbcType=DATE}
- group by snapid ) t
- left join alarmsnap s on t.snapid = s.id
- order by s.windturbineid
- </select>
- <select id="statAlarmCount3" parameterType="java.util.Map" resultType="com.gyee.wisdom.alarm.schedule.entity.AlarmStat" >
- select t.snapid, t.count as sum, t.times as times, s.windturbineid as wtnum, s.alerttext as text from (
- select snapid, sum(count) as count, sum(time) as times from alarmcount a
- left join alarmsnap ss on a.snapid = ss.id
- <where>
- 1=1
- <if test="startdate !=null and enddate !=null">
- and a.alarmdate >= #{startdate,jdbcType=DATE} and a.alarmdate <= #{enddate,jdbcType=DATE}
- </if>
- <if test="stationid !=null and stationid !=''">
- and ss.stationid=#{stationid}
- </if>
- <if test="windturbineid !=null and windturbineid !=''">
- and ss.windturbineid=#{windturbineid}
- </if>
- </where>
- group by snapid ) t
- left join alarmsnap s on t.snapid = s.id
- order by s.windturbineid
- </select>
- <select id="statAlarmCountByName" parameterType="java.util.Map" resultType="com.gyee.wisdom.alarm.schedule.entity.AlarmStat" >
- select t.count as sum, s.windturbineid as wtnum, s.alerttext as text from (
- select snapid, sum(count) as count from alarmcount a
- left join alarmsnap ss on a.snapid = ss.id
- where ss.alerttext=#{name} and ss.stationid = #{stationid} and ss.windturbineid is not null
- and alarmdate >= #{startdate,jdbcType=DATE} and alarmdate <= #{enddate,jdbcType=DATE}
- group by snapid ) t
- left join alarmsnap s on t.snapid = s.id
- order by s.windturbineid
- </select>
- <select id="selectAlertRuleNames" resultType="com.gyee.wisdom.alarm.schedule.model.CodeValue" >
- select name as code, description as value from alertrule2 group by name, description
- </select>
- <select id="statAlarmCount2" resultType="com.gyee.wisdom.alarm.schedule.entity.AlarmStat1">
- select t.*, s.stationid, s.windturbineid, s.alerttext from (
- select snapid, sum(count) as count,sum(time) time from alarmcount a
- left join alarmsnap ss on a.snapid = ss.id
- where
- ss.windturbineid is not null
- and a.alarmdate >= #{currentDate,jdbcType=DATE}
- <if test="stationid !=null and stationid !=''">
- and ss.stationid = #{stationid}
- </if>
- group by snapid ) t
- left join alarmsnap s on t.snapid = s.id
- order by s.windturbineid
- </select>
- <select id="getAlarmCountInfo" parameterType="java.util.Map" resultType="com.gyee.wisdom.alarm.schedule.entity.AlarmCountInfo">
- SELECT
- a.id, a.alarmdate,a.snapid,a.count, a.time,
- s.ALERTTEXT, s.WINDTURBINEID, s.RANK,
- r.id as alertruleid, r.relatedParts, r.PROJECT
- FROM
- alarmcount a
- LEFT JOIN alarmsnap s ON a.snapid = s.id
- LEFT JOIN alertrule2 r ON s.ALERTVALUE = r.ednaValue
- WHERE
- a.alarmdate = #{currentDate}
- AND s.windturbineid = #{windturbineid}
- </select>
- <select id="getAlarmCountBySnapIdList" parameterType="java.util.Map" resultMap="myAlarmCount">
- SELECT
- a.id as id, a.alarmdate as alarmDate,a.snapid as snapId,a.count as count, a.time as time, s.alertvalue as alertValue, s.windturbineid as windturbineId
- FROM
- alarmcount a
- LEFT JOIN alarmsnap s ON a.snapid = s.id
- WHERE
- 1=1
- <if test="startTime !=null and endTime !=null">
- and a.alarmdate >= #{startTime,jdbcType=DATE} and a.alarmdate <#{endTime,jdbcType=DATE}
- </if>
- <if test="snapIdList !=null and snapIdList.size > 0">
- and a.snapid in
- <foreach collection="snapIdList" item="snapId" index="index" open="(" close=")" separator=",">
- #{snapId}
- </foreach>
- </if>
- </select>
- </mapper>
|