dbbmapper.xml 25.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
<?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.DbbMapper">

    <resultMap id="BaseResultMap" type="com.brilliance.isc.bo.bopdecbo.Dbb">
        <result property="inr" column="inr" jdbcType="VARCHAR" />
        <result property="tmpref" column="tmpref" jdbcType="VARCHAR" />
        <result property="ownextkey" column="ownextkey" jdbcType="VARCHAR" />
        <result property="actiontype" column="actiontype" jdbcType="VARCHAR" />
        <result property="actiondesc" column="actiondesc" jdbcType="VARCHAR" />
        <result property="rptno" column="rptno" jdbcType="VARCHAR" />
        <result property="custype" column="custype" jdbcType="VARCHAR" />
        <result property="idcode" column="idcode" jdbcType="VARCHAR" />
        <result property="custcod" column="custcod" jdbcType="VARCHAR" />
        <result property="custnm" column="custnm" jdbcType="VARCHAR" />
        <result property="oppuser" column="oppuser" jdbcType="VARCHAR" />
        <result property="txccy" column="txccy" jdbcType="VARCHAR" />
        <result property="txamt" column="txamt" jdbcType="DECIMAL" />
        <result property="exrate" column="exrate" jdbcType="DECIMAL" />
        <result property="lcyamt" column="lcyamt" jdbcType="DECIMAL" />
        <result property="lcyacc" column="lcyacc" jdbcType="VARCHAR" />
        <result property="fcyamt" column="fcyamt" jdbcType="DECIMAL" />
        <result property="fcyacc" column="fcyacc" jdbcType="VARCHAR" />
        <result property="othamt" column="othamt" jdbcType="DECIMAL" />
        <result property="othacc" column="othacc" jdbcType="VARCHAR" />
        <result property="method" column="method" jdbcType="VARCHAR" />
        <result property="buscode" column="buscode" jdbcType="VARCHAR" />
    </resultMap>

    <resultMap id="BaseResultMap2" type="com.brilliance.isc.bo.bopdecbo.Dbb">
        <result property="inr" column="inr" jdbcType="VARCHAR" />
        <result property="tmpref" column="tmpref" jdbcType="VARCHAR" />
        <result property="ownextkey" column="ownextkey" jdbcType="VARCHAR" />
        <result property="actiontype" column="actiontype" jdbcType="VARCHAR" />
        <result property="actiondesc" column="actiondesc" jdbcType="VARCHAR" />
        <result property="rptno" column="rptno" jdbcType="VARCHAR" />
        <result property="custype" column="custype" jdbcType="VARCHAR" />
        <result property="idcode" column="idcode" jdbcType="VARCHAR" />
        <result property="custcod" column="custcod" jdbcType="VARCHAR" />
        <result property="custnm" column="custnm" jdbcType="VARCHAR" />
        <result property="oppuser" column="oppuser" jdbcType="VARCHAR" />
        <result property="txccy" column="txccy" jdbcType="VARCHAR" />
        <result property="txamt" column="txamt" jdbcType="DECIMAL" />
        <result property="exrate" column="exrate" jdbcType="DECIMAL" />
        <result property="lcyamt" column="lcyamt" jdbcType="DECIMAL" />
        <result property="lcyacc" column="lcyacc" jdbcType="VARCHAR" />
        <result property="fcyamt" column="fcyamt" jdbcType="DECIMAL" />
        <result property="fcyacc" column="fcyacc" jdbcType="VARCHAR" />
        <result property="othamt" column="othamt" jdbcType="DECIMAL" />
        <result property="othacc" column="othacc" jdbcType="VARCHAR" />
        <result property="method" column="method" jdbcType="VARCHAR" />
        <result property="buscode" column="buscode" jdbcType="VARCHAR" />
        <result property="objtyp" column="objtyp" jdbcType="VARCHAR"/>
        <result property="sndflg" column="sndflg" jdbcType="VARCHAR"/>
        <result property="bassta" column="bassta" jdbcType="VARCHAR"/>
        <result property="dclsta" column="dclsta" jdbcType="VARCHAR"/>
        <result property="vrfsta" column="vrfsta" jdbcType="VARCHAR"/>
        <result property="bchnam" column="bchnam" jdbcType="VARCHAR"/>
        <result property="credat" column="credat" jdbcType="DATE"/>
        <result property="sfhdat" column="sfhdat" jdbcType="DATE"/>
        <result property="ownusr" column="ownusr" jdbcType="VARCHAR"/>
        <result property="datsrc" column="datsrc" jdbcType="VARCHAR"/>
        <result property="extinf" column="extinf" jdbcType="VARCHAR"/>
        <result property="exmandapp" column="exmandapp" jdbcType="VARCHAR"/>
    </resultMap>

    <resultMap id="BaseResultMap3" type="com.brilliance.isc.vo.bop.DbbResultVo">
        <result property="rptno" column="rptno" jdbcType="VARCHAR" />
        <result property="sndflg" column="sndflg" jdbcType="VARCHAR"/>
        <result property="bassta" column="bassta" jdbcType="VARCHAR"/>
        <result property="dclsta" column="dclsta" jdbcType="VARCHAR"/>
        <result property="vrfsta" column="vrfsta" jdbcType="VARCHAR"/>
        <result property="bchnam" column="bchnam" jdbcType="VARCHAR"/>
        <result property="credat" column="credat" jdbcType="DATE"/>
        <result property="actiontype" column="actiontype" jdbcType="VARCHAR" />
        <result property="actiondesc" column="actiondesc" jdbcType="VARCHAR" />
        <result property="custype" column="custype" jdbcType="VARCHAR" />
        <result property="idcode" column="idcode" jdbcType="VARCHAR" />
        <result property="custcod" column="custcod" jdbcType="VARCHAR" />
        <result property="custnm" column="custnm" jdbcType="VARCHAR" />
        <result property="oppuser" column="oppuser" jdbcType="VARCHAR" />
        <result property="txccy" column="txccy" jdbcType="VARCHAR" />
        <result property="txamt" column="txamt" jdbcType="DECIMAL" />
        <result property="exrate" column="exrate" jdbcType="DECIMAL" />
        <result property="lcyamt" column="lcyamt" jdbcType="DECIMAL" />
        <result property="lcyacc" column="lcyacc" jdbcType="VARCHAR" />
        <result property="fcyamt" column="fcyamt" jdbcType="DECIMAL" />
        <result property="fcyacc" column="fcyacc" jdbcType="VARCHAR" />
        <result property="othamt" column="othamt" jdbcType="DECIMAL" />
        <result property="othacc" column="othacc" jdbcType="VARCHAR" />
        <result property="method" column="method" jdbcType="VARCHAR" />
        <result property="buscode" column="buscode" jdbcType="VARCHAR" />
        <result property="dclActiontype" column="dclActiontype" jdbcType="VARCHAR" />
        <result property="dclActiondesc" column="dclActiondesc" jdbcType="VARCHAR" />
        <result property="country" column="country" jdbcType="VARCHAR" />
        <result property="paytype" column="paytype" jdbcType="VARCHAR" />
        <result property="txcode" column="txcode" jdbcType="VARCHAR" />
        <result property="tc1amt" column="tc1amt" jdbcType="DECIMAL" />
        <result property="txrem" column="txrem" jdbcType="VARCHAR" />
        <result property="txcode2" column="txcode2" jdbcType="VARCHAR" />
        <result property="tc2amt" column="tc2amt" jdbcType="DECIMAL" />
        <result property="tx2rem" column="tx2rem" jdbcType="VARCHAR" />
        <result property="isref" column="isref" jdbcType="VARCHAR" />
        <result property="crtuser" column="crtuser" jdbcType="VARCHAR" />
        <result property="inptelc" column="inptelc" jdbcType="VARCHAR" />
        <result property="rptdate" column="rptdate" jdbcType="DATE" />
        <result property="regno" column="regno" jdbcType="VARCHAR" />
        <result property="vrfActiontype" column="vrfActiontype" jdbcType="VARCHAR" />
        <result property="vrfActiondesc" column="vrfActiondesc" jdbcType="VARCHAR" />
        <result property="contrno" column="contrno" jdbcType="VARCHAR" />
        <result property="invoino" column="invoino" jdbcType="VARCHAR" />
        <result property="vrfCrtuser" column="vrfCrtuser" jdbcType="VARCHAR" />
        <result property="vrfInptelc" column="vrfInptelc" jdbcType="VARCHAR" />
        <result property="vrfRptdate" column="vrfRptdate" jdbcType="DATE" />
    </resultMap>

    <sql id="Base_Column_List">
        inr,tmpref,ownextkey,actiontype,actiondesc,rptno,custype,idcode,custcod,custnm,oppuser,txccy,txamt,exrate,lcyamt,lcyacc,fcyamt,fcyacc,othamt,othacc,method,buscode
    </sql>

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

    <select id="selectByBuscode" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from dbb
        where buscode = #{buscode,jdbcType=VARCHAR}
    </select>

    <select id="selectByCountryAndOppuser" resultType="com.brilliance.isc.vo.bop.BopdecSelectVo">
        select b.rptno,b.oppuser,h.country
        from dbl l,dbb b
        left join dbh h on h.tmpref = b.inr
        left join dbn n on b.inr = n.tmpref
        where
        b.inr = l.objinr
        and l.curflg = "*"
        and l.objtyp = "dbb"
        and h.country is not null
        and h.country != #{country}
        and upper(trim(b.oppuser)) = #{oppuser}
        and l.credat > curdate()-interval '1' year
        order by l.credat DESC
    </select>

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

    <insert id="insert">
        insert into dbb (<include refid="Base_Column_List" />)
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            #{inr,jdbcType=VARCHAR},
            #{tmpref,jdbcType=VARCHAR},
            #{ownextkey,jdbcType=VARCHAR},
            #{actiontype,jdbcType=VARCHAR},
            #{actiondesc,jdbcType=VARCHAR},
            #{rptno,jdbcType=VARCHAR},
            #{custype,jdbcType=VARCHAR},
            #{idcode,jdbcType=VARCHAR},
            #{custcod,jdbcType=VARCHAR},
            #{custnm,jdbcType=VARCHAR},
            #{oppuser,jdbcType=VARCHAR},
            #{txccy,jdbcType=VARCHAR},
            #{txamt,jdbcType=DECIMAL},
            #{exrate,jdbcType=DECIMAL},
            #{lcyamt,jdbcType=DECIMAL},
            #{lcyacc,jdbcType=VARCHAR},
            #{fcyamt,jdbcType=DECIMAL},
            #{fcyacc,jdbcType=VARCHAR},
            #{othamt,jdbcType=DECIMAL},
            #{othacc,jdbcType=VARCHAR},
            #{method,jdbcType=VARCHAR},
            #{buscode,jdbcType=VARCHAR},
        </trim>
    </insert>

    <insert id="insertSelective">
        insert into dbb
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="inr != null">inr,</if>
            <if test="tmpref != null">tmpref,</if>
            <if test="ownextkey != null">ownextkey,</if>
            <if test="actiontype != null">actiontype,</if>
            <if test="actiondesc != null">actiondesc,</if>
            <if test="rptno != null">rptno,</if>
            <if test="custype != null">custype,</if>
            <if test="idcode != null">idcode,</if>
            <if test="custcod != null">custcod,</if>
            <if test="custnm != null">custnm,</if>
            <if test="oppuser != null">oppuser,</if>
            <if test="txccy != null">txccy,</if>
            <if test="txamt != null">txamt,</if>
            <if test="exrate != null">exrate,</if>
            <if test="lcyamt != null">lcyamt,</if>
            <if test="lcyacc != null">lcyacc,</if>
            <if test="fcyamt != null">fcyamt,</if>
            <if test="fcyacc != null">fcyacc,</if>
            <if test="othamt != null">othamt,</if>
            <if test="othacc != null">othacc,</if>
            <if test="method != null">method,</if>
            <if test="buscode != null">buscode,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="inr != null">#{inr,jdbcType=VARCHAR}, </if>
            <if test="tmpref != null">#{tmpref,jdbcType=VARCHAR}, </if>
            <if test="ownextkey != null">#{ownextkey,jdbcType=VARCHAR}, </if>
            <if test="actiontype != null">#{actiontype,jdbcType=VARCHAR}, </if>
            <if test="actiondesc != null">#{actiondesc,jdbcType=VARCHAR}, </if>
            <if test="rptno != null">#{rptno,jdbcType=VARCHAR}, </if>
            <if test="custype != null">#{custype,jdbcType=VARCHAR}, </if>
            <if test="idcode != null">#{idcode,jdbcType=VARCHAR}, </if>
            <if test="custcod != null">#{custcod,jdbcType=VARCHAR}, </if>
            <if test="custnm != null">#{custnm,jdbcType=VARCHAR}, </if>
            <if test="oppuser != null">#{oppuser,jdbcType=VARCHAR}, </if>
            <if test="txccy != null">#{txccy,jdbcType=VARCHAR}, </if>
            <if test="txamt != null">#{txamt,jdbcType=DECIMAL}, </if>
            <if test="exrate != null">#{exrate,jdbcType=DECIMAL}, </if>
            <if test="lcyamt != null">#{lcyamt,jdbcType=DECIMAL}, </if>
            <if test="lcyacc != null">#{lcyacc,jdbcType=VARCHAR}, </if>
            <if test="fcyamt != null">#{fcyamt,jdbcType=DECIMAL}, </if>
            <if test="fcyacc != null">#{fcyacc,jdbcType=VARCHAR}, </if>
            <if test="othamt != null">#{othamt,jdbcType=DECIMAL}, </if>
            <if test="othacc != null">#{othacc,jdbcType=VARCHAR}, </if>
            <if test="method != null">#{method,jdbcType=VARCHAR}, </if>
            <if test="buscode != null">#{buscode,jdbcType=VARCHAR}, </if>
        </trim>
    </insert>

    <update id="updateByPrimaryKeySelective">
        update dbb
        <set>
            <if test="tmpref != null">tmpref = #{tmpref,jdbcType=VARCHAR},</if>
            <if test="ownextkey != null">ownextkey = #{ownextkey,jdbcType=VARCHAR},</if>
            <if test="actiontype != null">actiontype = #{actiontype,jdbcType=VARCHAR},</if>
            <if test="actiondesc != null">actiondesc = #{actiondesc,jdbcType=VARCHAR},</if>
            <if test="rptno != null">rptno = #{rptno,jdbcType=VARCHAR},</if>
            <if test="custype != null">custype = #{custype,jdbcType=VARCHAR},</if>
            <if test="idcode != null">idcode = #{idcode,jdbcType=VARCHAR},</if>
            <if test="custcod != null">custcod = #{custcod,jdbcType=VARCHAR},</if>
            <if test="custnm != null">custnm = #{custnm,jdbcType=VARCHAR},</if>
            <if test="oppuser != null">oppuser = #{oppuser,jdbcType=VARCHAR},</if>
            <if test="txccy != null">txccy = #{txccy,jdbcType=VARCHAR},</if>
            <if test="txamt != null">txamt = #{txamt,jdbcType=DECIMAL},</if>
            <if test="exrate != null">exrate = #{exrate,jdbcType=DECIMAL},</if>
            <if test="lcyamt != null">lcyamt = #{lcyamt,jdbcType=DECIMAL},</if>
            <if test="lcyacc != null">lcyacc = #{lcyacc,jdbcType=VARCHAR},</if>
            <if test="fcyamt != null">fcyamt = #{fcyamt,jdbcType=DECIMAL},</if>
            <if test="fcyacc != null">fcyacc = #{fcyacc,jdbcType=VARCHAR},</if>
            <if test="othamt != null">othamt = #{othamt,jdbcType=DECIMAL},</if>
            <if test="othacc != null">othacc = #{othacc,jdbcType=VARCHAR},</if>
            <if test="method != null">method = #{method,jdbcType=VARCHAR},</if>
            <if test="buscode != null">buscode = #{buscode,jdbcType=VARCHAR},</if>
        </set>
        where inr = #{inr,jdbcType=VARCHAR}
    </update>

    <update id="updateByPrimaryKey">
        update dbb
        <set>
            tmpref = #{tmpref,jdbcType=VARCHAR},
            ownextkey = #{ownextkey,jdbcType=VARCHAR},
            actiontype = #{actiontype,jdbcType=VARCHAR},
            actiondesc = #{actiondesc,jdbcType=VARCHAR},
            rptno = #{rptno,jdbcType=VARCHAR},
            custype = #{custype,jdbcType=VARCHAR},
            idcode = #{idcode,jdbcType=VARCHAR},
            custcod = #{custcod,jdbcType=VARCHAR},
            custnm = #{custnm,jdbcType=VARCHAR},
            oppuser = #{oppuser,jdbcType=VARCHAR},
            txccy = #{txccy,jdbcType=VARCHAR},
            txamt = #{txamt,jdbcType=DECIMAL},
            exrate = #{exrate,jdbcType=DECIMAL},
            lcyamt = #{lcyamt,jdbcType=DECIMAL},
            lcyacc = #{lcyacc,jdbcType=VARCHAR},
            fcyamt = #{fcyamt,jdbcType=DECIMAL},
            fcyacc = #{fcyacc,jdbcType=VARCHAR},
            othamt = #{othamt,jdbcType=DECIMAL},
            othacc = #{othacc,jdbcType=VARCHAR},
            method = #{method,jdbcType=VARCHAR},
            buscode = #{buscode,jdbcType=VARCHAR},
        </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>

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

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

    <select id="selectByArgmodVo" resultMap="BaseResultMap2">
        select
        m2.inr,m2.tmpref,m2.ownextkey,m2.actiontype,m2.actiondesc,m2.rptno,m2.custype,m2.idcode,m2.custcod,m2.custnm,m2.oppuser,m2.txccy,m2.txamt,m2.exrate,m2.lcyamt,m2.lcyacc,m2.fcyamt,m2.fcyacc,m2.othamt,m2.othacc,m2.method,m2.buscode
        ,
        m1.objtyp,m1.sndflg,m1.bassta,m1.dclsta,m1.vrfsta,concat(m3.branch,m3.bchname) as bchnam,m1.reldat as credat,m1.sfhdat,m1.ownusr,m1.datsrc,m1.extinf,m1.exmandapp
