<?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.BfdMapper">

    <resultMap id="BaseResultMap" type="com.brilliance.isc.bo.Bfd">
        <result property="inr" column="inr" jdbcType="VARCHAR"/>
        <result property="ownref" column="ownref" jdbcType="VARCHAR"/>
        <result property="nam" column="nam" jdbcType="VARCHAR"/>
        <result property="pnttyp" column="pnttyp" jdbcType="VARCHAR"/>
        <result property="pntinr" column="pntinr" jdbcType="VARCHAR"/>
        <result property="predat" column="predat" jdbcType="DATE"/>
        <result property="rcvdat" column="rcvdat" jdbcType="DATE"/>
        <result property="shpdat" column="shpdat" jdbcType="DATE"/>
        <result property="advdat" column="advdat" jdbcType="DATE"/>
        <result property="matdat" column="matdat" jdbcType="DATE"/>
        <result property="doctypcod" column="doctypcod" jdbcType="VARCHAR"/>
        <result property="opndat" column="opndat" jdbcType="DATE"/>
        <result property="clsdat" column="clsdat" jdbcType="DATE"/>
        <result property="credat" column="credat" jdbcType="DATE"/>
        <result property="ownusr" column="ownusr" jdbcType="VARCHAR"/>
        <result property="ver" column="ver" jdbcType="VARCHAR"/>
        <result property="approvcod" column="approvcod" jdbcType="VARCHAR"/>
        <result property="frepayflg" column="frepayflg" jdbcType="VARCHAR"/>
        <result property="docprbrol" column="docprbrol" jdbcType="VARCHAR"/>
        <result property="payrol" column="payrol" jdbcType="VARCHAR"/>
        <result property="orddat" column="orddat" jdbcType="DATE"/>
        <result property="mattxtflg" column="mattxtflg" jdbcType="VARCHAR"/>
        <result property="dscinsflg" column="dscinsflg" jdbcType="VARCHAR"/>
        <result property="acpnowflg" column="acpnowflg" jdbcType="VARCHAR"/>
        <result property="advtyp" column="advtyp" jdbcType="VARCHAR"/>
        <result property="disdat" column="disdat" jdbcType="DATE"/>
        <result property="totcur" column="totcur" jdbcType="VARCHAR"/>
        <result property="totamt" column="totamt" jdbcType="DECIMAL"/>
        <result property="totdat" column="totdat" jdbcType="DATE"/>
        <result property="docsta" column="docsta" jdbcType="VARCHAR"/>
        <result property="docrol" column="docrol" jdbcType="VARCHAR"/>
        <result property="docrolflg" column="docrolflg" jdbcType="VARCHAR"/>
        <result property="dta770snd" column="dta770snd" jdbcType="DATE"/>
        <result property="advdocflg" column="advdocflg" jdbcType="VARCHAR"/>
        <result property="etyextkey" column="etyextkey" jdbcType="VARCHAR"/>
        <result property="rmbrol" column="rmbrol" jdbcType="VARCHAR"/>
        <result property="lescom" column="lescom" jdbcType="DECIMAL"/>
        <result property="bchkeyinr" column="bchkeyinr" jdbcType="VARCHAR"/>
        <result property="branchinr" column="branchinr" jdbcType="VARCHAR"/>
        <result property="forflg" column="forflg" jdbcType="VARCHAR"/>
        <result property="resdat" column="resdat" jdbcType="DATE"/>
        <result property="amcflg" column="amcflg" jdbcType="VARCHAR"/>
        <result property="invtyp" column="invtyp" jdbcType="VARCHAR"/>
        <result property="expmno" column="expmno" jdbcType="VARCHAR"/>
        <result property="invref" column="invref" jdbcType="VARCHAR"/>
        <result property="negflg" column="negflg" jdbcType="VARCHAR"/>
        <result property="rcssta" column="rcssta" jdbcType="VARCHAR"/>
        <result property="paytyp" column="paytyp" jdbcType="VARCHAR"/>
        <result property="clrmtd" column="clrmtd" jdbcType="VARCHAR"/>
        <result property="bilpro" column="bilpro" jdbcType="VARCHAR"/>
        <result property="dckref" column="dckref" jdbcType="VARCHAR"/>
        <result property="revdat" column="revdat" jdbcType="DATE"/>
        <result property="anobnkcod" column="anobnkcod" jdbcType="VARCHAR"/>
        <result property="anodat" column="anodat" jdbcType="DATE"/>
        <result property="anodsp" column="anodsp" jdbcType="VARCHAR"/>
        <result property="chfdat" column="chfdat" jdbcType="DATE"/>
        <result property="chfcur" column="chfcur" jdbcType="VARCHAR"/>
        <result property="chfamt" column="chfamt" jdbcType="DECIMAL"/>
        <result property="yxused" column="yxused" jdbcType="VARCHAR"/>
        <result property="invamt" column="invamt" jdbcType="DECIMAL"/>
    </resultMap>

    <sql id="Base_Column_List">
        inr,ownref,nam,pnttyp,pntinr,predat,rcvdat,shpdat,advdat,matdat,doctypcod,opndat,clsdat,credat,ownusr,ver,approvcod,frepayflg,docprbrol,payrol,orddat,mattxtflg,dscinsflg,acpnowflg,advtyp,disdat,totcur,totamt,totdat,docsta,docrol,docrolflg,dta770snd,advdocflg,etyextkey,rmbrol,lescom,bchkeyinr,branchinr,forflg,resdat,amcflg,invtyp,expmno,invref,negflg,rcssta,paytyp,clrmtd,bilpro,dckref,revdat,anobnkcod,anodat,anodsp,chfdat,chfcur,chfamt,yxused,invamt
    </sql>

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

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

    <insert id="insert">
        insert into bfd (<include refid="Base_Column_List" />)
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            #{inr,jdbcType=VARCHAR},
            #{ownref,jdbcType=VARCHAR},
            #{nam,jdbcType=VARCHAR},
            #{pnttyp,jdbcType=VARCHAR},
            #{pntinr,jdbcType=VARCHAR},
            #{predat,jdbcType=DATE},
            #{rcvdat,jdbcType=DATE},
            #{shpdat,jdbcType=DATE},
            #{advdat,jdbcType=DATE},
            #{matdat,jdbcType=DATE},
            #{doctypcod,jdbcType=VARCHAR},
            #{opndat,jdbcType=DATE},
            #{clsdat,jdbcType=DATE},
            #{credat,jdbcType=DATE},
            #{ownusr,jdbcType=VARCHAR},
            #{ver,jdbcType=VARCHAR},
            #{approvcod,jdbcType=VARCHAR},
            #{frepayflg,jdbcType=VARCHAR},
            #{docprbrol,jdbcType=VARCHAR},
            #{payrol,jdbcType=VARCHAR},
            #{orddat,jdbcType=DATE},
            #{mattxtflg,jdbcType=VARCHAR},
            #{dscinsflg,jdbcType=VARCHAR},
            #{acpnowflg,jdbcType=VARCHAR},
            #{advtyp,jdbcType=VARCHAR},
            #{disdat,jdbcType=DATE},
            #{totcur,jdbcType=VARCHAR},
            #{totamt,jdbcType=DECIMAL},
            #{totdat,jdbcType=DATE},
            #{docsta,jdbcType=VARCHAR},
            #{docrol,jdbcType=VARCHAR},
            #{docrolflg,jdbcType=VARCHAR},
            #{dta770snd,jdbcType=DATE},
            #{advdocflg,jdbcType=VARCHAR},
            #{etyextkey,jdbcType=VARCHAR},
            #{rmbrol,jdbcType=VARCHAR},
            #{lescom,jdbcType=DECIMAL},
            #{bchkeyinr,jdbcType=VARCHAR},
            #{branchinr,jdbcType=VARCHAR},
            #{forflg,jdbcType=VARCHAR},
            #{resdat,jdbcType=DATE},
            #{amcflg,jdbcType=VARCHAR},
            #{invtyp,jdbcType=VARCHAR},
            #{expmno,jdbcType=VARCHAR},
            #{invref,jdbcType=VARCHAR},
            #{negflg,jdbcType=VARCHAR},
            #{rcssta,jdbcType=VARCHAR},
            #{paytyp,jdbcType=VARCHAR},
            #{clrmtd,jdbcType=VARCHAR},
            #{bilpro,jdbcType=VARCHAR},
            #{dckref,jdbcType=VARCHAR},
            #{revdat,jdbcType=DATE},
            #{anobnkcod,jdbcType=VARCHAR},
            #{anodat,jdbcType=DATE},
            #{anodsp,jdbcType=VARCHAR},
            #{chfdat,jdbcType=DATE},
            #{chfcur,jdbcType=VARCHAR},
            #{chfamt,jdbcType=DECIMAL},
            #{yxused,jdbcType=VARCHAR},
            #{invamt,jdbcType=DECIMAL},
        </trim>
    </insert>

    <insert id="insertSelective">
        insert into bfd
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="inr != null">inr,</if>
            <if test="ownref != null">ownref,</if>
            <if test="nam != null">nam,</if>
            <if test="pnttyp != null">pnttyp,</if>
            <if test="pntinr != null">pntinr,</if>
            <if test="predat != null">predat,</if>
            <if test="rcvdat != null">rcvdat,</if>
            <if test="shpdat != null">shpdat,</if>
            <if test="advdat != null">advdat,</if>
            <if test="matdat != null">matdat,</if>
            <if test="doctypcod != null">doctypcod,</if>
            <if test="opndat != null">opndat,</if>
            <if test="clsdat != null">clsdat,</if>
            <if test="credat != null">credat,</if>
            <if test="ownusr != null">ownusr,</if>
            <if test="ver != null">ver,</if>
            <if test="approvcod != null">approvcod,</if>
            <if test="frepayflg != null">frepayflg,</if>
            <if test="docprbrol != null">docprbrol,</if>
            <if test="payrol != null">payrol,</if>
            <if test="orddat != null">orddat,</if>
            <if test="mattxtflg != null">mattxtflg,</if>
            <if test="dscinsflg != null">dscinsflg,</if>
            <if test="acpnowflg != null">acpnowflg,</if>
            <if test="advtyp != null">advtyp,</if>
            <if test="disdat != null">disdat,</if>
            <if test="totcur != null">totcur,</if>
            <if test="totamt != null">totamt,</if>
            <if test="totdat != null">totdat,</if>
            <if test="docsta != null">docsta,</if>
            <if test="docrol != null">docrol,</if>
            <if test="docrolflg != null">docrolflg,</if>
            <if test="dta770snd != null">dta770snd,</if>
            <if test="advdocflg != null">advdocflg,</if>
            <if test="etyextkey != null">etyextkey,</if>
            <if test="rmbrol != null">rmbrol,</if>
            <if test="lescom != null">lescom,</if>
            <if test="bchkeyinr != null">bchkeyinr,</if>
            <if test="branchinr != null">branchinr,</if>
            <if test="forflg != null">forflg,</if>
            <if test="resdat != null">resdat,</if>
            <if test="amcflg != null">amcflg,</if>
            <if test="invtyp != null">invtyp,</if>
            <if test="expmno != null">expmno,</if>
            <if test="invref != null">invref,</if>
            <if test="negflg != null">negflg,</if>
            <if test="rcssta != null">rcssta,</if>
            <if test="paytyp != null">paytyp,</if>
            <if test="clrmtd != null">clrmtd,</if>
            <if test="bilpro != null">bilpro,</if>
            <if test="dckref != null">dckref,</if>
            <if test="revdat != null">revdat,</if>
            <if test="anobnkcod != null">anobnkcod,</if>
            <if test="anodat != null">anodat,</if>
            <if test="anodsp != null">anodsp,</if>
            <if test="chfdat != null">chfdat,</if>
            <if test="chfcur != null">chfcur,</if>
            <if test="chfamt != null">chfamt,</if>
            <if test="yxused != null">yxused,</if>
            <if test="invamt != null">invamt,</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="pnttyp != null">#{pnttyp,jdbcType=VARCHAR}, </if>
            <if test="pntinr != null">#{pntinr,jdbcType=VARCHAR}, </if>
            <if test="predat != null">#{predat,jdbcType=DATE}, </if>
            <if test="rcvdat != null">#{rcvdat,jdbcType=DATE}, </if>
            <if test="shpdat != null">#{shpdat,jdbcType=DATE}, </if>
            <if test="advdat != null">#{advdat,jdbcType=DATE}, </if>
            <if test="matdat != null">#{matdat,jdbcType=DATE}, </if>
            <if test="doctypcod != null">#{doctypcod,jdbcType=VARCHAR}, </if>
            <if test="opndat != null">#{opndat,jdbcType=DATE}, </if>
            <if test="clsdat != null">#{clsdat,jdbcType=DATE}, </if>
            <if test="credat != null">#{credat,jdbcType=DATE}, </if>
            <if test="ownusr != null">#{ownusr,jdbcType=VARCHAR}, </if>
            <if test="ver != null">#{ver,jdbcType=VARCHAR}, </if>
            <if test="approvcod != null">#{approvcod,jdbcType=VARCHAR}, </if>
            <if test="frepayflg != null">#{frepayflg,jdbcType=VARCHAR}, </if>
            <if test="docprbrol != null">#{docprbrol,jdbcType=VARCHAR}, </if>
            <if test="payrol != null">#{payrol,jdbcType=VARCHAR}, </if>
            <if test="orddat != null">#{orddat,jdbcType=DATE}, </if>
            <if test="mattxtflg != null">#{mattxtflg,jdbcType=VARCHAR}, </if>
            <if test="dscinsflg != null">#{dscinsflg,jdbcType=VARCHAR}, </if>
            <if test="acpnowflg != null">#{acpnowflg,jdbcType=VARCHAR}, </if>
            <if test="advtyp != null">#{advtyp,jdbcType=VARCHAR}, </if>
            <if test="disdat != null">#{disdat,jdbcType=DATE}, </if>
            <if test="totcur != null">#{totcur,jdbcType=VARCHAR}, </if>
            <if test="totamt != null">#{totamt,jdbcType=DECIMAL}, </if>
            <if test="totdat != null">#{totdat,jdbcType=DATE}, </if>
            <if test="docsta != null">#{docsta,jdbcType=VARCHAR}, </if>
            <if test="docrol != null">#{docrol,jdbcType=VARCHAR}, </if>
            <if test="docrolflg != null">#{docrolflg,jdbcType=VARCHAR}, </if>
            <if test="dta770snd != null">#{dta770snd,jdbcType=DATE}, </if>
            <if test="advdocflg != null">#{advdocflg,jdbcType=VARCHAR}, </if>
            <if test="etyextkey != null">#{etyextkey,jdbcType=VARCHAR}, </if>
            <if test="rmbrol != null">#{rmbrol,jdbcType=VARCHAR}, </if>
            <if test="lescom != null">#{lescom,jdbcType=DECIMAL}, </if>
            <if test="bchkeyinr != null">#{bchkeyinr,jdbcType=VARCHAR}, </if>
            <if test="branchinr != null">#{branchinr,jdbcType=VARCHAR}, </if>
            <if test="forflg != null">#{forflg,jdbcType=VARCHAR}, </if>
            <if test="resdat != null">#{resdat,jdbcType=DATE}, </if>
            <if test="amcflg != null">#{amcflg,jdbcType=VARCHAR}, </if>
            <if test="invtyp != null">#{invtyp,jdbcType=VARCHAR}, </if>
            <if test="expmno != null">#{expmno,jdbcType=VARCHAR}, </if>
            <if test="invref != null">#{invref,jdbcType=VARCHAR}, </if>
            <if test="negflg != null">#{negflg,jdbcType=VARCHAR}, </if>
            <if test="rcssta != null">#{rcssta,jdbcType=VARCHAR}, </if>
            <if test="paytyp != null">#{paytyp,jdbcType=VARCHAR}, </if>
            <if test="clrmtd != null">#{clrmtd,jdbcType=VARCHAR}, </if>
            <if test="bilpro != null">#{bilpro,jdbcType=VARCHAR}, </if>
            <if test="dckref != null">#{dckref,jdbcType=VARCHAR}, </if>
            <if test="revdat != null">#{revdat,jdbcType=DATE}, </if>
            <if test="anobnkcod != null">#{anobnkcod,jdbcType=VARCHAR}, </if>
            <if test="anodat != null">#{anodat,jdbcType=DATE}, </if>
            <if test="anodsp != null">#{anodsp,jdbcType=VARCHAR}, </if>
            <if test="chfdat != null">#{chfdat,jdbcType=DATE}, </if>
            <if test="chfcur != null">#{chfcur,jdbcType=VARCHAR}, </if>
            <if test="chfamt != null">#{chfamt,jdbcType=DECIMAL}, </if>
            <if test="yxused != null">#{yxused,jdbcType=VARCHAR}, </if>
            <if test="invamt != null">#{invamt,jdbcType=DECIMAL}, </if>
        </trim>
    </insert>

    <update id="updateByPrimaryKeySelective">
        update bfd
        <set>
            <if test="ownref != null">ownref = #{ownref,jdbcType=VARCHAR},</if>
            <if test="nam != null">nam = #{nam,jdbcType=VARCHAR},</if>
            <if test="pnttyp != null">pnttyp = #{pnttyp,jdbcType=VARCHAR},</if>
            <if test="pntinr != null">pntinr = #{pntinr,jdbcType=VARCHAR},</if>
            <if test="predat != null">predat = #{predat,jdbcType=DATE},</if>
            <if test="rcvdat != null">rcvdat = #{rcvdat,jdbcType=DATE},</if>
            <if test="shpdat != null">shpdat = #{shpdat,jdbcType=DATE},</if>
            <if test="advdat != null">advdat = #{advdat,jdbcType=DATE},</if>
            <if test="matdat != null">matdat = #{matdat,jdbcType=DATE},</if>
            <if test="doctypcod != null">doctypcod = #{doctypcod,jdbcType=VARCHAR},</if>
            <if test="opndat != null">opndat = #{opndat,jdbcType=DATE},</if>
            <if test="clsdat != null">clsdat = #{clsdat,jdbcType=DATE},</if>
            <if test="credat != null">credat = #{credat,jdbcType=DATE},</if>
            <if test="ownusr != null">ownusr = #{ownusr,jdbcType=VARCHAR},</if>
            <if test="ver != null">ver = #{ver,jdbcType=VARCHAR},</if>
            <if test="approvcod != null">approvcod = #{approvcod,jdbcType=VARCHAR},</if>
            <if test="frepayflg != null">frepayflg = #{frepayflg,jdbcType=VARCHAR},</if>
            <if test="docprbrol != null">docprbrol = #{docprbrol,jdbcType=VARCHAR},</if>
            <if test="payrol != null">payrol = #{payrol,jdbcType=VARCHAR},</if>
            <if test="orddat != null">orddat = #{orddat,jdbcType=DATE},</if>
            <if test="mattxtflg != null">mattxtflg = #{mattxtflg,jdbcType=VARCHAR},</if>
            <if test="dscinsflg != null">dscinsflg = #{dscinsflg,jdbcType=VARCHAR},</if>
            <if test="acpnowflg != null">acpnowflg = #{acpnowflg,jdbcType=VARCHAR},</if>
            <if test="advtyp != null">advtyp = #{advtyp,jdbcType=VARCHAR},</if>
            <if test="disdat != null">disdat = #{disdat,jdbcType=DATE},</if>
            <if test="totcur != null">totcur = #{totcur,jdbcType=VARCHAR},</if>
            <if test="totamt != null">totamt = #{totamt,jdbcType=DECIMAL},</if>
            <if test="totdat != null">totdat = #{totdat,jdbcType=DATE},</if>
            <if test="docsta != null">docsta = #{docsta,jdbcType=VARCHAR},</if>
            <if test="docrol != null">docrol = #{docrol,jdbcType=VARCHAR},</if>
            <if test="docrolflg != null">docrolflg = #{docrolflg,jdbcType=VARCHAR},</if>
            <if test="dta770snd != null">dta770snd = #{dta770snd,jdbcType=DATE},</if>
            <if test="advdocflg != null">advdocflg = #{advdocflg,jdbcType=VARCHAR},</if>
            <if test="etyextkey != null">etyextkey = #{etyextkey,jdbcType=VARCHAR},</if>
            <if test="rmbrol != null">rmbrol = #{rmbrol,jdbcType=VARCHAR},</if>
            <if test="lescom != null">lescom = #{lescom,jdbcType=DECIMAL},</if>
            <if test="bchkeyinr != null">bchkeyinr = #{bchkeyinr,jdbcType=VARCHAR},</if>
            <if test="branchinr != null">branchinr = #{branchinr,jdbcType=VARCHAR},</if>
            <if test="forflg != null">forflg = #{forflg,jdbcType=VARCHAR},</if>
            <if test="resdat != null">resdat = #{resdat,jdbcType=DATE},</if>
            <if test="amcflg != null">amcflg = #{amcflg,jdbcType=VARCHAR},</if>
            <if test="invtyp != null">invtyp = #{invtyp,jdbcType=VARCHAR},</if>
            <if test="expmno != null">expmno = #{expmno,jdbcType=VARCHAR},</if>
            <if test="invref != null">invref = #{invref,jdbcType=VARCHAR},</if>
            <if test="negflg != null">negflg = #{negflg,jdbcType=VARCHAR},</if>
            <if test="rcssta != null">rcssta = #{rcssta,jdbcType=VARCHAR},</if>
            <if test="paytyp != null">paytyp = #{paytyp,jdbcType=VARCHAR},</if>
            <if test="clrmtd != null">clrmtd = #{clrmtd,jdbcType=VARCHAR},</if>
            <if test="bilpro != null">bilpro = #{bilpro,jdbcType=VARCHAR},</if>
            <if test="dckref != null">dckref = #{dckref,jdbcType=VARCHAR},</if>
            <if test="revdat != null">revdat = #{revdat,jdbcType=DATE},</if>
            <if test="anobnkcod != null">anobnkcod = #{anobnkcod,jdbcType=VARCHAR},</if>
            <if test="anodat != null">anodat = #{anodat,jdbcType=DATE},</if>
            <if test="anodsp != null">anodsp = #{anodsp,jdbcType=VARCHAR},</if>
            <if test="chfdat != null">chfdat = #{chfdat,jdbcType=DATE},</if>
            <if test="chfcur != null">chfcur = #{chfcur,jdbcType=VARCHAR},</if>
            <if test="chfamt != null">chfamt = #{chfamt,jdbcType=DECIMAL},</if>
            <if test="yxused != null">yxused = #{yxused,jdbcType=VARCHAR},</if>
            <if test="invamt != null">invamt = #{invamt,jdbcType=DECIMAL},</if>
        </set>
        where inr = #{inr,jdbcType=VARCHAR}
    </update>

    <update id="updateByPrimaryKey">
        update bfd
        <set>
            ownref = #{ownref,jdbcType=VARCHAR},
            nam = #{nam,jdbcType=VARCHAR},
            pnttyp = #{pnttyp,jdbcType=VARCHAR},
            pntinr = #{pntinr,jdbcType=VARCHAR},
            predat = #{predat,jdbcType=DATE},
            rcvdat = #{rcvdat,jdbcType=DATE},
            shpdat = #{shpdat,jdbcType=DATE},
            advdat = #{advdat,jdbcType=DATE},
            matdat = #{matdat,jdbcType=DATE},
            doctypcod = #{doctypcod,jdbcType=VARCHAR},
            opndat = #{opndat,jdbcType=DATE},
            clsdat = #{clsdat,jdbcType=DATE},
            credat = #{credat,jdbcType=DATE},
            ownusr = #{ownusr,jdbcType=VARCHAR},
            ver = #{ver,jdbcType=VARCHAR},
            approvcod = #{approvcod,jdbcType=VARCHAR},
            frepayflg = #{frepayflg,jdbcType=VARCHAR},
            docprbrol = #{docprbrol,jdbcType=VARCHAR},
            payrol = #{payrol,jdbcType=VARCHAR},
            orddat = #{orddat,jdbcType=DATE},
            mattxtflg = #{mattxtflg,jdbcType=VARCHAR},
            dscinsflg = #{dscinsflg,jdbcType=VARCHAR},
            acpnowflg = #{acpnowflg,jdbcType=VARCHAR},
            advtyp = #{advtyp,jdbcType=VARCHAR},
            disdat = #{disdat,jdbcType=DATE},
            totcur = #{totcur,jdbcType=VARCHAR},
            totamt = #{totamt,jdbcType=DECIMAL},
            totdat = #{totdat,jdbcType=DATE},
            docsta = #{docsta,jdbcType=VARCHAR},
            docrol = #{docrol,jdbcType=VARCHAR},
            docrolflg = #{docrolflg,jdbcType=VARCHAR},
            dta770snd = #{dta770snd,jdbcType=DATE},
            advdocflg = #{advdocflg,jdbcType=VARCHAR},
            etyextkey = #{etyextkey,jdbcType=VARCHAR},
            rmbrol = #{rmbrol,jdbcType=VARCHAR},
            lescom = #{lescom,jdbcType=DECIMAL},
            bchkeyinr = #{bchkeyinr,jdbcType=VARCHAR},
            branchinr = #{branchinr,jdbcType=VARCHAR},
            forflg = #{forflg,jdbcType=VARCHAR},
            resdat = #{resdat,jdbcType=DATE},
            amcflg = #{amcflg,jdbcType=VARCHAR},
            invtyp = #{invtyp,jdbcType=VARCHAR},
            expmno = #{expmno,jdbcType=VARCHAR},
            invref = #{invref,jdbcType=VARCHAR},
            negflg = #{negflg,jdbcType=VARCHAR},
            rcssta = #{rcssta,jdbcType=VARCHAR},
            paytyp = #{paytyp,jdbcType=VARCHAR},
            clrmtd = #{clrmtd,jdbcType=VARCHAR},
            bilpro = #{bilpro,jdbcType=VARCHAR},
            dckref = #{dckref,jdbcType=VARCHAR},
            revdat = #{revdat,jdbcType=DATE},
            anobnkcod = #{anobnkcod,jdbcType=VARCHAR},
            anodat = #{anodat,jdbcType=DATE},
            anodsp = #{anodsp,jdbcType=VARCHAR},
            chfdat = #{chfdat,jdbcType=DATE},
            chfcur = #{chfcur,jdbcType=VARCHAR},
            chfamt = #{chfamt,jdbcType=DECIMAL},
            yxused = #{yxused,jdbcType=VARCHAR},
            invamt = #{invamt,jdbcType=DECIMAL},
        </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 bfd
        <set>
            <if test="module.ownref != null">ownref = #{module.ownref,jdbcType=VARCHAR},</if>
            <if test="module.nam != null">nam = #{module.nam,jdbcType=VARCHAR},</if>
            <if test="module.pnttyp != null">pnttyp = #{module.pnttyp,jdbcType=VARCHAR},</if>
            <if test="module.pntinr != null">pntinr = #{module.pntinr,jdbcType=VARCHAR},</if>
            <if test="module.predat != null">predat = #{module.predat,jdbcType=DATE},</if>
            <if test="module.rcvdat != null">rcvdat = #{module.rcvdat,jdbcType=DATE},</if>
            <if test="module.shpdat != null">shpdat = #{module.shpdat,jdbcType=DATE},</if>
            <if test="module.advdat != null">advdat = #{module.advdat,jdbcType=DATE},</if>
            <if test="module.matdat != null">matdat = #{module.matdat,jdbcType=DATE},</if>
            <if test="module.doctypcod != null">doctypcod = #{module.doctypcod,jdbcType=VARCHAR},</if>
            <if test="module.opndat != null">opndat = #{module.opndat,jdbcType=DATE},</if>
            <if test="module.clsdat != null">clsdat = #{module.clsdat,jdbcType=DATE},</if>
            <if test="module.credat != null">credat = #{module.credat,jdbcType=DATE},</if>
            <if test="module.ownusr != null">ownusr = #{module.ownusr,jdbcType=VARCHAR},</if>
            <if test="module.ver != null">ver = #{module.ver,jdbcType=VARCHAR},</if>
            <if test="module.approvcod != null">approvcod = #{module.approvcod,jdbcType=VARCHAR},</if>
            <if test="module.frepayflg != null">frepayflg = #{module.frepayflg,jdbcType=VARCHAR},</if>
            <if test="module.docprbrol != null">docprbrol = #{module.docprbrol,jdbcType=VARCHAR},</if>
            <if test="module.payrol != null">payrol = #{module.payrol,jdbcType=VARCHAR},</if>
            <if test="module.orddat != null">orddat = #{module.orddat,jdbcType=DATE},</if>
            <if test="module.mattxtflg != null">mattxtflg = #{module.mattxtflg,jdbcType=VARCHAR},</if>
            <if test="module.dscinsflg != null">dscinsflg = #{module.dscinsflg,jdbcType=VARCHAR},</if>
            <if test="module.acpnowflg != null">acpnowflg = #{module.acpnowflg,jdbcType=VARCHAR},</if>
            <if test="module.advtyp != null">advtyp = #{module.advtyp,jdbcType=VARCHAR},</if>
            <if test="module.disdat != null">disdat = #{module.disdat,jdbcType=DATE},</if>
            <if test="module.totcur != null">totcur = #{module.totcur,jdbcType=VARCHAR},</if>
            <if test="module.totamt != null">totamt = #{module.totamt,jdbcType=DECIMAL},</if>
            <if test="module.totdat != null">totdat = #{module.totdat,jdbcType=DATE},</if>
            <if test="module.docsta != null">docsta = #{module.docsta,jdbcType=VARCHAR},</if>
            <if test="module.docrol != null">docrol = #{module.docrol,jdbcType=VARCHAR},</if>
            <if test="module.docrolflg != null">docrolflg = #{module.docrolflg,jdbcType=VARCHAR},</if>
            <if test="module.dta770snd != null">dta770snd = #{module.dta770snd,jdbcType=DATE},</if>
            <if test="module.advdocflg != null">advdocflg = #{module.advdocflg,jdbcType=VARCHAR},</if>
            <if test="module.etyextkey != null">etyextkey = #{module.etyextkey,jdbcType=VARCHAR},</if>
            <if test="module.rmbrol != null">rmbrol = #{module.rmbrol,jdbcType=VARCHAR},</if>
            <if test="module.lescom != null">lescom = #{module.lescom,jdbcType=DECIMAL},</if>
            <if test="module.bchkeyinr != null">bchkeyinr = #{module.bchkeyinr,jdbcType=VARCHAR},</if>
            <if test="module.branchinr != null">branchinr = #{module.branchinr,jdbcType=VARCHAR},</if>
            <if test="module.forflg != null">forflg = #{module.forflg,jdbcType=VARCHAR},</if>
            <if test="module.resdat != null">resdat = #{module.resdat,jdbcType=DATE},</if>
            <if test="module.amcflg != null">amcflg = #{module.amcflg,jdbcType=VARCHAR},</if>
            <if test="module.invtyp != null">invtyp = #{module.invtyp,jdbcType=VARCHAR},</if>
            <if test="module.expmno != null">expmno = #{module.expmno,jdbcType=VARCHAR},</if>
            <if test="module.invref != null">invref = #{module.invref,jdbcType=VARCHAR},</if>
            <if test="module.negflg != null">negflg = #{module.negflg,jdbcType=VARCHAR},</if>
            <if test="module.rcssta != null">rcssta = #{module.rcssta,jdbcType=VARCHAR},</if>
            <if test="module.paytyp != null">paytyp = #{module.paytyp,jdbcType=VARCHAR},</if>
            <if test="module.clrmtd != null">clrmtd = #{module.clrmtd,jdbcType=VARCHAR},</if>
            <if test="module.bilpro != null">bilpro = #{module.bilpro,jdbcType=VARCHAR},</if>
            <if test="module.dckref != null">dckref = #{module.dckref,jdbcType=VARCHAR},</if>
            <if test="module.revdat != null">revdat = #{module.revdat,jdbcType=DATE},</if>
            <if test="module.anobnkcod != null">anobnkcod = #{module.anobnkcod,jdbcType=VARCHAR},</if>
            <if test="module.anodat != null">anodat = #{module.anodat,jdbcType=DATE},</if>
            <if test="module.anodsp != null">anodsp = #{module.anodsp,jdbcType=VARCHAR},</if>
            <if test="module.chfdat != null">chfdat = #{module.chfdat,jdbcType=DATE},</if>
            <if test="module.chfcur != null">chfcur = #{module.chfcur,jdbcType=VARCHAR},</if>
            <if test="module.chfamt != null">chfamt = #{module.chfamt,jdbcType=DECIMAL},</if>
            <if test="module.yxused != null">yxused = #{module.yxused,jdbcType=VARCHAR},</if>
            <if test="module.invamt != null">invamt = #{module.invamt,jdbcType=DECIMAL},</if>
        </set>
        ${conditions}
    </update>

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

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

    <select id="GetActUtlBFCount" resultType="java.lang.String">
    select
	count(*)
    from
	BFD
    where
	PNTINR = #{inr}
	and PNTTYP = 'DED'
	and RCVDAT is not null
    </select>
    <select id="queryBfd" resultType="com.brilliance.isc.vo.domlc.BfdWithPtsCbbResponseVo">
        select
        bfd.*,ded.OWNREF pntref,pte.MATDAT udpdat,ded.STAGOD,
        cbb.cur cur, cbb.amt amt,pts1.extkey aplExtkey,pts1.nam aplName,pts1.cnnam aplCnname,
        pts2.extkey benExtkey,pts2.nam benName,pts2.cnnam benCnname,pts3.extkey prbExtkey,
        pts3.nam prbName,pts3.cnnam prbCnname, pts3.JIGOMC prbLhname
        from bfd
        left join cbb on cbb.OBJINR = bfd.inr and cbb.OBJTYP = 'BFD'  and cbb.cbc = 'MAXSUM' and cbb.extid = 'AMT1' and cbb.enddat = '2299-12-31'
        left join pts pts1 on pts1.OBJINR = bfd.inr and pts1.OBJTYP = 'BFD' and pts1.rol = 'APL'
        left join pts pts2 on pts2.OBJINR = bfd.inr and pts2.OBJTYP = 'BFD' and pts2.rol = 'BEN'
        left join pts pts3 on pts3.OBJINR = bfd.inr and pts3.OBJTYP = 'BFD' and pts3.rol = 'PRB'
        left join pts pts4 on pts4.OBJINR = bfd.inr and pts4.OBJTYP = 'BFD' and pts4.rol = 'ISS'
        left join pte pte on pte.objinr = pts4.inr and pte.objtyp = 'PTS' and pte.cbtpfx = 'AKZ'
        left join ded on ded.INR = bfd.PNTINR and bfd.PNTTYP = 'DED'
        where 1 = 1
        <!--信用证INR-->
        <if test="dedinr != null and dedinr != '' ">
            AND bfd.PNTINR = #{dedinr}
            AND bfd.PNTTYP = 'DED'
        </if>
        <!--机构隔离-->
        <if test="bchinr != null and bchinr != '' ">
            AND bfd.BCHKEYINR = #{bchinr}
        </if>
        <!--单据业务编号-->
        <if test="seaownref != null and seaownref != ''">
            AND UPPER(ded.OWNREF) LIKE concat(concat('%', UPPER(#{seaownref})), '%')
        </if>
        <!--单据业务编号-->
        <if test="bfownref != null and bfownref != ''">
            AND UPPER(bfd.OWNREF) LIKE concat(concat('%', UPPER(#{bfownref})), '%')
        </if>
        <!--日期-->
        <if test="opndatfrom != null and opndatfrom != ''">
            AND bfd.CREDAT &gt;= #{opndatfrom}
        </if>
        <if test="opndatto != null and opndatto != ''">
            AND bfd.CREDAT &lt;= #{opndatto}
        </if>
        <!--单据状态-->
        <if test="docsta != null and docsta != '' ">
            AND bfd.docsta = #{docsta}
        </if>
        <!--申请人 -->
        <if test="aplref != null and aplref != ''">
            and exists (
            select 1 from PTS,PTY
            where bfd.INR = PTS.OBJINR
            AND PTY.INR = PTS.PTYINR
            AND PTS.OBJTYP = 'BDD'
            AND PTS.ROL = 'APL'
            AND (
            PTS.EXTKEY LIKE concat(concat('%', #{aplref}), '%')
            or PTS.NAM LIKE concat(concat('%', #{aplref}), '%')
            or PTS.CNNAM LIKE concat(concat('%', #{aplref}), '%')
            or PTS.ENNAM LIKE concat(concat('%', #{aplref}), '%')
            or PTY.NAM LIKE concat(concat('%', #{aplref}), '%')
            )
            )
        </if>
        <!--受益人 -->
        <if test="benref != null and benref != ''">
            and exists (
            select 1 from PTS,PTY
            where bfd.INR = PTS.OBJINR
            AND PTY.INR = PTS.PTYINR
            AND PTS.OBJTYP = 'BDD'
            AND PTS.ROL = 'BEN'
            AND (
            PTS.EXTKEY LIKE concat(concat('%', #{benref}), '%')
            or PTS.NAM LIKE concat(concat('%', #{benref}), '%')
            or PTS.CNNAM LIKE concat(concat('%', #{benref}), '%')
            or PTS.ENNAM LIKE concat(concat('%', #{benref}), '%')
            or PTY.NAM LIKE concat(concat('%', #{benref}), '%')
            )
            )
        </if>
        <!--是否闭卷 -->
        <if test="isClosed != null and isClosed != ''">
            <if test="isClosed == 'Y'.toString()">
                and bfd.CLSDAT is not null
            </if>
            <if test="isClosed == 'N'.toString()">
                and bfd.CLSDAT is  null
            </if>
        </if>
        order by bfd.CREDAT desc , bfd.OWNREF desc
    </select>

    <select id="GetActAdvisedBFCount" resultType="java.lang.String">
    select
	count(*)
    from
	BFD
    where
	PNTINR = #{inr}
	and PNTTYP = 'DED'
	and RCVDAT is null
    </select>
    <select id="selectByPntinrInt" resultType="java.lang.Integer">
        select
            count(*)
        from
            BFD
        where
            PNTINR = #{pntInr}
          and PNTTYP = 'DED'
          and CLSDAT is null
    </select>

    <select id="getInrByOwnref" resultType="java.lang.String">
    select INR from BFD where
	OWNREF = #{ownref}
    </select>

    <select id="selectByAnyref" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from BFD WHERE INR in ( select distinct OBJINR from PTS where OBJTYP = #{objtyp} and REF = #{ref}
        <if test="rol != null and rol != ''">
            and rol = #{rol}
        </if>
        )
        ORDER BY CREDAT desc
        limit 1
    </select>

    <select id="selectByWhere" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from BFD WHERE 1=1
        <if test="ownref != null and ownref != ''"> and ownref = #{ownref,jdbcType=VARCHAR}</if>
        <!--<if test="oldref != null and oldref != ''"> and oldref = #{oldref,jdbcType=VARCHAR}</if>-->
        limit 1
    </select>
    <select id="queryBfdInfo" resultType="com.brilliance.isc.vo.domlc.BfdWithPtsCbbResponseVo">
        select
        bfd.*,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,ben.EXTKEY benExtkey,ben.nam benName,iss.EXTKEY issExtkey,iss.nam issName,
        pub.EXTKEY pubExtkey,pub.nam pubName
        from bfd
        left join cbb max1 on max1.OBJINR = bfd.inr and max1.OBJTYP = 'BFD' and max1.cbc = 'MAXSUM' and max1.extid =
        'AMT1' and max1.enddat = '2299-12-31'
        left join cbb max2 on max2.OBJINR = bfd.inr and max2.OBJTYP = 'BFD' and max2.cbc = 'MAXSUM' and max2.extid =
        'AMT2' and max2.enddat = '2299-12-31'
        left join cbb opn1 on opn1.OBJINR = bfd.inr and opn1.OBJTYP = 'BFD' and opn1.cbc = 'OPN' and opn1.extid = 'AMT1'
        and opn1.enddat = '2299-12-31'
        left join cbb opn2 on opn2.OBJINR = bfd.inr and opn2.OBJTYP = 'BFD' and opn2.cbc = 'OPN' and opn2.extid = 'AMT2'
        and opn2.enddat = '2299-12-31'
        left join pts apl on apl.OBJINR = bfd.inr and apl.OBJTYP = 'BFD' and apl.rol = 'APL'
        left join pts ben on ben.OBJINR = bfd.inr and ben.OBJTYP = 'BFD' and ben.rol = 'BEN'
        left join pts iss on iss.OBJINR = bfd.inr and iss.OBJTYP = 'BFD' and iss.rol = 'ISS'
        left join pts pub on pub.OBJINR = bfd.inr and pub.OBJTYP = 'BFD' and pub.rol = 'PUB'
        left join bch bch on bch.inr = bfd.BCHKEYINR
        left join usr usr on usr.EXTKEY = bfd.OWNUSR
        left join ded ded on ded.inr = bfd.pntinr
        where bfd.flwsta = 'R'
        <!--机构隔离-->
        <if test="bchinr != null and bchinr != '' ">
            AND bfd.bchkeyinr = #{bchinr}
        </if>
        <!--业务编号-->
        <if test="seaownref != null and seaownref != ''">
            AND UPPER(bfd.OWNREF) LIKE concat(concat('%', UPPER(#{seaownref})), '%')
        </if>
        <!--日期-->
        <if test="opndatfrom != null and opndatfrom != ''">
            AND bfd.CREDAT &gt;= #{opndatfrom}
        </if>
        <if test="opndatto != null and opndatto != ''">
            AND bfd.CREDAT &lt;= #{opndatto}
        </if>
        <!--单据类型-->
        <if test="seadoctyp != null and seadoctyp != '' ">
            AND bfd.DOCTYPCOD = #{seadoctyp}
        </if>
        <!--转卖单据-->
        <if test="seaforflg != null and seaforflg != '' ">
            AND bfd.forflg = 'X'
        </if>
        <!--是否经过电证系统 -->
        <if test="seaelcflg != null and seaelcflg != '' ">
            AND ded.elcflg = #{seaelcflg}
        </if>
        <!--客户号/名称 -->
        <if test="ptyExtkey != null and ptyExtkey != ''">
            and exists (
            select 1 from PTS
            where bfd.INR = PTS.OBJINR
            AND PTS.OBJTYP = 'BFD'
            AND PTS.ROL = 'BEN'
            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 bfd.INR = PTS.OBJINR
            AND PTS.OBJTYP = 'BFD'
            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 bfd.INR = PTS.OBJINR
            AND PTS.OBJTYP = 'BFD'
            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 = 'BFD'
            AND INFCONCBS.OBJINR = BFD.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 bfd.clsdat is not null
            </if>
            <if test="seasta == 'O'.toString()">
                and bfd.clsdat is null
            </if>
        </if>

        <if test='column != null and column!="" '>
            order by  ${column}  ${order}
        </if>
        <if test='column == null or column=="" '>
            order by bfd.credat desc , bfd.ownref desc
        </if>
    </select>
    <update id="updateDocsta">
        update bfd set docsta=#{docsta} where inr=#{inr}
    </update>

    <select id="selectByOwnref" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from bfd
        where ownref = #{ownref}
    </select>

</mapper>