<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.njcn.event.mapper.majornetwork.RmpEventDetailMapper">

    <select id="getDetailsOfTransientEvents" resultType="com.njcn.event.pojo.po.RmpEventDetailPO">
        SELECT
        event_id as eventId,
        measurement_point_id as measurementPointId,
        Event_Type as eventType,
        start_time as startTime,
        Duration as duration,
        feature_amplitude as featureAmplitude,
        phase as phase,
        event_describe as eventDescribe,
        wave_path as wavePath
        FROM
        r_mp_event_detail
        WHERE
        measurement_point_id IN
        <foreach collection="monitorIds" item="item" open="(" close=")" separator=",">
            #{item}
        </foreach>
        <if test="eventType != null and eventType.size() >0">
            AND Event_Type IN
            <foreach collection="eventType" item="item" open="(" close=")" separator=",">
                #{item}
            </foreach>
        </if>
        <if test="startTime != null and startTime != ''">
            AND DATE_FORMAT(start_time, '%Y-%m-%d') &gt;= DATE_FORMAT(#{startTime}, '%Y-%m-%d')
        </if>
        <if test="endTime != null and endTime != ''">
            AND DATE_FORMAT(start_time, '%Y-%m-%d') &lt;= DATE_FORMAT(#{endTime}, '%Y-%m-%d')
        </if>
        order by start_time desc
    </select>

<!--  获取暂态事件明细 与上面的方法区别是日期精确到月 yy-MM -->
    <select id="getDetailsOfTransientEventsByMonth" resultType="com.njcn.event.pojo.po.RmpEventDetailPO">
        SELECT
        event_id as eventId,
        measurement_point_id as measurementPointId,
        Event_Type as eventType,
        start_time as startTime,
        Duration as duration,
        feature_amplitude as featureAmplitude,
        phase as phase,
        event_describe as eventDescribe,
        wave_path as wavePath
        FROM
        r_mp_event_detail
        WHERE
        measurement_point_id IN
        <foreach collection="monitorIds" item="item" open="(" close=")" separator=",">
            #{item}
        </foreach>
        <if test="eventType != null and eventType.size() >0">
            AND Event_Type IN
            <foreach collection="eventType" item="item" open="(" close=")" separator=",">
                #{item}
            </foreach>
        </if>
        <if test="startTime != null and startTime != ''">
            AND DATE_FORMAT(start_time, '%Y-%m') &gt;= SUBSTRING(#{startTime}, 1, 7)
        </if>
        <if test="endTime != null and endTime != ''">
            AND DATE_FORMAT(start_time, '%Y-%m') &lt;= SUBSTRING(#{endTime}, 1, 7)
        </if>
    </select>
    <select id="getByEventId" resultType="com.njcn.event.pojo.po.RmpEventDetailPO">
        SELECT
            *
        from
            r_mp_event_detail
        where event_id=#{id}
    </select>
</mapper>
