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

    <resultMap id="BaseResultMap" type="com.brilliance.isc.bo.Bcd">
        <result property="inr" column="inr" jdbcType="VARCHAR"/>
        <result property="ownref" column="ownref" jdbcType="VARCHAR"/>
        <result property="nam" column="nam" jdbcType="VARCHAR"/>
        <result property="relgodflg" column="relgodflg" jdbcType="VARCHAR"/>
        <result property="relgoddat" column="relgoddat" jdbcType="DATE"/>
        <result property="rcvdat" column="rcvdat" jdbcType="DATE"/>
        <result property="predat" column="predat" jdbcType="DATE"/>
        <result property="shpdat" column="shpdat" jdbcType="DATE"/>
        <result property="credat" column="credat" jdbcType="DATE"/>
        <result property="advdat" column="advdat" jdbcType="DATE"/>
        <result property="clsdat" column="clsdat" jdbcType="DATE"/>
        <result property="matdat" column="matdat" jdbcType="DATE"/>
        <result property="opndat" column="opndat" jdbcType="DATE"/>
        <result property="doctypcod" column="doctypcod" jdbcType="VARCHAR"/>
        <result property="matperbeg" column="matperbeg" jdbcType="VARCHAR"/>
        <result property="matpercnt" column="matpercnt" jdbcType="INTEGER"/>
        <result property="matpertyp" column="matpertyp" jdbcType="VARCHAR"/>
        <result property="ownusr" column="ownusr" jdbcType="VARCHAR"/>
        <result property="ver" column="ver" jdbcType="VARCHAR"/>
        <result property="trpdoctyp" column="trpdoctyp" jdbcType="VARCHAR"/>
        <result property="trpdocnum" column="trpdocnum" jdbcType="VARCHAR"/>
        <result property="tradat" column="tradat" jdbcType="DATE"/>
        <result property="tramod" column="tramod" jdbcType="VARCHAR"/>
        <result property="shpfro" column="shpfro" jdbcType="VARCHAR"/>
        <result property="shpto" column="shpto" jdbcType="VARCHAR"/>
        <result property="chato" column="chato" jdbcType="VARCHAR"/>
        <result property="othins" column="othins" jdbcType="VARCHAR"/>
        <result property="stacty" column="stacty" jdbcType="VARCHAR"/>
        <result property="stagod" column="stagod" jdbcType="VARCHAR"/>
        <result property="accdat" column="accdat" jdbcType="DATE"/>
        <result property="amenbr" column="amenbr" jdbcType="INTEGER"/>
        <result property="dftgarflg" column="dftgarflg" jdbcType="VARCHAR"/>
        <result property="reltyp" column="reltyp" jdbcType="VARCHAR"/>
        <result property="expdat" column="expdat" jdbcType="DATE"/>
        <result property="rtodreflg" column="rtodreflg" jdbcType="VARCHAR"/>
        <result property="mattxtflg" column="mattxtflg" jdbcType="VARCHAR"/>
        <result property="focflg" column="focflg" jdbcType="VARCHAR"/>
        <result property="waicolcod" column="waicolcod" jdbcType="VARCHAR"/>
        <result property="wairmtcod" column="wairmtcod" jdbcType="VARCHAR"/>
        <result property="oridre" column="oridre" jdbcType="VARCHAR"/>
        <result property="docsta" column="docsta" jdbcType="VARCHAR"/>
        <result property="resflg" column="resflg" jdbcType="VARCHAR"/>
        <result property="agtdat" column="agtdat" jdbcType="DATE"/>
        <result property="etyextkey" column="etyextkey" jdbcType="VARCHAR"/>
        <result property="proins" column="proins" jdbcType="VARCHAR"/>
        <result property="branchinr" column="branchinr" jdbcType="VARCHAR"/>
        <result property="bchkeyinr" column="bchkeyinr" jdbcType="VARCHAR"/>
        <result property="invref" column="invref" jdbcType="VARCHAR"/>
        <result property="rptref" column="rptref" jdbcType="VARCHAR"/>
        <result property="prechkdat" column="prechkdat" jdbcType="DATE"/>
        <result property="ischktyp" column="ischktyp" jdbcType="VARCHAR"/>
        <result property="invtyp" column="invtyp" jdbcType="VARCHAR"/>
        <result property="goddspcn" column="goddspcn" jdbcType="VARCHAR"/>
        <result property="oppnam" column="oppnam" jdbcType="VARCHAR"/>
    </resultMap>

    <sql id="Base_Column_List">
        inr,ownref,nam,relgodflg,relgoddat,rcvdat,predat,shpdat,credat,advdat,clsdat,matdat,opndat,doctypcod,matperbeg,matpercnt,matpertyp,ownusr,ver,trpdoctyp,trpdocnum,tradat,tramod,shpfro,shpto,chato,othins,stacty,stagod,accdat,amenbr,dftgarflg,reltyp,expdat,rtodreflg,mattxtflg,focflg,waicolcod,wairmtcod,oridre,docsta,resflg,agtdat,etyextkey,proins,branchinr,bchkeyinr,invref,rptref,prechkdat,ischktyp,invtyp,goddspcn,oppnam
    </sql>

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

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

    <insert id="insert">
        insert into bcd (<include refid="Base_Column_List" />)
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            #{inr,jdbcType=VARCHAR},
            #{ownref,jdbcType=VARCHAR},
            #{nam,jdbcType=VARCHAR},
            #{relgodflg,jdbcType=VARCHAR},
            #{relgoddat,jdbcType=DATE},
            #{rcvdat,jdbcType=DATE},
            #{predat,jdbcType=DATE},
            #{shpdat,jdbcType=DATE},
            #{credat,jdbcType=DATE},
            #{advdat,jdbcType=DATE},
            #{clsdat,jdbcType=DATE},
            #{matdat,jdbcType=DATE},
            #{opndat,jdbcType=DATE},
            #{doctypcod,jdbcType=VARCHAR},
            #{matperbeg,jdbcType=VARCHAR},
            #{matpercnt,jdbcType=INTEGER},
            #{matpertyp,jdbcType=VARCHAR},
            #{ownusr,jdbcType=VARCHAR},
            #{ver,jdbcType=VARCHAR},
            #{trpdoctyp,jdbcType=VARCHAR},
            #{trpdocnum,jdbcType=VARCHAR},
            #{tradat,jdbcType=DATE},
            #{tramod,jdbcType=VARCHAR},
            #{shpfro,jdbcType=VARCHAR},
            #{shpto,jdbcType=VARCHAR},
            #{chato,jdbcType=VARCHAR},
            #{othins,jdbcType=VARCHAR},
            #{stacty,jdbcType=VARCHAR},
            #{stagod,jdbcType=VARCHAR},
            #{accdat,jdbcType=DATE},
            #{amenbr,jdbcType=INTEGER},
            #{dftgarflg,jdbcType=VARCHAR},
            #{reltyp,jdbcType=VARCHAR},
            #{expdat,jdbcType=DATE},
            #{rtodreflg,jdbcType=VARCHAR},
            #{mattxtflg,jdbcType=VARCHAR},
            #{focflg,jdbcType=VARCHAR},
            #{waicolcod,jdbcType=VARCHAR},
            #{wairmtcod,jdbcType=VARCHAR},
            #{oridre,jdbcType=VARCHAR},
            #{docsta,jdbcType=VARCHAR},
            #{resflg,jdbcType=VARCHAR},
            #{agtdat,jdbcType=DATE},
            #{etyextkey,jdbcType=VARCHAR},
            #{proins,jdbcType=VARCHAR},
            #{branchinr,jdbcType=VARCHAR},
            #{bchkeyinr,jdbcType=VARCHAR},
            #{invref,jdbcType=VARCHAR},
            #{rptref,jdbcType=VARCHAR},
            #{prechkdat,jdbcType=DATE},
            #{ischktyp,jdbcType=VARCHAR},
            #{invtyp,jdbcType=VARCHAR},
            #{goddspcn,jdbcType=VARCHAR},
            #{oppnam,jdbcType=VARCHAR},
        </trim>
    </insert>

    <insert id="insertSelective">
        insert into bcd
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="inr != null">inr,</if>
            <if test="ownref != null">ownref,</if>
            <if test="nam != null">nam,</if>
            <if test="relgodflg != null">relgodflg,</if>
            <if test="relgoddat != null">relgoddat,</if>
            <if test="rcvdat != null">rcvdat,</if>
            <if test="predat != null">predat,</if>
            <if test="shpdat != null">shpdat,</if>
            <if test="credat != null">credat,</if>
            <if test="advdat != null">advdat,</if>
            <if test="clsdat != null">clsdat,</if>
            <if test="matdat != null">matdat,</if>
            <if test="opndat != null">opndat,</if>
            <if test="doctypcod != null">doctypcod,</if>
            <if test="matperbeg != null">matperbeg,</if>
            <if test="matpercnt != null">matpercnt,</if>
            <if test="matpertyp != null">matpertyp,</if>
            <if test="ownusr != null">ownusr,</if>
            <if test="ver != null">ver,</if>
            <if test="trpdoctyp != null">trpdoctyp,</if>
            <if test="trpdocnum != null">trpdocnum,</if>
            <if test="tradat != null">tradat,</if>
            <if test="tramod != null">tramod,</if>
            <if test="shpfro != null">shpfro,</if>
            <if test="shpto != null">shpto,</if>
            <if test="chato != null">chato,</if>
            <if test="othins != null">othins,</if>
            <if test="stacty != null">stacty,</if>
            <if test="stagod != null">stagod,</if>
            <if test="accdat != null">accdat,</if>
            <if test="amenbr != null">amenbr,</if>
            <if test="dftgarflg != null">dftgarflg,</if>
            <if test="reltyp != null">reltyp,</if>
            <if test="expdat != null">expdat,</if>
            <if test="rtodreflg != null">rtodreflg,</if>
            <if test="mattxtflg != null">mattxtflg,</if>
            <if test="focflg != null">focflg,</if>
            <if test="waicolcod != null">waicolcod,</if>
            <if test="wairmtcod != null">wairmtcod,</if>
            <if test="oridre != null">oridre,</if>
            <if test="docsta != null">docsta,</if>
            <if test="resflg != null">resflg,</if>
            <if test="agtdat != null">agtdat,</if>
            <if test="etyextkey != null">etyextkey,</if>
            <if test="proins != null">proins,</if>
            <if test="branchinr != null">branchinr,</if>
            <if test="bchkeyinr != null">bchkeyinr,</if>
            <if test="invref != null">invref,</if>
            <if test="rptref != null">rptref,</if>
            <if test="prechkdat != null">prechkdat,</if>
            <if test="ischktyp != null">ischktyp,</if>
            <if test="invtyp != null">invtyp,</if>
            <if test="goddspcn != null">goddspcn,</if>
            <if test="oppnam != null">oppnam,</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="relgodflg != null">#{relgodflg,jdbcType=VARCHAR}, </if>
            <if test="relgoddat != null">#{relgoddat,jdbcType=DATE}, </if>
            <if test="rcvdat != null">#{rcvdat,jdbcType=DATE}, </if>
            <if test="predat != null">#{predat,jdbcType=DATE}, </if>
            <if test="shpdat != null">#{shpdat,jdbcType=DATE}, </if>
            <if test="credat != null">#{credat,jdbcType=DATE}, </if>
            <if test="advdat != null">#{advdat,jdbcType=DATE}, </if>
            <if test="clsdat != null">#{clsdat,jdbcType=DATE}, </if>
            <if test="matdat != null">#{matdat,jdbcType=DATE}, </if>
            <if test="opndat != null">#{opndat,jdbcType=DATE}, </if>
            <if test="doctypcod != null">#{doctypcod,jdbcType=VARCHAR}, </if>
            <if test="matperbeg != null">#{matperbeg,jdbcType=VARCHAR}, </if>
            <if test="matpercnt != null">#{matpercnt,jdbcType=INTEGER}, </if>
            <if test="matpertyp != null">#{matpertyp,jdbcType=VARCHAR}, </if>
            <if test="ownusr != null">#{ownusr,jdbcType=VARCHAR}, </if>
            <if test="ver != null">#{ver,jdbcType=VARCHAR}, </if>
            <if test="trpdoctyp != null">#{trpdoctyp,jdbcType=VARCHAR}, </if>
            <if test="trpdocnum != null">#{trpdocnum,jdbcType=VARCHAR}, </if>
            <if test="tradat != null">#{tradat,jdbcType=DATE}, </if>
            <if test="tramod != null">#{tramod,jdbcType=VARCHAR}, </if>
            <if test="shpfro != null">#{shpfro,jdbcType=VARCHAR}, </if>
            <if test="shpto != null">#{shpto,jdbcType=VARCHAR}, </if>
            <if test="chato != null">#{chato,jdbcType=VARCHAR}, </if>
            <if test="othins != null">#{othins,jdbcType=VARCHAR}, </if>
            <if test="stacty != null">#{stacty,jdbcType=VARCHAR}, </if>
            <if test="stagod != null">#{stagod,jdbcType=VARCHAR}, </if>
            <if test="accdat != null">#{accdat,jdbcType=DATE}, </if>
            <if test="amenbr != null">#{amenbr,jdbcType=INTEGER}, </if>
            <if test="dftgarflg != null">#{dftgarflg,jdbcType=VARCHAR}, </if>
            <if test="reltyp != null">#{reltyp,jdbcType=VARCHAR}, </if>
            <if test="expdat != null">#{expdat,jdbcType=DATE}, </if>
            <if test="rtodreflg != null">#{rtodreflg,jdbcType=VARCHAR}, </if>
            <if test="mattxtflg != null">#{mattxtflg,jdbcType=VARCHAR}, </if>
            <if test="focflg != null">#{focflg,jdbcType=VARCHAR}, </if>
            <if test="waicolcod != null">#{waicolcod,jdbcType=VARCHAR}, </if>
            <if test="wairmtcod != null">#{wairmtcod,jdbcType=VARCHAR}, </if>
            <if test="oridre != null">#{oridre,jdbcType=VARCHAR}, </if>
            <if test="docsta != null">#{docsta,jdbcType=VARCHAR}, </if>
            <if test="resflg != null">#{resflg,jdbcType=VARCHAR}, </if>
            <if test="agtdat != null">#{agtdat,jdbcType=DATE}, </if>
            <if test="etyextkey != null">#{etyextkey,jdbcType=VARCHAR}, </if>
            <if test="proins != null">#{proins,jdbcType=VARCHAR}, </if>
            <if test="branchinr != null">#{branchinr,jdbcType=VARCHAR}, </if>
            <if test="bchkeyinr != null">#{bchkeyinr,jdbcType=VARCHAR}, </if>
            <if test="invref != null">#{invref,jdbcType=VARCHAR}, </if>
            <if test="rptref != null">#{rptref,jdbcType=VARCHAR}, </if>
            <if test="prechkdat != null">#{prechkdat,jdbcType=DATE}, </if>
            <if test="ischktyp != null">#{ischktyp,jdbcType=VARCHAR}, </if>
            <if test="invtyp != null">#{invtyp,jdbcType=VARCHAR}, </if>
            <if test="goddspcn != null">#{goddspcn,jdbcType=VARCHAR}, </if>
            <if test="oppnam != null">#{oppnam,jdbcType=VARCHAR}, </if>
        </trim>
    </insert>

    <update id="updateByPrimaryKeySelective">
        update bcd
        <set>
            <if test="ownref != null">ownref = #{ownref,jdbcType=VARCHAR},</if>
            <if test="nam != null">nam = #{nam,jdbcType=VARCHAR},</if>
            <if test="relgodflg != null">relgodflg = #{relgodflg,jdbcType=VARCHAR},</if>
            <if test="relgoddat != null">relgoddat = #{relgoddat,jdbcType=DATE},</if>
            <if test="rcvdat != null">rcvdat = #{rcvdat,jdbcType=DATE},</if>
            <if test="predat != null">predat = #{predat,jdbcType=DATE},</if>
            <if test="shpdat != null">shpdat = #{shpdat,jdbcType=DATE},</if>
            <if test="credat != null">credat = #{credat,jdbcType=DATE},</if>
            <if test="advdat != null">advdat = #{advdat,jdbcType=DATE},</if>
            <if test="matdat != null">matdat = #{matdat,jdbcType=DATE},</if>
            <if test="opndat != null">opndat = #{opndat,jdbcType=DATE},</if>
            <if test="doctypcod != null">doctypcod = #{doctypcod,jdbcType=VARCHAR},</if>
            <if test="matperbeg != null">matperbeg = #{matperbeg,jdbcType=VARCHAR},</if>
            <if test="matpercnt != null">matpercnt = #{matpercnt,jdbcType=INTEGER},</if>
            <if test="matpertyp != null">matpertyp = #{matpertyp,jdbcType=VARCHAR},</if>
            <if test="ownusr != null">ownusr = #{ownusr,jdbcType=VARCHAR},</if>
            <if test="ver != null">ver = #{ver,jdbcType=VARCHAR},</if>
            <if test="trpdoctyp != null">trpdoctyp = #{trpdoctyp,jdbcType=VARCHAR},</if>
            <if test="trpdocnum != null">trpdocnum = #{trpdocnum,jdbcType=VARCHAR},</if>
            <if test="tradat != null">tradat = #{tradat,jdbcType=DATE},</if>
            <if test="tramod != null">tramod = #{tramod,jdbcType=VARCHAR},</if>
            <if test="shpfro != null">shpfro = #{shpfro,jdbcType=VARCHAR},</if>
            <if test="shpto != null">shpto = #{shpto,jdbcType=VARCHAR},</if>
            <if test="chato != null">chato = #{chato,jdbcType=VARCHAR},</if>
            <if test="othins != null">othins = #{othins,jdbcType=VARCHAR},</if>
            <if test="stacty != null">stacty = #{stacty,jdbcType=VARCHAR},</if>
            <if test="stagod != null">stagod = #{stagod,jdbcType=VARCHAR},</if>
            <if test="accdat != null">accdat = #{accdat,jdbcType=DATE},</if>
            <if test="amenbr != null">amenbr = #{amenbr,jdbcType=INTEGER},</if>
            <if test="dftgarflg != null">dftgarflg = #{dftgarflg,jdbcType=VARCHAR},</if>
            <if test="reltyp != null">reltyp = #{reltyp,jdbcType=VARCHAR},</if>
            <if test="expdat != null">expdat = #{expdat,jdbcType=DATE},</if>
            <if test="rtodreflg != null">rtodreflg = #{rtodreflg,jdbcType=VARCHAR},</if>
            <if test="mattxtflg != null">mattxtflg = #{mattxtflg,jdbcType=VARCHAR},</if>
            <if test="focflg != null">focflg = #{focflg,jdbcType=VARCHAR},</if>
            <if test="waicolcod != null">waicolcod = #{waicolcod,jdbcType=VARCHAR},</if>
            <if test="wairmtcod != null">wairmtcod = #{wairmtcod,jdbcType=VARCHAR},</if>
            <if test="oridre != null">oridre = #{oridre,jdbcType=VARCHAR},</if>
            <if test="docsta != null">docsta = #{docsta,jdbcType=VARCHAR},</if>
            <if test="resflg != null">resflg = #{resflg,jdbcType=VARCHAR},</if>
            <if test="agtdat != null">agtdat = #{agtdat,jdbcType=DATE},</if>
            <if test="etyextkey != null">etyextkey = #{etyextkey,jdbcType=VARCHAR},</if>
            <if test="proins != null">proins = #{proins,jdbcType=VARCHAR},</if>
            <if test="branchinr != null">branchinr = #{branchinr,jdbcType=VARCHAR},</if>
            <if test="bchkeyinr != null">bchkeyinr = #{bchkeyinr,jdbcType=VARCHAR},</if>
            <if test="invref != null">invref = #{invref,jdbcType=VARCHAR},</if>
            <if test="rptref != null">rptref = #{rptref,jdbcType=VARCHAR},</if>
            <if test="prechkdat != null">prechkdat = #{prechkdat,jdbcType=DATE},</if>
            <if test="ischktyp != null">ischktyp = #{ischktyp,jdbcType=VARCHAR},</if>
            <if test="invtyp != null">invtyp = #{invtyp,jdbcType=VARCHAR},</if>
            <if test="goddspcn != null">goddspcn = #{goddspcn,jdbcType=VARCHAR},</if>
            <if test="oppnam != null">oppnam = #{oppnam,jdbcType=VARCHAR},</if>
            clsdat = #{clsdat,jdbcType=DATE}
        </set>
        where inr = #{inr,jdbcType=VARCHAR}
    </update>

    <update id="updateByPrimaryKey">
        update bcd
        <set>
            ownref = #{ownref,jdbcType=VARCHAR},
            nam = #{nam,jdbcType=VARCHAR},
            relgodflg = #{relgodflg,jdbcType=VARCHAR},
            relgoddat = #{relgoddat,jdbcType=DATE},
            rcvdat = #{rcvdat,jdbcType=DATE},
            predat = #{predat,jdbcType=DATE},
            shpdat = #{shpdat,jdbcType=DATE},
            credat = #{credat,jdbcType=DATE},
            advdat = #{advdat,jdbcType=DATE},
            clsdat = #{clsdat,jdbcType=DATE},
            matdat = #{matdat,jdbcType=DATE},
            opndat = #{opndat,jdbcType=DATE},
            doctypcod = #{doctypcod,jdbcType=VARCHAR},
            matperbeg = #{matperbeg,jdbcType=VARCHAR},
            matpercnt = #{matpercnt,jdbcType=INTEGER},
            matpertyp = #{matpertyp,jdbcType=VARCHAR},
            ownusr = #{ownusr,jdbcType=VARCHAR},
            ver = #{ver,jdbcType=VARCHAR},
            trpdoctyp = #{trpdoctyp,jdbcType=VARCHAR},
            trpdocnum = #{trpdocnum,jdbcType=VARCHAR},
            tradat = #{tradat,jdbcType=DATE},
            tramod = #{tramod,jdbcType=VARCHAR},
            shpfro = #{shpfro,jdbcType=VARCHAR},
            shpto = #{shpto,jdbcType=VARCHAR},
            chato = #{chato,jdbcType=VARCHAR},
            othins = #{othins,jdbcType=VARCHAR},
            stacty = #{stacty,jdbcType=VARCHAR},
            stagod = #{stagod,jdbcType=VARCHAR},
            accdat = #{accdat,jdbcType=DATE},
            amenbr = #{amenbr,jdbcType=INTEGER},
            dftgarflg = #{dftgarflg,jdbcType=VARCHAR},
            reltyp = #{reltyp,jdbcType=VARCHAR},
            expdat = #{expdat,jdbcType=DATE},
            rtodreflg = #{rtodreflg,jdbcType=VARCHAR},
            mattxtflg = #{mattxtflg,jdbcType=VARCHAR},
            focflg = #{focflg,jdbcType=VARCHAR},
            waicolcod = #{waicolcod,jdbcType=VARCHAR},
            wairmtcod = #{wairmtcod,jdbcType=VARCHAR},
            oridre = #{oridre,jdbcType=VARCHAR},
            docsta = #{docsta,jdbcType=VARCHAR},
            resflg = #{resflg,jdbcType=VARCHAR},
            agtdat = #{agtdat,jdbcType=DATE},
            etyextkey = #{etyextkey,jdbcType=VARCHAR},
            proins = #{proins,jdbcType=VARCHAR},
            branchinr = #{branchinr,jdbcType=VARCHAR},
            bchkeyinr = #{bchkeyinr,jdbcType=VARCHAR},
            invref = #{invref,jdbcType=VARCHAR},
            rptref = #{rptref,jdbcType=VARCHAR},
            prechkdat = #{prechkdat,jdbcType=DATE},
            ischktyp = #{ischktyp,jdbcType=VARCHAR},
            invtyp = #{invtyp,jdbcType=VARCHAR},
            goddspcn = #{goddspcn,jdbcType=VARCHAR},
            oppnam = #{oppnam,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>

    <update id="dyncUpdate">
        update bcd
        <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.relgodflg != null">relgodflg = #{module.relgodflg,jdbcType=VARCHAR},</if>
            <if test="module.relgoddat != null">relgoddat = #{module.relgoddat,jdbcType=DATE},</if>
            <if test="module.rcvdat != null">rcvdat = #{module.rcvdat,jdbcType=DATE},</if>
            <if test="module.predat != null">predat = #{module.predat,jdbcType=DATE},</if>
            <if test="module.shpdat != null">shpdat = #{module.shpdat,jdbcType=DATE},</if>
            <if test="module.credat != null">credat = #{module.credat,jdbcType=DATE},</if>
            <if test="module.advdat != null">advdat = #{module.advdat,jdbcType=DATE},</if>
            <if test="module.clsdat != null">clsdat = #{module.clsdat,jdbcType=DATE},</if>
            <if test="module.matdat != null">matdat = #{module.matdat,jdbcType=DATE},</if>
            <if test="module.opndat != null">opndat = #{module.opndat,jdbcType=DATE},</if>
            <if test="module.doctypcod != null">doctypcod = #{module.doctypcod,jdbcType=VARCHAR},</if>
            <if test="module.matperbeg != null">matperbeg = #{module.matperbeg,jdbcType=VARCHAR},</if>
            <if test="module.matpercnt != null">matpercnt = #{module.matpercnt,jdbcType=INTEGER},</if>
            <if test="module.matpertyp != null">matpertyp = #{module.matpertyp,jdbcType=VARCHAR},</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.trpdoctyp != null">trpdoctyp = #{module.trpdoctyp,jdbcType=VARCHAR},</if>
            <if test="module.trpdocnum != null">trpdocnum = #{module.trpdocnum,jdbcType=VARCHAR},</if>
            <if test="module.tradat != null">tradat = #{module.tradat,jdbcType=DATE},</if>
            <if test="module.tramod != null">tramod = #{module.tramod,jdbcType=VARCHAR},</if>
            <if test="module.shpfro != null">shpfro = #{module.shpfro,jdbcType=VARCHAR},</if>
            <if test="module.shpto != null">shpto = #{module.shpto,jdbcType=VARCHAR},</if>
            <if test="module.chato != null">chato = #{module.chato,jdbcType=VARCHAR},</if>
            <if test="module.othins != null">othins = #{module.othins,jdbcType=VARCHAR},</if>
            <if test="module.stacty != null">stacty = #{module.stacty,jdbcType=VARCHAR},</if>
            <if test="module.stagod != null">stagod = #{module.stagod,jdbcType=VARCHAR},</if>
            <if test="module.accdat != null">accdat = #{module.accdat,jdbcType=DATE},</if>
            <if test="module.amenbr != null">amenbr = #{module.amenbr,jdbcType=INTEGER},</if>
            <if test="module.dftgarflg != null">dftgarflg = #{module.dftgarflg,jdbcType=VARCHAR},</if>
            <if test="module.reltyp != null">reltyp = #{module.reltyp,jdbcType=VARCHAR},</if>
            <if test="module.expdat != null">expdat = #{module.expdat,jdbcType=DATE},</if>
            <if test="module.rtodreflg != null">rtodreflg = #{module.rtodreflg,jdbcType=VARCHAR},</if>
            <if test="module.mattxtflg != null">mattxtflg = #{module.mattxtflg,jdbcType=VARCHAR},</if>
            <if test="module.focflg != null">focflg = #{module.focflg,jdbcType=VARCHAR},</if>
            <if test="module.waicolcod != null">waicolcod = #{module.waicolcod,jdbcType=VARCHAR},</if>
            <if test="module.wairmtcod != null">wairmtcod = #{module.wairmtcod,jdbcType=VARCHAR},</if>
            <if test="module.oridre != null">oridre = #{module.oridre,jdbcType=VARCHAR},</if>
            <if test="module.docsta != null">docsta = #{module.docsta,jdbcType=VARCHAR},</if>
            <if test="module.resflg != null">resflg = #{module.resflg,jdbcType=VARCHAR},</if>
            <if test="module.agtdat != null">agtdat = #{module.agtdat,jdbcType=DATE},</if>
            <if test="module.etyextkey != null">etyextkey = #{module.etyextkey,jdbcType=VARCHAR},</if>
            <if test="module.proins != null">proins = #{module.proins,jdbcType=VARCHAR},</if>
            <if test="module.branchinr != null">branchinr = #{module.branchinr,jdbcType=VARCHAR},</if>
            <if test="module.bchkeyinr != null">bchkeyinr = #{module.bchkeyinr,jdbcType=VARCHAR},</if>
            <if test="module.invref != null">invref = #{module.invref,jdbcType=VARCHAR},</if>
            <if test="module.rptref != null">rptref = #{module.rptref,jdbcType=VARCHAR},</if>
            <if test="module.prechkdat != null">prechkdat = #{module.prechkdat,jdbcType=DATE},</if>
            <if test="module.ischktyp != null">ischktyp = #{module.ischktyp,jdbcType=VARCHAR},</if>
            <if test="module.invtyp != null">invtyp = #{module.invtyp,jdbcType=VARCHAR},</if>
            <if test="module.goddspcn != null">goddspcn = #{module.goddspcn,jdbcType=VARCHAR},</if>
            <if test="module.oppnam != null">oppnam = #{module.oppnam,jdbcType=VARCHAR},</if>
        </set>
        ${conditions}
    </update>

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

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

    <select id="selectByAnyref" resultType="com.brilliance.isc.bo.Bcd">
        select
        <include refid="Base_Column_List"/>
        from bcd 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" resultType="com.brilliance.isc.bo.Bcd">
        select
        <include refid="Base_Column_List"/>
        from bcd WHERE 1=1
        <if test="ownref != null and ownref != ''"> and ownref = #{ownref,jdbcType=VARCHAR}</if>
        limit 1
    </select>

    <select id="selectInrByownref" resultType="java.lang.String">
        select inr from bcd where ownref = #{ownref}
    </select>
    <select id="queryBcd" resultType="com.brilliance.isc.vo.collection.BcdWithPtsCbbResponseVo">
        select
        bcd.*,
        cbb.cur cur, cbb.amt amt,pty.extkey dreExtkey,pty.nam1 dreName,
        pts2.extkey rmiExtkey,pts2.nam rmiName
        from bcd
        left join cbb on cbb.OBJINR = bcd.inr and cbb.OBJTYP = 'BCD'  and cbb.cbc = 'MAXSUM' and cbb.extid = 'AMT1' and cbb.enddat = '2299-12-31'
        left join pts pts1 on pts1.OBJINR = bcd.inr and pts1.OBJTYP = 'BCD' and pts1.rol = 'DRE'
        left join pts pts2 on pts2.OBJINR = bcd.inr and pts2.OBJTYP = 'BCD' and pts2.rol = 'RMI'
        left join pty pty on pty.inr = pts1.ptyinr
        where 1 = 1
        <!--机构隔离-->
        <if test="bchinr != null and bchinr != '' ">
            AND bcd.bchkeyinr = #{bchinr}
        </if>
        <!--业务编号-->
        <if test="seaownref != null and seaownref != ''">
            AND UPPER(bcd.OWNREF) LIKE concat(concat('%', UPPER(#{seaownref})), '%')
        </if>
        <!--日期-->
        <if test="opndatfrom != null and opndatfrom != ''">
            AND bcd.CREDAT &gt;= #{opndatfrom}
        </if>
        <if test="opndatto != null and opndatto != ''">
            AND bcd.CREDAT &lt;= #{opndatto}
        </if>
        <!--客户号/名称 -->
        <if test="searef != null and searef != ''">
            and exists (
            select 1 from PTS,PTY
            where bcd.INR = PTS.OBJINR
            AND PTY.INR = PTS.PTYINR
            AND PTS.OBJTYP = 'BCD'
            AND PTS.ROL = 'DRE'
            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 bcd.clsdat is not null
            </if>
            <if test="isClosed == 'N'.toString()">
                and bcd.clsdat is  null
            </if>
        </if>
        order by bcd.CREDAT desc , bcd.ownref desc
    </select>

    <select id="selectByOwn" resultType="com.brilliance.isc.bo.Bcd">
        select
        <include refid="Base_Column_List"/>
        from bcd
        where
        (ownref LIKE concat(concat('%', #{ownref}), '%')
        or nam LIKE concat(concat('%', #{ownref}), '%'))
        and clsdat is null
        <if test="bchkeyinr != null and bchkeyinr != '' ">
            AND bchkeyinr = #{bchkeyinr}
        </if>
    </select>

    <select id="queryByInr" resultType="com.brilliance.isc.bo.Bcd">
        select
        <include refid="Base_Column_List" />
        from bcd
        where inr = #{inr,jdbcType=VARCHAR}
    </select>
    <select id="queryBcdInfo" resultType="com.brilliance.isc.vo.collection.BcdWithPtsCbbResponseVo">
        select
        bcd.*,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,
        dre.extkey dreExtkey,dre.nam dreName,drr.EXTKEY drrExtkey,drr.nam drrName,rmi.EXTKEY rmiExtkey,rmi.nam rmiName
        from bcd
        left join cbb max1 on max1.OBJINR = bcd.inr and max1.OBJTYP = 'BCD' and max1.cbc = 'MAXSUM' and max1.extid =
        'AMT1' and max1.enddat = '2299-12-31'
        left join cbb max2 on max2.OBJINR = bcd.inr and max2.OBJTYP = 'BCD' and max2.cbc = 'MAXSUM' and max2.extid =
        'AMT2' and max2.enddat = '2299-12-31'
        left join cbb opn1 on opn1.OBJINR = bcd.inr and opn1.OBJTYP = 'BCD' and opn1.cbc = 'OPN' and opn1.extid = 'AMT1'
        and opn1.enddat = '2299-12-31'
        left join cbb opn2 on opn2.OBJINR = bcd.inr and opn2.OBJTYP = 'BCD' and opn2.cbc = 'OPN' and opn2.extid = 'AMT2'
        and opn2.enddat = '2299-12-31'
        left join pts dre on dre.OBJINR = bcd.inr and dre.OBJTYP = 'BCD' and dre.rol = 'DRE'
        left join pts drr on drr.OBJINR = bcd.inr and drr.OBJTYP = 'BCD' and drr.rol = 'DRR'
        left join pts rmi on rmi.OBJINR = bcd.inr and rmi.OBJTYP = 'BCD' and rmi.rol = 'RMI'
        left join bch bch on bch.inr = bcd.BCHKEYINR
        left join usr usr on usr.EXTKEY = bcd.OWNUSR
        where bcd.flwsta = 'R'
        <!--机构隔离-->
        <if test="bchinr != null and bchinr != '' ">
            AND bcd.bchkeyinr = #{bchinr}
        </if>
        <!--业务编号-->
        <if test="seaownref != null and seaownref != ''">
            AND UPPER(bcd.OWNREF) LIKE concat(concat('%', UPPER(#{seaownref})), '%')
        </if>
        <!--日期-->
        <if test="opndatfrom != null and opndatfrom != ''">
            AND bcd.CREDAT &gt;= #{opndatfrom}
        </if>
        <if test="opndatto != null and opndatto != ''">
            AND bcd.CREDAT &lt;= #{opndatto}
        </if>
          <if test="seadoctyp != null and seadoctyp != ''">
            AND bcd.doctypcod = #{seadoctyp}
          </if>
        <!--客户号/名称 -->
        <if test="ptyExtkey != null and ptyExtkey != ''">
            and exists (
            select 1 from PTS
            where bcd.INR = PTS.OBJINR
            AND PTS.OBJTYP = 'BCD'
            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 bcd.INR = PTS.OBJINR
            AND PTS.OBJTYP = 'BCD'
            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}), '%')
            or PTS.NAM LIKE concat(concat('%', #{seapty}), '%')
            )
            )
        </if>
        <!--当事人参考号 -->
        <if test="searef != null and searef != ''">
            and exists (
            select 1 from PTS
            where bcd.INR = PTS.OBJINR
            AND PTS.OBJTYP = 'BCD'
            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 = 'BCD'
            AND INFCONCBS.OBJINR = BCD.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 bcd.clsdat is not null
            </if>
            <if test="seasta == 'O'.toString()">
                and bcd.clsdat is null
            </if>
        </if>
        <!--货物类型-->
        <if test="seagodcod != null and seagodcod != '' ">
            AND bcd.stagod = #{seagodcod}
        </if>
        <if test='column != null and column!="" '>
            order by  ${column}  ${order}
        </if>
        <if test='column == null or column=="" '>
            order by bcd.credat desc , bcd.ownref desc
        </if>
    </select>

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

</mapper>