<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tofly.xrtygis.custom.mapper.YhBingAreaMapper">
    <select id="getClientInfo" resultType="com.tofly.xrtygis.entity.Dmausertable">
        select
        A.CBB,
        B.CBB_MC CBBMC,
        A.CBPQ,
        C.CBPQ_MC as CBPQMC,
        A.YHBH,
        A.YHXM,
        A.YHDZ,
        A.SBBH,
        A.DAY_WATER,
        A.ZH_XGRQ
        from TF_YWPN_DMAUSERTABLE_W A
        left join TF_YWPN_DMACISCBB_W B on A.CBB=B.CBB_BM
        left join TF_YWPN_DMACISCBPQ_W C on A.CBPQ=C.CBPQ_BM
        where 1=1
        <if test="guid!=null">
            and A.DMA_IDS like '%' || #{guid} || '%'
        </if>
        <if test="cbbName != null">
            and B.CBB_MC = #{cbbName}
        </if>
        <if test="inputcontent != null">
            and A.YHBH || A.YHXM || A.YHDZ like '%' || #{inputcontent} || '%'
        </if>
    </select>

    <select id="getCbbBm" resultType="long">
        select distinct CBB
        from TF_YWPN_DMAUSERTABLE_W
        where DMA_IDS like '%' || #{guid} || '%'
    </select>

    <insert id="bingCbb">
        insert into TF_YWPN_DMAANDCBB_W(ID , DMA_ID , CBBBM)
        <foreach collection="list" item="l" separator="union all">
            select
            #{l.id} ,
            #{l.dmaId} ,
            #{l.cbbbm}
            from dual
        </foreach>
    </insert>
</mapper>