<?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.si.dao.FhzgSwitchProtectionSettingsMapper">

    <resultMap id="BaseResultMap" type="com.hdkj.lt.core.bizms.modle.po.FhzgSwitchProtectionSettings">
            <id property="id" column="id" jdbcType="BIGINT"/>
            <result property="deviceName" column="device_name" jdbcType="VARCHAR"/>
            <result property="devicePrsId" column="device_prs_id" jdbcType="VARCHAR"/>
            <result property="parentLineName" column="parent_line_name" jdbcType="VARCHAR"/>
            <result property="parentLinePsrId" column="parent_line_psr_id" jdbcType="VARCHAR"/>
            <result property="zoneISoftBlock" column="zone_i_soft_block" jdbcType="VARCHAR"/>
            <result property="zoneISetting" column="zone_i_setting" jdbcType="VARCHAR"/>
            <result property="zoneIDelay" column="zone_i_delay" jdbcType="VARCHAR"/>
            <result property="zoneIiSoftBlock" column="zone_ii_soft_block" jdbcType="VARCHAR"/>
            <result property="zoneIiSetting" column="zone_ii_setting" jdbcType="VARCHAR"/>
            <result property="zoneIiDelay" column="zone_ii_delay" jdbcType="VARCHAR"/>
            <result property="creator" column="creator" jdbcType="BIGINT"/>
            <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
            <result property="lastEditor" column="last_editor" jdbcType="BIGINT"/>
            <result property="lastTime" column="last_time" jdbcType="TIMESTAMP"/>
            <result property="oc1AlarmA" column="oc1_alarm_a" jdbcType="VARCHAR"/>
            <result property="oc1AlarmS" column="oc1_alarm_s" jdbcType="VARCHAR"/>
            <result property="oc1TripA" column="oc1_trip_a" jdbcType="VARCHAR"/>
            <result property="oc1TripS" column="oc1_trip_s" jdbcType="VARCHAR"/>
            <result property="oc2AlarmA" column="oc2_alarm_a" jdbcType="VARCHAR"/>
            <result property="oc2AlarmS" column="oc2_alarm_s" jdbcType="VARCHAR"/>
            <result property="oc2TripA" column="oc2_trip_a" jdbcType="VARCHAR"/>
            <result property="oc2TripS" column="oc2_trip_s" jdbcType="VARCHAR"/>
            <result property="protEnableStatus" column="prot_enable_status" jdbcType="INTEGER"/>
            <result property="recloseEnableStatus" column="reclose_enable_status" jdbcType="INTEGER"/>
            <result property="oc1Value" column="oc1_value" jdbcType="VARCHAR"/>
            <result property="oc1Delay" column="oc1_delay" jdbcType="VARCHAR"/>
            <result property="oc1Setting" column="oc1_setting" jdbcType="TINYINT"/>
            <result property="oc2Value" column="oc2_value" jdbcType="VARCHAR"/>
            <result property="oc2Delay" column="oc2_delay" jdbcType="VARCHAR"/>
            <result property="oc2Setting" column="oc2_setting" jdbcType="TINYINT"/>
            <result property="oc3Value" column="oc3_value" jdbcType="VARCHAR"/>
            <result property="oc3Delay" column="oc3_delay" jdbcType="VARCHAR"/>
            <result property="oc3Setting" column="oc3_setting" jdbcType="TINYINT"/>
    </resultMap>

    <sql id="Base_Column_List">
        id,device_name,device_prs_id,
        parent_line_name,parent_line_psr_id,zone_i_soft_block,
        zone_i_setting,zone_i_delay,zone_ii_soft_block,
        zone_ii_setting,zone_ii_delay,creator,
        create_time,last_editor,last_time,
        oc1_alarm_a,oc1_alarm_s,oc1_trip_a,
        oc1_trip_s,oc2_alarm_a,oc2_alarm_s,
        oc2_trip_a,oc2_trip_s,prot_enable_status,
        reclose_enable_status,oc1_value,oc1_delay,
        oc1_setting,oc2_value,oc2_delay,
        oc2_setting,oc3_value,oc3_delay,
        oc3_setting
    </sql>

    <select id="getSetting" resultType="com.hdkj.lt.modle.vo.setting.DeviceSettingVO">
        SELECT
        b.feeder AS linePsrId,
        b.psr_id AS switchPsrId,
        b.NAME AS switchName,
        a.prot_enable_status AS protectionInputExit,
        a.reclose_enable_status AS switchInputExit,
        a.oc1_value AS zoneISetting,
        a.oc1_delay AS zoneIDelay,
        oc1_setting AS protectionOperatedTypeI,
        oc2_value AS zoneIISetting,
        oc2_delay AS zoneIDelay,
        oc2_setting AS protectionOperatedTypeII,
        oc3_value AS zoneIIISetting,
        oc3_delay AS zoneIIIDelay,
        oc3_setting AS protectionOperatedTypeIII
        FROM
        fhzg_switch_protection_settings a,
        dwd_shb_ds_switch_base b
        WHERE
        a.device_prs_id = b.psr_id
        <if test="params.linePsrIds != null and params.linePsrIds.size > 0">
            AND b.feeder IN
            <foreach collection="params.linePsrIds" open="(" item="id" separator="," close=")">
                #{id}
            </foreach>
        </if>
        <if test="params.switchPsrIds != null and params.switchPsrIds.size > 0">
            AND b.psr_id IN
            <foreach collection="params.switchPsrIds" open="(" item="id" separator="," close=")">
                #{id}
            </foreach>
        </if>
    </select>

</mapper>
