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

    <resultMap id="BaseResultMap" type="com.brilliance.isc.bo.Oit">
        <result property="inr" column="inr" jdbcType="VARCHAR"/>
        <result property="objtyp" column="objtyp" jdbcType="VARCHAR"/>
        <result property="objinr" column="objinr" jdbcType="VARCHAR"/>
        <result property="subtyp" column="subtyp" jdbcType="VARCHAR"/>
        <result property="subbus" column="subbus" jdbcType="VARCHAR"/>
        <result property="inflev" column="inflev" jdbcType="VARCHAR"/>
        <result property="inftxt" column="inftxt" jdbcType="CLOB"/>
        <result property="ver" column="ver" jdbcType="VARCHAR"/>
        <result property="etgextkey" column="etgextkey" jdbcType="VARCHAR"/>
    </resultMap>

    <resultMap id="BaseResultMap1" type="com.brilliance.isc.bo.Oit">
        <result property="inr" column="inr" jdbcType="VARCHAR"/>
        <result property="objtyp" column="objtyp" jdbcType="VARCHAR"/>
        <result property="objinr" column="objinr" jdbcType="VARCHAR"/>
        <result property="subtyp" column="subtyp" jdbcType="VARCHAR"/>
        <result property="subbus" column="subbus" jdbcType="VARCHAR"/>
        <result property="inflev" column="inflev" jdbcType="VARCHAR"/>
        <result property="inftxt" column="inftxt" jdbcType="VARCHAR"/>
        <result property="ver" column="ver" jdbcType="VARCHAR"/>
        <result property="etgextkey" column="etgextkey" jdbcType="VARCHAR"/>
        <result property="path" column="path"/>
    </resultMap>

    <resultMap id="FieldMap" type="com.brilliance.isc.vo.manager.OitManageVo">
        <result property="inr" column="inr" jdbcType="VARCHAR"/>
        <result property="objtyp" column="objtyp" jdbcType="VARCHAR"/>
        <result property="objinr" column="objinr" jdbcType="VARCHAR"/>
        <result property="subtyp" column="subtyp" jdbcType="VARCHAR"/>
        <result property="subbus" column="subbus" jdbcType="VARCHAR"/>
        <result property="inflev" column="inflev" jdbcType="VARCHAR"/>
        <result property="inftxt" column="inftxt" jdbcType="VARCHAR"/>
        <result property="ver" column="ver" jdbcType="VARCHAR"/>
        <result property="etgextkey" column="etgextkey" jdbcType="VARCHAR"/>
        <result property="objextkey" column="objextkey" jdbcType="VARCHAR"/>
        <result property="objnam" column="objnam" jdbcType="VARCHAR"/>
        <result property="objcod" column="objcod" jdbcType="VARCHAR"/>
    </resultMap>

    <resultMap id="OitTableResultMap" type="com.brilliance.isc.vo.manager.OitTableVo">
        <result property="stbuil" column="stbuil" jdbcType="VARCHAR"/>

        <result property="actinr" column="actinr" jdbcType="VARCHAR"/>
        <result property="actkey" column="actkey" jdbcType="VARCHAR"/>
        <result property="actnam" column="actnam" jdbcType="VARCHAR"/>
        <result property="actcur" column="actcur" jdbcType="VARCHAR"/>

        <result property="fecinr" column="fecinr" jdbcType="VARCHAR"/>
        <result property="feecod" column="feecod" jdbcType="VARCHAR"/>
        <result property="objtyp" column="objtyp" jdbcType="VARCHAR"/>
        <result property="objnam" column="objnam" jdbcType="VARCHAR"/>
        <result property="begdat" column="begdat" jdbcType="VARCHAR"/>
        <result property="enddat" column="enddat" jdbcType="VARCHAR"/>

        <result property="gidinr" column="gidinr" jdbcType="VARCHAR"/>
        <result property="gidref" column="gidref" jdbcType="VARCHAR"/>
        <result property="gidnam" column="gidnam" jdbcType="VARCHAR"/>

        <result property="nidinr" column="nidinr" jdbcType="VARCHAR"/>
        <result property="nidref" column="nidref" jdbcType="VARCHAR"/>
        <result property="nidnam" column="nidnam" jdbcType="VARCHAR"/>

        <result property="ptainr" column="ptainr" jdbcType="VARCHAR"/>
        <result property="ptakey" column="ptakey" jdbcType="VARCHAR"/>
        <result property="ptanam" column="ptanam" jdbcType="VARCHAR"/>

        <result property="ptyinr" column="ptyinr" jdbcType="VARCHAR"/>
        <result property="ptykey" column="ptykey" jdbcType="VARCHAR"/>
        <result property="ptynam" column="ptynam" jdbcType="VARCHAR"/>
    </resultMap>

    <sql id="Base_Column_List">
        inr,objtyp,objinr,subtyp,subbus,inflev,inftxt,ver,etgextkey
    </sql>

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

    <select id="selectByObj" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from oit
        where objinr = #{objinr,jdbcType=VARCHAR} and objtyp = #{objtyp,jdbcType=VARCHAR}
    </select>

    <select id="selectByObjInrAndTyp" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from oit
        where objinr = #{objinr,jdbcType=VARCHAR} and objtyp = #{objtyp,jdbcType=VARCHAR}
        order by inflev desc
    </select>

    <select id="selectByObjWithBatch" resultMap="BaseResultMap1">


    <foreach close="" collection="list" index="index"
             item="item" open="" separator=" union all ">
        select
        inr,objtyp,objinr,subtyp,subbus,inflev,inftxt,ver,etgextkey,#{item.path} as path
        from oit
        where objinr = #{item.objinr,jdbcType=VARCHAR} and objtyp = #{item.objtyp,jdbcType=VARCHAR}
    </foreach>

    </select>

    <select id="selectByExtkeyWithBatch" resultMap="BaseResultMap1">

        <foreach close="" collection="list" index="index"
                 item="item" open="" separator=" union all ">
            select
            inr,objtyp,objinr,subtyp,subbus,inflev,inftxt,ver,etgextkey,#{item.path} as path
            from oit
            where objinr in (select inr from ${item.objtyp} where ${item.column} = #{item.extkey})
             and objtyp = #{item.objtyp,jdbcType=VARCHAR}
        </foreach>

    </select>

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

    <!--    <insert id="insert">-->
    <!--        insert into oit (<include refid="Base_Column_List" />)-->
    <!--        <trim prefix="values (" suffix=")" suffixOverrides=",">-->
    <!--            #{inr,jdbcType=VARCHAR},-->
    <!--            #{objtyp,jdbcType=VARCHAR},-->
    <!--            #{objinr,jdbcType=VARCHAR},-->
    <!--            #{subtyp,jdbcType=VARCHAR},-->
    <!--            #{subbus,jdbcType=VARCHAR},-->
    <!--            #{inflev,jdbcType=VARCHAR},-->
    <!--            #{inftxt,jdbcType=CLOB},-->
    <!--            #{ver,jdbcType=VARCHAR},-->
    <!--            #{etgextkey,jdbcType=VARCHAR},-->
    <!--        </trim>-->
    <!--    </insert>-->

    <insert id="insert" keyProperty="" useGeneratedKeys="true">
        insert into OIT(INR, OBJTYP, OBJINR, SUBTYP, SUBBUS, INFLEV, INFTXT, VER, ETGEXTKEY)
        values (#{inr}, #{objtyp}, #{objinr}, #{subtyp}, #{subbus}, #{inflev}, #{inftxt}, '0000', 'CEBGRP')
    </insert>

    <insert id="insertSelective">
        insert into oit
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="inr != null">inr,</if>
            <if test="objtyp != null">objtyp,</if>
            <if test="objinr != null">objinr,</if>
            <if test="subtyp != null">subtyp,</if>
            <if test="subbus != null">subbus,</if>
            <if test="inflev != null">inflev,</if>
            <if test="inftxt != null">inftxt,</if>
            <if test="ver != null">ver,</if>
            etgextkey,
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="inr != null">#{inr,jdbcType=VARCHAR},</if>
            <if test="objtyp != null">#{objtyp,jdbcType=VARCHAR},</if>
            <if test="objinr != null">#{objinr,jdbcType=VARCHAR},</if>
            <if test="subtyp != null">#{subtyp,jdbcType=VARCHAR},</if>
            <if test="subbus != null">#{subbus,jdbcType=VARCHAR},</if>
            <if test="inflev != null">#{inflev,jdbcType=VARCHAR},</if>
            <if test="inftxt != null">#{inftxt,jdbcType=CLOB},</if>
            <if test="ver != null">#{ver,jdbcType=VARCHAR},</if>
            'CEBGRP',
        </trim>
    </insert>

    <update id="updateByPrimaryKeySelective">
        update oit
        <set>
            <if test="objtyp != null">objtyp = #{objtyp,jdbcType=VARCHAR},</if>
            <if test="objinr != null">objinr = #{objinr,jdbcType=VARCHAR},</if>
            <if test="subtyp != null">subtyp = #{subtyp,jdbcType=VARCHAR},</if>
            <if test="subbus != null">subbus = #{subbus,jdbcType=VARCHAR},</if>
            <if test="inflev != null">inflev = #{inflev,jdbcType=VARCHAR},</if>
            <if test="inftxt != null">inftxt = #{inftxt,jdbcType=CLOB},</if>
            <if test="ver != null">ver = #{ver,jdbcType=VARCHAR},</if>
            etgextkey = 'CEBGRP',
        </set>
        where inr = #{inr,jdbcType=VARCHAR}
    </update>

    <update id="updateByPrimaryKey">
        update oit
        <set>
            objtyp = #{objtyp,jdbcType=VARCHAR},
            objinr = #{objinr,jdbcType=VARCHAR},
            subtyp = #{subtyp,jdbcType=VARCHAR},
            subbus = #{subbus,jdbcType=VARCHAR},
            inflev = #{inflev,jdbcType=VARCHAR},
            inftxt = #{inftxt,jdbcType=CLOB},
            ver = #{ver,jdbcType=VARCHAR},
            etgextkey = 'CEBGRP',
        </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 oit
        <set>
            <if test="module.objtyp != null">objtyp = #{module.objtyp,jdbcType=VARCHAR},</if>
            <if test="module.objinr != null">objinr = #{module.objinr,jdbcType=VARCHAR},</if>
            <if test="module.subtyp != null">subtyp = #{module.subtyp,jdbcType=VARCHAR},</if>
            <if test="module.subbus != null">subbus = #{module.subbus,jdbcType=VARCHAR},</if>
            <if test="module.inflev != null">inflev = #{module.inflev,jdbcType=VARCHAR},</if>
            <if test="module.inftxt != null">inftxt = #{module.inftxt,jdbcType=CLOB},</if>
            <if test="module.ver != null">ver = #{module.ver,jdbcType=VARCHAR},</if>
            etgextkey = 'CEBGRP',
        </set>
        ${conditions}
    </update>

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

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

    <select id="selectCountByPtyinr" resultType="java.lang.Integer">
        select COUNT(*) from OIT WHERE OBJTYP='PTY' AND (SUBTYP='STP' and INFLEV='9') AND OBJINR=#{objinr,jdbcType=CLOB}
    </select>

    <!--查询单个-->
    <select id="queryById" resultMap="BaseResultMap">
        select
          INR, OBJTYP, OBJINR, SUBTYP, SUBBUS, INFLEV, INFTXT, VER, ETGEXTKEY
        from OIT
        where INR = #{inr}
    </select>

    <select id="queryfield" resultMap="FieldMap">
        select
        <if test="objtyp == 'BRD'">
            OWNREF,
        </if>
        NAM from ${objtyp}
        <where>
            inr = #{objinr}
            <if test="objtyp == 'BRD'">
                and OWNREF is not null
            </if>
            and nam is not null
        </where>
    </select>

    <!--查询指定行数据-->
    <select id="queryAllByLimit" resultMap="BaseResultMap">
        select
        INR, OBJTYP, OBJINR, SUBTYP, SUBBUS, INFLEV, INFTXT, VER, ETGEXTKEY
        from OIT
        <where>
            <if test="inr != null and inr != ''">
                and INR like concat(concat ('%',#{inr}),'%')
            </if>
            <if test="objtyp != null and objtyp != ''">
                and OBJTYP like concat(concat ('%',#{objtyp}),'%')
            </if>
            <if test="objinr != null and objinr != ''">
                and OBJINR like concat(concat ('%',#{objinr}),'%')
            </if>
            <if test="subtyp != null and subtyp != ''">
                and SUBTYP like concat(concat ('%',#{subtyp}),'%')
            </if>
            <if test="subbus != null and subbus != ''">
                and SUBBUS like concat(concat ('%',#{subbus}),'%')
            </if>
            <if test="inflev != null and inflev != ''">
                and INFLEV like concat(concat ('%',#{inflev}),'%')
            </if>
            <if test="inftxt != null and inftxt != ''">
                and INFTXT like concat(concat ('%',#{inftxt}),'%')
            </if>
            <if test="ver != null and ver != ''">
                and VER like concat(concat ('%',#{ver}),'%')
            </if>
            <if test="etgextkey != null and etgextkey != ''">
                and ETGEXTKEY like concat(concat ('%','CEBGRP'),'%')
            </if>
        </where>
        order by length(INR) DESC, INR DESC
    </select>

    <!--统计总行数-->
    <select id="count" resultType="java.lang.Long">
        select count(1)
        from OIT
        <where>
            <if test="inr != null and inr != ''">
                and INR = #{inr}
            </if>
            <if test="objtyp != null and objtyp != ''">
                and OBJTYP = #{objtyp}
            </if>
            <if test="objinr != null and objinr != ''">
                and OBJINR = #{objinr}
            </if>
            <if test="subtyp != null and subtyp != ''">
                and SUBTYP = #{subtyp}
            </if>
            <if test="subbus != null and subbus != ''">
                and SUBBUS = #{subbus}
            </if>
            <if test="inflev != null and inflev != ''">
                and INFLEV = #{inflev}
            </if>
            <if test="inftxt != null and inftxt != ''">
                and INFTXT = #{inftxt}
            </if>
            <if test="ver != null and ver != ''">
                and VER = #{ver}
            </if>
            <if test="etgextkey != null and etgextkey != ''">
                and ETGEXTKEY = 'CEBGRP'
            </if>
        </where>
    </select>


    <select id="queryAllByLimitRelPty" resultMap="FieldMap">
        select
        OIT.INR INR,
        OIT.OBJTYP OBJTYP,
        OIT.OBJINR OBJINR,
        OIT.SUBTYP SUBTYP,
        OIT.SUBBUS SUBBUS,
        OIT.INFLEV INFLEV,
        OIT.INFTXT INFTXT,
        OIT.VER VER,
        OIT.ETGEXTKEY ETGEXTKEY,
        PTY.EXTKEY OBJEXTKEY,
        PTY.NAM OBJNAM,
        '' OBJCOD
        from OIT,PTY WHERE OIT.OBJINR=PTY.INR and OIT.OBJTYP='PTY'
        <if test="objtyp != null and objtyp != ''">
            and OIT.OBJTYP = #{objtyp}
        </if>

        <if test="subtyp != null and subtyp != ''">
            and OIT.SUBTYP = #{subtyp}
        </if>

        <if test="objextkey != null and objextkey != ''">
            and PTY.extkey like concat(concat ('%',#{objextkey}),'%')
        </if>
        <if test="objnam != null and objnam != ''">
            and (
            PTY.nam like concat(concat ('%',#{objnam}),'%')
            or
            PTY.nam1 like concat(concat ('%',#{objnam}),'%')
            )
        </if>

        <if test="bchkeyinr != null and bchkeyinr != ''">
            and PTY.bchkeyinr = #{bchkeyinr}
        </if>
        order by length(OIT.INR) DESC, INR DESC
    </select>


    <select id="queryAllByLimitRelPta" resultMap="FieldMap">
        select
        OIT.INR INR,
        OIT.OBJTYP OBJTYP,
        OIT.OBJINR OBJINR,
        OIT.SUBTYP SUBTYP,
        OIT.SUBBUS SUBBUS,
        OIT.INFLEV INFLEV,
        OIT.INFTXT INFTXT,
        OIT.VER VER,
        OIT.ETGEXTKEY ETGEXTKEY,
        PTA.OBJKEY OBJEXTKEY,
        PTA.NAM OBJNAM,
        '' OBJCOD
        from OIT,PTA WHERE OIT.OBJINR=PTA.INR and OIT.OBJTYP='PTA'
        <if test="objtyp != null and objtyp != ''">
            and OIT.OBJTYP = #{objtyp}
        </if>

        <if test="subtyp != null and subtyp != ''">
            and OIT.SUBTYP = #{subtyp}
        </if>

        <if test="objextkey != null and objextkey != ''">
            and PTA.objkey like concat(concat ('%',#{objextkey}),'%')
        </if>
        <if test="objnam != null and objnam != ''">
            and (
            PTA.nam like concat(concat ('%',#{objnam}),'%')

            )
        </if>
        <if test="bchkeyinr != null and bchkeyinr != ''">
            and PTA.bchkeyinr = #{bchkeyinr}
        </if>
        order by length(OIT.INR) DESC, INR DESC
    </select>

    <select id="queryAllByLimitRelAct" resultMap="FieldMap">
        select
        OIT.INR INR,
        OIT.OBJTYP OBJTYP,
        OIT.OBJINR OBJINR,
        OIT.SUBTYP SUBTYP,
        OIT.SUBBUS SUBBUS,
        OIT.INFLEV INFLEV,
        OIT.INFTXT INFTXT,
        OIT.VER VER,
        OIT.ETGEXTKEY ETGEXTKEY,
        ACT.EXTKEY OBJEXTKEY,
        ACT.NAM OBJNAM,
        '' OBJCOD
        from OIT, ACT, PTY WHERE OIT.OBJINR=ACT.INR and OIT.OBJTYP='ACT'
        AND ACT.HOLPTYINR=PTY.INR
        <if test="objtyp != null and objtyp != ''">
            and OIT.OBJTYP = #{objtyp}
        </if>

        <if test="subtyp != null and subtyp != ''">
            and OIT.SUBTYP = #{subtyp}
        </if>

        <if test="objextkey != null and objextkey != ''">
            and ACT.EXTKEY like concat(concat ('%',#{objextkey}),'%')
        </if>
        <if test="objnam != null and objnam != ''">
            and (
            ACT.nam like concat(concat ('%',#{objnam}),'%')

            )
        </if>
        <if test="bchkeyinr != null and bchkeyinr != ''">
            and PTY.bchkeyinr = #{bchkeyinr}
        </if>
        order by length(OIT.INR) DESC, INR DESC
    </select>

    <select id="queryAllByLimitRelGid" resultMap="FieldMap">
        select
        OIT.INR INR,
        OIT.OBJTYP OBJTYP,
        OIT.OBJINR OBJINR,
        OIT.SUBTYP SUBTYP,
        OIT.SUBBUS SUBBUS,
        OIT.INFLEV INFLEV,
        OIT.INFTXT INFTXT,
        OIT.VER VER,
        OIT.ETGEXTKEY ETGEXTKEY,
        GID.OWNREF OBJEXTKEY,
        GID.NAM OBJNAM,
        '' OBJCOD
        from OIT,GID WHERE OIT.OBJINR=GID.INR and OIT.OBJTYP='GID'
        <if test="objtyp != null and objtyp != ''">
            and OIT.OBJTYP = #{objtyp}
        </if>

        <if test="subtyp != null and subtyp != ''">
            and OIT.SUBTYP = #{subtyp}
        </if>

        <if test="objextkey != null and objextkey != ''">
            and GID.OWNREF like concat(concat ('%',#{objextkey}),'%')
        </if>
        <if test="objnam != null and objnam != ''">
            and (
            GID.NAM like concat(concat ('%',#{objnam}),'%')

            )
        </if>
        <if test="bchkeyinr != null and bchkeyinr != ''">
            and GID.bchkeyinr = #{bchkeyinr}
        </if>
        order by length(OIT.INR) DESC, INR DESC
    </select>

    <select id="queryAllByLimitRelNid" resultMap="FieldMap">
        select
        OIT.INR INR,
        OIT.OBJTYP OBJTYP,
        OIT.OBJINR OBJINR,
        OIT.SUBTYP SUBTYP,
        OIT.SUBBUS SUBBUS,
        OIT.INFLEV INFLEV,
        OIT.INFTXT  INFTXT,
        OIT.VER VER,
        OIT.ETGEXTKEY ETGEXTKEY,
        NID.OWNREF OBJEXTKEY,
        NID.NAM OBJNAM,
        '' OBJCOD
        from OIT,NID WHERE OIT.OBJINR=NID.INR and OIT.OBJTYP='NID'
        <if test="objtyp != null and objtyp != ''">
            and OIT.OBJTYP = #{objtyp}
        </if>

        <if test="subtyp != null and subtyp != ''">
            and OIT.SUBTYP = #{subtyp}
        </if>

        <if test="objextkey != null and objextkey != ''">
            and NID.OWNREF like concat(concat ('%',#{objextkey}),'%')
        </if>
        <if test="objnam != null and objnam != ''">
            and (
            NID.NAM like concat(concat ('%',#{objnam}),'%')

            )
        </if>
        <if test="bchkeyinr != null and bchkeyinr != ''">
            and NID.bchkeyinr = #{bchkeyinr}
        </if>
        order by length(OIT.INR) DESC, INR DESC
    </select>

    <select id="queryAllByLimitRelCty" resultMap="FieldMap">
        select
        OIT.INR INR,
        OIT.OBJTYP OBJTYP,
        OIT.OBJINR OBJINR,
        OIT.SUBTYP SUBTYP,
        OIT.SUBBUS SUBBUS,
        OIT.INFLEV INFLEV,
        OIT.INFTXT INFTXT,
        OIT.VER VER,
        OIT.ETGEXTKEY ETGEXTKEY,
        CTY.COD OBJEXTKEY,
        CTY.COD OBJNAM,
        '' OBJCOD
        from OIT,CTY WHERE OIT.OBJINR=CTY.INR and OIT.OBJTYP='CTY'
        <if test="objtyp != null and objtyp != ''">
            and OIT.OBJTYP = #{objtyp}
        </if>

        <if test="subtyp != null and subtyp != ''">
            and OIT.SUBTYP = #{subtyp}
        </if>

        <if test="objextkey != null and objextkey != ''">
            and CTY.COD like concat(concat ('%',#{objextkey}),'%')
        </if>

        order by length(OIT.INR) DESC, INR DESC
    </select>

    <select id="queryAllByLimitRelFec" resultMap="FieldMap">
        select
        OIT.INR INR,
        OIT.OBJTYP OBJTYP,
        OIT.OBJINR OBJINR,
        OIT.SUBTYP SUBTYP,
        OIT.SUBBUS SUBBUS,
        OIT.INFLEV INFLEV,
        OIT.INFTXT INFTXT,
        OIT.VER VER,
        OIT.ETGEXTKEY ETGEXTKEY,
        FEC.FEEINR OBJEXTKEY
        from OIT,FEC WHERE OIT.OBJINR=FEC.INR and OIT.OBJTYP='FEC'
        <if test="objtyp != null and objtyp != ''">
            and OIT.OBJTYP = #{objtyp}
        </if>

        <if test="subtyp != null and subtyp != ''">
            and OIT.SUBTYP = #{subtyp}
        </if>
        <if test="objextkey != null and objextkey != ''">
            and FEC.FEEINR = (select inr from fee where cod = #{objextkey})
        </if>
        order by length(OIT.INR) DESC, INR DESC
    </select>

    <!--通过主键修改数据-->
    <update id="update">
        update OIT
        <set>
            <if test="inr != null and inr != ''">
                INR = #{inr},
            </if>
            <if test="objtyp != null and objtyp != ''">
                OBJTYP = #{objtyp},
            </if>
            <if test="objinr != null and objinr != ''">
                OBJINR = #{objinr},
            </if>
            <if test="subtyp != null and subtyp != ''">
                SUBTYP = #{subtyp},
            </if>
            <if test="subbus != null and subbus != ''">
                SUBBUS = #{subbus},
            </if>
            <if test="inflev != null and inflev != ''">
                INFLEV = #{inflev},
            </if>
            <if test="inftxt != null and inftxt != ''">
                INFTXT = #{inftxt},
            </if>
            <if test="ver != null and ver != ''">
                VER = #{ver},
            </if>
                ETGEXTKEY = 'CEBGRP',
        </set>
        where INR = #{inr}
    </update>

    <!--通过主键删除-->
    <delete id="deleteById">
        delete from OIT where INR = #{inr}
    </delete>

    <select id="queryByPtyinr" resultMap="BaseResultMap">
        select subtyp, inflev, inftxt from oit where objtyp = 'PTY' and objinr = #{ptyinr}
    </select>

    <select id="queryByAdrinr" resultMap="BaseResultMap">
        select subtyp, inflev, inftxt from oit where objtyp = 'ADR' and objinr = #{adrinr} and subtyp = 'INF'
    </select>

    <select id="queryByCondition" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"></include>
        from oit
        <where>
            <if test="objtyp != null and objtyp != ''">
                and objtyp = #{objtyp}
            </if>
            <if test="objinr != null and objinr != ''">
                and objinr = #{objinr}
            </if>
            <if test="subtyp != null and subtyp != ''">
                and subtyp = #{subtyp}
            </if>
        </where>
    </select>

    <update id="updateByAdrsign">
        update oit
        <set>
            <trim suffixOverrides=",">
                <if test="inflev != null">
                    inflev = #{inflev},
                </if>
                <if test="inftxt != null">
                    inftxt = #{inftxt},
                </if>
            </trim>
        </set>
        <where>
            <if test="objtyp != null and objtyp != ''">
                and objtyp = #{objtyp}
            </if>
            <if test="objinr != null and objinr != ''">
                and objinr = #{objinr}
            </if>
            <if test="subtyp != null and subtyp != ''">
                and subtyp = #{subtyp}
            </if>
        </where>
    </update>

    <insert id="insertAdrOit">
        insert into oit
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="inr != null">inr,</if>
            <if test="objtyp != null">objtyp,</if>
            <if test="objinr != null">objinr,</if>
            <if test="subtyp != null">subtyp,</if>
            <if test="subbus != null">subbus,</if>
            <if test="inflev != null">inflev,</if>
            <if test="inftxt != null">inftxt,</if>
            <if test="ver != null">ver,</if>
            <if test="etgextkey != null">etgextkey,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="inr != null">#{inr,jdbcType=VARCHAR},</if>
            <if test="objtyp != null">#{objtyp,jdbcType=VARCHAR},</if>
            <if test="objinr != null">#{objinr,jdbcType=VARCHAR},</if>
            <if test="subtyp != null">#{subtyp,jdbcType=VARCHAR},</if>
            <if test="subbus != null">#{subbus,jdbcType=VARCHAR},</if>
            <if test="inflev != null">#{inflev,jdbcType=VARCHAR},</if>
            <if test="inftxt != null">#{inftxt,jdbcType=CLOB},</if>
            <if test="ver != null">'0000',</if>
            <if test="etgextkey != null">'CEBGRP',</if>
        </trim>
    </insert>

    <select id="queryObjByObjextkeyPty" resultMap="FieldMap">
        select inr objinr,extkey objextkey,CONCAT_WS('/',extkey,nam) objnam from pty where extkey = #{objextkey}
    </select>

    <select id="queryObjByObjextkeyPta" resultMap="FieldMap">
        select inr objinr,objkey objextkey,CONCAT_WS('/',objkey,nam) objnam from pta where objkey = #{objextkey}
    </select>

    <select id="queryObjByObjextkeyAct" resultMap="FieldMap">
        select inr objinr,extkey objextkey,CONCAT_WS('/',extkey,nam) objnam from act where extkey = #{objextkey}
    </select>

    <select id="queryObjByObjextkeyCty" resultMap="FieldMap">
        select inr objinr,cod objextkey from cty where cod = #{objextkey}
    </select>

    <select id="queryObjByObjextkeyGid" resultMap="FieldMap">
        select inr objinr,ownref objextkey,CONCAT_WS('/',ownref,nam) objnam from gid where ownref = #{objextkey}
    </select>

    <select id="queryObjByObjextkeyNid" resultMap="FieldMap">
        select inr objinr,ownref objextkey,CONCAT_WS('/',ownref,nam) objnam from nid where ownref = #{objextkey}
    </select>


    <select id="getObjByPty" resultMap="FieldMap">
        select extkey objextkey,CONCAT_WS('/',extkey,nam) objnam from pty where inr = #{objinr}
    </select>

    <select id="getObjByPta" resultMap="FieldMap">
        select objkey objextkey,CONCAT_WS('/',objkey,nam) objnam from pta where inr = #{objinr}
    </select>

    <select id="getObjByAct" resultMap="FieldMap">
        select extkey objextkey,CONCAT_WS('/',extkey,nam) objnam from act where inr = #{objinr}
    </select>

    <select id="getObjByCty" resultMap="FieldMap">
        select cod objcod from cty where inr = #{objinr}
    </select>

    <select id="getObjByGid" resultMap="FieldMap">
        select ownref objextkey,CONCAT_WS('/',ownref,nam) objnam from gid where inr = #{objinr}
    </select>

    <select id="getObjByNid" resultMap="FieldMap">
        select ownref objextkey,CONCAT_WS('/',ownref,nam) objnam from nid where inr = #{objinr}
    </select>

    <select id="getObjByFec" resultMap="FieldMap">
        select fee.cod objcod,fec.feepri objextkey,fec.objinr objnam from fec,fee where fee.inr = fec.feeinr and fec.inr = #{objinr}
    </select>

    <select id="queryByRecord" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"></include>
        from oit
        <where>
            <if test="inr != null and inr != ''">
                and INR = #{inr}
            </if>
            <if test="objtyp != null and objtyp != ''">
                and OBJTYP = #{objtyp}
            </if>
            <if test="objinr != null and objinr != ''">
                and OBJINR = #{objinr}
            </if>
            <if test="subtyp != null and subtyp != ''">
                and SUBTYP = #{subtyp}
            </if>
            <if test="subbus != null and subbus != ''">
                and SUBBUS = #{subbus}
            </if>
            <if test="inflev != null and inflev != ''">
                and INFLEV = #{inflev}
            </if>
            <if test="inftxt != null and inftxt != ''">
                and INFTXT = #{inftxt}
            </if>
            <if test="ver != null and ver != ''">
                and VER = #{ver}
            </if>
            <if test="etgextkey != null and etgextkey != ''">
                and ETGEXTKEY = 'CEBGRP'
            </if>
        </where>
    </select>

    <select id="queryActList" resultMap="OitTableResultMap">
        select a.inr actinr,a.extkey actkey, a.nam actnam,a.cur actcur from act a
        left join pty y on a.HOLPTYINR  = y.inr
        where a.extkey like concat('%', #{actkey}, '%')
        <if test="bchkeyinr != null and bchkeyinr != ''">
            and y.bchkeyinr = #{bchkeyinr}
        </if>
    </select>

    <select id="queryFecList" resultMap="OitTableResultMap">
        select a.inr fecinr, b.cod feecod, c.txt objtyp, c.txt objnam, a.begdat begdat, a.enddat enddat
        from fec a
        left join fee b on a.feeinr = b.inr
        left join stb c on a.feepri = c.cod and c.tbl = 'FEEPRI' and c.uil = #{stbuil}
        where a.feepri = '!'
        <if test="feecod != null and feecod != ''">
            and b.cod  = #{feecod}
        </if>

        union all

        select a.inr fecinr,b.cod feecod, c.txt objtyp, concat(c.txt,' / ',d.COD,' ',e.txt) objnam, a.begdat begdat, a.enddat enddat
        from fec a
        left join fee b on a.feeinr = b.inr
        left join stb c on a.feepri = c.cod and c.tbl = 'FEEPRI' and c.uil = #{stbuil}
        left join reg d on a.objinr = d.inr
        left join stb e on d.cod = e.cod and e.TBL = 'REGTXT' and e.uil = #{stbuil}
        where a.feepri = '1'
        <if test="feecod != null and feecod != ''">
            and b.cod  = #{feecod}
        </if>

        union all

        select a.inr fecinr,b.cod feecod, c.txt objtyp, concat(c.txt,' / ',d.COD,' ',e.txt) objnam, a.begdat begdat, a.enddat enddat
        from fec a
        left join fee b on a.feeinr = b.inr
        left join stb c on a.feepri = c.cod and c.tbl = 'FEEPRI' and c.uil = #{stbuil}
        left join cty d on a.objinr = d.inr
        left join stb e on d.COD = e.cod and e.TBL = 'CTYTXT' and e.uil = #{stbuil}
        where a.feepri = '2'
        <if test="feecod != null and feecod != ''">
            and b.cod  = #{feecod}
        </if>

        union all

        select a.inr fecinr,b.cod feecod, c.txt objtyp,concat(c.txt,' / ',d.extkey,' ',d.nam) objnam, a.begdat begdat, a.enddat enddat
        from fec a
        left join fee b on a.feeinr = b.inr
        left join stb c on a.feepri = c.cod and c.tbl = 'FEEPRI' and c.uil = #{stbuil}
        left join pty d on a.objinr = d.inr
        where a.feepri = '4'
        <if test="feecod != null and feecod != ''">
            and b.cod  = #{feecod}
        </if>
    </select>

    <select id="queryGidList" resultMap="OitTableResultMap">
        select inr gidinr, ownref gidref, nam gidnam from gid where ownref like concat('%', #{gidref}, '%')
        <if test="bchkeyinr != null and bchkeyinr != ''">
            and bchkeyinr = #{bchkeyinr}
        </if>
    </select>

    <select id="queryNidList" resultMap="OitTableResultMap">
        select inr nidinr, ownref nidref, nam nidnam from nid where ownref like concat('%', #{nidref}, '%')
        <if test="bchkeyinr != null and bchkeyinr != ''">
            and bchkeyinr = #{bchkeyinr}
        </if>
    </select>


    <select id="queryPtyList" resultMap="OitTableResultMap">
        select
        a.inr ptyinr,
        a.extkey ptykey,
        a.nam ptynam,
        a.nam1 ptynam1
        from pty a
        where a.extkey like concat(concat ('%',#{ptykey}),'%')
        <if test="bchkeyinr != null and bchkeyinr != ''">
            and a.bchkeyinr = #{bchkeyinr}
        </if>
        order by a.extkey desc
    </select>

    <select id="queryPtaList" resultMap="OitTableResultMap">
        select
        a.inr ptainr,
        a.objkey ptakey,
        a.nam ptanam,
        a.nam1 ptanam1
        from pta a
        where a.objkey like concat(concat ('%',#{ptakey}),'%')
        <if test="bchkeyinr != null and bchkeyinr != ''">
            and a.bchkeyinr = #{bchkeyinr}
        </if>
        order by a.objkey desc
    </select>

    <select id="getStopPtyList" resultType="java.lang.String">
        select  objinr
        from  oit
        where  objtyp = 'PTY'
          and subtyp = 'STP'
          and inflev>'0'
          and objinr in (
          select  inr
          from pty
          where extkey in (
          select distinct cliextkey
          from  gle
          where  trninr in (
          select inr
          from  trn where
          relflg in ('R','F')
          <if test="begdat != null ">
              and TRN.CPLDATTIM >= #{begdat}
          </if>
          <if test="enddat != null ">
              and TRN.CPLDATTIM &lt;= #{enddat}
          </if>
          and not TRN.CPLDATTIM is null
          <if test="bchLst != null and bchLst.size() >0 and branch != '1000'.toString()">
              and TRN.BRANCHINR in
              <foreach item="bch" collection="bchLst" open="(" separator="," close=")">
                  #{bch.inr}
              </foreach>
          </if>  )))
    </select>
</mapper>