mcdmapper.xml 14.7 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
<?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.McdMapper">

    <resultMap id="BaseResultMap" type="com.brilliance.isc.bo.Mcd">
        <result property="inr" column="inr" jdbcType="VARCHAR"/>
        <result property="ownref" column="ownref" jdbcType="VARCHAR"/>
        <result property="nam" column="nam" jdbcType="VARCHAR"/>
        <result property="ownusr" column="ownusr" jdbcType="VARCHAR"/>
        <result property="credat" column="credat" jdbcType="DATE"/>
        <result property="opndat" column="opndat" jdbcType="DATE"/>
        <result property="clsdat" column="clsdat" jdbcType="DATE"/>
        <result property="expdat" column="expdat" jdbcType="DATE"/>
        <result property="orddat" column="orddat" jdbcType="DATE"/>
        <result property="aderef" column="aderef" jdbcType="VARCHAR"/>
        <result property="aplref" column="aplref" jdbcType="VARCHAR"/>
        <result property="ver" column="ver" jdbcType="VARCHAR"/>
        <result property="stacty" column="stacty" jdbcType="VARCHAR"/>
        <result property="etyextkey" column="etyextkey" jdbcType="VARCHAR"/>
        <result property="branchinr" column="branchinr" jdbcType="VARCHAR"/>
        <result property="bchkeyinr" column="bchkeyinr" jdbcType="VARCHAR"/>
        <result property="mcttyp" column="mcttyp" jdbcType="VARCHAR"/>
        <result property="subref" column="subref" jdbcType="VARCHAR"/>
    </resultMap>

    <sql id="Base_Column_List">
        inr,ownref,nam,ownusr,credat,opndat,clsdat,expdat,orddat,aderef,aplref,ver,stacty,etyextkey,branchinr,bchkeyinr,mcttyp,subref
    </sql>

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

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

    <insert id="insert">
        insert into mcd (<include refid="Base_Column_List" />)
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            #{inr,jdbcType=VARCHAR},
            #{ownref,jdbcType=VARCHAR},
            #{nam,jdbcType=VARCHAR},
            #{ownusr,jdbcType=VARCHAR},
            #{credat,jdbcType=DATE},
            #{opndat,jdbcType=DATE},
            #{clsdat,jdbcType=DATE},
            #{expdat,jdbcType=DATE},
            #{orddat,jdbcType=DATE},
            #{aderef,jdbcType=VARCHAR},
            #{aplref,jdbcType=VARCHAR},
            #{ver,jdbcType=VARCHAR},
            #{stacty,jdbcType=VARCHAR},
            #{etyextkey,jdbcType=VARCHAR},
            #{branchinr,jdbcType=VARCHAR},
            #{bchkeyinr,jdbcType=VARCHAR},
            #{mcttyp,jdbcType=VARCHAR},
            #{subref,jdbcType=VARCHAR},
        </trim>
    </insert>

    <insert id="insertSelective">
        insert into mcd
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="inr != null">inr,</if>
            <if test="ownref != null">ownref,</if>
            <if test="nam != null">nam,</if>
            <if test="ownusr != null">ownusr,</if>
            <if test="credat != null">credat,</if>
            <if test="opndat != null">opndat,</if>
            <if test="clsdat != null">clsdat,</if>
            <if test="expdat != null">expdat,</if>
            <if test="orddat != null">orddat,</if>
            <if test="aderef != null">aderef,</if>
            <if test="aplref != null">aplref,</if>
            <if test="ver != null">ver,</if>
            <if test="stacty != null">stacty,</if>
            <if test="etyextkey != null">etyextkey,</if>
            <if test="branchinr != null">branchinr,</if>
            <if test="bchkeyinr != null">bchkeyinr,</if>
            <if test="mcttyp != null">mcttyp,</if>
            <if test="subref != null">subref,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="inr != null">#{inr,jdbcType=VARCHAR}, </if>
            <if test="ownref != null">#{ownref,jdbcType=VARCHAR}, </if>
            <if test="nam != null">#{nam,jdbcType=VARCHAR}, </if>
            <if test="ownusr != null">#{ownusr,jdbcType=VARCHAR}, </if>
            <if test="credat != null">#{credat,jdbcType=DATE}, </if>
            <if test="opndat != null">#{opndat,jdbcType=DATE}, </if>
            <if test="clsdat != null">#{clsdat,jdbcType=DATE}, </if>
            <if test="expdat != null">#{expdat,jdbcType=DATE}, </if>
            <if test="orddat != null">#{orddat,jdbcType=DATE}, </if>
            <if test="aderef != null">#{aderef,jdbcType=VARCHAR}, </if>
            <if test="aplref != null">#{aplref,jdbcType=VARCHAR}, </if>
            <if test="ver != null">#{ver,jdbcType=VARCHAR}, </if>
            <if test="stacty != null">#{stacty,jdbcType=VARCHAR}, </if>
            <if test="etyextkey != null">#{etyextkey,jdbcType=VARCHAR}, </if>
            <if test="branchinr != null">#{branchinr,jdbcType=VARCHAR}, </if>
            <if test="bchkeyinr != null">#{bchkeyinr,jdbcType=VARCHAR}, </if>
            <if test="mcttyp != null">#{mcttyp,jdbcType=VARCHAR}, </if>
            <if test="subref != null">#{subref,jdbcType=VARCHAR}, </if>
        </trim>
    </insert>

    <update id="updateByPrimaryKeySelective">
        update mcd
        <set>
            <if test="ownref != null">ownref = #{ownref,jdbcType=VARCHAR},</if>
            <if test="nam != null">nam = #{nam,jdbcType=VARCHAR},</if>
            <if test="ownusr != null">ownusr = #{ownusr,jdbcType=VARCHAR},</if>
            <if test="credat != null">credat = #{credat,jdbcType=DATE},</if>
            <if test="opndat != null">opndat = #{opndat,jdbcType=DATE},</if>
            <if test="clsdat != null">clsdat = #{clsdat,jdbcType=DATE},</if>
            <if test="expdat != null">expdat = #{expdat,jdbcType=DATE},</if>
            <if test="orddat != null">orddat = #{orddat,jdbcType=DATE},</if>
            <if test="aderef != null">aderef = #{aderef,jdbcType=VARCHAR},</if>
            <if test="aplref != null">aplref = #{aplref,jdbcType=VARCHAR},</if>
            <if test="ver != null">ver = #{ver,jdbcType=VARCHAR},</if>
            <if test="stacty != null">stacty = #{stacty,jdbcType=VARCHAR},</if>
            <if test="etyextkey != null">etyextkey = #{etyextkey,jdbcType=VARCHAR},</if>
            <if test="branchinr != null">branchinr = #{branchinr,jdbcType=VARCHAR},</if>
            <if test="bchkeyinr != null">bchkeyinr = #{bchkeyinr,jdbcType=VARCHAR},</if>
            <if test="mcttyp != null">mcttyp = #{mcttyp,jdbcType=VARCHAR},</if>
            <if test="subref != null">subref = #{subref,jdbcType=VARCHAR},</if>
        </set>
        where inr = #{inr,jdbcType=VARCHAR}
    </update>

    <update id="updateByPrimaryKey">
        update mcd
        <set>
            ownref = #{ownref,jdbcType=VARCHAR},
            nam = #{nam,jdbcType=VARCHAR},
            ownusr = #{ownusr,jdbcType=VARCHAR},
            credat = #{credat,jdbcType=DATE},
            opndat = #{opndat,jdbcType=DATE},
            clsdat = #{clsdat,jdbcType=DATE},
            expdat = #{expdat,jdbcType=DATE},
            orddat = #{orddat,jdbcType=DATE},
            aderef = #{aderef,jdbcType=VARCHAR},
            aplref = #{aplref,jdbcType=VARCHAR},
            ver = #{ver,jdbcType=VARCHAR},
            stacty = #{stacty,jdbcType=VARCHAR},
            etyextkey = #{etyextkey,jdbcType=VARCHAR},
            branchinr = #{branchinr,jdbcType=VARCHAR},
            bchkeyinr = #{bchkeyinr,jdbcType=VARCHAR},
            mcttyp = #{mcttyp,jdbcType=VARCHAR},
            subref = #{subref,jdbcType=VARCHAR},
        </set>
        where inr = #{inr,jdbcType=VARCHAR}
    </update>

    <select id="queryMcd" resultType="com.brilliance.isc.vo.component.mcd.McdWithPtsCbbResponseVo">
        select
        mcd.*,
        cbb.cur cur, cbb.amt amt,pts.extkey adeExtkey,pts.nam adeName
        from mcd
        left join cbb on cbb.OBJINR = mcd.inr and cbb.OBJTYP = 'MCD'  and cbb.cbc = 'MAXSUM' and cbb.extid = 'AMT1' and cbb.enddat = '2299-12-31'
        left join pts on pts.OBJINR = mcd.inr and pts.OBJTYP = 'MCD' and pts.rol = 'ADE'
        where 1 = 1
        <!--机构隔离-->
        <if test="bchinr != null and bchinr != '' ">
            AND mcd.bchkeyinr = #{bchinr}
        </if>
        <!--业务编号-->
        <if test="seaownref != null and seaownref != ''">
            AND UPPER(mcd.OWNREF) LIKE concat(concat('%', UPPER(#{seaownref})), '%')
        </if>
        <!--日期-->
        <if test="opndatfrom != null and opndatfrom != ''">
            AND mcd.CREDAT &gt;= #{opndatfrom}
        </if>
        <if test="opndatto != null and opndatto != ''">
            AND mcd.CREDAT &lt;= #{opndatto}
        </if>
        <!--客户号/名称 -->
        <if test="searef != null and searef != ''">
            and exists (
            select 1 from PTS,PTY
            where mcd.INR = PTS.OBJINR
            AND PTY.INR = PTS.PTYINR
            AND PTS.OBJTYP = 'MCD'
            AND PTS.ROL = 'ADE'
            AND (
            PTS.EXTKEY LIKE concat(concat('%', #{searef}), '%')
            or PTS.NAM LIKE concat(concat('%', #{searef}), '%')
            or PTS.CNNAM LIKE concat(concat('%', #{searef}), '%')
            or PTS.ENNAM LIKE concat(concat('%', #{searef}), '%')
            or PTY.NAM LIKE concat(concat('%', #{searef}), '%')
            )
            )
        </if>
        <!--是否闭卷 -->
        <if test="isClosed != null and isClosed != ''">
            <if test="isClosed == 'Y'.toString()">
                and mcd.clsdat is not null
            </if>
            <if test="isClosed == 'N'.toString()">
                and mcd.clsdat is  null
            </if>
        </if>
        order by mcd.CREDAT desc , mcd.ownref desc
    </select>

    <select id="selectByOwnrefAndBchkeyinr" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from mcd
        where ownref = #{ownref,jdbcType=VARCHAR} and bchkeyinr = #{bchkeyinr,jdbcType=VARCHAR}
    </select>

    <select id="queryMcdInfo" resultType="com.brilliance.isc.vo.component.mcd.McdWithPtsCbbResponseVo">
        select
        mcd.*,bch.BCHNAME bchName,usr.NAM usrNam,
        max1.cur cur, case when max2.amt is not null then (max1.amt + max2.amt ) else max1.amt end amt,
        opn1.cur opncur,case when opn2.amt is not null then (opn1.amt + opn2.amt) else opn1.amt end opnamt,
        apl.extkey aplExtkey,apl.nam aplName,ade.EXTKEY adeExtkey,ade.nam adeName
        from mcd
        left join cbb max1 on max1.OBJINR = mcd.inr and max1.OBJTYP = 'MCD' and max1.cbc = 'MAXSUM' and max1.extid =
        'AMT1' and max1.enddat = '2299-12-31'
        left join cbb max2 on max2.OBJINR = mcd.inr and max2.OBJTYP = 'MCD' and max2.cbc = 'MAXSUM' and max2.extid =
        'AMT2' and max2.enddat = '2299-12-31'
        left join cbb opn1 on opn1.OBJINR = mcd.inr and opn1.OBJTYP = 'MCD' and opn1.cbc = 'OPN' and opn1.extid = 'AMT1'
        and opn1.enddat = '2299-12-31'
        left join cbb opn2 on opn2.OBJINR = mcd.inr and opn2.OBJTYP = 'MCD' and opn2.cbc = 'OPN' and opn2.extid = 'AMT2'
        and opn2.enddat = '2299-12-31'
        left join pts apl on apl.OBJINR = mcd.inr and apl.OBJTYP = 'MCD' and apl.rol = 'APL'
        left join pts ade on ade.OBJINR = mcd.inr and ade.OBJTYP = 'MCD' and ade.rol = 'ADE'
        left join bch bch on bch.inr = mcd.BCHKEYINR
        left join usr usr on usr.EXTKEY = mcd.OWNUSR
        where mcd.flwsta = 'R'
        <!--机构隔离-->
        <if test="bchinr != null and bchinr != '' ">
            AND mcd.bchkeyinr = #{bchinr}
        </if>
        <!--业务编号-->
        <if test="seaownref != null and seaownref != ''">
            AND UPPER(mcd.OWNREF) LIKE concat(concat('%', UPPER(#{seaownref})), '%')
        </if>
        <!--日期-->
        <if test="opndatfrom != null and opndatfrom != ''">
            AND mcd.CREDAT &gt;= #{opndatfrom}
        </if>
        <if test="opndatto != null and opndatto != ''">
            AND mcd.CREDAT &lt;= #{opndatto}
        </if>
        <!--客户号/名称 -->
        <if test="ptyExtkey != null and ptyExtkey != ''">
            and exists (
            select 1 from PTS
            where mcd.INR = PTS.OBJINR
            AND PTS.OBJTYP = 'MCD'
            AND (
            PTS.EXTKEY LIKE concat(concat('%', #{ptyExtkey}), '%')
            or PTS.NAM LIKE concat(concat('%', #{ptyExtkey}), '%')
            or PTS.CNNAM LIKE concat(concat('%', #{ptyExtkey}), '%')
            or PTS.ENNAM LIKE concat(concat('%', #{ptyExtkey}), '%')
            )
            )
        </if>
        <!--当事人BIC/名称 -->
        <if test="seapty != null and seapty != ''">
            and exists (
            select 1 from PTS,PTA
            where mcd.INR = PTS.OBJINR
            AND PTS.OBJTYP = 'MCD'
            AND PTA.INR = PTS.PTAINR
            AND (
            PTA.PTYEXTKEY LIKE concat(concat('%', #{seapty}), '%')
            or PTA.NAM LIKE concat(concat('%', #{seapty}), '%')
            or PTA.BIC LIKE concat(concat('%', #{seapty}), '%')
            )
            )
        </if>
        <!--当事人参考号 -->
        <if test="searef != null and searef != ''">
            and exists (
            select 1 from PTS
            where mcd.INR = PTS.OBJINR
            AND PTS.OBJTYP = 'MCD'
            AND
            PTS.REF LIKE concat(concat('%', #{searef}), '%')
            )
        </if>
        <!-- 币种以及金额-->
        <if test="seacur != null and seacur != ''">
            AND EXISTS (
            select 1 from CBB INFCONCBS where
            UPPER(INFCONCBS.CUR ) = UPPER(#{seacur})
            <if test="seaamtfr != null and seaamtfr != ''">
                AND INFCONCBS.AMT >= #{seaamtfr}
            </if>
            <if test="seaamtto != null and seaamtto != ''">
                AND INFCONCBS.AMT &lt;= #{seaamtto}
            </if>
            AND (INFCONCBS.OBJTYP = 'MCD'
            AND INFCONCBS.OBJINR = MCD.INR
            AND (INFCONCBS.BEGDAT &lt;= STR_TO_DATE('2299-12-30', '%Y-%m-%d')
            AND INFCONCBS.ENDDAT &gt; STR_TO_DATE('2299-12-30', '%Y-%m-%d'))
            AND INFCONCBS.EXTID IN (' ', 'AMT1')
            AND INFCONCBS.CBC IN ('MAXSUM', 'PRESUM', 'NOMSUM', 'OPN'))
            )
        </if>

        <!--业务状态  -->
        <if test="seasta != null and seasta != ''">
            <if test="seasta == 'C'.toString()">
                and mcd.clsdat is not null
            </if>
            <if test="seasta == 'O'.toString()">
                and mcd.clsdat is null
            </if>
        </if>

        <if test='column != null and column!="" '>
            order by  ${column}  ${order}
        </if>
        <if test='column == null or column=="" '>
            order by mcd.opndat desc , mcd.ownref desc
        </if>
    </select>
</mapper>