<?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.prepare.harmonic.mapper.mysql.line.RMpEventDetailMapper">
  <resultMap id="BaseResultMap" type="com.njcn.prepare.harmonic.pojo.mysql.RMpEventDetailPO">
    <!--@mbg.generated-->
    <!--@Table r_mp_event_detail-->
    <id column="event_id" jdbcType="CHAR" property="eventId" />
    <result column="measurement_point_id" jdbcType="VARCHAR" property="measurementPointId" />
    <result column="event_type" jdbcType="CHAR" property="eventType" />
    <result column="advance_reason" jdbcType="CHAR" property="advanceReason" />
    <result column="advance_type" jdbcType="CHAR" property="advanceType" />
    <result column="eventass_index" jdbcType="VARCHAR" property="eventassIndex" />
    <result column="dq_time" jdbcType="DOUBLE" property="dqTime" />
    <result column="deal_time" jdbcType="TIMESTAMP" property="dealTime" />
    <result column="num" jdbcType="INTEGER" property="num" />
    <result column="file_flag" jdbcType="BOOLEAN" property="fileFlag" />
    <result column="deal_flag" jdbcType="BOOLEAN" property="dealFlag" />
    <result column="first_time" jdbcType="TIMESTAMP" property="firstTime" />
    <result column="first_type" jdbcType="VARCHAR" property="firstType" />
    <result column="first_ms" jdbcType="DECIMAL" property="firstMs" />
    <result column="energy" jdbcType="DOUBLE" property="energy" />
    <result column="severity" jdbcType="DOUBLE" property="severity" />
    <result column="sagsource" jdbcType="VARCHAR" property="sagsource" />
    <result column="start_time" jdbcType="TIMESTAMP" property="startTime" />
    <result column="duration" jdbcType="DECIMAL" property="duration" />
    <result column="feature_amplitude" jdbcType="DECIMAL" property="featureAmplitude" />
    <result column="phase" jdbcType="VARCHAR" property="phase" />
    <result column="event_describe" jdbcType="VARCHAR" property="eventDescribe" />
    <result column="wave_path" jdbcType="VARCHAR" property="wavePath" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="transient_value" jdbcType="DOUBLE" property="transientValue" />
  </resultMap>
  <sql id="Base_Column_List">
    <!--@mbg.generated-->
    event_id, measurement_point_id, event_type, advance_reason, advance_type, eventass_index, 
    dq_time, deal_time, num, file_flag, deal_flag, first_time, first_type, first_ms, 
    energy, severity, sagsource, start_time, duration, feature_amplitude, phase, event_describe, 
    wave_path, create_time, transient_value
  </sql>


  <select id="handleDay" resultType="com.njcn.harmonic.pojo.po.RMpEventDetailDPO">
    SELECT
      #{dataDate} dataDate,
      measurement_point_id measurement_point_id,
      sum( event_type = #{voltageDip} ) AS sagTimes,
      sum( event_type = #{voltageRise} ) AS swellTimes,
      sum( event_type = #{shortInterruptions} ) AS interruptTimes
    FROM
      r_mp_event_detail r_mp_event_detail
    where r_mp_event_detail.start_time between #{beginDay} and #{endDay}
    AND r_mp_event_detail.measurement_point_id
        IN
        <foreach collection="lineIds" item="lineId" separator="," open="(" close=")">
          #{lineId}
        </foreach>
    GROUP BY
      measurement_point_id
  </select>



</mapper>