oitmapper.xml 33.5 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 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925
<?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.OitMapper">

    <resultMap id="BaseResultMap" type="com.brilliance.isc.bo.Oit">
        <result property="inr" column="inr" jdbcType="VARCHAR"/>
        <result property="objtyp" column="objtyp" jdbcType="VARCHAR"/>
        <result property="objinr" column="objinr" jdbcType="VARCHAR"/>
        <result property="subtyp" column="subtyp" jdbcType="VARCHAR"/>
        <result property="subbus" column="subbus" jdbcType="VARCHAR"/>
        <result property="inflev" column="inflev" jdbcType="VARCHAR"/>
        <result property="inftxt" column="inftxt" jdbcType="CLOB"/>
        <result property="ver" column="ver" jdbcType="VARCHAR"/>
        <result property="etgextkey" column="etgextkey" jdbcType="VARCHAR"/>
    </resultMap>

    <resultMap id="BaseResultMap1" type="com.brilliance.isc.bo.Oit">
        <result property="inr" column="inr" jdbcType="VARCHAR"/>
        <result property="objtyp" column="objtyp" jdbcType="VARCHAR"/>
        <result property="objinr" column="objinr" jdbcType="VARCHAR"/>
        <result property="subtyp" column="subtyp" jdbcType="VARCHAR"/>
        <result property="subbus" column="subbus" jdbcType="VARCHAR"/>
        <result property="inflev" column="inflev" jdbcType="VARCHAR"/>
        <result property="inftxt" column="inftxt" jdbcType="VARCHAR"/>
        <result property="ver" column="ver" jdbcType="VARCHAR"/>
        <result property="etgextkey" column="etgextkey" jdbcType="VARCHAR"/>
        <result property="path" column="path"/>
    </resultMap>

    <resultMap id="FieldMap" type="com.brilliance.isc.vo.manager.OitManageVo">
        <result property="inr" column="inr" jdbcType="VARCHAR"/>
        <result property="objtyp" column="objtyp" jdbcType="VARCHAR"/>
        <result property="objinr" column="objinr" jdbcType="VARCHAR"/>
        <result property="subtyp" column="subtyp" jdbcType="VARCHAR"/>
        <result property="subbus" column="subbus" jdbcType="VARCHAR"/>
        <result property="inflev" column="inflev" jdbcType="VARCHAR"/>
        <result property="inftxt" column="inftxt" jdbcType="VARCHAR"/>
        <result property="ver" column="ver" jdbcType="VARCHAR"/>
        <result property="etgextkey" column="etgextkey" jdbcType="VARCHAR"/>
        <result property="objextkey" column="objextkey" jdbcType="VARCHAR"/>
        <result property="objnam" column="objnam" jdbcType="VARCHAR"/>
        <result property="objcod" column="objcod" jdbcType="VARCHAR"/>
    </resultMap>

    <resultMap id="OitTableResultMap" type="com.brilliance.isc.vo.manager.OitTableVo">
        <result property="stbuil" column="stbuil" jdbcType="VARCHAR"/>

        <result property="actinr" column="actinr" jdbcType="VARCHAR"/>
        <result property="actkey" column="actkey" jdbcType="VARCHAR"/>
        <result property="actnam" column="actnam" jdbcType="VARCHAR"/>
        <result property="actcur" column="actcur" jdbcType="VARCHAR"/>

        <result property="fecinr" column="fecinr" jdbcType="VARCHAR"/>
        <result property="feecod" column="feecod" jdbcType="VARCHAR"/>
        <result property="objtyp" column="objtyp" jdbcType="VARCHAR"/>
        <result property="objnam" column="objnam" jdbcType="VARCHAR"/>
        <result property="begdat" column="begdat" jdbcType="VARCHAR"/>
        <result property="enddat" column="enddat" jdbcType="VARCHAR"/>

        <result property="gidinr" column="gidinr" jdbcType="VARCHAR"/>
        <result property="gidref" column="gidref" jdbcType="VARCHAR"/>
        <result property="gidnam" column="gidnam" jdbcType="VARCHAR"/>

        <result property="nidinr" column="nidinr" jdbcType="VARCHAR"/>
        <result property="nidref" column="nidref" jdbcType="VARCHAR"/>
        <result property="nidnam" column="nidnam" jdbcType="VARCHAR"/>

        <result property="ptainr" column="ptainr" jdbcType="VARCHAR"/>
        <result property="ptakey" column="ptakey" jdbcType="VARCHAR"/>
        <result property="ptanam" column="ptanam" jdbcType="VARCHAR"/>

        <result property="ptyinr" column="ptyinr" jdbcType="VARCHAR"/>
        <result property="ptykey" column="ptykey" jdbcType="VARCHAR"/>
        <result property="ptynam" column="ptynam" jdbcType="VARCHAR"/>
    </resultMap>

    <sql id="Base_Column_List">
        inr,objtyp,objinr,subtyp,subbus,inflev,inftxt,ver,etgextkey
    </sql>

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

    <select id="selectByObj" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from oit
        where objinr = #{objinr,jdbcType=VARCHAR} and objtyp = #{objtyp,jdbcType=VARCHAR}
    </select>

    <select id="selectByObjInrAndTyp" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from oit
        where objinr = #{objinr,jdbcType=VARCHAR} and objtyp = #{objtyp,jdbcType=VARCHAR}
        order by inflev desc
    </select>

    <select id="selectByObjWithBatch" resultMap="BaseResultMap1">


    <foreach close="" collection="list" index="index"
             item="item" open="" separator=" union all ">
        select
        inr,objtyp,objinr,subtyp,subbus,inflev,inftxt,ver,etgextkey,#{item.path} as path
        from oit
        where objinr = #{item.objinr,jdbcType=VARCHAR} and objtyp = #{item.objtyp,jdbcType=VARCHAR}
    </foreach>

    </select>

    <select id="selectByExtkeyWithBatch" resultMap="BaseResultMap1">

        <foreach close="" collection="list" index="index"
                 item="item" open="" separator=" union all ">
            select
            inr,objtyp,objinr,subtyp,subbus,inflev,inftxt,ver,etgextkey,#{item.path} as path
            from oit
            where objinr in (select inr from ${item.objtyp} where ${item.column} = #{item.extkey})
             and objtyp = #{item.objtyp,jdbcType=VARCHAR}
        </foreach>

    </select>

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

    <!--    <insert id="insert">-->
    <!--        insert into oit (<include refid="Base_Column_List" />)-->
    <!--        <trim prefix="values (" suffix=")" suffixOverrides=",">-->
    <!--            #{inr,jdbcType=VARCHAR},-->
    <!--            #{objtyp,jdbcType=VARCHAR},-->
    <!--            #{objinr,jdbcType=VARCHAR},-->
    <!--            #{subtyp,jdbcType=VARCHAR},-->
    <!--            #{subbus,jdbcType=VARCHAR},-->
    <!--            #{inflev,jdbcType=VARCHAR},-->
    <!--            #{inftxt,jdbcType=CLOB},-->
    <!--            #{ver,jdbcType=VARCHAR},-->
    <!--            #{etgextkey,jdbcType=VARCHAR},-->
    <!--        </trim>-->
    <!--    </insert>-->

    <insert id="insert" keyProperty="" useGeneratedKeys="true">
        insert into OIT(INR, OBJTYP, OBJINR, SUBTYP, SUBBUS, INFLEV, INFTXT, VER, ETGEXTKEY)
        values (#{inr}, #{objtyp}, #{objinr}, #{subtyp}, #{subbus}, #{inflev}, #{inftxt}, '0000', 'CEBGRP')
    </insert>

    <insert id="insertSelective">
        insert into oit
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="inr != null">inr,</if>
            <if test="objtyp != null">objtyp,</if>
            <if test="objinr != null">objinr,</if>
            <if test="subtyp != null">subtyp,</if>
            <if test="subbus != null">subbus,</if>
            <if test="inflev != null">inflev,</if>
            <if test="inftxt != null">inftxt,</if>
            <if test="ver != null">ver,</if>
            etgextkey,
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="inr != null">#{inr,jdbcType=VARCHAR},</if>
            <if test="objtyp != null">#{objtyp,jdbcType=VARCHAR},</if>
            <if test="objinr != null">#{objinr,jdbcType=VARCHAR},</if>
            <if test="subtyp != null">#{subtyp,jdbcType=VARCHAR},</if>
            <if test="subbus != null">#{subbus,jdbcType=VARCHAR},</if>
            <if test="inflev != null">#{inflev,jdbcType=VARCHAR},</if>
            <if test="inftxt != null">#{inftxt,jdbcType=CLOB},</if>
            <if test="ver != null">#{ver,jdbcType=VARCHAR},</if>
            'CEBGRP',
        </trim>
    </insert>

    <update id="updateByPrimaryKeySelective">
        update oit
        <set>
            <if test="objtyp != null">objtyp = #{objtyp,jdbcType=VARCHAR},</if>
            <if test="objinr != null">objinr = #{objinr,jdbcType=VARCHAR},</if>
            <if test="subtyp != null">subtyp = #{subtyp,jdbcType=VARCHAR},</if>
            <if test="subbus != null">subbus = #{subbus,jdbcType=VARCHAR},</if>
            <if test="inflev != null">inflev = #{inflev,jdbcType=VARCHAR},</if>
            <if test="inftxt != null">inftxt = #{inftxt,jdbcType=CLOB},</if>
            <if test="ver != null">ver = #{ver,jdbcType=VARCHAR},</if>
            etgextkey = 'CEBGRP',
        </set>
        where inr = #{inr,jdbcType=VARCHAR}
    </update>

    <update id="updateByPrimaryKey">
        update oit
        <set>
            objtyp = #{objtyp,jdbcType=VARCHAR},
            objinr = #{objinr,jdbcType=VARCHAR},
            subtyp = #{subtyp,jdbcType=VARCHAR},
            subbus = #{subbus,jdbcType=VARCHAR},
            inflev = #{inflev,jdbcType=VARCHAR},
            inftxt = #{inftxt,jdbcType=CLOB},
            ver = #{ver,jdbcType=VARCHAR},
            etgextkey = 'CEBGRP',
        </set>
        where inr = #{inr,jdbcType=VARCHAR}
    </update>

    <delete id="deleteByIds">
        delete from act where inr in
        <foreach item="item" index="index" collection="collection" open="(" separator="," close=")">
            #{item}
        </foreach>
    </delete>

    <update id="dyncUpdate">
        update oit
        <set>
            <if test="module.objtyp != null">objtyp = #{module.objtyp,jdbcType=VARCHAR},</if>
            <if test="module.objinr != null">objinr = #{module.objinr,jdbcType=VARCHAR},</if>
            <if test="module.subtyp != null">subtyp = #{module.subtyp,jdbcType=VARCHAR},</if>
            <if test="module.subbus != null">subbus = #{module.subbus,jdbcType=VARCHAR},</if>
            <if test="module.inflev != null">inflev = #{module.inflev,jdbcType=VARCHAR},</if>
            <if test="module.inftxt != null">inftxt = #{module.inftxt,jdbcType=CLOB},</if>
            <if test="module.ver != null">ver = #{module.ver,jdbcType=VARCHAR},</if>
            etgextkey = 'CEBGRP',
        </set>
        ${conditions}
    </update>

    <delete id="dyncDelete">
        ${sql}
    </delete>

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

    <select id="selectCountByPtyinr" resultType="java.lang.Integer">
        select COUNT(*) from OIT WHERE OBJTYP='PTY' AND (SUBTYP='STP' and INFLEV='9') AND OBJINR=#{objinr,jdbcType=CLOB}
    </select>

    <!--查询单个-->
    <select id="queryById" resultMap="BaseResultMap">
        select
          INR, OBJTYP, OBJINR, SUBTYP, SUBBUS, INFLEV, INFTXT, VER, ETGEXTKEY
        from OIT
        where INR = #{inr}
    </select>

    <select id="queryfield" resultMap="FieldMap">
        select
        <if test="objtyp == 'BRD'">
            OWNREF,
        </if>
        NAM from ${objtyp}
        <where>
            inr = #{objinr}
            <if test="objtyp == 'BRD'">
                and OWNREF is not null
            </if>
            and nam is not null
        </where>
    </select>

    <!--查询指定行数据-->
    <select id="queryAllByLimit" resultMap="BaseResultMap">
        select
        INR, OBJTYP, OBJINR, SUBTYP, SUBBUS, INFLEV, INFTXT, VER, ETGEXTKEY
        from OIT
        <where>
            <if test="inr != null and inr != ''">
                and INR like concat(concat ('%',#{inr}),'%')
            </if>
            <if test="objtyp != null and objtyp != ''">
                and OBJTYP like concat(concat ('%',#{objtyp}),'%')
            </if>
            <if test="objinr != null and objinr != ''">
                and OBJINR like concat(concat ('%',#{objinr}),'%')
            </if>
            <if test="subtyp != null and subtyp != ''">
                and SUBTYP like concat(concat ('%',#{subtyp}),'%')
            </if>
            <if test="subbus != null and subbus != ''">
                and SUBBUS like concat(concat ('%',#{subbus}),'%')
            </if>
            <if test="inflev != null and inflev != ''">
                and INFLEV like concat(concat ('%',#{inflev}),'%')
            </if>
            <if test="inftxt != null and inftxt != ''">
                and INFTXT like concat(concat ('%',#{inftxt}),'%')
            </if>
            <if test="ver != null and ver != ''">
                and VER like concat(concat ('%',#{ver}),'%')
            </if>
            <if test="etgextkey != null and etgextkey != ''">
                and ETGEXTKEY like concat(concat ('%','CEBGRP'),'%')
            </if>
        </where>
        order by length(INR) DESC, INR DESC
    </select>

    <!--统计总行数-->
    <select id="count" resultType="java.lang.Long">
        select count(1)
        from OIT
        <where>
            <if test="inr != null and inr != ''">
                and INR = #{inr}
            </if>
            <if test="objtyp != null and objtyp != ''">
                and OBJTYP = #{objtyp}
            </if>
            <if test="objinr != null and objinr != ''">
                and OBJINR = #{objinr}
            </if>
            <if test="subtyp != null and subtyp != ''">
                and SUBTYP = #{subtyp}
            </if>
            <if test="subbus != null and subbus != ''">
                and SUBBUS = #{subbus}
            </if>
            <if test="inflev != null and inflev != ''">
                and INFLEV = #{inflev}
            </if>
            <if test="inftxt != null and inftxt != ''">
                and INFTXT = #{inftxt}
            </if>
            <if test="ver != null and ver != ''">
                and VER = #{ver}
            </if>
            <if test="etgextkey != null and etgextkey != ''">
                and ETGEXTKEY = 'CEBGRP'
            </if>
        </where>
    </select>


    <select id="queryAllByLimitRelPty" resultMap="FieldMap">
        select
        OIT.INR INR,
        OIT.OBJTYP OBJTYP,
        OIT.OBJINR OBJINR,
        OIT.SUBTYP SUBTYP,
        OIT.SUBBUS SUBBUS,
        OIT.INFLEV INFLEV,
        OIT.INFTXT INFTXT,
        OIT.VER VER,
        OIT.ETGEXTKEY ETGEXTKEY,
        PTY.EXTKEY OBJEXTKEY,
        PTY.NAM OBJNAM,
        '' OBJCOD
        from OIT,PTY WHERE OIT.OBJINR=PTY.INR and OIT.OBJTYP='PTY'
        <if test="objtyp != null and objtyp != ''">
            and OIT.OBJTYP = #{objtyp}
        </if>

        <if test="subtyp != null and subtyp != ''">
            and OIT.SUBTYP = #{subtyp}
        </if>

        <if test="objextkey != null and objextkey != ''">
            and PTY.extkey like concat(concat ('%',#{objextkey}),'%')
        </if>
        <if test="objnam != null and objnam != ''">
            and (
            PTY.nam like concat(concat ('%',#{objnam}),'%')
            or
            PTY.nam1 like concat(concat ('%',#{objnam}),'%')
            )
        </if>

        <if test="bchkeyinr != null and bchkeyinr != ''">
            and PTY.bchkeyinr = #{bchkeyinr}
        </if>
        order by length(OIT.INR) DESC, INR DESC
    </select>


    <select id="queryAllByLimitRelPta" resultMap="FieldMap">
        select
        OIT.INR INR,
        OIT.OBJTYP OBJTYP,
        OIT.OBJINR OBJINR,
        OIT.SUBTYP SUBTYP,
        OIT.SUBBUS SUBBUS,
        OIT.INFLEV INFLEV,
        OIT.INFTXT INFTXT,
        OIT.VER VER,
        OIT.ETGEXTKEY ETGEXTKEY,
        PTA.OBJKEY OBJEXTKEY,
        PTA.NAM OBJNAM,
        '' OBJCOD
        from OIT,PTA WHERE OIT.OBJINR=PTA.INR and OIT.OBJTYP='PTA'
        <if test="objtyp != null and objtyp != ''">
            and OIT.OBJTYP = #{objtyp}
        </if>

        <if test="subtyp != null and subtyp != ''">
            and OIT.SUBTYP = #{subtyp}
        </if>

        <if test="objextkey != null and objextkey != ''">
            and PTA.objkey like concat(concat ('%',#{objextkey}),'%')
        </if>
        <if test="objnam != null and objnam != ''">
            and (
            PTA.nam like concat(concat ('%',#{objnam}),'%')

            )
        </if>
        <if test="bchkeyinr != null and bchkeyinr != ''">
            and PTA.bchkeyinr = #{bchkeyinr}
        </if>
        order by length(OIT.INR) DESC, INR DESC
    </select>

    <select id="queryAllByLimitRelAct" resultMap="FieldMap">
        select
        OIT.INR INR,
        OIT.OBJTYP OBJTYP,
        OIT.OBJINR OBJINR,
        OIT.SUBTYP SUBTYP,
        OIT.SUBBUS SUBBUS,
        OIT.INFLEV INFLEV,
        OIT.INFTXT INFTXT,
        OIT.VER VER,
        OIT.ETGEXTKEY ETGEXTKEY,
        ACT.EXTKEY OBJEXTKEY,
        ACT.NAM OBJNAM,
        '' OBJCOD
        from OIT, ACT, PTY WHERE OIT.OBJINR=ACT.INR and OIT.OBJTYP='ACT'
        AND ACT.HOLPTYINR=PTY.INR
        <if test="objtyp != null and objtyp != ''">
            and OIT.OBJTYP = #{objtyp}
        </if>

        <if test="subtyp != null and subtyp != ''">
            and OIT.SUBTYP = #{subtyp}
        </if>

        <if test="objextkey != null and objextkey != ''">
            and ACT.EXTKEY like concat(concat ('%',#{objextkey}),'%')
        </if>
        <if test="objnam != null and objnam != ''">
            and (
            ACT.nam like concat(concat ('%',#{objnam}),'%')

            )
        </if>
        <if test="bchkeyinr != null and bchkeyinr != ''">
            and PTY.bchkeyinr = #{bchkeyinr}
        </if>
        order by length(OIT.INR) DESC, INR DESC
    </select>

    <select id="queryAllByLimitRelGid" resultMap="FieldMap">
        select
        OIT.INR INR,
        OIT.OBJTYP OBJTYP,
        OIT.OBJINR OBJINR,
        OIT.SUBTYP SUBTYP,
        OIT.SUBBUS SUBBUS,
        OIT.INFLEV INFLEV,
        OIT.INFTXT INFTXT,
        OIT.VER VER,
        OIT.ETGEXTKEY ETGEXTKEY,
        GID.OWNREF OBJEXTKEY,
        GID.NAM OBJNAM,
        '' OBJCOD
        from OIT,GID WHERE OIT.OBJINR=GID.INR and OIT.OBJTYP='GID'
        <if test="objtyp != null and objtyp != ''">
            and OIT.OBJTYP = #{objtyp}
        </if>

        <if test="subtyp != null and subtyp != ''">
            and OIT.SUBTYP = #{subtyp}
        </if>

        <if test="objextkey != null and objextkey != ''">
            and GID.OWNREF like concat(concat ('%',#{objextkey}),'%')
        </if>
        <if test="objnam != null and objnam != ''">
            and (
            GID.NAM like concat(concat ('%',#{objnam}),'%')

            )
        </if>
        <if test="bchkeyinr != null and bchkeyinr != ''">
            and GID.bchkeyinr = #{bchkeyinr}
        </if>
        order by length(OIT.INR) DESC, INR DESC
    </select>

    <select id="queryAllByLimitRelNid" resultMap="FieldMap">
        select
        OIT.INR INR,
        OIT.OBJTYP OBJTYP,
        OIT.OBJINR OBJINR,
        OIT.SUBTYP SUBTYP,
        OIT.SUBBUS SUBBUS,
        OIT.INFLEV INFLEV,
        OIT.INFTXT  INFTXT,
        OIT.VER VER,
        OIT.ETGEXTKEY ETGEXTKEY,
        NID.OWNREF OBJEXTKEY,
        NID.NAM OBJNAM,
        '' OBJCOD
        from OIT,NID WHERE OIT.OBJINR=NID.INR and OIT.OBJTYP='NID'
        <if test="objtyp != null and objtyp != ''">
            and OIT.OBJTYP = #{objtyp}
        </if>

        <if test="subtyp != null and subtyp != ''">
            and OIT.SUBTYP = #{subtyp}
        </if>

        <if test="objextkey != null and objextkey != ''">
            and NID.OWNREF like concat(concat ('%',#{objextkey}),'%')
        </if>
        <if test="objnam != null and objnam != ''">
            and (
            NID.NAM like concat(concat ('%',#{objnam}),'%')

            )
        </if>
        <if test="bchkeyinr != null and bchkeyinr != ''">
            and NID.bchkeyinr = #{bchkeyinr}
        </if>
        order by length(OIT.INR) DESC, INR DESC
    </select>

    <select id="queryAllByLimitRelCty" resultMap="FieldMap">
        select
        OIT.INR INR,
        OIT.OBJTYP OBJTYP,
        OIT.OBJINR OBJINR,
        OIT.SUBTYP SUBTYP,
        OIT.SUBBUS SUBBUS,
        OIT.INFLEV INFLEV,
        OIT.INFTXT INFTXT,
        OIT.VER VER,
        OIT.ETGEXTKEY ETGEXTKEY,
        CTY.COD OBJEXTKEY,
        CTY.COD OBJNAM,
        '' OBJCOD
        from OIT,CTY WHERE OIT.OBJINR=CTY.INR and OIT.OBJTYP='CTY'
        <if test="objtyp != null and objtyp != ''">
            and OIT.OBJTYP = #{objtyp}
        </if>

        <if test="subtyp != null and subtyp != ''">
            and OIT.SUBTYP = #{subtyp}
        </if>

        <if test="objextkey != null and objextkey != ''">
            and CTY.COD like concat(concat ('%',#{objextkey}),'%')
        </if>

        order by length(OIT.INR) DESC, INR DESC
    </select>

    <select id="queryAllByLimitRelFec" resultMap="FieldMap">
        select
        OIT.INR INR,
        OIT.OBJTYP OBJTYP,
        OIT.OBJINR OBJINR,
        OIT.SUBTYP SUBTYP,
        OIT.SUBBUS SUBBUS,
        OIT.INFLEV INFLEV,
        OIT.INFTXT INFTXT,
        OIT.VER VER,
        OIT.ETGEXTKEY ETGEXTKEY,
        FEC.FEEINR OBJEXTKEY
        from OIT,FEC WHERE OIT.OBJINR=FEC.INR and OIT.OBJTYP='FEC'
        <if test="objtyp != null and objtyp != ''">
            and OIT.OBJTYP = #{objtyp}
        </if>

        <if test="subtyp != null and subtyp != ''">
            and OIT.SUBTYP = #{subtyp}
        </if>
        <if test="objextkey != null and objextkey != ''">
            and FEC.FEEINR = (select inr from fee where cod = #{objextkey})
        </if>
        order by length(OIT.INR) DESC, INR DESC
    </select>

    <!--通过主键修改数据-->
    <update id="update">
        update OIT
        <set>
            <if test="inr != null and inr != ''">
                INR = #{inr},
            </if>
            <if test="objtyp != null and objtyp != ''">
                OBJTYP = #{objtyp},
            </if>
            <if test="objinr != null and objinr != ''">
                OBJINR = #{objinr},
            </if>
            <if test="subtyp != null and subtyp != ''">
                SUBTYP = #{subtyp},
            </if>
            <if test="subbus != null and subbus != ''">
                SUBBUS = #{subbus},
            </if>
            <if test="inflev != null and inflev != ''">
                INFLEV = #{inflev},
            </if>
            <if test="inftxt != null and inftxt != ''">
                INFTXT = #{inftxt},
            </if>
            <if test="ver != null and ver != ''">
                VER = #{ver},
            </if>
                ETGEXTKEY = 'CEBGRP',
        </set>
        where INR = #{inr}
    </update>

    <!--通过主键删除-->
    <delete id="deleteById">
        delete from OIT where INR = #{inr}
    </delete>

    <select id="queryByPtyinr" resultMap="BaseResultMap">
        select subtyp, inflev, inftxt from oit where objtyp = 'PTY' and objinr = #{ptyinr}
    </select>

    <select id="queryByAdrinr" resultMap="BaseResultMap">
        select subtyp, inflev, inftxt from oit where objtyp = 'ADR' and objinr = #{adrinr} and subtyp = 'INF'
    </select>

    <select id="queryByCondition" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"></include>
        from oit
        <where>
            <if test="objtyp != null and objtyp != ''">
                and objtyp = #{objtyp}
            </if>
            <if test="objinr != null and objinr != ''">
                and objinr = #{objinr}
            </if>
            <if test="subtyp != null and subtyp != ''">
                and subtyp = #{subtyp}
            </if>
        </where>
    </select>

    <update id="updateByAdrsign">
        update oit
        <set>
            <trim suffixOverrides=",">
                <if test="inflev != null">
                    inflev = #{inflev},
                </if>
                <if test="inftxt != null">
                    inftxt = #{inftxt},
                </if>
            </trim>
        </set>
        <where>
            <if test="objtyp != null and objtyp != ''">
                and objtyp = #{objtyp}
            </if>
            <if test="objinr != null and objinr != ''">
                and objinr = #{objinr}
            </if>
            <if test="subtyp != null and subtyp != ''">
                and subtyp = #{subtyp}
            </if>
        </where>
    </update>

    <insert id="insertAdrOit">
        insert into oit
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="inr != null">inr,</if>
            <if test="objtyp != null">objtyp,</if>
            <if test="objinr != null">objinr,</if>
            <if test="subtyp != null">subtyp,</if>
            <if test="subbus != null">subbus,</if>
            <if test="inflev != null">inflev,</if>
            <if test="inftxt != null">inftxt,</if>
            <if test="ver != null">ver,</if>
            <if test="etgextkey != null">etgextkey,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="inr != null">#{inr,jdbcType=VARCHAR},</if>
            <if test="objtyp != null">#{objtyp,jdbcType=VARCHAR},</if>
            <if test="objinr != null">#{objinr,jdbcType=VARCHAR},</if>
            <if test="subtyp != null">#{subtyp,jdbcType=VARCHAR},</if>
            <if test="subbus != null">#{subbus,jdbcType=VARCHAR},</if>
            <if test="inflev != null">#{inflev,jdbcType=VARCHAR},</if>
            <if test="inftxt != null">#{inftxt,jdbcType=CLOB},</if>
            <if test="ver != null">'0000',</if>
            <if test="etgextkey != null">'CEBGRP',</if>
        </trim>
    </insert>

    <select id="queryObjByObjextkeyPty" resultMap="FieldMap">
        select inr objinr,extkey objextkey,CONCAT_WS('/',extkey,nam) objnam from pty where extkey = #{objextkey}
    </select>

    <select id="queryObjByObjextkeyPta" resultMap="FieldMap">
        select inr objinr,objkey objextkey,CONCAT_WS('/',objkey,nam) objnam from pta where objkey = #{objextkey}
    </select>

    <select id="queryObjByObjextkeyAct" resultMap="FieldMap">
        select inr objinr,extkey objextkey,CONCAT_WS('/',extkey,nam) objnam from act where extkey = #{objextkey}
    </select>

    <select id="queryObjByObjextkeyCty" resultMap="FieldMap">
        select inr objinr,cod objextkey from cty where cod = #{objextkey}
    </select>

    <select id="queryObjByObjextkeyGid" resultMap="FieldMap">
        select inr objinr,ownref objextkey,CONCAT_WS('/',ownref,nam) objnam from gid where ownref = #{objextkey}
    </select>

    <select id="queryObjByObjextkeyNid" resultMap="FieldMap">
        select inr objinr,ownref objextkey,CONCAT_WS('/',ownref,nam) objnam from nid where ownref = #{objextkey}
    </select>


    <select id="getObjByPty" resultMap="FieldMap">
        select extkey objextkey,CONCAT_WS('/',extkey,nam) objnam from pty where inr = #{objinr}
    </select>

    <select id="getObjByPta" resultMap="FieldMap">
        select objkey objextkey,CONCAT_WS('/',objkey,nam) objnam from pta where inr = #{objinr}
    </select>

    <select id="getObjByAct" resultMap="FieldMap">
        select extkey objextkey,CONCAT_WS('/',extkey,nam) objnam from act where inr = #{objinr}
    </select>

    <select id="getObjByCty" resultMap="FieldMap">
        select cod objcod from cty where inr = #{objinr}
    </select>

    <select id="getObjByGid" resultMap="FieldMap">
        select ownref objextkey,CONCAT_WS('/',ownref,nam) objnam from gid where inr = #{objinr}
    </select>

    <select id="getObjByNid" resultMap="FieldMap">
        select ownref objextkey,CONCAT_WS('/',ownref,nam) objnam from nid where inr = #{objinr}
    </select>

    <select id="getObjByFec" resultMap="FieldMap">
        select fee.cod objcod,fec.feepri objextkey,fec.objinr objnam from fec,fee where fee.inr = fec.feeinr and fec.inr = #{objinr}
    </select>

    <select id="queryByRecord" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"></include>
        from oit
        <where>
            <if test="inr != null and inr != ''">
                and INR = #{inr}
            </if>
            <if test="objtyp != null and objtyp != ''">
                and OBJTYP = #{objtyp}
            </if>
            <if test="objinr != null and objinr != ''">
                and OBJINR = #{objinr}
            </if>
            <if test="subtyp != null and subtyp != ''">
                and SUBTYP = #{subtyp}
            </if>
            <if test="subbus != null and subbus != ''">
                and SUBBUS = #{subbus}
            </if>
            <if test="inflev != null and inflev != ''">
                and INFLEV = #{inflev}
            </if>
            <if test="inftxt != null and inftxt != ''">
                and INFTXT = #{inftxt}
            </if>
            <if test="ver != null and ver != ''">
                and VER = #{ver}
            </if>
            <if test="etgextkey != null and etgextkey != ''">
                and ETGEXTKEY = 'CEBGRP'
            </if>
        </where>
    </select>

    <select id="queryActList" resultMap="OitTableResultMap">
        select a.inr actinr,a.extkey actkey, a.nam actnam,a.cur actcur from act a
        left join pty y on a.HOLPTYINR  = y.inr
        where a.extkey like concat('%', #{actkey}, '%')
        <if test="bchkeyinr != null and bchkeyinr != ''">
            and y.bchkeyinr = #{bchkeyinr}
        </if>
    </select>

    <select id="queryFecList" resultMap="OitTableResultMap">
        select a.inr fecinr, b.cod feecod, c.txt objtyp, c.txt objnam, a.begdat begdat, a.enddat enddat
        from fec a
        left join fee b on a.feeinr = b.inr
        left join stb c on a.feepri = c.cod and c.tbl = 'FEEPRI' and c.uil = #{stbuil}
        where a.feepri = '!'
        <if test="feecod != null and feecod != ''">
            and b.cod  = #{feecod}
        </if>

        union all

        select a.inr fecinr,b.cod feecod, c.txt objtyp, concat(c.txt,' / ',d.COD,' ',e.txt) objnam, a.begdat begdat, a.enddat enddat
        from fec a
        left join fee b on a.feeinr = b.inr
        left join stb c on a.feepri = c.cod and c.tbl = 'FEEPRI' and c.uil = #{stbuil}
        left join reg d on a.objinr = d.inr
        left join stb e on d.cod = e.cod and e.TBL = 'REGTXT' and e.uil = #{stbuil}
        where a.feepri = '1'
        <if test="feecod != null and feecod != ''">
            and b.cod  = #{feecod}
        </if>

        union all

        select a.inr fecinr,b.cod feecod, c.txt objtyp, concat(c.txt,' / ',d.COD,' ',e.txt) objnam, a.begdat begdat, a.enddat enddat
        from fec a
        left join fee b on a.feeinr = b.inr
        left join stb c on a.feepri = c.cod and c.tbl = 'FEEPRI' and c.uil = #{stbuil}
        left join cty d on a.objinr = d.inr
        left join stb e on d.COD = e.cod and e.TBL = 'CTYTXT' and e.uil = #{stbuil}
        where a.feepri = '2'
        <if test="feecod != null and feecod != ''">
            and b.cod  = #{feecod}
        </if>

        union all

        select a.inr fecinr,b.cod feecod, c.txt objtyp,concat(c.txt,' / ',d.extkey,' ',d.nam) objnam, a.begdat begdat, a.enddat enddat
        from fec a
        left join fee b on a.feeinr = b.inr
        left join stb c on a.feepri = c.cod and c.tbl = 'FEEPRI' and c.uil = #{stbuil}
        left join pty d on a.objinr = d.inr
        where a.feepri = '4'
        <if test="feecod != null and feecod != ''">
            and b.cod  = #{feecod}
        </if>
    </select>

    <select id="queryGidList" resultMap="OitTableResultMap">
        select inr gidinr, ownref gidref, nam gidnam from gid where ownref like concat('%', #{gidref}, '%')
        <if test="bchkeyinr != null and bchkeyinr != ''">
            and bchkeyinr = #{bchkeyinr}
        </if>
    </select>

    <select id="queryNidList" resultMap="OitTableResultMap">
        select inr nidinr, ownref nidref, nam nidnam from nid where ownref like concat('%', #{nidref}, '%')
        <if test="bchkeyinr != null and bchkeyinr != ''">
            and bchkeyinr = #{bchkeyinr}
        </if>
    </select>


    <select id="queryPtyList" resultMap="OitTableResultMap">
        select
        a.inr ptyinr,
        a.extkey ptykey,
        a.nam ptynam,
        a.nam1 ptynam1
        from pty a
        where a.extkey like concat(concat ('%',#{ptykey}),'%')
        <if test="bchkeyinr != null and bchkeyinr != ''">
            and a.bchkeyinr = #{bchkeyinr}
        </if>
        order by a.extkey desc
    </select>

    <select id="queryPtaList" resultMap="OitTableResultMap">
        select
        a.inr ptainr,
        a.objkey ptakey,
        a.nam ptanam,
        a.nam1 ptanam1
        from pta a
        where a.objkey like concat(concat ('%',#{ptakey}),'%')
        <if test="bchkeyinr != null and bchkeyinr != ''">
            and a.bchkeyinr = #{bchkeyinr}
        </if>
        order by a.objkey desc
    </select>

    <select id="getStopPtyList" resultType="java.lang.String">
        select  objinr
        from  oit
        where  objtyp = 'PTY'
          and subtyp = 'STP'
          and inflev>'0'
          and objinr in (
          select  inr
          from pty
          where extkey in (
          select distinct cliextkey
          from  gle
          where  trninr in (
          select inr
          from  trn where
          relflg in ('R','F')
          <if test="begdat != null ">
              and TRN.CPLDATTIM >= #{begdat}
          </if>
          <if test="enddat != null ">
              and TRN.CPLDATTIM &lt;= #{enddat}
          </if>
          and not TRN.CPLDATTIM is null
          <if test="bchLst != null and bchLst.size() >0 and branch != '1000'.toString()">
              and TRN.BRANCHINR in
              <foreach item="bch" collection="bchLst" open="(" separator="," close=")">
                  #{bch.inr}
              </foreach>
          </if>  )))
    </select>
</mapper>