bchmapper.xml 24 KB
Newer Older
hulei committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616
<?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.brilliance.isc.mda.dao.BchMapper">

    <resultMap id="BaseResultMap" type="com.brilliance.isc.bo.Bch">
        <result property="inr" column="inr" jdbcType="VARCHAR"/>
        <result property="branch" column="branch" jdbcType="VARCHAR"/>
        <result property="bchkey" column="bchkey" jdbcType="VARCHAR"/>
        <result property="bchname" column="bchname" jdbcType="VARCHAR"/>
        <result property="lev" column="lev" jdbcType="VARCHAR"/>
        <result property="upbranch" column="upbranch" jdbcType="VARCHAR"/>
        <result property="bchtyp" column="bchtyp" jdbcType="VARCHAR"/>
        <result property="bchflg" column="bchflg" jdbcType="VARCHAR"/>
        <result property="decnum" column="decnum" jdbcType="VARCHAR"/>
        <result property="tel" column="tel" jdbcType="VARCHAR"/>
        <result property="fax" column="fax" jdbcType="VARCHAR"/>
        <result property="adr" column="adr" jdbcType="VARCHAR"/>
        <result property="swfcod" column="swfcod" jdbcType="VARCHAR"/>
        <result property="adr2" column="adr2" jdbcType="VARCHAR"/>
        <result property="ver" column="ver" jdbcType="VARCHAR"/>
        <result property="namen" column="namen" jdbcType="VARCHAR"/>
        <result property="adren" column="adren" jdbcType="VARCHAR"/>
        <result property="adren2" column="adren2" jdbcType="VARCHAR"/>
        <result property="ydjcod" column="ydjcod" jdbcType="VARCHAR"/>
        <result property="tid" column="tid" jdbcType="VARCHAR"/>
        <result property="bchref" column="bchref" jdbcType="VARCHAR"/>
        <result property="bchusr" column="bchusr" jdbcType="VARCHAR"/>
        <result property="sta" column="sta" jdbcType="VARCHAR"/>
        <result property="lhanum" column="lhanum" jdbcType="VARCHAR"/>
        <result property="lhanam" column="lhanam" jdbcType="VARCHAR"/>
        <result property="zmqflg" column="zmqflg" jdbcType="VARCHAR"/>
        <result property="bchusr2" column="bchusr2" jdbcType="VARCHAR"/>
        <result property="dzlhhh" column="dzlhhh" jdbcType="VARCHAR"/>
        <result property="dzlhmc" column="dzlhmc" jdbcType="VARCHAR"/>
        <result property="bchfzr" column="bchfzr" jdbcType="VARCHAR"/>
    </resultMap>

    <sql id="Base_Column_List">
        inr,branch,bchkey,bchname,lev,upbranch,bchtyp,bchflg,decnum,tel,fax,adr,swfcod,adr2,ver,namen,adren,adren2,ydjcod,tid,bchref,bchusr,sta,lhanum,lhanam,zmqflg,bchusr2,dzlhhh,dzlhmc,bchfzr
    </sql>

    <insert id="insert">
        insert into bch (<include refid="Base_Column_List"/>)
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            #{inr,jdbcType=VARCHAR},
            #{branch,jdbcType=VARCHAR},
            #{bchkey,jdbcType=VARCHAR},
            #{bchname,jdbcType=VARCHAR},
            #{lev,jdbcType=VARCHAR},
            #{upbranch,jdbcType=VARCHAR},
            #{bchtyp,jdbcType=VARCHAR},
            #{bchflg,jdbcType=VARCHAR},
            #{decnum,jdbcType=VARCHAR},
            #{tel,jdbcType=VARCHAR},
            #{fax,jdbcType=VARCHAR},
            #{adr,jdbcType=VARCHAR},
            #{swfcod,jdbcType=VARCHAR},
            #{adr2,jdbcType=VARCHAR},
            #{ver,jdbcType=VARCHAR},
            #{namen,jdbcType=VARCHAR},
            #{adren,jdbcType=VARCHAR},
            #{adren2,jdbcType=VARCHAR},
            #{ydjcod,jdbcType=VARCHAR},
            #{tid,jdbcType=VARCHAR},
            #{bchref,jdbcType=VARCHAR},
            #{bchusr,jdbcType=VARCHAR},
            #{sta,jdbcType=VARCHAR},
            #{lhanum,jdbcType=VARCHAR},
            #{lhanam,jdbcType=VARCHAR},
            #{zmqflg,jdbcType=VARCHAR},
            #{bchusr2,jdbcType=VARCHAR},
            #{dzlhhh,jdbcType=VARCHAR},
            #{dzlhmc,jdbcType=VARCHAR},
            #{bchfzr,jdbcType=VARCHAR},
        </trim>
    </insert>

    <insert id="insertSelective">
        insert into bch
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="inr != null">inr,</if>
            <if test="branch != null">branch,</if>
            <if test="bchkey != null">bchkey,</if>
            <if test="bchname != null">bchname,</if>
            <if test="lev != null">lev,</if>
            <if test="upbranch != null">upbranch,</if>
            <if test="bchtyp != null">bchtyp,</if>
            <if test="bchflg != null">bchflg,</if>
            <if test="decnum != null">decnum,</if>
            <if test="tel != null">tel,</if>
            <if test="fax != null">fax,</if>
            <if test="adr != null">adr,</if>
            <if test="swfcod != null">swfcod,</if>
            <if test="adr2 != null">adr2,</if>
            <if test="ver != null">ver,</if>
            <if test="namen != null">namen,</if>
            <if test="adren != null">adren,</if>
            <if test="adren2 != null">adren2,</if>
            <if test="ydjcod != null">ydjcod,</if>
            <if test="tid != null">tid,</if>
            <if test="bchref != null">bchref,</if>
            <if test="bchusr != null">bchusr,</if>
            <if test="sta != null">sta,</if>
            <if test="lhanum != null">lhanum,</if>
            <if test="lhanam != null">lhanam,</if>
            <if test="zmqflg != null">zmqflg,</if>
            <if test="bchusr2 != null">bchusr2,</if>
            <if test="dzlhhh != null">dzlhhh,</if>
            <if test="dzlhmc != null">dzlhmc,</if>
            <if test="bchfzr != null">bchfzr,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="inr != null">#{inr,jdbcType=VARCHAR},</if>
            <if test="branch != null">#{branch,jdbcType=VARCHAR},</if>
            <if test="bchkey != null">#{bchkey,jdbcType=VARCHAR},</if>
            <if test="bchname != null">#{bchname,jdbcType=VARCHAR},</if>
            <if test="lev != null">#{lev,jdbcType=VARCHAR},</if>
            <if test="upbranch != null">#{upbranch,jdbcType=VARCHAR},</if>
            <if test="bchtyp != null">#{bchtyp,jdbcType=VARCHAR},</if>
            <if test="bchflg != null">#{bchflg,jdbcType=VARCHAR},</if>
            <if test="decnum != null">#{decnum,jdbcType=VARCHAR},</if>
            <if test="tel != null">#{tel,jdbcType=VARCHAR},</if>
            <if test="fax != null">#{fax,jdbcType=VARCHAR},</if>
            <if test="adr != null">#{adr,jdbcType=VARCHAR},</if>
            <if test="swfcod != null">#{swfcod,jdbcType=VARCHAR},</if>
            <if test="adr2 != null">#{adr2,jdbcType=VARCHAR},</if>
            <if test="ver != null">#{ver,jdbcType=VARCHAR},</if>
            <if test="namen != null">#{namen,jdbcType=VARCHAR},</if>
            <if test="adren != null">#{adren,jdbcType=VARCHAR},</if>
            <if test="adren2 != null">#{adren2,jdbcType=VARCHAR},</if>
            <if test="ydjcod != null">#{ydjcod,jdbcType=VARCHAR},</if>
            <if test="tid != null">#{tid,jdbcType=VARCHAR},</if>
            <if test="bchref != null">#{bchref,jdbcType=VARCHAR},</if>
            <if test="bchusr != null">#{bchusr,jdbcType=VARCHAR},</if>
            <if test="sta != null">#{sta,jdbcType=VARCHAR},</if>
            <if test="lhanum != null">#{lhanum,jdbcType=VARCHAR},</if>
            <if test="lhanam != null">#{lhanam,jdbcType=VARCHAR},</if>
            <if test="zmqflg != null">#{zmqflg,jdbcType=VARCHAR},</if>
            <if test="bchusr2 != null">#{bchusr2,jdbcType=VARCHAR},</if>
            <if test="dzlhhh != null">#{dzlhhh,jdbcType=VARCHAR},</if>
            <if test="dzlhmc != null">#{dzlhmc,jdbcType=VARCHAR},</if>
            <if test="bchfzr != null">#{bchfzr,jdbcType=VARCHAR},</if>
        </trim>
    </insert>

    <update id="updateByPrimaryKeySelective">
        update bch
        <set>
            <if test="branch != null">branch = #{branch,jdbcType=VARCHAR},</if>
            <if test="bchkey != null">bchkey = #{bchkey,jdbcType=VARCHAR},</if>
            <if test="bchname != null">bchname = #{bchname,jdbcType=VARCHAR},</if>
            <if test="lev != null">lev = #{lev,jdbcType=VARCHAR},</if>
            <if test="upbranch != null">upbranch = #{upbranch,jdbcType=VARCHAR},</if>
            <if test="bchtyp != null">bchtyp = #{bchtyp,jdbcType=VARCHAR},</if>
            <if test="bchflg != null">bchflg = #{bchflg,jdbcType=VARCHAR},</if>
            <if test="decnum != null">decnum = #{decnum,jdbcType=VARCHAR},</if>
            <if test="tel != null">tel = #{tel,jdbcType=VARCHAR},</if>
            <if test="fax != null">fax = #{fax,jdbcType=VARCHAR},</if>
            <if test="adr != null">adr = #{adr,jdbcType=VARCHAR},</if>
            <if test="swfcod != null">swfcod = #{swfcod,jdbcType=VARCHAR},</if>
            <if test="adr2 != null">adr2 = #{adr2,jdbcType=VARCHAR},</if>
            <if test="ver != null">ver = #{ver,jdbcType=VARCHAR},</if>
            <if test="namen != null">namen = #{namen,jdbcType=VARCHAR},</if>
            <if test="adren != null">adren = #{adren,jdbcType=VARCHAR},</if>
            <if test="adren2 != null">adren2 = #{adren2,jdbcType=VARCHAR},</if>
            <if test="ydjcod != null">ydjcod = #{ydjcod,jdbcType=VARCHAR},</if>
            <if test="tid != null">tid = #{tid,jdbcType=VARCHAR},</if>
            <if test="bchref != null">bchref = #{bchref,jdbcType=VARCHAR},</if>
            <if test="bchusr != null">bchusr = #{bchusr,jdbcType=VARCHAR},</if>
            <if test="sta != null">sta = #{sta,jdbcType=VARCHAR},</if>
            <if test="lhanum != null">lhanum = #{lhanum,jdbcType=VARCHAR},</if>
            <if test="lhanam != null">lhanam = #{lhanam,jdbcType=VARCHAR},</if>
            <if test="zmqflg != null">zmqflg = #{zmqflg,jdbcType=VARCHAR},</if>
            <if test="bchusr2 != null">bchusr2 = #{bchusr2,jdbcType=VARCHAR},</if>
            <if test="dzlhhh != null">dzlhhh = #{dzlhhh,jdbcType=VARCHAR},</if>
            <if test="dzlhmc != null">dzlhmc = #{dzlhmc,jdbcType=VARCHAR},</if>
            <if test="bchfzr != null">bchfzr = #{bchfzr,jdbcType=VARCHAR},</if>
        </set>
        where inr = #{inr,jdbcType=VARCHAR}
    </update>

    <update id="updateByPrimaryKey">
        update bch
        <set>
            branch = #{branch,jdbcType=VARCHAR},
            bchkey = #{bchkey,jdbcType=VARCHAR},
            bchname = #{bchname,jdbcType=VARCHAR},
            lev = #{lev,jdbcType=VARCHAR},
            upbranch = #{upbranch,jdbcType=VARCHAR},
            bchtyp = #{bchtyp,jdbcType=VARCHAR},
            bchflg = #{bchflg,jdbcType=VARCHAR},
            decnum = #{decnum,jdbcType=VARCHAR},
            tel = #{tel,jdbcType=VARCHAR},
            fax = #{fax,jdbcType=VARCHAR},
            adr = #{adr,jdbcType=VARCHAR},
            swfcod = #{swfcod,jdbcType=VARCHAR},
            adr2 = #{adr2,jdbcType=VARCHAR},
            ver = #{ver,jdbcType=VARCHAR},
            namen = #{namen,jdbcType=VARCHAR},
            adren = #{adren,jdbcType=VARCHAR},
            adren2 = #{adren2,jdbcType=VARCHAR},
            ydjcod = #{ydjcod,jdbcType=VARCHAR},
            tid = #{tid,jdbcType=VARCHAR},
            bchref = #{bchref,jdbcType=VARCHAR},
            bchusr = #{bchusr,jdbcType=VARCHAR},
            sta = #{sta,jdbcType=VARCHAR},
            lhanum = #{lhanum,jdbcType=VARCHAR},
            lhanam = #{lhanam,jdbcType=VARCHAR},
            zmqflg = #{zmqflg,jdbcType=VARCHAR},
            bchusr2 = #{bchusr2,jdbcType=VARCHAR},
            dzlhhh = #{dzlhhh,jdbcType=VARCHAR},
            dzlhmc = #{dzlhmc,jdbcType=VARCHAR},
            bchfzr = #{bchfzr,jdbcType=VARCHAR},
        </set>
        where inr = #{inr,jdbcType=VARCHAR}
    </update>

    <delete id="deleteByPrimaryKey">
        delete from bch
        where inr = #{inr,jdbcType=VARCHAR}
    </delete>

    <select id="selectByPrimaryKey" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from bch
        where inr = #{inr,jdbcType=VARCHAR}
    </select>

    <select id="listByUpbranch" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from bch
        where upbranch like concat(concat ('%',#{upbranch}),'%')
    </select>

    <select id="selectByRecord" resultMap="BaseResultMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM bch
        <where>
            <if test="inr != null and inr != ''">
                and inr = #{inr}
            </if>
            <if test="branch != null and branch != ''">
                and branch = #{branch}
            </if>
            <if test="bchkey != null and bchkey != ''">
                and bchkey = #{bchkey}
            </if>
            <if test="bchname != null and bchname != ''">
                and bchname = #{bchname}
            </if>
            <if test="lev != null and lev != ''">
                and lev = #{lev}
            </if>
            <if test="upbranch != null and upbranch != ''">
                and upbranch = #{upbranch}
            </if>
            <if test="bchtyp != null and bchtyp != ''">
                and bchtyp = #{bchtyp}
            </if>
            <if test="bchflg != null and bchflg != ''">
                and bchflg = #{bchflg}
            </if>
            <if test="decnum != null and decnum != ''">
                and decnum = #{decnum}
            </if>
            <if test="tel != null and tel != ''">
                and tel = #{tel}
            </if>
            <if test="fax != null and fax != ''">
                and fax = #{fax}
            </if>
            <if test="adr != null and adr != ''">
                and adr = #{adr}
            </if>
            <if test="swfcod != null and swfcod != ''">
                and swfcod = #{swfcod}
            </if>
            <if test="adr2 != null and adr2 != ''">
                and adr2 = #{adr2}
            </if>
            <if test="ver != null and ver != ''">
                and ver = #{ver}
            </if>
            <if test="namen != null and namen != ''">
                and namen = #{namen}
            </if>
            <if test="adren != null and adren != ''">
                and adren = #{adren}
            </if>
            <if test="adren2 != null and adren2 != ''">
                and adren2 = #{adren2}
            </if>
            <if test="ydjcod != null and ydjcod != ''">
                and ydjcod = #{ydjcod}
            </if>
            <if test="tid != null and tid != ''">
                and tid = #{tid}
            </if>
            <if test="bchref != null and bchref != ''">
                and bchref = #{bchref}
            </if>
            <if test="bchusr != null and bchusr != ''">
                and bchusr = #{bchusr}
            </if>
            <if test="sta != null and sta != ''">
                and sta = #{sta}
            </if>
            <if test="lhanum != null and lhanum != ''">
                and lhanum = #{lhanum}
            </if>
            <if test="lhanam != null and lhanam != ''">
                and lhanam = #{lhanam}
            </if>
            <if test="zmqflg != null and zmqflg != ''">
                and zmqflg = #{zmqflg}
            </if>
            <if test="bchusr2 != null and bchusr2 != ''">
                and bchusr2 = #{bchusr2}
            </if>
            <if test="dzlhhh != null and dzlhhh != ''">
                and dzlhhh = #{dzlhhh}
            </if>
            <if test="dzlhmc != null and dzlhmc != ''">
                and dzlhmc = #{dzlhmc}
            </if>
            <if test="bchfzr != null and bchfzr != ''">
                and bchfzr = #{bchfzr}
            </if>
        </where>
    </select>

    <select id="selectByActBranch" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from bch
        where LEV in('1','0')  or  (lev ='2' and bchtyp in('6','1'))
    </select>

    <select id="selectChildBchListByBranch" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from bch
        where UPBRANCH like concat(concat ('%',#{branch}),'%')
    </select>

    <select id="selectAccBchListByBranch" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from bch
        where UPBRANCH like concat(concat ('%',#{branch}),'%') and lev in ('1','2') and BCHTYP in('1','6')
    </select>

    <select id="selectAccBchListByBranchAndIt" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from bch
        where 1=1
            and UPBRANCH like concat(concat ('%',#{branch}),'%') and lev in ('1','2') and BCHTYP in('1','6')
        <if test="branch =='1000'">
             or branch='1000'
        </if>
        order  by branch asc
    </select>

    <select id="selectAllBchList" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from bch
        where lev in ('1','2')
    </select>

    <select id="selectAllAccBchList" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from bch
        where LEV in ('1','2') and BCHTYP in('1','6')
    </select>

    <select id="selectAccBchList" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from bch
        where LEV in('0','1')  and BCHTYP in('0','1','6')
        and  UPPER(upbranch) LIKE concat(concat('%', UPPER(#{branch})), '%')
        order by lev
    </select>

    <select id="dyncRead" resultMap="BaseResultMap">
        ${sql}
    </select>

    <select id="queryAll" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from bch
    </select>

    <select id="queryByNam" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        FROM BCH WHERE BCHNAME = #{bchname}
    </select>

    <select id="getBchNameandBranchByBchkey" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List"/>
    FROM BCH WHERE bchkey= #{bchkey}
    </select>


    <select id="getBchnameByBchtyp" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        FROM BCH WHERE BCHTYP in ('1','6')
    </select>

    <select id="selectChildBchInrListByBranch" resultType="String">
        select
        inr
        from bch
        where UPBRANCH like concat(concat ('%',#{branch}),'%')
    </select>
    <select id="selectByInr" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from bch
        where
        inr = #{inr,jdbcType=VARCHAR}
    </select>
    <select id="selectByUsrExtkey" resultMap="BaseResultMap">
            select
            <include refid="Base_Column_List"/>
            from bch
            right join usr on usr.extkey=#{usr}
            left join ec_org_personconndepartment ub on ub.personid=usr.USERDETAILSID
            and  ub.STATE ='1' and ub.ifdefault='1'
            left join ec_org_department dep on dep.id=ub.DEPARTMENTID
            where 1=1
            and (usr.extkey is not null and usr.extkey !='')
            and bch.branch=dep.DEPARTMENTNUMBER
    </select>

    <select id="selectByLhanum" resultType="int">
        select
        count(1)
        from bch
        where lhanum = #{lhanum,jdbcType=VARCHAR}
    </select>
    <select id="selectByUroUserId" resultType="String">
        select
        inr
        from bch
        where
        branch in(select accbch from uro
                where HDLATH='1' and USERDETAILSID =#{userId,jdbcType=INTEGER})
    </select>
    <select id="selectByBranch" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from bch
        where
        branch = #{branch,jdbcType=VARCHAR}
    </select>

    <select id="selectAllJurisdictionBranch" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from bch
        where
        lev in ('A','B')
    </select>

    <select id="queryBchlist" resultType="com.brilliance.isc.vo.lg.BchlistVo">
    select
        inr bchinr,
        bchname bchname,
        branch branch
    from
        bch
    where
        length(UPBRANCH) = 14
        and bchtyp in(1,
        6)
        and zmqflg = ''
    order by
        branch
    </select>

    <select id="getBchNameFromYptuid" resultType="com.brilliance.isc.vo.lg.BchlistVo">
    select
        inr bchinr,
        bchname bchname,
        branch branch
    from
        bch
    where BCHTYP in ('1','6') and branch in (select distinct BRANCH from yptuid where BRANCH is not null and trim(BRANCH) !='' and  branch !='1000' )
        <if test="branch != null and branch !=''">
            and branch != #{branch}
        </if>
    order by branch
    </select>
    
    <select id="selectByPtyinr" resultType="java.util.Map">
        select
        bch.branch branch,bch.bchname bchname
        from bch,pty,pta
        where bch.inr = pta.branchinr and pta.ptyinr = pty.inr and pta.usg = 'MAA' and pty.inr = #{ptyinr,jdbcType=VARCHAR}
    </select>

    <select id="selecetBchInfoByLhanum" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from bch
        where
        lhanum = #{lhanum,jdbcType=VARCHAR}
    </select>

    <select id="selectCountByBchtypAndDzlhhh" resultType="java.util.HashMap">
        SELECT lev,SUM(count) count FROM (
        SELECT '0' lev, 0 count from dual
        UNION ALL
        SELECT '1' lev, 0 count from dual
        UNION ALL
        SELECT '2' lev, 0 count from dual
        UNION ALL
        select lev,count(*) count from BCH where 1=1
        <if test="dzlhhh != null and dzlhhh != ''">
            and dzlhhh = #{dzlhhh}
        </if>
        <if test="lhanum != null and lhanum != ''">
            and lhanum = #{lhanum}
        </if>
        and bchtyp in ('6','1') GROUP BY lev
        ) a GROUP BY lev ORDER BY lev ASC
    </select>

    <select id="selectCountByWhere" resultType="java.lang.Integer">
        select count(*) from bch where 1=1
        <if test="dzlhhh != null and dzlhhh != ''">
            and dzlhhh = #{dzlhhh}
        </if>
        <if test="lhanum != null and lhanum != ''">
            and lhanum = #{lhanum}
        </if>
    </select>

    <!--来报清分使用,不要修改-->
    <select id="selectByBchtypAndDzlhhhAndLev" resultMap="BaseResultMap">
        select inr,bchkey from bch where 1=1
        <if test="dzlhhh != null and dzlhhh != ''">
            and dzlhhh = #{dzlhhh}
        </if>
        <if test="lhanum != null and lhanum != ''">
            and lhanum = #{lhanum}
        </if>
        <if test="lev != null and lev != '' and lev != '9'.toString()">
            and lev = #{lev}
        </if>
        <if test="lev != null and lev == '9'.toString()">
            and lev != '0'
        </if>
        AND BCHTYP IN('6','1')
    </select>

    <select id="selectByWherer" resultMap="BaseResultMap">
        select inr,bchkey from bch where 1=1
        <if test="dzlhhh != null and dzlhhh != ''">
            and dzlhhh = #{dzlhhh}
        </if>
        <if test="lhanum != null and lhanum != ''">
            and lhanum = #{lhanum}
        </if>
        limit 1
    </select>

    <select id="selectBySwfcod" resultType="java.lang.String">
        SELECT inr FROM bch
        WHERE swfcod = #{swfcod,jdbcType=VARCHAR}
        AND lev='1' and bchtyp in('1','6')
    </select>

    <select id="selectByupbranch" resultType="java.lang.String">
        select DZLHHH from bch where branch = #{upbranch,jdbcType=VARCHAR}
    </select>

    <select id="selectByLevAndBchFlg" resultMap="BaseResultMap">
        select
            <include refid="Base_Column_List"/>
            from bch where (lev='1' or lev='2')
            and bchflg='AA'
    </select>

    <select id="selectEInfoByBranch" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from bch where branch in (SELECT BCHKEY FROM BCH WHERE branch = #{branch,jdbcType=VARCHAR}) and BCHTYP IN ('1', '6')  AND LEV = '1'
    </select>

    <select id="selectEInfoByInr" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from bch where inr = #{inr,jdbcType=VARCHAR} and BCHTYP IN ('1', '6')  AND LEV = '1'
    </select>

    <select id="selectBchkeyinrByBchinr" resultType="string">
        SELECT BCHKEY.INR FROM BCH BCHKEY,BCH BCHBRA
        WHERE BCHKEY.BRANCH=BCHBRA.BCHREF
        and BCHBRA.INR = #{inr,jdbcType=VARCHAR}
        limit 1
    </select>
</mapper>