<?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.mq.mapper.plan.PlanAwaitTransferUsersMapper">

    <select id="getTransformerNameByTransformerNo" resultType="java.lang.String">
        select distinct trim(tb.station_name)
        from dwd_shb_ds_joinec_transformer_base jt
                 left join dwd_shb_ds_joinec_base jb on jb.psr_id = jt.join_ec
                 join dwd_shb_ds_transformer_base tb on jt.psr_id = tb.psr_id and tb.psr_state = '20'
        where jt.join_ec = #{transformerNo}
          and trim(tb.station_name) is not null
    </select>
    <select id="getTransformerNameListByJoinecId" resultType="java.lang.String">
        select distinct tb.name
        from dwd_shb_ds_joinec_transformer_base jt
                 left join dwd_shb_ds_joinec_base jb on jb.psr_id = jt.join_ec
                 join dwd_shb_ds_transformer_base tb on jt.psr_id = tb.psr_id and tb.psr_state = '20'
        where jt.join_ec = #{join_ec}
          and tb.name is not null
    </select>

    <select id="getTransformerName" resultType="com.hdkj.lt.core.bizms.modle.dto.TransformerNameDTO">
        select distinct jt.join_ec                                                                            as joinEc,
                        concat(group_concat(distinct tb.name), '(', jb.name, ')')                             as dedicated_name,
                        concat(group_concat(distinct trim(tb.station_name) separator '-'), '(', jb.name,')')  as transformer_name
        from dwd_shb_ds_joinec_transformer_base jt
                 left join dwd_shb_ds_joinec_base jb on jb.psr_id = jt.join_ec
                 join dwd_shb_ds_transformer_base tb on jt.psr_id = tb.psr_id and tb.psr_state = '20'
        group by jt.join_ec;
    </select>
</mapper>
