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

    <resultMap id="BaseResultMap" type="com.brilliance.isc.bo.Ltd">
        <result property="inr" column="inr" jdbcType="VARCHAR"/>
        <result property="ownref" column="ownref" jdbcType="VARCHAR"/>
        <result property="nam" column="nam" jdbcType="VARCHAR"/>
        <result property="credat" column="credat" jdbcType="DATE"/>
        <result property="adlflg" column="adlflg" jdbcType="VARCHAR"/>
        <result property="amedat" column="amedat" jdbcType="DATE"/>
        <result property="amenbr" column="amenbr" jdbcType="INTEGER"/>
        <result property="avbby" column="avbby" jdbcType="VARCHAR"/>
        <result property="avbwth" column="avbwth" jdbcType="VARCHAR"/>
        <result property="chato" column="chato" jdbcType="VARCHAR"/>
        <result property="clsdat" column="clsdat" jdbcType="DATE"/>
        <result property="cnfins" column="cnfins" jdbcType="VARCHAR"/>
        <result property="expdat" column="expdat" jdbcType="DATE"/>
        <result property="expplc" column="expplc" jdbcType="VARCHAR"/>
        <result property="lcrtyp" column="lcrtyp" jdbcType="VARCHAR"/>
        <result property="nomspc" column="nomspc" jdbcType="VARCHAR"/>
        <result property="nomtop" column="nomtop" jdbcType="INTEGER"/>
        <result property="nomton" column="nomton" jdbcType="INTEGER"/>
        <result property="opndat" column="opndat" jdbcType="DATE"/>
        <result property="ownusr" column="ownusr" jdbcType="VARCHAR"/>
        <result property="rmbact" column="rmbact" jdbcType="VARCHAR"/>
        <result property="rmbcha" column="rmbcha" jdbcType="VARCHAR"/>
        <result property="rmbflg" column="rmbflg" jdbcType="VARCHAR"/>
        <result property="shpdat" column="shpdat" jdbcType="DATE"/>
        <result property="shpfro" column="shpfro" jdbcType="VARCHAR"/>
        <result property="shppar" column="shppar" jdbcType="VARCHAR"/>
        <result property="shpto" column="shpto" jdbcType="VARCHAR"/>
        <result property="shptrs" column="shptrs" jdbcType="VARCHAR"/>
        <result property="stacty" column="stacty" jdbcType="VARCHAR"/>
        <result property="utlnbr" column="utlnbr" jdbcType="INTEGER"/>
        <result property="advnbr" column="advnbr" jdbcType="INTEGER"/>
        <result property="redclsflg" column="redclsflg" jdbcType="VARCHAR"/>
        <result property="ver" column="ver" jdbcType="VARCHAR"/>
        <result property="ledinr" column="ledinr" jdbcType="VARCHAR"/>
        <result property="docsubflg" column="docsubflg" jdbcType="VARCHAR"/>
        <result property="porloa" column="porloa" jdbcType="VARCHAR"/>
        <result property="pordis" column="pordis" jdbcType="VARCHAR"/>
        <result property="apprul" column="apprul" jdbcType="VARCHAR"/>
        <result property="apprultxt" column="apprultxt" jdbcType="VARCHAR"/>
        <result property="apprulrmb" column="apprulrmb" jdbcType="VARCHAR"/>
        <result property="autdat" column="autdat" jdbcType="DATE"/>
        <result property="spcrcbflg" column="spcrcbflg" jdbcType="VARCHAR"/>
        <result property="prepers18" column="prepers18" jdbcType="INTEGER"/>
        <result property="prepertxts18" column="prepertxts18" jdbcType="VARCHAR"/>
        <result property="shppars18" column="shppars18" jdbcType="VARCHAR"/>
        <result property="shptrss18" column="shptrss18" jdbcType="VARCHAR"/>
        <result property="spcbenflg" column="spcbenflg" jdbcType="VARCHAR"/>
        <result property="etyextkey" column="etyextkey" jdbcType="VARCHAR"/>
        <result property="tenmaxday" column="tenmaxday" jdbcType="INTEGER"/>
        <result property="branchinr" column="branchinr" jdbcType="VARCHAR"/>
        <result property="bchkeyinr" column="bchkeyinr" jdbcType="VARCHAR"/>
        <result property="oppnam" column="oppnam" jdbcType="VARCHAR"/>
    </resultMap>

    <sql id="Base_Column_List">
        inr,ownref,nam,credat,adlflg,amedat,amenbr,avbby,avbwth,chato,clsdat,cnfins,expdat,expplc,lcrtyp,nomspc,nomtop,nomton,opndat,ownusr,rmbact,rmbcha,rmbflg,shpdat,shpfro,shppar,shpto,shptrs,stacty,utlnbr,advnbr,redclsflg,ver,ledinr,docsubflg,porloa,pordis,apprul,apprultxt,apprulrmb,autdat,spcrcbflg,prepers18,prepertxts18,shppars18,shptrss18,spcbenflg,etyextkey,tenmaxday,branchinr,bchkeyinr,oppnam
    </sql>

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

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

    <insert id="insert">
        insert into ltd (<include refid="Base_Column_List" />)
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            #{inr,jdbcType=VARCHAR},
            #{ownref,jdbcType=VARCHAR},
            #{nam,jdbcType=VARCHAR},
            #{credat,jdbcType=DATE},
            #{adlflg,jdbcType=VARCHAR},
            #{amedat,jdbcType=DATE},
            #{amenbr,jdbcType=INTEGER},
            #{avbby,jdbcType=VARCHAR},
            #{avbwth,jdbcType=VARCHAR},
            #{chato,jdbcType=VARCHAR},
            #{clsdat,jdbcType=DATE},
            #{cnfins,jdbcType=VARCHAR},
            #{expdat,jdbcType=DATE},
            #{expplc,jdbcType=VARCHAR},
            #{lcrtyp,jdbcType=VARCHAR},
            #{nomspc,jdbcType=VARCHAR},
            #{nomtop,jdbcType=INTEGER},
            #{nomton,jdbcType=INTEGER},
            #{opndat,jdbcType=DATE},
            #{ownusr,jdbcType=VARCHAR},
            #{rmbact,jdbcType=VARCHAR},
            #{rmbcha,jdbcType=VARCHAR},
            #{rmbflg,jdbcType=VARCHAR},
            #{shpdat,jdbcType=DATE},
            #{shpfro,jdbcType=VARCHAR},
            #{shppar,jdbcType=VARCHAR},
            #{shpto,jdbcType=VARCHAR},
            #{shptrs,jdbcType=VARCHAR},
            #{stacty,jdbcType=VARCHAR},
            #{utlnbr,jdbcType=INTEGER},
            #{advnbr,jdbcType=INTEGER},
            #{redclsflg,jdbcType=VARCHAR},
            #{ver,jdbcType=VARCHAR},
            #{ledinr,jdbcType=VARCHAR},
            #{docsubflg,jdbcType=VARCHAR},
            #{porloa,jdbcType=VARCHAR},
            #{pordis,jdbcType=VARCHAR},
            #{apprul,jdbcType=VARCHAR},
            #{apprultxt,jdbcType=VARCHAR},
            #{apprulrmb,jdbcType=VARCHAR},
            #{autdat,jdbcType=DATE},
            #{spcrcbflg,jdbcType=VARCHAR},
            #{prepers18,jdbcType=INTEGER},
            #{prepertxts18,jdbcType=VARCHAR},
            #{shppars18,jdbcType=VARCHAR},
            #{shptrss18,jdbcType=VARCHAR},
            #{spcbenflg,jdbcType=VARCHAR},
            #{etyextkey,jdbcType=VARCHAR},
            #{tenmaxday,jdbcType=INTEGER},
            #{branchinr,jdbcType=VARCHAR},
            #{bchkeyinr,jdbcType=VARCHAR},
            #{oppnam,jdbcType=VARCHAR},
        </trim>
    </insert>

    <insert id="insertSelective">
        insert into ltd
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="inr != null">inr,</if>
            <if test="ownref != null">ownref,</if>
            <if test="nam != null">nam,</if>
            <if test="credat != null">credat,</if>
            <if test="adlflg != null">adlflg,</if>
            <if test="amedat != null">amedat,</if>
            <if test="amenbr != null">amenbr,</if>
            <if test="avbby != null">avbby,</if>
            <if test="avbwth != null">avbwth,</if>
            <if test="chato != null">chato,</if>
            <if test="clsdat != null">clsdat,</if>
            <if test="cnfins != null">cnfins,</if>
            <if test="expdat != null">expdat,</if>
            <if test="expplc != null">expplc,</if>
            <if test="lcrtyp != null">lcrtyp,</if>
            <if test="nomspc != null">nomspc,</if>
            <if test="nomtop != null">nomtop,</if>
            <if test="nomton != null">nomton,</if>
            <if test="opndat != null">opndat,</if>
            <if test="ownusr != null">ownusr,</if>
            <if test="rmbact != null">rmbact,</if>
            <if test="rmbcha != null">rmbcha,</if>
            <if test="rmbflg != null">rmbflg,</if>
            <if test="shpdat != null">shpdat,</if>
            <if test="shpfro != null">shpfro,</if>
            <if test="shppar != null">shppar,</if>
            <if test="shpto != null">shpto,</if>
            <if test="shptrs != null">shptrs,</if>
            <if test="stacty != null">stacty,</if>
            <if test="utlnbr != null">utlnbr,</if>
            <if test="advnbr != null">advnbr,</if>
            <if test="redclsflg != null">redclsflg,</if>
            <if test="ver != null">ver,</if>
            <if test="ledinr != null">ledinr,</if>
            <if test="docsubflg != null">docsubflg,</if>
            <if test="porloa != null">porloa,</if>
            <if test="pordis != null">pordis,</if>
            <if test="apprul != null">apprul,</if>
            <if test="apprultxt != null">apprultxt,</if>
            <if test="apprulrmb != null">apprulrmb,</if>
            <if test="autdat != null">autdat,</if>
            <if test="spcrcbflg != null">spcrcbflg,</if>
            <if test="prepers18 != null">prepers18,</if>
            <if test="prepertxts18 != null">prepertxts18,</if>
            <if test="shppars18 != null">shppars18,</if>
            <if test="shptrss18 != null">shptrss18,</if>
            <if test="spcbenflg != null">spcbenflg,</if>
            <if test="etyextkey != null">etyextkey,</if>
            <if test="tenmaxday != null">tenmaxday,</if>
            <if test="branchinr != null">branchinr,</if>
            <if test="bchkeyinr != null">bchkeyinr,</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="credat != null">#{credat,jdbcType=DATE}, </if>
            <if test="adlflg != null">#{adlflg,jdbcType=VARCHAR}, </if>
            <if test="amedat != null">#{amedat,jdbcType=DATE}, </if>
            <if test="amenbr != null">#{amenbr,jdbcType=INTEGER}, </if>
            <if test="avbby != null">#{avbby,jdbcType=VARCHAR}, </if>
            <if test="avbwth != null">#{avbwth,jdbcType=VARCHAR}, </if>
            <if test="chato != null">#{chato,jdbcType=VARCHAR}, </if>
            <if test="clsdat != null">#{clsdat,jdbcType=DATE}, </if>
            <if test="cnfins != null">#{cnfins,jdbcType=VARCHAR}, </if>
            <if test="expdat != null">#{expdat,jdbcType=DATE}, </if>
            <if test="expplc != null">#{expplc,jdbcType=VARCHAR}, </if>
            <if test="lcrtyp != null">#{lcrtyp,jdbcType=VARCHAR}, </if>
            <if test="nomspc != null">#{nomspc,jdbcType=VARCHAR}, </if>
            <if test="nomtop != null">#{nomtop,jdbcType=INTEGER}, </if>
            <if test="nomton != null">#{nomton,jdbcType=INTEGER}, </if>
            <if test="opndat != null">#{opndat,jdbcType=DATE}, </if>
            <if test="ownusr != null">#{ownusr,jdbcType=VARCHAR}, </if>
            <if test="rmbact != null">#{rmbact,jdbcType=VARCHAR}, </if>
            <if test="rmbcha != null">#{rmbcha,jdbcType=VARCHAR}, </if>
            <if test="rmbflg != null">#{rmbflg,jdbcType=VARCHAR}, </if>
            <if test="shpdat != null">#{shpdat,jdbcType=DATE}, </if>
            <if test="shpfro != null">#{shpfro,jdbcType=VARCHAR}, </if>
            <if test="shppar != null">#{shppar,jdbcType=VARCHAR}, </if>
            <if test="shpto != null">#{shpto,jdbcType=VARCHAR}, </if>
            <if test="shptrs != null">#{shptrs,jdbcType=VARCHAR}, </if>
            <if test="stacty != null">#{stacty,jdbcType=VARCHAR}, </if>
            <if test="utlnbr != null">#{utlnbr,jdbcType=INTEGER}, </if>
            <if test="advnbr != null">#{advnbr,jdbcType=INTEGER}, </if>
            <if test="redclsflg != null">#{redclsflg,jdbcType=VARCHAR}, </if>
            <if test="ver != null">#{ver,jdbcType=VARCHAR}, </if>
            <if test="ledinr != null">#{ledinr,jdbcType=VARCHAR}, </if>
            <if test="docsubflg != null">#{docsubflg,jdbcType=VARCHAR}, </if>
            <if test="porloa != null">#{porloa,jdbcType=VARCHAR}, </if>
            <if test="pordis != null">#{pordis,jdbcType=VARCHAR}, </if>
            <if test="apprul != null">#{apprul,jdbcType=VARCHAR}, </if>
            <if test="apprultxt != null">#{apprultxt,jdbcType=VARCHAR}, </if>
            <if test="apprulrmb != null">#{apprulrmb,jdbcType=VARCHAR}, </if>
            <if test="autdat != null">#{autdat,jdbcType=DATE}, </if>
            <if test="spcrcbflg != null">#{spcrcbflg,jdbcType=VARCHAR}, </if>
            <if test="prepers18 != null">#{prepers18,jdbcType=INTEGER}, </if>
            <if test="prepertxts18 != null">#{prepertxts18,jdbcType=VARCHAR}, </if>
            <if test="shppars18 != null">#{shppars18,jdbcType=VARCHAR}, </if>
            <if test="shptrss18 != null">#{shptrss18,jdbcType=VARCHAR}, </if>
            <if test="spcbenflg != null">#{spcbenflg,jdbcType=VARCHAR}, </if>
            <if test="etyextkey != null">#{etyextkey,jdbcType=VARCHAR}, </if>
            <if test="tenmaxday != null">#{tenmaxday,jdbcType=INTEGER}, </if>
            <if test="branchinr != null">#{branchinr,jdbcType=VARCHAR}, </if>
            <if test="bchkeyinr != null">#{bchkeyinr,jdbcType=VARCHAR}, </if>
            <if test="oppnam != null">#{oppnam,jdbcType=VARCHAR}, </if>
        </trim>
    </insert>

    <update id="updateByPrimaryKeySelective">
        update ltd
        <set>
            <if test="ownref != null">ownref = #{ownref,jdbcType=VARCHAR},</if>
            <if test="nam != null">nam = #{nam,jdbcType=VARCHAR},</if>
            <if test="credat != null">credat = #{credat,jdbcType=DATE},</if>
            <if test="adlflg != null">adlflg = #{adlflg,jdbcType=VARCHAR},</if>
            <if test="amedat != null">amedat = #{amedat,jdbcType=DATE},</if>
            <if test="amenbr != null">amenbr = #{amenbr,jdbcType=INTEGER},</if>
            <if test="avbby != null">avbby = #{avbby,jdbcType=VARCHAR},</if>
            <if test="avbwth != null">avbwth = #{avbwth,jdbcType=VARCHAR},</if>
            <if test="chato != null">chato = #{chato,jdbcType=VARCHAR},</if>
            clsdat = #{clsdat,jdbcType=DATE},
            <if test="cnfins != null">cnfins = #{cnfins,jdbcType=VARCHAR},</if>
            <if test="expdat != null">expdat = #{expdat,jdbcType=DATE},</if>
            <if test="expplc != null">expplc = #{expplc,jdbcType=VARCHAR},</if>
            <if test="lcrtyp != null">lcrtyp = #{lcrtyp,jdbcType=VARCHAR},</if>
            <if test="nomspc != null">nomspc = #{nomspc,jdbcType=VARCHAR},</if>
            <if test="nomtop != null">nomtop = #{nomtop,jdbcType=INTEGER},</if>
            <if test="nomton != null">nomton = #{nomton,jdbcType=INTEGER},</if>
            <if test="opndat != null">opndat = #{opndat,jdbcType=DATE},</if>
            <if test="ownusr != null">ownusr = #{ownusr,jdbcType=VARCHAR},</if>
            <if test="rmbact != null">rmbact = #{rmbact,jdbcType=VARCHAR},</if>
            <if test="rmbcha != null">rmbcha = #{rmbcha,jdbcType=VARCHAR},</if>
            <if test="rmbflg != null">rmbflg = #{rmbflg,jdbcType=VARCHAR},</if>
            <if test="shpdat != null">shpdat = #{shpdat,jdbcType=DATE},</if>
            <if test="shpfro != null">shpfro = #{shpfro,jdbcType=VARCHAR},</if>
            <if test="shppar != null">shppar = #{shppar,jdbcType=VARCHAR},</if>
            <if test="shpto != null">shpto = #{shpto,jdbcType=VARCHAR},</if>
            <if test="shptrs != null">shptrs = #{shptrs,jdbcType=VARCHAR},</if>
            <if test="stacty != null">stacty = #{stacty,jdbcType=VARCHAR},</if>
            <if test="utlnbr != null">utlnbr = #{utlnbr,jdbcType=INTEGER},</if>
            <if test="advnbr != null">advnbr = #{advnbr,jdbcType=INTEGER},</if>
            <if test="redclsflg != null">redclsflg = #{redclsflg,jdbcType=VARCHAR},</if>
            <if test="ver != null">ver = #{ver,jdbcType=VARCHAR},</if>
            <if test="ledinr != null">ledinr = #{ledinr,jdbcType=VARCHAR},</if>
            <if test="docsubflg != null">docsubflg = #{docsubflg,jdbcType=VARCHAR},</if>
            <if test="porloa != null">porloa = #{porloa,jdbcType=VARCHAR},</if>
            <if test="pordis != null">pordis = #{pordis,jdbcType=VARCHAR},</if>
            <if test="apprul != null">apprul = #{apprul,jdbcType=VARCHAR},</if>
            <if test="apprultxt != null">apprultxt = #{apprultxt,jdbcType=VARCHAR},</if>
            <if test="apprulrmb != null">apprulrmb = #{apprulrmb,jdbcType=VARCHAR},</if>
            <if test="autdat != null">autdat = #{autdat,jdbcType=DATE},</if>
            <if test="spcrcbflg != null">spcrcbflg = #{spcrcbflg,jdbcType=VARCHAR},</if>
            <if test="prepers18 != null">prepers18 = #{prepers18,jdbcType=INTEGER},</if>
            <if test="prepertxts18 != null">prepertxts18 = #{prepertxts18,jdbcType=VARCHAR},</if>
            <if test="shppars18 != null">shppars18 = #{shppars18,jdbcType=VARCHAR},</if>
            <if test="shptrss18 != null">shptrss18 = #{shptrss18,jdbcType=VARCHAR},</if>
            <if test="spcbenflg != null">spcbenflg = #{spcbenflg,jdbcType=VARCHAR},</if>
            <if test="etyextkey != null">etyextkey = #{etyextkey,jdbcType=VARCHAR},</if>
            <if test="tenmaxday != null">tenmaxday = #{tenmaxday,jdbcType=INTEGER},</if>
            <if test="branchinr != null">branchinr = #{branchinr,jdbcType=VARCHAR},</if>
            <if test="bchkeyinr != null">bchkeyinr = #{bchkeyinr,jdbcType=VARCHAR},</if>
            <if test="oppnam != null">oppnam = #{oppnam,jdbcType=VARCHAR},</if>
        </set>
        where inr = #{inr,jdbcType=VARCHAR}
    </update>

    <update id="updateByPrimaryKey">
        update ltd
        <set>
            ownref = #{ownref,jdbcType=VARCHAR},
            nam = #{nam,jdbcType=VARCHAR},
            credat = #{credat,jdbcType=DATE},
            adlflg = #{adlflg,jdbcType=VARCHAR},
            amedat = #{amedat,jdbcType=DATE},
            amenbr = #{amenbr,jdbcType=INTEGER},
            avbby = #{avbby,jdbcType=VARCHAR},
            avbwth = #{avbwth,jdbcType=VARCHAR},
            chato = #{chato,jdbcType=VARCHAR},
            clsdat = #{clsdat,jdbcType=DATE},
            cnfins = #{cnfins,jdbcType=VARCHAR},
            expdat = #{expdat,jdbcType=DATE},
            expplc = #{expplc,jdbcType=VARCHAR},
            lcrtyp = #{lcrtyp,jdbcType=VARCHAR},
            nomspc = #{nomspc,jdbcType=VARCHAR},
            nomtop = #{nomtop,jdbcType=INTEGER},
            nomton = #{nomton,jdbcType=INTEGER},
            opndat = #{opndat,jdbcType=DATE},
            ownusr = #{ownusr,jdbcType=VARCHAR},
            rmbact = #{rmbact,jdbcType=VARCHAR},
            rmbcha = #{rmbcha,jdbcType=VARCHAR},
            rmbflg = #{rmbflg,jdbcType=VARCHAR},
            shpdat = #{shpdat,jdbcType=DATE},
            shpfro = #{shpfro,jdbcType=VARCHAR},
            shppar = #{shppar,jdbcType=VARCHAR},
            shpto = #{shpto,jdbcType=VARCHAR},
            shptrs = #{shptrs,jdbcType=VARCHAR},
            stacty = #{stacty,jdbcType=VARCHAR},
            utlnbr = #{utlnbr,jdbcType=INTEGER},
            advnbr = #{advnbr,jdbcType=INTEGER},
            redclsflg = #{redclsflg,jdbcType=VARCHAR},
            ver = #{ver,jdbcType=VARCHAR},
            ledinr = #{ledinr,jdbcType=VARCHAR},
            docsubflg = #{docsubflg,jdbcType=VARCHAR},
            porloa = #{porloa,jdbcType=VARCHAR},
            pordis = #{pordis,jdbcType=VARCHAR},
            apprul = #{apprul,jdbcType=VARCHAR},
            apprultxt = #{apprultxt,jdbcType=VARCHAR},
            apprulrmb = #{apprulrmb,jdbcType=VARCHAR},
            autdat = #{autdat,jdbcType=DATE},
            spcrcbflg = #{spcrcbflg,jdbcType=VARCHAR},
            prepers18 = #{prepers18,jdbcType=INTEGER},
            prepertxts18 = #{prepertxts18,jdbcType=VARCHAR},
            shppars18 = #{shppars18,jdbcType=VARCHAR},
            shptrss18 = #{shptrss18,jdbcType=VARCHAR},
            spcbenflg = #{spcbenflg,jdbcType=VARCHAR},
            etyextkey = #{etyextkey,jdbcType=VARCHAR},
            tenmaxday = #{tenmaxday,jdbcType=INTEGER},
            branchinr = #{branchinr,jdbcType=VARCHAR},
            bchkeyinr = #{bchkeyinr,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 ltd
        <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.credat != null">credat = #{module.credat,jdbcType=DATE},</if>
            <if test="module.adlflg != null">adlflg = #{module.adlflg,jdbcType=VARCHAR},</if>
            <if test="module.amedat != null">amedat = #{module.amedat,jdbcType=DATE},</if>
            <if test="module.amenbr != null">amenbr = #{module.amenbr,jdbcType=INTEGER},</if>
            <if test="module.avbby != null">avbby = #{module.avbby,jdbcType=VARCHAR},</if>
            <if test="module.avbwth != null">avbwth = #{module.avbwth,jdbcType=VARCHAR},</if>
            <if test="module.chato != null">chato = #{module.chato,jdbcType=VARCHAR},</if>
            <if test="module.clsdat != null">clsdat = #{module.clsdat,jdbcType=DATE},</if>
            <if test="module.cnfins != null">cnfins = #{module.cnfins,jdbcType=VARCHAR},</if>
            <if test="module.expdat != null">expdat = #{module.expdat,jdbcType=DATE},</if>
            <if test="module.expplc != null">expplc = #{module.expplc,jdbcType=VARCHAR},</if>
            <if test="module.lcrtyp != null">lcrtyp = #{module.lcrtyp,jdbcType=VARCHAR},</if>
            <if test="module.nomspc != null">nomspc = #{module.nomspc,jdbcType=VARCHAR},</if>
            <if test="module.nomtop != null">nomtop = #{module.nomtop,jdbcType=INTEGER},</if>
            <if test="module.nomton != null">nomton = #{module.nomton,jdbcType=INTEGER},</if>
            <if test="module.opndat != null">opndat = #{module.opndat,jdbcType=DATE},</if>
            <if test="module.ownusr != null">ownusr = #{module.ownusr,jdbcType=VARCHAR},</if>
            <if test="module.rmbact != null">rmbact = #{module.rmbact,jdbcType=VARCHAR},</if>
            <if test="module.rmbcha != null">rmbcha = #{module.rmbcha,jdbcType=VARCHAR},</if>
            <if test="module.rmbflg != null">rmbflg = #{module.rmbflg,jdbcType=VARCHAR},</if>
            <if test="module.shpdat != null">shpdat = #{module.shpdat,jdbcType=DATE},</if>
            <if test="module.shpfro != null">shpfro = #{module.shpfro,jdbcType=VARCHAR},</if>
            <if test="module.shppar != null">shppar = #{module.shppar,jdbcType=VARCHAR},</if>
            <if test="module.shpto != null">shpto = #{module.shpto,jdbcType=VARCHAR},</if>
            <if test="module.shptrs != null">shptrs = #{module.shptrs,jdbcType=VARCHAR},</if>
            <if test="module.stacty != null">stacty = #{module.stacty,jdbcType=VARCHAR},</if>
            <if test="module.utlnbr != null">utlnbr = #{module.utlnbr,jdbcType=INTEGER},</if>
            <if test="module.advnbr != null">advnbr = #{module.advnbr,jdbcType=INTEGER},</if>
            <if test="module.redclsflg != null">redclsflg = #{module.redclsflg,jdbcType=VARCHAR},</if>
            <if test="module.ver != null">ver = #{module.ver,jdbcType=VARCHAR},</if>
            <if test="module.ledinr != null">ledinr = #{module.ledinr,jdbcType=VARCHAR},</if>
            <if test="module.docsubflg != null">docsubflg = #{module.docsubflg,jdbcType=VARCHAR},</if>
            <if test="module.porloa != null">porloa = #{module.porloa,jdbcType=VARCHAR},</if>
            <if test="module.pordis != null">pordis = #{module.pordis,jdbcType=VARCHAR},</if>
            <if test="module.apprul != null">apprul = #{module.apprul,jdbcType=VARCHAR},</if>
            <if test="module.apprultxt != null">apprultxt = #{module.apprultxt,jdbcType=VARCHAR},</if>
            <if test="module.apprulrmb != null">apprulrmb = #{module.apprulrmb,jdbcType=VARCHAR},</if>
            <if test="module.autdat != null">autdat = #{module.autdat,jdbcType=DATE},</if>
            <if test="module.spcrcbflg != null">spcrcbflg = #{module.spcrcbflg,jdbcType=VARCHAR},</if>
            <if test="module.prepers18 != null">prepers18 = #{module.prepers18,jdbcType=INTEGER},</if>
            <if test="module.prepertxts18 != null">prepertxts18 = #{module.prepertxts18,jdbcType=VARCHAR},</if>
            <if test="module.shppars18 != null">shppars18 = #{module.shppars18,jdbcType=VARCHAR},</if>
            <if test="module.shptrss18 != null">shptrss18 = #{module.shptrss18,jdbcType=VARCHAR},</if>
            <if test="module.spcbenflg != null">spcbenflg = #{module.spcbenflg,jdbcType=VARCHAR},</if>
            <if test="module.etyextkey != null">etyextkey = #{module.etyextkey,jdbcType=VARCHAR},</if>
            <if test="module.tenmaxday != null">tenmaxday = #{module.tenmaxday,jdbcType=INTEGER},</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.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.Ltd">
        select
        <include refid="Base_Column_List"/>
        from ltd 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.Ltd">
        select
        <include refid="Base_Column_List"/>
        from ltd WHERE 1=1
        <if test="ownref != null and ownref != ''"> and ownref = #{ownref,jdbcType=VARCHAR}</if>
        limit 1
    </select>
    <select id="queryLtd" resultType="com.brilliance.isc.vo.lc.LtdWithPtsCbbResponseVo">
        select
        ltd.*,led.ownref leownref,
        cbb.cur cur, cbb.amt amt,pty.extkey be1Extkey,pty.nam1 be1Name
        from ltd
        left join cbb on cbb.OBJINR = ltd.inr and cbb.OBJTYP = 'LTD'  and cbb.cbc = 'MAXSUM' and cbb.extid = 'AMT1' and cbb.enddat = '2299-12-31'
        left join pts on pts.OBJINR = ltd.inr and pts.OBJTYP = 'LTD' and pts.rol = 'BE1'
        left join led on led.INR = ltd.LEDINR
        left join pty pty on pty.inr = pts.ptyinr
        where 1 = 1
        <if test="bchtyp == '6'.toString()">
            and ltd.flwsta = 'R'
        </if>
        <!--信用证INR-->
        <if test="ledinr != null and ledinr != '' ">
            AND ltd.LEDINR = #{ledinr}
        </if>
        <!--机构隔离-->
        <if test="bchinr != null and bchinr != '' ">
            AND ltd.BCHKEYINR = #{bchinr}
        </if>
        <!--信用证业务编号-->
        <if test="seaownref != null and seaownref != ''">
            AND UPPER(led.OWNREF) LIKE concat(concat('%', UPPER(#{seaownref})), '%')
        </if>
        <!--信用证业务编号-->
        <if test="ltownref != null and ltownref != ''">
            AND UPPER(ltd.OWNREF) LIKE concat(concat('%', UPPER(#{ltownref})), '%')
        </if>
        <!--日期-->
        <if test="opndatfrom != null and opndatfrom != ''">
            AND ltd.CREDAT &gt;= #{opndatfrom}
        </if>
        <!--日期-->
        <if test="opndatto != null and opndatto != ''">
            AND ltd.CREDAT &lt;= #{opndatto}
        </if>
        <!--客户号/名称 -->
        <if test="searef != null and searef != ''">
            and exists (
            select 1 from PTS,PTY
            where ltd.INR = PTS.OBJINR
            AND PTY.INR = PTS.PTYINR
            AND PTS.OBJTYP = 'LTD'
            AND PTS.ROL = 'BE1'
            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 ltd.CLSDAT is not null
            </if>
            <if test="isClosed == 'N'.toString()">
                and ltd.CLSDAT is  null
            </if>
        </if>
        order by CREDAT desc , OWNREF desc
    </select>
    <select id="selectByLedinrInt" resultType="java.lang.Integer">
        select count(1) from ltd
        where ledinr = #{pntInr,jdbcType=VARCHAR}
          and clsdat is null
    </select>
    <select id="queryLtdInfo" resultType="com.brilliance.isc.vo.lc.LtdWithPtsCbbResponseVo">
        select
        ltd.*,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,
        be1.extkey be1Extkey,be1.nam be1Name,be2.EXTKEY be2Extkey,be2.nam be2Name,adv.EXTKEY advExtkey,adv.nam advName
        from ltd
        left join cbb max1 on max1.OBJINR = ltd.inr and max1.OBJTYP = 'LTD' and max1.cbc = 'MAXSUM' and max1.extid =
        'AMT1' and max1.enddat = '2299-12-31'
        left join cbb max2 on max2.OBJINR = ltd.inr and max2.OBJTYP = 'LTD' and max2.cbc = 'MAXSUM' and max2.extid =
        'AMT2' and max2.enddat = '2299-12-31'
        left join cbb opn1 on opn1.OBJINR = ltd.inr and opn1.OBJTYP = 'LTD' and opn1.cbc = 'OPN' and opn1.extid = 'AMT1'
        and opn1.enddat = '2299-12-31'
        left join cbb opn2 on opn2.OBJINR = ltd.inr and opn2.OBJTYP = 'LTD' and opn2.cbc = 'OPN' and opn2.extid = 'AMT2'
        and opn2.enddat = '2299-12-31'
        left join pts be1 on be1.OBJINR = ltd.inr and be1.OBJTYP = 'LTD' and be1.rol = 'BE1'
        left join pts be2 on be2.OBJINR = ltd.inr and be2.OBJTYP = 'LTD' and be2.rol = 'BE2'
        left join pts adv on adv.OBJINR = ltd.inr and adv.OBJTYP = 'LTD' and adv.rol = 'ADT'
        left join bch bch on bch.inr = ltd.BCHKEYINR
        left join usr usr on usr.EXTKEY = ltd.OWNUSR
        where ltd.flwsta = 'R'
        <!--机构隔离-->
        <if test="bchinr != null and bchinr != '' ">
            AND ltd.bchkeyinr = #{bchinr}
        </if>
        <!--业务编号-->
        <if test="seaownref != null and seaownref != ''">
            AND UPPER(ltd.OWNREF) LIKE concat(concat('%', UPPER(#{seaownref})), '%')
        </if>
        <!--日期-->
        <if test="opndatfrom != null and opndatfrom != ''">
            AND ltd.CREDAT &gt;= #{opndatfrom}
        </if>
        <if test="opndatto != null and opndatto != ''">
            AND ltd.CREDAT &lt;= #{opndatto}
        </if>
        <!--信用证类型-->
        <if test="sealcrtyp != null and sealcrtyp != '' ">
            AND ltd.lcrtyp = #{sealcrtyp}
        </if>
        <!--客户号/名称 -->
        <if test="ptyExtkey != null and ptyExtkey != ''">
            and exists (
            select 1 from PTS
            where ltd.INR = PTS.OBJINR
            AND PTS.OBJTYP = 'LTD'
            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 ltd.INR = PTS.OBJINR
            AND PTS.OBJTYP = 'LTD'
            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 ltd.INR = PTS.OBJINR
            AND PTS.OBJTYP = 'LTD'
            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 = 'LTD'
            AND INFCONCBS.OBJINR = LTD.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 ltd.clsdat is not null
            </if>
            <if test="seasta == 'O'.toString()">
                and ltd.clsdat is null
            </if>
        </if>

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


    <select id="queryLtdsByLedinr" resultType="com.brilliance.isc.bo.Ltd">
        select
        <include refid="Base_Column_List"/>
        from LTD
        where LEDINR = #{ledInr,jdbcType=VARCHAR}
        AND CLSDAT IS NULL
    </select>

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

</mapper>