312
        from dbl m1,dbb m2,bch m3 WHERE m1.objtyp='DBB' and m1.objinr=m2.inr and m1.ownextkey=m3.branch and (m1.trninr is null or m1.trninr = '')
hulei committed
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
        <!--只查询出最新数据 -->
        and m1.curflg='*'

        <!--申报主体名称 -->
        <if test="custnm != null and custnm != ''">
            and  m2.custnm LIKE concat('%', #{custnm}, '%')
        </if>
        <!--业务号码 -->
        <if test="extinfbop != null and extinfbop != ''">
            and  m2.buscode LIKE concat('%', #{extinfbop}, '%')
        </if>
        <!--账号 -->
        <if test="rptno != null and rptno != ''">
            and  m2.rptno LIKE concat('%', #{rptno}, '%')
        </if>

        <if test="branchInrs != null and branchInrs.size() >0 ">
            and (
            m1.ownextkey in
            <foreach item="branchinr" collection="branchInrs" open="(" separator="," close=")">
                #{branchinr}
            </foreach>
            or m1.ownextkey is null
            )
        </if>

        <if test="selectdat == 'B'.toString() ">
            <!--经办起始时间 -->
            <if test="ywcredat != null" >
                and  m1.reldat >=  #{ywcredat}
            </if>
            <if test="ywtildat != null" >
                and  m1.reldat &lt;=  #{ywtildat}
            </if>
        </if>


        <if test="selectdat == 'A'.toString() ">
            <!--业务起始时间 -->
            <if test="ywcredat != null" >
                and  m1.sfhdat >=  #{ywcredat}
            </if>
            <if test="ywtildat != null" >
                and  m1.sfhdat &lt;=  #{ywtildat}
            </if>
        </if>

        <!--数据来源 -->
        <if test="datsrc != null and datsrc != ''">
            and  m1.datsrc = #{datsrc}
        </if>
        <!--数据状态查询条件 -->
        <if test="selsta != null and selsta != ''">
            <choose>
                <!--如果是待确认,则查找待确认数据 -->
                <when test="selsta == 'Q'.toString()">
                    and m1.sndflg = 'W'
                </when>
                <!--如果是D,基础操作类型为删除 -->
                <when test="selsta == 'D'.toString()">
                    and m2.actiontype = 'D'
                </when>
                <otherwise>
                    and (
                    <!--基础状态 -->
                    m1.bassta = #{selsta}
                    or
                    <!--申报状态 -->
                    m1.dclsta = #{selsta}
                    or
                    <!--管理状态 -->
                    m1.vrfsta = #{selsta}
                    )
                </otherwise>
            </choose>
        </if>
        <!--收入款币种 -->
        <if test="txccy != null and txccy != ''">
            and m2.txccy=#{txccy}
        </if>

        <!--收入款币种 -->
        <if test="usr != null and usr != ''">
            and m1.ownusr LIKE  concat('%', #{usr}, '%')
        </if>
        <!--机构号 -->
        <if test="branch != null and branch != ''">
            and m3.branch LIKE  concat('%', #{branch}, '%')
        </if>
        <!--组织机构代码 -->
        <if test="custcod != null and custcod != ''">
            and m2.custcod LIKE  concat('%', #{custcod}, '%')
        </if>
        <!--金融机构标识号 -->
        <if test="bchcod != null and bchcod != ''">
            and m3.decnum LIKE  concat('%', #{bchcod}, '%')
        </if>
        union select
        m2.inr,m2.tmpref,m2.ownextkey,m2.actiontype,m2.actiondesc,m2.rptno,m2.custype,m2.idcode,m2.custcod,m2.custnm,m2.oppuser,m2.txccy,m2.txamt,m2.exrate,m2.lcyamt,m2.lcyacc,m2.fcyamt,m2.fcyacc,m2.othamt,m2.othacc,m2.method,m2.buscode
        ,
        m1.objtyp,m1.sndflg,m1.bassta,m1.dclsta,m1.vrfsta,concat(m3.branch,m3.bchname) as bchnam,m1.reldat as credat,m1.sfhdat,m1.ownusr,m1.datsrc,m1.extinf,m1.exmandapp
        from dbl m1,dbb m2,bch m3,trn m4 WHERE m1.objtyp='dbb' and m1.objinr=m2.inr and m1.ownextkey=m3.branch and m1.trninr = m4.inr and m4.relflg = 'R'
        <!--只查询出最新数据 -->
        and m1.curflg='*'

        <!--申报主体名称 -->
        <if test="custnm != null and custnm != ''">
            and  m2.custnm LIKE concat('%', #{custnm}, '%')
        </if>
        <!--业务号码 -->
        <if test="extinfbop != null and extinfbop != ''">
            and  m2.buscode LIKE concat('%', #{extinfbop}, '%')
        </if>
        <!--账号 -->
        <if test="rptno != null and rptno != ''">
            and  m2.rptno LIKE concat('%', #{rptno}, '%')
        </if>

        <if test="branchInrs != null and branchInrs.size() >0 ">
            and (
            m1.ownextkey in
            <foreach item="branchinr" collection="branchInrs" open="(" separator="," close=")">
                #{branchinr}
            </foreach>
            or m1.ownextkey is null
            )
        </if>

        <if test="selectdat == 'B'.toString() ">
            <!--经办起始时间 -->
            <if test="ywcredat != null" >
                and  m1.reldat >=  #{ywcredat}
            </if>
            <if test="ywtildat != null" >
                and  m1.reldat &lt;=  #{ywtildat}
            </if>
        </if>


        <if test="selectdat == 'A'.toString() ">
            <!--业务起始时间 -->
            <if test="ywcredat != null" >
                and  m1.sfhdat >=  #{ywcredat}
            </if>
            <if test="ywtildat != null" >
                and  m1.sfhdat &lt;=  #{ywtildat}
            </if>
        </if>

        <!--数据来源 -->
        <if test="datsrc != null and datsrc != ''">
            and  m1.datsrc = #{datsrc}
        </if>
        <!--数据状态查询条件 -->
        <if test="selsta != null and selsta != ''">
            <choose>
                <!--如果是待确认,则查找待确认数据 -->
                <when test="selsta == 'Q'.toString()">
                    and m1.sndflg = 'W'
                </when>
                <!--如果是D,基础操作类型为删除 -->
                <when test="selsta == 'D'.toString()">
                    and m2.actiontype = 'D'
                </when>
                <otherwise>
                    and (
                    <!--基础状态 -->
                    m1.bassta = #{selsta}
                    or
                    <!--申报状态 -->
                    m1.dclsta = #{selsta}
                    or
                    <!--管理状态 -->
                    m1.vrfsta = #{selsta}
                    )
                </otherwise>
            </choose>
        </if>
        <!--收入款币种 -->
        <if test="txccy != null and txccy != ''">
            and m2.txccy=#{txccy}
        </if>

        <!--收入款币种 -->
        <if test="usr != null and usr != ''">
            and m1.ownusr LIKE  concat('%', #{usr}, '%')
        </if>
        <!--机构号 -->
        <if test="branch != null and branch != ''">
            and m3.branch LIKE  concat('%', #{branch}, '%')
        </if>
        <!--组织机构代码 -->
        <if test="custcod != null and custcod != ''">
            and m2.custcod LIKE  concat('%', #{custcod}, '%')
        </if>
        <!--金融机构标识号 -->
        <if test="bchcod != null and bchcod != ''">
            and m3.decnum LIKE  concat('%', #{bchcod}, '%')
        </if>
        order by sfhdat DESC, credat DESC
    </select>

    <select id="selectByBasInrs" resultMap="BaseResultMap3">
        select m2.rptno,m1.sndflg,m1.bassta,m1.dclsta,m1.vrfsta,concat(m5.branch,m5.bchname) as bchnam,m1.reldat as credat,
        m2.actiontype,m2.actiondesc,m2.custype,m2.idcode,m2.custcod,m2.custnm,m2.oppuser,m2.txccy,m2.txamt,m2.exrate,m2.lcyamt,m2.lcyacc,m2.fcyamt,m2.fcyacc,m2.othamt,m2.othacc,m2.method,m2.buscode,
        m3.actiontype as dclActiontype,m3.actiondesc as dclActiondesc, m3.country,m3.paytype,m3.txcode,m3.tc1amt,m3.txrem,m3.txcode2,m3.tc2amt,m3.tx2rem,m3.isref,m3.crtuser,m3.inptelc,m3.rptdate,m3.regno,
        m4.actiontype as vrfActiontype,m4.actiondesc as vrfActiondesc,m4.contrno,m4.invoino,m4.crtuser as vrfCrtuser,m4.inptelc as vrfInptelc,m4.rptdate as vrfRptdate
        from dbl m1,bch m5, dbb m2
        left join dbh m3 on m2.inr=m3.TMPREF and m2.RPTNO =m3.RPTNO
        left join dbn m4 on m2.inr=m4.TMPREF and m2.RPTNO =m4.RPTNO
        where m1.OBJTYP ='dbb' and m1.OBJINR =m2.inr and m1.ownextkey=m5.branch and m1.bassta != 'G' and m1.curflg='*'
        <if test="basInrs != null and basInrs.size() >0 ">
            and (
            m2.inr in
            <foreach item="basInr" collection="basInrs" open="(" separator="," close=")">
                #{basInr}
            </foreach>
            )
        </if>
        order by m1.sfhdat DESC, credat DESC
    </select>

</mapper>