<?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.XlRelMapper">

    <select id="getContactSwitchListByFeeder" resultType="com.hdkj.lt.bf.entity.vo.XlRelVO">

        with reb as (select LLSB_ID, LLSB_NAME, XL_ID_ONE, XL_NAME_ONE, XL_ID_TWO, XL_NAME_TWO
                     from ct_xl_rel
                     where XL_ID_ONE = #{lineId}
                     union
                     select LLSB_ID, LLSB_NAME, XL_ID_ONE, XL_NAME_ONE, XL_ID_TWO, XL_NAME_TWO
                     from ct_xl_rel
                     where XL_ID_TWO = #{lineId})
        select *
        from reb t
        where not exists (select 1
                          from t_disable_llkg_config l
                          where t.llsb_id = l.LLSB_ID and l.llsb_type in ('0','1'))

    </select>

    <select id="getContactSwitchListByFeederOperation" resultType="com.hdkj.lt.bf.entity.vo.XlRelVO">
        with reb as (select LLSB_ID, LLSB_NAME, XL_ID_ONE, XL_NAME_ONE, XL_ID_TWO, XL_NAME_TWO
                     from ct_xl_rel c
                              inner join fhzg_operation_abnormality_line_loadfactor_loss t on t.psr_id = c.XL_ID_ONE
                     where t.oa_id = #{oaId}
                     union
                     select LLSB_ID, LLSB_NAME, XL_ID_ONE, XL_NAME_ONE, XL_ID_TWO, XL_NAME_TWO
                     from ct_xl_rel c
                              inner join fhzg_operation_abnormality_line_loadfactor_loss t on t.psr_id = c.XL_ID_TWO
                     where t.oa_id = #{oaId})
        select *
        from reb t
        where not exists (select 1
                          from t_disable_llkg_config l
                          where t.llsb_id = l.LLSB_ID and l.llsb_type in ('0','1'))
    </select>

    <select id="getContactSwitchListByStationId" resultType="com.hdkj.lt.bf.entity.vo.XlRelVO">
        with reb as (select LLSB_ID, LLSB_NAME, XL_ID_ONE, XL_NAME_ONE, XL_ID_TWO, XL_NAME_TWO
                     from ct_xl_rel c
                              inner join dwd_shb_ds_feeder_base t on t.psr_id = c.XL_ID_ONE
                     where t.start_station = #{stationId}
                     union
                     select LLSB_ID, LLSB_NAME, XL_ID_ONE, XL_NAME_ONE, XL_ID_TWO, XL_NAME_TWO
                     from ct_xl_rel c
                              inner join dwd_shb_ds_feeder_base t on t.psr_id = c.XL_ID_TWO
                     where t.start_station = #{stationId})
        select *
        from reb t
        where not exists (select 1
                          from t_disable_llkg_config l
                          where t.llsb_id = l.LLSB_ID and l.llsb_type in ('0','1'))
    </select>


</mapper>
