<?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.njcn.mapper.data.EventDetailMapper">


    <select id="queryVoltageCountsByLineIndexs" resultType="Integer">
        SELECT
        count(1)
        FROM
        PQS_EVENTDETAIL
        WHERE
        LINEID IN
        <foreach collection="list" item="item" separator="," open="("
                 close=")">
            #{item}
        </foreach>
        AND TIMEID between #{startTime} and #{endTime}
        AND WaveType=1
    </select>


    <select id="querySubLevel" resultType="simpleValue">
        SELECT
            t1.name name,
            t2.allcount value
        FROM
            pq_substation t1,
            (
                SELECT
                    COUNT (A.lineid) allcount
                FROM
                    pqs_eventdetail A,
                    pq_line b,
                    pq_substation c,
                    PQ_DEVICE d
                WHERE
                    c.sub_index = #{subIndex}
                AND b.sub_index = c.sub_index
                AND A .lineid = b.line_index
                AND b.DEV_INDEX=d.DEV_INDEX
                AND d.DEVMODEL = 1
                AND d.DATATYPE in (0,2)
                and b.line_index in
                <foreach collection="lineIndex" open="(" close=")" separator="," item="lineId">
                    #{lineId}
                </foreach>
                and a.TIMEID between #{startTime}
		            and #{endTime}
            ) t2
        WHERE
            t1.sub_index =#{subIndex}
	</select>

    <select id="queryLineLevel" resultType="simpleValue" databaseId="Oracle">
        select * from
        (
        select
        LINEID name,
        count(1) VALUE
        FROM
        PQS_EVENTDETAIL A
        WHERE
        TIMEID between #{startTime} and #{endTime}
        AND
        LINEID IN
        <foreach collection="lineIndex" item="item" index="index"
                 open="(" separator="," close=")">
            #{item}
        </foreach>
        GROUP BY LINEID
        ORDER BY VALUE DESC)
        WHERE ROWNUM  <![CDATA[ <= ]]>
        30

    </select>
    <select id="queryLineLevel" resultType="simpleValue" databaseId="MariaDB">
        select * from
        (
        select
        LINEID name,
        count(1) VALUE
        FROM
        PQS_EVENTDETAIL A
        WHERE
        TIMEID between #{startTime} and #{endTime}
        AND
        LINEID IN
        <foreach collection="lineIndex" item="item" index="index"
                 open="(" separator="," close=")">
            #{item}
        </foreach>
        GROUP BY LINEID
        ORDER BY VALUE DESC) as t
        limit 30

    </select>


    <select id="queryEventDetail" resultType="StatisticsEventDetail" databaseId="Oracle">
        SELECT
        M .TIMEID,
        M.EVENTDETAIL_INDEX,
        to_char(M .TIMEID,'YYYY-mm-dd
        hh24:mi:ss.')||M.MS time,
        round(M.PERSISTTIME/1000,3) PERSISTTIME,
        round(M.EVENTVALUE*100,2) EVENTVALUE,
        M.EVENTREASON,
        M.EVENTTYPE,
        M.NAME,
        M.LINEID,
        S.DIC_NAME SCALE,
        S1.DIC_NAME LOADTYPE,
        s2.name gdName,
        s3.name subName
        FROM
        (SELECT
        T1.TIMEID,
        T1.EVENTDETAIL_INDEX,
        nvl(substr(10000+T1.MS,-3),T1.MS) MS,
        T1.PERSISTTIME,
        T1.EVENTVALUE,
        T2.DIC_NAME EVENTREASON,
        T3.BACK_UP EVENTTYPE,
        T4. NAME,
        T1.LINEID,
        T4.SCALE,
        T4.SUB_INDEX,
        T4.GD_INDEX,
        T5.LOADTYPE
        FROM
        PQS_EVENTDETAIL T1
        INNER JOIN PQS_DICDATA T2 ON T1.EVENTREASON = T2.DIC_INDEX
        INNER JOIN
        PQS_DICDATA T3 ON T1.EVENTTYPE = T3.DIC_INDEX
        INNER JOIN PQ_LINE T4 ON
        T1.LINEID = T4.LINE_INDEX
        INNER JOIN PQ_LINEDETAIL T5 ON
        T1.LINEID=T5.LINE_INDEX
        WHERE
        T1.LINEID IN
        <foreach collection="list" item="item" index="index" open="("
                 separator="," close=")">
            #{item}
        </foreach>
        AND
        T1.TIMEID BETWEEN #{startTime} AND #{endTime}
        and T1.WaveType &lt;&gt;  5
        )M
        INNER JOIN
        PQS_DICDATA S ON M.SCALE=S.DIC_INDEX
        INNER JOIN PQS_DICDATA
        S1 ON
        M.LOADTYPE=S1.DIC_INDEX
        INNER JOIN PQ_GDINFORMATION S2 ON
        M.gd_index=S2.gd_INDEX
        INNER JOIN PQ_SUBSTATION S3 ON
        M.sub_index=S3.sub_index

    </select>
    <select id="queryEventDetail" resultType="StatisticsEventDetail" databaseId="MariaDB">
        SELECT
        M .TIMEID,
        M.EVENTDETAIL_INDEX,
        CONCAT(date_format(M .TIMEID,'%Y-%m-%d %H:%i:%S.'), M.MS) time,
        round(M.PERSISTTIME/1000,3) PERSISTTIME,
        round(M.EVENTVALUE*100,2) EVENTVALUE,
        M.EVENTREASON,
        M.EVENTTYPE,
        M.NAME,
        M.LINEID,
        S.DIC_NAME SCALE,
        S1.DIC_NAME LOADTYPE,
        s2.name gdName,
        s3.name subName
        FROM
        (SELECT
        T1.TIMEID,
        T1.EVENTDETAIL_INDEX,
        nvl(substr(10000+T1.MS,-3),T1.MS) MS,
        T1.PERSISTTIME,
        T1.EVENTVALUE,
        T2.DIC_NAME EVENTREASON,
        T3.BACK_UP EVENTTYPE,
        T4. NAME,
        T1.LINEID,
        T4.SCALE,
        T4.SUB_INDEX,
        T4.GD_INDEX,
        T5.LOADTYPE
        FROM
        PQS_EVENTDETAIL T1
        INNER JOIN PQS_DICDATA T2 ON T1.EVENTREASON = T2.DIC_INDEX
        INNER JOIN
        PQS_DICDATA T3 ON T1.EVENTTYPE = T3.DIC_INDEX
        INNER JOIN PQ_LINE T4 ON
        T1.LINEID = T4.LINE_INDEX
        INNER JOIN PQ_LINEDETAIL T5 ON
        T1.LINEID=T5.LINE_INDEX
        WHERE
        T1.LINEID IN
        <foreach collection="list" item="item" index="index" open="("
                 separator="," close=")">
            #{item}
        </foreach>
        AND
        T1.TIMEID BETWEEN #{startTime} AND #{endTime}
        and T1.WaveType &lt;&gt;  5
        )M
        INNER JOIN
        PQS_DICDATA S ON M.SCALE=S.DIC_INDEX
        INNER JOIN PQS_DICDATA
        S1 ON
        M.LOADTYPE=S1.DIC_INDEX
        INNER JOIN PQ_GDINFORMATION S2 ON
        M.gd_index=S2.gd_INDEX
        INNER JOIN PQ_SUBSTATION S3 ON
        M.sub_index=S3.sub_index
    </select>


    <select id="queryVoltageList" resultType="eventDetail" databaseId="Oracle">
        SELECT
        M.EVENTDETAIL_INDEX,
        M.LINEID,
        M.WAVETYPE,
        M.fileflag,
        TO_CHAR (
        M.TIMEID,
        'YYYY-mm-dd hh24:mi:ss.'
        ) || M.MS TIME,
        ROUND (M.PERSISTTIME / 1000, 3) PERSISTTIME,
        ROUND(M.EVENTVALUE * 100 ,2) EVENTVALUE,
        M .EVENTREASON,
        M .EVENTTYPE,
        M . NAME lineName,
        M .EVENTASS_INDEX,
        M .severity,
        S. NAME GDNAME,
        S1. NAME SUBNAME,
        S2.DIC_NAME SCALE,
        S3.IP,
        M.DEVTYPE devtype
        FROM
        (
        SELECT
        T1.EVENTDETAIL_INDEX,
        T1.LINEID,
        T1.TIMEID,
        T1.FILEFLAG,
        NVL (
        SUBSTR (10000 + T1.MS ,- 3),
        T1.MS
        ) MS,
        T1.PERSISTTIME,
        T1.severity,
        T1.EVENTVALUE,
        T1.WAVETYPE,
        T2.DIC_NAME EVENTREASON,
        T3.DIC_NAME EVENTTYPE,
        T1.EVENTASS_INDEX,
        T4. NAME,
        T4.GD_INDEX GDINDEX,
        T4.SUB_INDEX SUBINDEX,
        T4. SCALE,
        T4.DEV_INDEX DEVINDEX,
        s5.DIC_NAME DEVTYPE
        FROM
        PQS_EVENTDETAIL T1
        INNER JOIN PQS_DICDATA T2 ON T1.EVENTREASON = T2.DIC_INDEX
        INNER JOIN PQS_DICDATA T3 ON T1.EVENTTYPE = T3.DIC_INDEX
        INNER JOIN PQ_LINE T4 ON T1.LINEID = T4.LINE_INDEX
        INNER JOIN pq_device S4	 ON T4 .dev_index = S4.Dev_index
        INNER JOIN PQS_DICDATA S5	 ON S4.devtype=S5 .DIC_INDEX
        WHERE
        T1.TIMEID
        BETWEEN #{startTime} AND #{endTime}
        and
        T1.LINEID in
        <foreach collection="list" item="item" index="index" open="("
                 separator="," close=")">
            #{item}
        </foreach>
        <if test="minfuzhi !=null and maxfuzhi!=null">
            and T1.EVENTVALUE  between #{minfuzhi} and #{maxfuzhi}
        </if>
        <if test="minfuzhi !=null and maxfuzhi==null">
            and T1.EVENTVALUE > #{minfuzhi}
        </if>
        <if test="minfuzhi ==null and maxfuzhi!=null">
            and T1.EVENTVALUE &lt; #{maxfuzhi}
        </if>

        <if test="mintime !=null and maxtime!=null">
            and T1.PERSISTTIME  between #{mintime} and #{maxtime}
        </if>
        <if test="mintime !=null and maxtime==null">
            and T1.PERSISTTIME > #{mintime}
        </if>
        <if test="mintime ==null and maxtime!=null">
            and T1.PERSISTTIME &lt; #{maxtime}
        </if>

        <if test="minseverity !=null and maxseverity!=null">
            and T1.severity  between #{minseverity} and #{maxseverity}
        </if>
        <if test="minseverity !=null and maxseverity==null">
            and T1.severity > #{minseverity}
        </if>
        <if test="minseverity ==null and maxseverity!=null">
            and T1.severity &lt; #{maxseverity}
        </if>


        <if test="eventType!=null">
            and T1.EVENTTYPE in
            <foreach collection="eventType" item="item" index="index" separator="," open="(" close=")">
                #{item}
            </foreach>
        </if>
        <if test="eventReason!=null">
            and T1.EVENTREASON in
            <foreach collection="eventReason" item="item" index="index" separator="," open="(" close=")">
                #{item}
            </foreach>
        </if>
        <if test="triggerType!=null">
            and T1.WAVETYPE in
            <foreach collection="triggerType" item="item" index="index" separator="," open="(" close=")">
                #{item}
            </foreach>
        </if>
        <if test="fileflag!=null">
            and T1.FILEFLAG = #{fileflag}
        </if>
        ) M
        INNER JOIN PQ_GDINFORMATION S ON M .GDINDEX = S.GD_INDEX
        INNER JOIN PQ_SUBSTATION S1 ON M .SUBINDEX = S1.SUB_INDEX
        INNER JOIN PQS_DICDATA S2 ON M . SCALE = S2.DIC_INDEX
        INNER JOIN pq_device S3 ON M .DEVINDEX = S3.Dev_index
        ORDER BY
        M .TIMEID DESC
    </select>
    <select id="queryVoltageList" resultType="eventDetail" databaseId="MariaDB">
        SELECT
        M .EVENTDETAIL_INDEX,
        M .LINEID,
        M.WAVETYPE,
        m.fileflag,
        CONCAT(date_format(M .TIMEID,'%Y-%m-%d %H:%i:%S.'), M.MS) time,
        round(M
        .PERSISTTIME/1000, 3) PERSISTTIME,
        round(M.EVENTVALUE*100,2) EVENTVALUE,
        M
        .EVENTREASON,
        M .EVENTTYPE,
        M .NAME lineName,
        M.EVENTASS_INDEX,
        M.severity,
        S. NAME GDNAME,
        S1. NAME SUBNAME,
        S2.DIC_NAME SCALE,
        S3.IP,
        M.DEVTYPE devtype
        FROM
        (
        SELECT
        T1.EVENTDETAIL_INDEX,
        T1.LINEID,
        T1.TIMEID,
        T1.FILEFLAG,
        nvl(substr(10000+T1.MS,-3),T1.MS) MS,
        T1.PERSISTTIME,
        T1.severity,
        T1.EVENTVALUE,
        T1.WAVETYPE,
        T2.DIC_NAME EVENTREASON,
        T3.DIC_NAME EVENTTYPE,
        T1.EVENTASS_INDEX,
        T4.NAME,
        T4.GD_INDEX GDINDEX,
        T4.SUB_INDEX SUBINDEX,
        T4.SCALE,
        T4.DEV_INDEX DEVINDEX,
        s5.DIC_NAME DEVTYPE
        FROM
        PQS_EVENTDETAIL T1
        INNER JOIN
        PQS_DICDATA T2 ON T1.EVENTREASON =
        T2.DIC_INDEX
        INNER JOIN PQS_DICDATA
        T3 ON T1.EVENTTYPE = T3.DIC_INDEX
        INNER JOIN PQ_LINE T4 ON T1.LINEID =
        T4.LINE_INDEX
        INNER JOIN pq_device S4	 ON T4 .dev_index = S4.Dev_index
        INNER JOIN PQS_DICDATA S5	 ON S4.devtype=S5 .DIC_INDEX
        WHERE
        T1.TIMEID
        BETWEEN #{startTime} AND #{endTime}
        and
        T1.LINEID in
        <foreach collection="list" item="item" index="index" open="("
                 separator="," close=")">
            #{item}
        </foreach>
        ) M
        INNER JOIN PQ_GDINFORMATION S ON M .GDINDEX = S.GD_INDEX
        INNER JOIN
        PQ_SUBSTATION S1 ON M .SUBINDEX = S1.SUB_INDEX
        INNER JOIN PQS_DICDATA
        S2 ON M . SCALE = S2.DIC_INDEX
        INNER JOIN pq_device S3 ON M . DEVINDEX
        = S3.Dev_index
        ORDER BY
        M .TIMEID DESC
    </select>

    <select id="getCountsByInterval" resultType="Integer" databaseId="Oracle">
        select count(*) from PQS_EVENTDETAIL where to_char(TIMEID,'YYYY-MM') =
        #{interTime} and LINEID in
        <foreach collection="list" item="item" index="index" open="("
                 separator="," close=")">
            #{item}
        </foreach>
        AND WaveType=1
    </select>
    <select id="getCountsByInterval" resultType="Integer" databaseId="MariaDB">
        select count(*) from PQS_EVENTDETAIL where date_format(TIMEID,'%Y-%m') =
        #{interTime} and LINEID in
        <foreach collection="list" item="item" index="index" open="("
                 separator="," close=")">
            #{item}
        </foreach>
        AND
        WaveType=1
    </select>

    <select id="getrunevent" resultType="eventDetail" databaseId="Oracle">
		select * from (select
		pq_line.name
		lineName,pqs_eventdetail.timeid
		timeId,c.dic_name as eventType
		from
		pq_gdinformation,pq_substation,pq_subvoltage,pq_line,pqs_eventdetail,pqs_dicdata
		c
		where
		pq_line.subv_index = pq_subvoltage.subv_index
		and
		pqs_eventdetail.eventass_index is null
        AND
        pqs_eventdetail.LINEID IN
        <foreach collection="lineIndex" item="item" index="index"
                 open="(" separator="," close=")">
            #{item}
        </foreach>
		and
		pq_line.sub_index =
		pq_substation.sub_index and pq_line.gd_index =
		pq_gdinformation.gd_index and pq_line.line_index =
		pqs_eventdetail.lineid
		and pqs_eventdetail.eventtype=c.dic_index
		order
		by pqs_eventdetail.timeid desc)
		where ROWNUM <![CDATA[ <= ]]>10
	</select>
	<select id="getrunevent" resultType="eventDetail" databaseId="MariaDB">
		select * from (select
		pq_line.name
		lineName,pqs_eventdetail.timeid
		timeId,c.dic_name as eventType
		from
		pq_gdinformation,pq_substation,pq_subvoltage,pq_line,pqs_eventdetail,pqs_dicdata
		c
		where
		pq_line.subv_index = pq_subvoltage.subv_index
		and
		pqs_eventdetail.eventass_index is null
		and
		pq_line.sub_index =
		pq_substation.sub_index and pq_line.gd_index =
		pq_gdinformation.gd_index and pq_line.line_index =
		pqs_eventdetail.lineid
		and pqs_eventdetail.eventtype=c.dic_index
		order
		by pqs_eventdetail.timeid desc) as t
		limit 10
	</select>

    <select id="queryDealFlag" resultType="java.lang.Integer"
            parameterType="java.lang.String">
		select dealflag from pqs_eventdetail where
		eventdetail_index = #{indexEvt}
	</select>

    <update id="updateDealFlag">
		update pqs_eventdetail set dealflag = #{code} where
		eventdetail_index = #{indexEvt}
	</update>

    <update id="updateCause">
		update pqs_eventdetail set eventreason = (select
		a.dic_index from pqs_dicdata a,pqs_dictype b where b.dictype_name =
		'暂降原因' and a.dic_type = b.dictype_index and a.triphase = #{code} and
		a.state = 1 and b.state = 1)
		where
		eventdetail_index = #{indexEvt}
	</update>

    <select id="querySagDescriptionbyId" resultType="java.lang.String">
		select
		a.dic_name from pqs_dicdata a,pqs_dictype b where b.dictype_name =
		#{typename} and a.dic_type = b.dictype_index and a.triphase =#{code}
		and a.state = 1 and b.state = 1
	</select>

    <select id="querySagDescriptionbyIndex" resultType="java.lang.String">
		select
		b.dic_name from pqs_dicdata b,pqs_eventdetail
		a where a.eventreason =
		b.dic_index and a.eventdetail_index =
		#{indexEvt}
	</select>

    <update id="updateSagData">
		update pqs_eventdetail
		set eventtype =(select
		a.dic_index from pqs_dicdata a,pqs_dictype b where b.dictype_name =
		'暂降类型' and a.dic_type = b.dictype_index and a.triphase =
		#{sagEvent.sagType} and a.state = 1 and b.state = 1)
		,dqtime =
		#{sagEvent.dqTime},
		num =
		#{sagEvent.number},firsttime =
		#{sagEvent.firstTime},firstms =
		#{sagEvent.firstMs}
		,firsttype = (select
		a.dic_index from pqs_dicdata
		a,pqs_dictype b where b.dictype_name =
		'暂降类型' and a.dic_type =
		b.dictype_index and a.triphase =
		#{sagEvent.firstType} and a.state = 1 and b.state = 1)
		where
		eventdetail_index =
		#{sagEvent.indexEventDetail}
	</update>




    <update id="updateSeverity" >
        update
          PQS_EVENTDETAIL
        set
          Severity = #{severity}
        where
          EVENTDETAIL_INDEX=#{index}
    </update>

    <select id="queryLineEvents" resultType="simpleValue"  databaseId="Oracle">
		select i."LINE_NAME" as name, i."GD_NAME" as gdName, i."SUB_NAME" as subName, h.totalcount value
		  from ((select distinct MainTable.lineid, NVL(SubTable.count, 0) totalcount
		           from pqs_eventdetail MainTable
		           LEFT JOIN (select count(*) count, lineid
		                       from pqs_eventdetail
		                      where  WAVETYPE = 1 and timeid between #{startTime} and #{endTime}
		                      group by lineid
		                      order by lineid) SubTable
		             ON MainTable.lineid = SubTable.lineid) h RIGHT JOIN
		        (select a.line_index line_index, a.name line_name, b.name gd_name, c.name sub_name
		           from pq_line a, pq_gdinformation b,pq_substation c, pq_device e
		          where a.gd_index = b.gd_index
		          	and a.sub_index = c.sub_index
		            and a.dev_index = e.dev_index
		            and e.devmodel = 1
		            and e.datatype in (0, 2)
		            and a.line_index in
			        <foreach collection="list" item="item" separator="," open="("
			                 close=")">
			            #{item}
			        </foreach>
		          ) i ON h.lineid = i.line_index)
		 where h.totalcount > 0  and rownum  &lt; 101
		 order by value desc
    </select>

    <select id="queryLineEvents" resultType="simpleValue"  databaseId="MariaDB">
		select i.LINE_NAME as name, i.GD_NAME as gdName, i.SUB_NAME as subName, h.totalcount value
		  from ((select distinct MainTable.lineid, NVL(SubTable.count, 0) totalcount
		           from pqs_eventdetail MainTable
		           LEFT JOIN (select count(*) count, lineid
		                       from pqs_eventdetail
		                      where  WAVETYPE = 1
		                        and timeid between #{startTime} and #{endTime}
		                      group by lineid
		                      order by lineid) SubTable
		             ON MainTable.lineid = SubTable.lineid) h RIGHT JOIN
		        (select a.line_index line_index, a.name line_name, b.name gd_name, c.name sub_name
		           from pq_line a, pq_gdinformation b,pq_substation c, pq_device e
		          where a.gd_index = b.gd_index
		          	and a.sub_index = c.sub_index
		            and a.dev_index = e.dev_index
		            and e.devmodel = 1
		            and e.datatype in (0, 2)
		            and a.line_index in
			        <foreach collection="list" item="item" separator="," open="("
			                 close=")">
			            #{item}
			        </foreach>
		          ) i ON h.lineid = i.line_index)
		 where h.totalcount > 0
		 order by value desc LIMIT 10
    </select>

    <resultMap type="com.njcn.pojo.commons.EventInfoDetail" id="EventInfoDetailMapperMap"
               autoMapping="true">
        <id property="eventDetailIndex" column="EVENTDETAIL_INDEX"/>
    </resultMap>
    <select id="eventDetailBaseInfoByIndex" resultMap="EventInfoDetailMapperMap">
          SELECT LINE.name lineName,
               gd.name gdName,
               sub.name bdzName,
               dev.name devName,
               dic.dic_name scale,
               dev.ip ip,
               EV.EVENTDETAIL_INDEX eventDetailIndex,
               EV.TIMEID timeID,
               EV.PERSISTTIME / 1000 persistTime,
               round(EV.EVENTVALUE * 100,2) eventValue,
               ev.ms ms
          FROM PQS_EVENTDETAIL  ev,
               PQ_LINE          line,
               PQ_GDINFORMATION gd,
               PQ_SUBSTATION    sub,
               PQ_DEVICE        dev,
		       PQS_DICDATA dic
         WHERE line.line_index = ev.lineid
           AND gd.gd_index = line.gd_index
           AND sub.sub_index = line.sub_index
           AND dev.dev_index = line.dev_index
           and dic.dic_index = line.scale
           AND ev.eventdetail_index = #{eventdetailIndex}
    </select>

    <select id="getPtType" resultType="java.lang.Integer">
        select b.pttype
        from pqs_eventdetail a, pq_linedetail b
        where a.eventdetail_index = #{eventIndex}
        and a.lineid = b.line_index
    </select>

    <select id="selectByIndex" resultType="eventDetail">
        SELECT
            EVENTDETAIL_INDEX,
            LINEID,
            TIMEID,
            MS,
            WAVETYPE,
            PERSISTTIME,
            EVENTVALUE,
            EVENTREASON,
            EVENTTYPE,
            EVENTASS_INDEX,
            DQTIME,
            DEALTIME,
            NUM,
            FILEFLAG,
            DEALFLAG,
            FIRSTTIME,
            FIRSTTYPE,
            FIRSTMS,
            WAVENAME,
            Energy,
            Severity
        FROM
            PQS_EVENTDETAIL
        WHERE
            EVENTDETAIL_INDEX = #{eventIndex}
    </select>
    <select id="selectByTimeIdAndLineIndex" resultType="eventDetail">
        SELECT
            EVENTDETAIL_INDEX,
            LINEID,
            TIMEID,
            MS,
            WAVETYPE,
            PERSISTTIME,
            EVENTVALUE,
            EVENTREASON,
            EVENTTYPE,
            EVENTASS_INDEX,
            DQTIME,
            DEALTIME,
            NUM,
            FILEFLAG,
            DEALFLAG,
            FIRSTTIME,
            FIRSTTYPE,
            FIRSTMS,
            WAVENAME,
            Energy,
            Severity
        FROM
            PQS_EVENTDETAIL
        WHERE
            TIMEID = #{timeId}
            and
            MS = #{ms}
            and
            lineId =#{lineId}
    </select>

    <select id="getSuspendByMonitor" resultType="java.lang.Integer">
        SELECT
        NVL(COUNT(1),0)
        FROM
        PQS_EVENTDETAIL T1
        WHERE
        T1.TIMEID
        BETWEEN #{startTime} AND #{endTime}
        and T1.LINEID in
        <foreach collection="list" item="item" index="index" open="("
                 separator="," close=")">
            #{item}
        </foreach>
        and T1.WAVETYPE = 1
    </select>
</mapper>
