<?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.hdkj.lt.bf.mapper.FhzgVoltageLimitViolationPowerCutMapper">

    <resultMap id="BaseResultMap"
               type="com.hdkj.lt.core.bizms.modle.po.voltageLimitViolation.FhzgVoltageLimitViolationPowerCut">
        <id property="id" column="id" jdbcType="BIGINT"/>
        <result property="reason" column="reason" jdbcType="VARCHAR"/>
        <result property="eventType" column="event_type" jdbcType="VARCHAR"/>
        <result property="eventCreateTime" column="event_create_time" jdbcType="TIMESTAMP"/>
        <result property="lineId" column="line_id" jdbcType="VARCHAR"/>
        <result property="lineName" column="line_name" jdbcType="VARCHAR"/>
        <result property="voltageLimitStartTime" column="voltage_limit_start_time" jdbcType="TIMESTAMP"/>
        <result property="voltageLimitEndTime" column="voltage_limit_end_time" jdbcType="TIMESTAMP"/>
        <result property="voltageIndex" column="voltage_index" jdbcType="VARCHAR"/>
        <result property="overVoltageIndexNormal" column="over_voltage_index_normal" jdbcType="VARCHAR"/>
        <result property="overVoltageIndexHeavy" column="over_voltage_index_heavy" jdbcType="VARCHAR"/>
        <result property="underVoltageIndexNormal" column="under_voltage_index_normal" jdbcType="VARCHAR"/>
        <result property="overVoltageTime" column="over_voltage_time" jdbcType="INTEGER"/>
        <result property="underVoltageTime" column="under_voltage_time" jdbcType="INTEGER"/>
        <result property="underVoltageIndexHeavy" column="under_voltage_index_heavy" jdbcType="VARCHAR"/>
        <result property="underVoltageLineNum" column="under_voltage_line_num" jdbcType="INTEGER"/>
        <result property="underVoltageLineCount" column="under_voltage_line_count" jdbcType="INTEGER"/>
        <result property="underVoltageTransformerNum" column="under_voltage_transformer_num" jdbcType="INTEGER"/>
        <result property="underVoltageTransformerCount" column="under_voltage_transformer_count" jdbcType="INTEGER"/>
        <result property="underVoltageMvCustomerNum" column="under_voltage_mv_customer_num" jdbcType="INTEGER"/>
        <result property="underVoltageMvCustomerCount" column="under_voltage_mv_customer_count" jdbcType="INTEGER"/>
        <result property="underVoltageLvCustomerNum" column="under_voltage_lv_customer_num" jdbcType="INTEGER"/>
        <result property="underVoltageLvCustomerCount" column="under_voltage_lv_customer_count" jdbcType="INTEGER"/>
        <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
        <result property="creator" column="creator" jdbcType="VARCHAR"/>
        <result property="lastTime" column="last_time" jdbcType="TIMESTAMP"/>
        <result property="lastEditor" column="last_editor" jdbcType="VARCHAR"/>
    </resultMap>

    <sql id="Base_Column_List">
        id
        ,reason,event_type,
        event_create_time,line_id,line_name,
        voltage_limit_start_time,voltage_limit_end_time,voltage_index,
        over_voltage_index_normal,over_voltage_index_heavy,under_voltage_index_normal,
        over_voltage_time,under_voltage_time,under_voltage_index_heavy,
        under_voltage_line_num,under_voltage_line_count,under_voltage_transformer_num,
        under_voltage_transformer_count,under_voltage_mv_customer_num,under_voltage_mv_customer_count,
        under_voltage_lv_customer_num,under_voltage_lv_customer_count,create_time,
        creator,last_time,last_editor
    </sql>
    <select id="getVolPowerCutList"
            resultType="com.hdkj.lt.core.bizms.modle.po.voltageLimitViolation.FhzgVoltageLimitViolationPowerCut">
        select t1.*, t3.short_name countyName
        from fhzg_voltage_limit_violation_power_cut t1
        left join dwd_shb_ds_feeder_base t2 on t1.line_id = t2.psr_id
        left join sys_dept t3 on t3.isc_org_id = t2.maint_org
        <where>
            <if test="queryDTO.countyCode != null and queryDTO.countyCode != ''">
                and t3.dept_id = #{queryDTO.countyCode}
            </if>
            <if test="queryDTO.countyCodeList != null and queryDTO.countyCodeList.size > 0">
                AND t3.dept_id IN
                <foreach collection="queryDTO.countyCodeList" open="(" item="item" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="queryDTO.feederName != null and queryDTO.feederName != ''">
                and t1.line_name like concat('%',#{queryDTO.feederName},'%')
            </if>
            <if test="queryDTO.volStartTime != null ">
                and t1.voltage_limit_start_time > #{queryDTO.volStartTime}
            </if>
            <if test="queryDTO.volEndTime != null ">
                and t1.voltage_limit_end_time &lt; #{queryDTO.volEndTime}
            </if>
            <if test="queryDTO.volType != null and queryDTO.volType != ''">
                and t1.event_type = #{queryDTO.volType}
            </if>
            <if test="queryDTO.limitNo != null and queryDTO.limitNo != ''">
                and t1.limit_no = #{queryDTO.limitNo}
            </if>
        </where>
        order by t1.event_create_time desc
    </select>
</mapper>
