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

    <resultMap id="BaseResultMap" type="com.brilliance.isc.bo.Bod">
        <result property="inr" column="inr" jdbcType="VARCHAR"/>
        <result property="ownref" column="ownref" jdbcType="VARCHAR"/>
        <result property="nam" column="nam" jdbcType="VARCHAR"/>
        <result property="agtref" column="agtref" jdbcType="VARCHAR"/>
        <result property="agtact" column="agtact" jdbcType="VARCHAR"/>
        <result property="agtcom" column="agtcom" jdbcType="VARCHAR"/>
        <result property="shpdat" column="shpdat" jdbcType="DATE"/>
        <result property="predat" column="predat" jdbcType="DATE"/>
        <result property="rcvdat" column="rcvdat" jdbcType="DATE"/>
        <result property="opndat" column="opndat" jdbcType="DATE"/>
        <result property="advdat" column="advdat" jdbcType="DATE"/>
        <result property="matdat" column="matdat" jdbcType="DATE"/>
        <result property="clsdat" column="clsdat" 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="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="waicolcod" column="waicolcod" jdbcType="VARCHAR"/>
        <result property="wairmtcod" column="wairmtcod" jdbcType="VARCHAR"/>
        <result property="chato" column="chato" jdbcType="VARCHAR"/>
        <result property="stacty" column="stacty" jdbcType="VARCHAR"/>
        <result property="stagod" column="stagod" jdbcType="VARCHAR"/>
        <result property="credat" column="credat" jdbcType="DATE"/>
        <result property="ownusr" column="ownusr" jdbcType="VARCHAR"/>
        <result property="ver" column="ver" jdbcType="VARCHAR"/>
        <result property="focflg" column="focflg" jdbcType="VARCHAR"/>
        <result property="dircolflg" column="dircolflg" jdbcType="VARCHAR"/>
        <result property="ccdpurflg" column="ccdpurflg" jdbcType="VARCHAR"/>
        <result property="ccdndrflg" column="ccdndrflg" jdbcType="VARCHAR"/>
        <result property="issdat" column="issdat" jdbcType="DATE"/>
        <result property="paydocnum" column="paydocnum" jdbcType="VARCHAR"/>
        <result property="paydoctyp" column="paydoctyp" jdbcType="VARCHAR"/>
        <result property="mattxtflg" column="mattxtflg" jdbcType="VARCHAR"/>
        <result property="othins" column="othins" jdbcType="VARCHAR"/>
        <result property="docsta" column="docsta" jdbcType="VARCHAR"/>
        <result property="resflg" column="resflg" jdbcType="VARCHAR"/>
        <result property="amenbr" column="amenbr" jdbcType="INTEGER"/>
        <result property="msgrol" column="msgrol" jdbcType="VARCHAR"/>
        <result property="etyextkey" column="etyextkey" jdbcType="VARCHAR"/>
        <result property="lescom" column="lescom" jdbcType="DECIMAL"/>
        <result property="branchinr" column="branchinr" jdbcType="VARCHAR"/>
        <result property="bchkeyinr" column="bchkeyinr" jdbcType="VARCHAR"/>
        <result property="invtyp" column="invtyp" jdbcType="VARCHAR"/>
        <result property="goddspcn" column="goddspcn" jdbcType="VARCHAR"/>
        <result property="invref" column="invref" jdbcType="VARCHAR"/>
        <result property="oppnam" column="oppnam" jdbcType="VARCHAR"/>
    </resultMap>

    <sql id="Base_Column_List">
        inr,ownref,nam,agtref,agtact,agtcom,shpdat,predat,rcvdat,opndat,advdat,matdat,clsdat,doctypcod,matperbeg,matpercnt,matpertyp,trpdoctyp,trpdocnum,tradat,tramod,shpfro,shpto,waicolcod,wairmtcod,chato,stacty,stagod,credat,ownusr,ver,focflg,dircolflg,ccdpurflg,ccdndrflg,issdat,paydocnum,paydoctyp,mattxtflg,othins,docsta,resflg,amenbr,msgrol,etyextkey,lescom,branchinr,bchkeyinr,invtyp,goddspcn,invref,oppnam
    </sql>

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

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

    <insert id="insert">
        insert into bod (<include refid="Base_Column_List" />)
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            #{inr,jdbcType=VARCHAR},
            #{ownref,jdbcType=VARCHAR},
            #{nam,jdbcType=VARCHAR},
            #{agtref,jdbcType=VARCHAR},
            #{agtact,jdbcType=VARCHAR},
            #{agtcom,jdbcType=VARCHAR},
            #{shpdat,jdbcType=DATE},
            #{predat,jdbcType=DATE},
            #{rcvdat,jdbcType=DATE},
            #{opndat,jdbcType=DATE},
            #{advdat,jdbcType=DATE},
            #{matdat,jdbcType=DATE},
            #{clsdat,jdbcType=DATE},
            #{doctypcod,jdbcType=VARCHAR},
            #{matperbeg,jdbcType=VARCHAR},
            #{matpercnt,jdbcType=INTEGER},
            #{matpertyp,jdbcType=VARCHAR},
            #{trpdoctyp,jdbcType=VARCHAR},
            #{trpdocnum,jdbcType=VARCHAR},
            #{tradat,jdbcType=DATE},
            #{tramod,jdbcType=VARCHAR},
            #{shpfro,jdbcType=VARCHAR},
            #{shpto,jdbcType=VARCHAR},
            #{waicolcod,jdbcType=VARCHAR},
            #{wairmtcod,jdbcType=VARCHAR},
            #{chato,jdbcType=VARCHAR},
            #{stacty,jdbcType=VARCHAR},
            #{stagod,jdbcType=VARCHAR},
            #{credat,jdbcType=DATE},
            #{ownusr,jdbcType=VARCHAR},
            #{ver,jdbcType=VARCHAR},
            #{focflg,jdbcType=VARCHAR},
            #{dircolflg,jdbcType=VARCHAR},
            #{ccdpurflg,jdbcType=VARCHAR},
            #{ccdndrflg,jdbcType=VARCHAR},
            #{issdat,jdbcType=DATE},
            #{paydocnum,jdbcType=VARCHAR},
            #{paydoctyp,jdbcType=VARCHAR},
            #{mattxtflg,jdbcType=VARCHAR},
            #{othins,jdbcType=VARCHAR},
            #{docsta,jdbcType=VARCHAR},
            #{resflg,jdbcType=VARCHAR},
            #{amenbr,jdbcType=INTEGER},
            #{msgrol,jdbcType=VARCHAR},
            #{etyextkey,jdbcType=VARCHAR},
            #{lescom,jdbcType=DECIMAL},
            #{branchinr,jdbcType=VARCHAR},
            #{bchkeyinr,jdbcType=VARCHAR},
            #{invtyp,jdbcType=VARCHAR},
            #{goddspcn,jdbcType=VARCHAR},
            #{invref,jdbcType=VARCHAR},
            #{oppnam,jdbcType=VARCHAR},
        </trim>
    </insert>

    <insert id="insertSelective">
        insert into bod
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="inr != null">inr,</if>
            <if test="ownref != null">ownref,</if>
            <if test="nam != null">nam,</if>
            <if test="agtref != null">agtref,</if>
            <if test="agtact != null">agtact,</if>
            <if test="agtcom != null">agtcom,</if>
            <if test="shpdat != null">shpdat,</if>
            <if test="predat != null">predat,</if>
            <if test="rcvdat != null">rcvdat,</if>
            <if test="opndat != null">opndat,</if>
            <if test="advdat != null">advdat,</if>
            <if test="matdat != null">matdat,</if>
            <if test="clsdat != null">clsdat,</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="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="waicolcod != null">waicolcod,</if>
            <if test="wairmtcod != null">wairmtcod,</if>
            <if test="chato != null">chato,</if>
            <if test="stacty != null">stacty,</if>
            <if test="stagod != null">stagod,</if>
            <if test="credat != null">credat,</if>
            <if test="ownusr != null">ownusr,</if>
            <if test="ver != null">ver,</if>
            <if test="focflg != null">focflg,</if>
            <if test="dircolflg != null">dircolflg,</if>
            <if test="ccdpurflg != null">ccdpurflg,</if>
            <if test="ccdndrflg != null">ccdndrflg,</if>
            <if test="issdat != null">issdat,</if>
            <if test="paydocnum != null">paydocnum,</if>
            <if test="paydoctyp != null">paydoctyp,</if>
            <if test="mattxtflg != null">mattxtflg,</if>
            <if test="othins != null">othins,</if>
            <if test="docsta != null">docsta,</if>
            <if test="resflg != null">resflg,</if>
            <if test="amenbr != null">amenbr,</if>
            <if test="msgrol != null">msgrol,</if>
            <if test="etyextkey != null">etyextkey,</if>
            <if test="lescom != null">lescom,</if>
            <if test="branchinr != null">branchinr,</if>
            <if test="bchkeyinr != null">bchkeyinr,</if>
            <if test="invtyp != null">invtyp,</if>
            <if test="goddspcn != null">goddspcn,</if>
            <if test="invref != null">invref,</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="agtref != null">#{agtref,jdbcType=VARCHAR}, </if>
            <if test="agtact != null">#{agtact,jdbcType=VARCHAR}, </if>
            <if test="agtcom != null">#{agtcom,jdbcType=VARCHAR}, </if>
            <if test="shpdat != null">#{shpdat,jdbcType=DATE}, </if>
            <if test="predat != null">#{predat,jdbcType=DATE}, </if>
            <if test="rcvdat != null">#{rcvdat,jdbcType=DATE}, </if>
            <if test="opndat != null">#{opndat,jdbcType=DATE}, </if>
            <if test="advdat != null">#{advdat,jdbcType=DATE}, </if>
            <if test="matdat != null">#{matdat,jdbcType=DATE}, </if>
            <if test="clsdat != null">#{clsdat,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="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="waicolcod != null">#{waicolcod,jdbcType=VARCHAR}, </if>
            <if test="wairmtcod != null">#{wairmtcod,jdbcType=VARCHAR}, </if>
            <if test="chato != null">#{chato,jdbcType=VARCHAR}, </if>
            <if test="stacty != null">#{stacty,jdbcType=VARCHAR}, </if>
            <if test="stagod != null">#{stagod,jdbcType=VARCHAR}, </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="focflg != null">#{focflg,jdbcType=VARCHAR}, </if>
            <if test="dircolflg != null">#{dircolflg,jdbcType=VARCHAR}, </if>
            <if test="ccdpurflg != null">#{ccdpurflg,jdbcType=VARCHAR}, </if>
            <if test="ccdndrflg != null">#{ccdndrflg,jdbcType=VARCHAR}, </if>
            <if test="issdat != null">#{issdat,jdbcType=DATE}, </if>
            <if test="paydocnum != null">#{paydocnum,jdbcType=VARCHAR}, </if>
            <if test="paydoctyp != null">#{paydoctyp,jdbcType=VARCHAR}, </if>
            <if test="mattxtflg != null">#{mattxtflg,jdbcType=VARCHAR}, </if>
            <if test="othins != null">#{othins,jdbcType=VARCHAR}, </if>
            <if test="docsta != null">#{docsta,jdbcType=VARCHAR}, </if>
            <if test="resflg != null">#{resflg,jdbcType=VARCHAR}, </if>
            <if test="amenbr != null">#{amenbr,jdbcType=INTEGER}, </if>
            <if test="msgrol != null">#{msgrol,jdbcType=VARCHAR}, </if>
            <if test="etyextkey != null">#{etyextkey,jdbcType=VARCHAR}, </if>
            <if test="lescom != null">#{lescom,jdbcType=DECIMAL}, </if>
            <if test="branchinr != null">#{branchinr,jdbcType=VARCHAR}, </if>
            <if test="bchkeyinr != null">#{bchkeyinr,jdbcType=VARCHAR}, </if>
            <if test="invtyp != null">#{invtyp,jdbcType=VARCHAR}, </if>
            <if test="goddspcn != null">#{goddspcn,jdbcType=VARCHAR}, </if>
            <if test="invref != null">#{invref,jdbcType=VARCHAR}, </if>
            <if test="oppnam != null">#{oppnam,jdbcType=VARCHAR}, </if>
        </trim>
    </insert>

    <update id="updateByPrimaryKeySelective">
        update bod
        <set>
            <if test="ownref != null">ownref = #{ownref,jdbcType=VARCHAR},</if>
            <if test="nam != null">nam = #{nam,jdbcType=VARCHAR},</if>
            <if test="agtref != null">agtref = #{agtref,jdbcType=VARCHAR},</if>
            <if test="agtact != null">agtact = #{agtact,jdbcType=VARCHAR},</if>
            <if test="agtcom != null">agtcom = #{agtcom,jdbcType=VARCHAR},</if>
            <if test="shpdat != null">shpdat = #{shpdat,jdbcType=DATE},</if>
            <if test="predat != null">predat = #{predat,jdbcType=DATE},</if>
            <if test="rcvdat != null">rcvdat = #{rcvdat,jdbcType=DATE},</if>
            <if test="opndat != null">opndat = #{opndat,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="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="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="waicolcod != null">waicolcod = #{waicolcod,jdbcType=VARCHAR},</if>
            <if test="wairmtcod != null">wairmtcod = #{wairmtcod,jdbcType=VARCHAR},</if>
            <if test="chato != null">chato = #{chato,jdbcType=VARCHAR},</if>
            <if test="stacty != null">stacty = #{stacty,jdbcType=VARCHAR},</if>
            <if test="stagod != null">stagod = #{stagod,jdbcType=VARCHAR},</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="focflg != null">focflg = #{focflg,jdbcType=VARCHAR},</if>
            <if test="dircolflg != null">dircolflg = #{dircolflg,jdbcType=VARCHAR},</if>
            <if test="ccdpurflg != null">ccdpurflg = #{ccdpurflg,jdbcType=VARCHAR},</if>
            <if test="ccdndrflg != null">ccdndrflg = #{ccdndrflg,jdbcType=VARCHAR},</if>
            <if test="issdat != null">issdat = #{issdat,jdbcType=DATE},</if>
            <if test="paydocnum != null">paydocnum = #{paydocnum,jdbcType=VARCHAR},</if>
            <if test="paydoctyp != null">paydoctyp = #{paydoctyp,jdbcType=VARCHAR},</if>
            <if test="mattxtflg != null">mattxtflg = #{mattxtflg,jdbcType=VARCHAR},</if>
            <if test="othins != null">othins = #{othins,jdbcType=VARCHAR},</if>
            <if test="docsta != null">docsta = #{docsta,jdbcType=VARCHAR},</if>
            <if test="resflg != null">resflg = #{resflg,jdbcType=VARCHAR},</if>
            <if test="amenbr != null">amenbr = #{amenbr,jdbcType=INTEGER},</if>
            <if test="msgrol != null">msgrol = #{msgrol,jdbcType=VARCHAR},</if>
            <if test="etyextkey != null">etyextkey = #{etyextkey,jdbcType=VARCHAR},</if>
            <if test="lescom != null">lescom = #{lescom,jdbcType=DECIMAL},</if>
            <if test="branchinr != null">branchinr = #{branchinr,jdbcType=VARCHAR},</if>
            <if test="bchkeyinr != null">bchkeyinr = #{bchkeyinr,jdbcType=VARCHAR},</if>
            <if test="invtyp != null">invtyp = #{invtyp,jdbcType=VARCHAR},</if>
            <if test="goddspcn != null">goddspcn = #{goddspcn,jdbcType=VARCHAR},</if>
            <if test="invref != null">invref = #{invref,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 bod
        <set>
            ownref = #{ownref,jdbcType=VARCHAR},
            nam = #{nam,jdbcType=VARCHAR},
            agtref = #{agtref,jdbcType=VARCHAR},
            agtact = #{agtact,jdbcType=VARCHAR},
            agtcom = #{agtcom,jdbcType=VARCHAR},
            shpdat = #{shpdat,jdbcType=DATE},
            predat = #{predat,jdbcType=DATE},
            rcvdat = #{rcvdat,jdbcType=DATE},
            opndat = #{opndat,jdbcType=DATE},
            advdat = #{advdat,jdbcType=DATE},
            matdat = #{matdat,jdbcType=DATE},
            clsdat = #{clsdat,jdbcType=DATE},
            doctypcod = #{doctypcod,jdbcType=VARCHAR},
            matperbeg = #{matperbeg,jdbcType=VARCHAR},
            matpercnt = #{matpercnt,jdbcType=INTEGER},
            matpertyp = #{matpertyp,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},
            waicolcod = #{waicolcod,jdbcType=VARCHAR},
            wairmtcod = #{wairmtcod,jdbcType=VARCHAR},
            chato = #{chato,jdbcType=VARCHAR},
            stacty = #{stacty,jdbcType=VARCHAR},
            stagod = #{stagod,jdbcType=VARCHAR},
            credat = #{credat,jdbcType=DATE},
            ownusr = #{ownusr,jdbcType=VARCHAR},
            ver = #{ver,jdbcType=VARCHAR},
            focflg = #{focflg,jdbcType=VARCHAR},
            dircolflg = #{dircolflg,jdbcType=VARCHAR},
            ccdpurflg = #{ccdpurflg,jdbcType=VARCHAR},
            ccdndrflg = #{ccdndrflg,jdbcType=VARCHAR},
            issdat = #{issdat,jdbcType=DATE},
            paydocnum = #{paydocnum,jdbcType=VARCHAR},
            paydoctyp = #{paydoctyp,jdbcType=VARCHAR},
            mattxtflg = #{mattxtflg,jdbcType=VARCHAR},
            othins = #{othins,jdbcType=VARCHAR},
            docsta = #{docsta,jdbcType=VARCHAR},
            resflg = #{resflg,jdbcType=VARCHAR},
            amenbr = #{amenbr,jdbcType=INTEGER},
            msgrol = #{msgrol,jdbcType=VARCHAR},
            etyextkey = #{etyextkey,jdbcType=VARCHAR},
            lescom = #{lescom,jdbcType=DECIMAL},
            branchinr = #{branchinr,jdbcType=VARCHAR},
            bchkeyinr = #{bchkeyinr,jdbcType=VARCHAR},
            invtyp = #{invtyp,jdbcType=VARCHAR},
            goddspcn = #{goddspcn,jdbcType=VARCHAR},
            invref = #{invref,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 bod
        <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.agtref != null">agtref = #{module.agtref,jdbcType=VARCHAR},</if>
            <if test="module.agtact != null">agtact = #{module.agtact,jdbcType=VARCHAR},</if>
            <if test="module.agtcom != null">agtcom = #{module.agtcom,jdbcType=VARCHAR},</if>
            <if test="module.shpdat != null">shpdat = #{module.shpdat,jdbcType=DATE},</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.opndat != null">opndat = #{module.opndat,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.clsdat != null">clsdat = #{module.clsdat,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.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.waicolcod != null">waicolcod = #{module.waicolcod,jdbcType=VARCHAR},</if>
            <if test="module.wairmtcod != null">wairmtcod = #{module.wairmtcod,jdbcType=VARCHAR},</if>
            <if test="module.chato != null">chato = #{module.chato,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.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.focflg != null">focflg = #{module.focflg,jdbcType=VARCHAR},</if>
            <if test="module.dircolflg != null">dircolflg = #{module.dircolflg,jdbcType=VARCHAR},</if>
            <if test="module.ccdpurflg != null">ccdpurflg = #{module.ccdpurflg,jdbcType=VARCHAR},</if>
            <if test="module.ccdndrflg != null">ccdndrflg = #{module.ccdndrflg,jdbcType=VARCHAR},</if>
            <if test="module.issdat != null">issdat = #{module.issdat,jdbcType=DATE},</if>
            <if test="module.paydocnum != null">paydocnum = #{module.paydocnum,jdbcType=VARCHAR},</if>
            <if test="module.paydoctyp != null">paydoctyp = #{module.paydoctyp,jdbcType=VARCHAR},</if>
            <if test="module.mattxtflg != null">mattxtflg = #{module.mattxtflg,jdbcType=VARCHAR},</if>
            <if test="module.othins != null">othins = #{module.othins,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.amenbr != null">amenbr = #{module.amenbr,jdbcType=INTEGER},</if>
            <if test="module.msgrol != null">msgrol = #{module.msgrol,jdbcType=VARCHAR},</if>
            <if test="module.etyextkey != null">etyextkey = #{module.etyextkey,jdbcType=VARCHAR},</if>
            <if test="module.lescom != null">lescom = #{module.lescom,jdbcType=DECIMAL},</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.invtyp != null">invtyp = #{module.invtyp,jdbcType=VARCHAR},</if>
            <if test="module.goddspcn != null">goddspcn = #{module.goddspcn,jdbcType=VARCHAR},</if>
            <if test="module.invref != null">invref = #{module.invref,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.Bod">
        select
        <include refid="Base_Column_List"/>
        from bod 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.Bod">
        select
        <include refid="Base_Column_List"/>
        from bod 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 bod where ownref = #{ownref}
    </select>

    <select id="selectByOwnref" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from bod where ownref = #{ownref}
    </select>
    <select id="queryBod" resultType="com.brilliance.isc.vo.collection.BodWithPtsCbbResponseVo">
        select
        bod.*,
        cbb.cur cur, cbb.amt amt,pty.extkey drrExtkey,pty.nam1 drrName,dre.EXTKEY dreExtkey,dre.NAM dreName,
        col.extkey colExtkey,col.nam colName
        from bod
        left join cbb on cbb.OBJINR = bod.inr and cbb.OBJTYP = 'BOD'  and cbb.cbc = 'MAXSUM' and cbb.extid = 'AMT1' and cbb.enddat = '2299-12-31'
        left join pts drr on drr.OBJINR = bod.inr and drr.OBJTYP = 'BOD' and drr.rol = 'DRR'
        left join pts dre on dre.OBJINR = bod.inr and dre.OBJTYP = 'BOD' and dre.rol = 'DRE'
        left join pts col on col.OBJINR = bod.inr and col.OBJTYP = 'BOD' and col.rol = 'COL'
        left join pty pty on pty.inr = drr.ptyinr
        where 1 = 1
        <if test="bchtyp == '6'.toString()">
            and bod.flwsta = 'R'
        </if>
        <!--机构隔离-->
        <if test="bchinr != null and bchinr != '' ">
            AND bod.bchkeyinr = #{bchinr}
        </if>
        <!--业务编号-->
        <if test="seaownref != null and seaownref != ''">
            AND UPPER(bod.OWNREF) LIKE concat(concat('%', UPPER(#{seaownref})), '%')
        </if>
        <!--日期-->
        <if test="opndatfrom != null and opndatfrom != ''">
            AND bod.credat &gt;= #{opndatfrom}
        </if>
        <if test="opndatto != null and opndatto != ''">
            AND bod.credat &lt;= #{opndatto}
        </if>
        <!--客户号/名称 -->
        <if test="searef != null and searef != ''">
            and exists (
            select 1 from PTS,PTY
            where bod.INR = PTS.OBJINR
            AND PTY.INR = PTS.PTYINR
            AND PTS.OBJTYP = 'BOD'
            AND PTS.ROL = 'DRR'
            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 bod.clsdat is not null
            </if>
            <if test="isClosed == 'N'.toString()">
                and bod.clsdat is  null
            </if>
        </if>
        order by bod.credat desc , bod.ownref desc
    </select>
    <select id="queryBodInfo" resultType="com.brilliance.isc.vo.collection.BodWithPtsCbbResponseVo">
        select
        bod.*,bch.BCHNAME bchName,usr.NAM usrNam,drr.REF drrRef,
        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,col.EXTKEY colExtkey,col.nam colName
        from bod
        left join cbb max1 on max1.OBJINR = bod.inr and max1.OBJTYP = 'BOD' and max1.cbc = 'MAXSUM' and max1.extid =
        'AMT1' and max1.enddat = '2299-12-31'
        left join cbb max2 on max2.OBJINR = bod.inr and max2.OBJTYP = 'BOD' and max2.cbc = 'MAXSUM' and max2.extid =
        'AMT2' and max2.enddat = '2299-12-31'
        left join cbb opn1 on opn1.OBJINR = bod.inr and opn1.OBJTYP = 'BOD' and opn1.cbc = 'OPN' and opn1.extid = 'AMT1'
        and opn1.enddat = '2299-12-31'
        left join cbb opn2 on opn2.OBJINR = bod.inr and opn2.OBJTYP = 'BOD' and opn2.cbc = 'OPN' and opn2.extid = 'AMT2'
        and opn2.enddat = '2299-12-31'
        left join pts dre on dre.OBJINR = bod.inr and dre.OBJTYP = 'BOD' and dre.rol = 'DRE'
        left join pts drr on drr.OBJINR = bod.inr and drr.OBJTYP = 'BOD' and drr.rol = 'DRR'
        left join pts col on col.OBJINR = bod.inr and col.OBJTYP = 'BOD' and col.rol = 'COL'
        left join bch bch on bch.inr = bod.BCHKEYINR
        left join usr usr on usr.EXTKEY = bod.OWNUSR
        where bod.flwsta = 'R'
        <!--机构隔离-->
        <if test="bchinr != null and bchinr != '' ">
            AND bod.bchkeyinr = #{bchinr}
        </if>
        <!--业务编号-->
        <if test="seaownref != null and seaownref != ''">
            AND UPPER(bod.OWNREF) LIKE concat(concat('%', UPPER(#{seaownref})), '%')
        </if>
        <!--日期-->
        <if test="opndatfrom != null and opndatfrom != ''">
            AND bod.CREDAT &gt;= #{opndatfrom}
        </if>
        <if test="opndatto != null and opndatto != ''">
            AND bod.CREDAT &lt;= #{opndatto}
        </if>
        <if test="seadoctyp != null and seadoctyp != ''">
            AND bod.doctypcod = #{seadoctyp}
        </if>
        <!--客户号/名称 -->
        <if test="ptyExtkey != null and ptyExtkey != ''">
            and exists (
            select 1 from PTS
            where bod.INR = PTS.OBJINR
            AND PTS.OBJTYP = 'BOD'
            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 bod.INR = PTS.OBJINR
            AND PTS.OBJTYP = 'BOD'
            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 bod.INR = PTS.OBJINR
            AND PTS.OBJTYP = 'BOD'
            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 = 'BOD'
            AND INFCONCBS.OBJINR = BOD.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 bod.clsdat is not null
            </if>
            <if test="seasta == 'O'.toString()">
                and bod.clsdat is null
            </if>
        </if>
        <if test='column != null and column!="" '>
            order by  ${column}  ${order}
        </if>
        <if test='column == null or column=="" '>
            order by bod.credat desc , bod.ownref desc
        </if>
    </select>
</mapper>