<?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.hzya.frame.sysnew.archivesContrast.dao.impl.SysArchivesContrastDaoImpl">

    <resultMap id="get-SysArchivesContrastEntity-result" type="com.hzya.frame.sysnew.archivesContrast.entity.SysArchivesContrastEntity" >
       <result property="id" column="id" jdbcType="VARCHAR"/>
           <result property="leftAppId" column="left_app_id" jdbcType="VARCHAR"/>
           <result property="leftAppCode" column="left_app_code" jdbcType="VARCHAR"/>
           <result property="leftAppName" column="left_app_name" jdbcType="VARCHAR"/>
           <result property="leftApiId" column="left_api_id" jdbcType="VARCHAR"/>
           <result property="leftId" column="left_id" jdbcType="VARCHAR"/>
           <result property="leftCode" column="left_code" jdbcType="VARCHAR"/>
           <result property="leftName" column="left_name" jdbcType="VARCHAR"/>
           <result property="leftTel" column="left_tel" jdbcType="VARCHAR"/>
           <result property="leftIc" column="left_ic" jdbcType="VARCHAR"/>
           <result property="rightAppId" column="right_app_id" jdbcType="VARCHAR"/>
           <result property="rightAppCode" column="right_app_code" jdbcType="VARCHAR"/>
           <result property="rightAppName" column="right_app_name" jdbcType="VARCHAR"/>
           <result property="rightApiId" column="right_api_id" jdbcType="VARCHAR"/>
           <result property="rightId" column="right_id" jdbcType="VARCHAR"/>
           <result property="rightCode" column="right_code" jdbcType="VARCHAR"/>
           <result property="rightName" column="right_name" jdbcType="VARCHAR"/>
           <result property="rightTel" column="right_tel" jdbcType="VARCHAR"/>
           <result property="rightIc" column="right_ic" jdbcType="VARCHAR"/>
           <result property="sorts" column="sorts" jdbcType="INTEGER"/>
           <result property="create_user_id" column="create_user_id" jdbcType="VARCHAR"/>
           <result property="create_time" column="create_time" jdbcType="TIMESTAMP"/>
           <result property="modify_user_id" column="modify_user_id" jdbcType="VARCHAR"/>
           <result property="modify_time" column="modify_time" jdbcType="TIMESTAMP"/>
           <result property="sts" column="sts" jdbcType="VARCHAR"/>
           <result property="org_id" column="org_id" jdbcType="VARCHAR"/>
           <result property="companyId" column="company_id" jdbcType="VARCHAR"/>
           <result property="leftOrg" column="left_org" jdbcType="VARCHAR"/>
           <result property="rightOrg" column="right_org" jdbcType="VARCHAR"/>
        </resultMap>
    <!-- 查询的字段-->
    <sql id = "SysArchivesContrastEntity_Base_Column_List_personnel">
        id
       ,left_app_id 
        ,left_app_code 
        ,left_app_name 
        ,left_api_id 
        ,left_id 
        ,left_code 
        ,left_name 
        ,left_tel 
        ,left_ic 
        ,right_app_id 
        ,right_app_code 
        ,right_app_name 
        ,right_api_id 
        ,right_id 
        ,right_code 
        ,right_name 
        ,right_tel 
        ,right_ic 
        ,sorts 
        ,create_user_id 
        ,create_time 
        ,modify_user_id 
        ,modify_time 
        ,sts 
        ,org_id 
        ,company_id 
        ,left_org 
        ,right_org 
     </sql>

    <sql id = "SysArchivesContrastEntity_Base_Column_List">
        id
       ,left_app_id
        ,left_app_code
        ,left_app_name
        ,left_api_id
        ,left_id
        ,left_code
        ,left_name
        ,right_app_id
        ,right_app_code
        ,right_app_name
        ,right_api_id
        ,right_id
        ,right_code
        ,right_name
        ,sorts
        ,create_user_id
        ,create_time
        ,modify_user_id
        ,modify_time
        ,sts
        ,org_id
        ,company_id
        ,left_org
        ,right_org
     </sql>
    <!--通过ID获取数据 -->
    <select id="entity_get" resultMap="get-SysArchivesContrastEntity-result">
        select
        <choose>
            <when test="type == '1'.toString()">
                <include refid="SysArchivesContrastEntity_Base_Column_List_personnel" />
            </when>
            <otherwise>
                <include refid="SysArchivesContrastEntity_Base_Column_List" />
            </otherwise>
        </choose>
        from
        <choose>
            <when test="type == '1'.toString()"> sys_personnel_control </when>
            <when test="type == '2'.toString()"> sys_org_control </when>
            <when test="type == '3'.toString()"> sys_stock_control </when>
            <when test="type == '4'.toString()"> sys_merchant_control </when>
            <when test="type == '5'.toString()"> sys_taxrate_control </when>
            <when test="type == '6'.toString()"> sys_project_control </when>
            <when test="type == '7'.toString()"> sys_bank_control </when>
            <when test="type == '8'.toString()"> sys_bankaccount_control </when>
            <when test="type == '9'.toString()"> sys_assets_control </when>
        </choose>
        where sts = 'Y' and  id = #{id}
    </select>

    <!--通过ID获取数据 -->
    <select id="getEntity" resultMap="get-SysArchivesContrastEntity-result" parameterType = "com.hzya.frame.sysnew.archivesContrast.entity.SysArchivesContrastEntity">
        select
        <choose>
            <when test="type == '1'.toString()">
                <include refid="SysArchivesContrastEntity_Base_Column_List_personnel" />
            </when>
            <otherwise>
                <include refid="SysArchivesContrastEntity_Base_Column_List" />
            </otherwise>
        </choose>
        from
        <choose>
            <when test="type == '1'.toString()"> sys_personnel_control </when>
            <when test="type == '2'.toString()"> sys_org_control </when>
            <when test="type == '3'.toString()"> sys_stock_control </when>
            <when test="type == '4'.toString()"> sys_merchant_control </when>
            <when test="type == '5'.toString()"> sys_taxrate_control </when>
            <when test="type == '6'.toString()"> sys_project_control </when>
            <when test="type == '7'.toString()"> sys_bank_control </when>
            <when test="type == '8'.toString()"> sys_bankaccount_control </when>
            <when test="type == '9'.toString()"> sys_assets_control </when>
        </choose>
        where sts = 'Y' and  id = #{id}
    </select>
 <!-- 查询 采用==查询 -->
 <select id="entity_list_base" resultMap="get-SysArchivesContrastEntity-result" parameterType = "com.hzya.frame.sysnew.archivesContrast.entity.SysArchivesContrastEntity">
    select
     <choose>
         <when test="type == '1'.toString()">
             <include refid="SysArchivesContrastEntity_Base_Column_List_personnel" />
         </when>
         <otherwise>
             <include refid="SysArchivesContrastEntity_Base_Column_List" />
         </otherwise>
     </choose>
    from
     <choose>
         <when test="type == '1'.toString()"> sys_personnel_control </when>
         <when test="type == '2'.toString()"> sys_org_control </when>
         <when test="type == '3'.toString()"> sys_stock_control </when>
         <when test="type == '4'.toString()"> sys_merchant_control </when>
         <when test="type == '5'.toString()"> sys_taxrate_control </when>
         <when test="type == '6'.toString()"> sys_project_control </when>
         <when test="type == '7'.toString()"> sys_bank_control </when>
         <when test="type == '8'.toString()"> sys_bankaccount_control </when>
         <when test="type == '9'.toString()"> sys_assets_control </when>
     </choose>
    <trim prefix="where" prefixOverrides="and"> 
        <if test="id != null and id != ''"> and id = #{id} </if>
            <if test="leftAppId != null and leftAppId != ''"> and left_app_id = #{leftAppId} </if>
            <if test="leftAppCode != null and leftAppCode != ''"> and left_app_code = #{leftAppCode} </if>
            <if test="leftAppName != null and leftAppName != ''"> and left_app_name = #{leftAppName} </if>
            <if test="leftApiId != null and leftApiId != ''"> and left_api_id = #{leftApiId} </if>
            <if test="leftId != null and leftId != ''"> and left_id = #{leftId} </if>
            <if test="leftCode != null and leftCode != ''"> and left_code = #{leftCode} </if>
            <if test="leftName != null and leftName != ''"> and left_name = #{leftName} </if>
            <if test="leftTel != null and leftTel != ''"> and left_tel = #{leftTel} </if>
            <if test="leftIc != null and leftIc != ''"> and left_ic = #{leftIc} </if>
            <if test="rightAppId != null and rightAppId != ''"> and right_app_id = #{rightAppId} </if>
            <if test="rightAppCode != null and rightAppCode != ''"> and right_app_code = #{rightAppCode} </if>
            <if test="rightAppName != null and rightAppName != ''"> and right_app_name = #{rightAppName} </if>
            <if test="rightApiId != null and rightApiId != ''"> and right_api_id = #{rightApiId} </if>
            <if test="rightId != null and rightId != ''"> and right_id = #{rightId} </if>
            <if test="rightCode != null and rightCode != ''"> and right_code = #{rightCode} </if>
            <if test="rightName != null and rightName != ''"> and right_name = #{rightName} </if>
            <if test="rightTel != null and rightTel != ''"> and right_tel = #{rightTel} </if>
            <if test="rightIc != null and rightIc != ''"> and right_ic = #{rightIc} </if>
            <if test="sorts != null"> and sorts = #{sorts} </if>
            <if test="create_user_id != null and create_user_id != ''"> and create_user_id = #{create_user_id} </if>
            <if test="create_time != null"> and create_time = #{create_time} </if>
            <if test="modify_user_id != null and modify_user_id != ''"> and modify_user_id = #{modify_user_id} </if>
            <if test="modify_time != null"> and modify_time = #{modify_time} </if>
            <if test="sts != null and sts != ''"> and sts = #{sts} </if>
            <if test="org_id != null and org_id != ''"> and org_id = #{org_id} </if>
            <if test="companyId != null and companyId != ''"> and company_id = #{companyId} </if>
            <if test="leftOrg != null and leftOrg != ''"> and left_org = #{leftOrg} </if>
            <if test="rightOrg != null and rightOrg != ''"> and right_org = #{rightOrg} </if>
            and sts='Y'
    </trim>
    <if test=" sort == null or sort == ''.toString() "> order by sorts asc</if>
    <if test=" sort !='' and sort!=null and order !='' and order!=null ">order by ${sort} ${order}</if>
</select>
    
<!-- 查询符合条件的数量 -->
<select id="entity_count" resultType="Integer" parameterType = "com.hzya.frame.sysnew.archivesContrast.entity.SysArchivesContrastEntity">
        select  count(1)   from
    <choose>
        <when test="type == '1'.toString()"> sys_personnel_control </when>
        <when test="type == '2'.toString()"> sys_org_control </when>
        <when test="type == '3'.toString()"> sys_stock_control </when>
        <when test="type == '4'.toString()"> sys_merchant_control </when>
        <when test="type == '5'.toString()"> sys_taxrate_control </when>
        <when test="type == '6'.toString()"> sys_project_control </when>
        <when test="type == '7'.toString()"> sys_bank_control </when>
        <when test="type == '8'.toString()"> sys_bankaccount_control </when>
        <when test="type == '9'.toString()"> sys_assets_control </when>
    </choose>
    <trim prefix="where" prefixOverrides="and"> 
        <if test="id != null and id != ''"> and id = #{id} </if>
            <if test="leftAppId != null and leftAppId != ''"> and left_app_id = #{leftAppId} </if>
            <if test="leftAppCode != null and leftAppCode != ''"> and left_app_code = #{leftAppCode} </if>
            <if test="leftAppName != null and leftAppName != ''"> and left_app_name = #{leftAppName} </if>
            <if test="leftApiId != null and leftApiId != ''"> and left_api_id = #{leftApiId} </if>
            <if test="leftId != null and leftId != ''"> and left_id = #{leftId} </if>
            <if test="leftCode != null and leftCode != ''"> and left_code = #{leftCode} </if>
            <if test="leftName != null and leftName != ''"> and left_name = #{leftName} </if>
            <if test="leftTel != null and leftTel != ''"> and left_tel = #{leftTel} </if>
            <if test="leftIc != null and leftIc != ''"> and left_ic = #{leftIc} </if>
            <if test="rightAppId != null and rightAppId != ''"> and right_app_id = #{rightAppId} </if>
            <if test="rightAppCode != null and rightAppCode != ''"> and right_app_code = #{rightAppCode} </if>
            <if test="rightAppName != null and rightAppName != ''"> and right_app_name = #{rightAppName} </if>
            <if test="rightApiId != null and rightApiId != ''"> and right_api_id = #{rightApiId} </if>
            <if test="rightId != null and rightId != ''"> and right_id = #{rightId} </if>
            <if test="rightCode != null and rightCode != ''"> and right_code = #{rightCode} </if>
            <if test="rightName != null and rightName != ''"> and right_name = #{rightName} </if>
            <if test="rightTel != null and rightTel != ''"> and right_tel = #{rightTel} </if>
            <if test="rightIc != null and rightIc != ''"> and right_ic = #{rightIc} </if>
            <if test="sorts != null"> and sorts = #{sorts} </if>
            <if test="create_user_id != null and create_user_id != ''"> and create_user_id = #{create_user_id} </if>
            <if test="create_time != null"> and create_time = #{create_time} </if>
            <if test="modify_user_id != null and modify_user_id != ''"> and modify_user_id = #{modify_user_id} </if>
            <if test="modify_time != null"> and modify_time = #{modify_time} </if>
            <if test="sts != null and sts != ''"> and sts = #{sts} </if>
            <if test="org_id != null and org_id != ''"> and org_id = #{org_id} </if>
            <if test="companyId != null and companyId != ''"> and company_id = #{companyId} </if>
            <if test="leftOrg != null and leftOrg != ''"> and left_org = #{leftOrg} </if>
            <if test="rightOrg != null and rightOrg != ''"> and right_org = #{rightOrg} </if>
            and sts='Y'
    </trim>
    <if test=" sort == null or sort == ''.toString() "> order by sorts asc</if>
    <if test=" sort !='' and sort!=null and order !='' and order!=null "> order by ${sort} ${order}</if>
    </select>

    <!-- 分页查询列表 采用like格式 -->
<select id="entity_list_like" resultMap="get-SysArchivesContrastEntity-result" parameterType = "com.hzya.frame.sysnew.archivesContrast.entity.SysArchivesContrastEntity">
    select
    <choose>
        <when test="type == '1'.toString()">
            <include refid="SysArchivesContrastEntity_Base_Column_List_personnel" />
        </when>
        <otherwise>
            <include refid="SysArchivesContrastEntity_Base_Column_List" />
        </otherwise>
    </choose>
    from
    <choose>
        <when test="type == '1'.toString()"> sys_personnel_control </when>
        <when test="type == '2'.toString()"> sys_org_control </when>
        <when test="type == '3'.toString()"> sys_stock_control </when>
        <when test="type == '4'.toString()"> sys_merchant_control </when>
        <when test="type == '5'.toString()"> sys_taxrate_control </when>
        <when test="type == '6'.toString()"> sys_project_control </when>
        <when test="type == '7'.toString()"> sys_bank_control </when>
        <when test="type == '8'.toString()"> sys_bankaccount_control </when>
        <when test="type == '9'.toString()"> sys_assets_control </when>
    </choose>
    <trim prefix="where" prefixOverrides="and"> 
        <if test="id != null and id != ''"> and id like concat('%',#{id},'%') </if>
            <if test="leftAppId != null and leftAppId != ''"> and left_app_id like concat('%',#{leftAppId},'%') </if>
            <if test="leftAppCode != null and leftAppCode != ''"> and left_app_code like concat('%',#{leftAppCode},'%') </if>
            <if test="leftAppName != null and leftAppName != ''"> and left_app_name like concat('%',#{leftAppName},'%') </if>
            <if test="leftApiId != null and leftApiId != ''"> and left_api_id like concat('%',#{leftApiId},'%') </if>
            <if test="leftId != null and leftId != ''"> and left_id like concat('%',#{leftId},'%') </if>
            <if test="leftCode != null and leftCode != ''"> and left_code like concat('%',#{leftCode},'%') </if>
            <if test="leftName != null and leftName != ''"> and left_name like concat('%',#{leftName},'%') </if>
            <if test="leftTel != null and leftTel != ''"> and left_tel like concat('%',#{leftTel},'%') </if>
            <if test="leftIc != null and leftIc != ''"> and left_ic like concat('%',#{leftIc},'%') </if>
            <if test="rightAppId != null and rightAppId != ''"> and right_app_id like concat('%',#{rightAppId},'%') </if>
            <if test="rightAppCode != null and rightAppCode != ''"> and right_app_code like concat('%',#{rightAppCode},'%') </if>
            <if test="rightAppName != null and rightAppName != ''"> and right_app_name like concat('%',#{rightAppName},'%') </if>
            <if test="rightApiId != null and rightApiId != ''"> and right_api_id like concat('%',#{rightApiId},'%') </if>
            <if test="rightId != null and rightId != ''"> and right_id like concat('%',#{rightId},'%') </if>
            <if test="rightCode != null and rightCode != ''"> and right_code like concat('%',#{rightCode},'%') </if>
            <if test="rightName != null and rightName != ''"> and right_name like concat('%',#{rightName},'%') </if>
            <if test="rightTel != null and rightTel != ''"> and right_tel like concat('%',#{rightTel},'%') </if>
            <if test="rightIc != null and rightIc != ''"> and right_ic like concat('%',#{rightIc},'%') </if>
            <if test="sorts != null"> and sorts like concat('%',#{sorts},'%') </if>
            <if test="create_user_id != null and create_user_id != ''"> and create_user_id like concat('%',#{create_user_id},'%') </if>
            <if test="create_time != null"> and create_time like concat('%',#{create_time},'%') </if>
            <if test="modify_user_id != null and modify_user_id != ''"> and modify_user_id like concat('%',#{modify_user_id},'%') </if>
            <if test="modify_time != null"> and modify_time like concat('%',#{modify_time},'%') </if>
            <if test="sts != null and sts != ''"> and sts like concat('%',#{sts},'%') </if>
            <if test="org_id != null and org_id != ''"> and org_id like concat('%',#{org_id},'%') </if>
            <if test="companyId != null and companyId != ''"> and company_id like concat('%',#{companyId},'%') </if>
            <if test="leftOrg != null and leftOrg != ''"> and left_org like concat('%',#{leftOrg},'%') </if>
            <if test="rightOrg != null and rightOrg != ''"> and right_org like concat('%',#{rightOrg},'%') </if>
            and sts='Y'
    </trim>
    <if test=" sort == null or sort == ''.toString() "> order by sorts asc</if>
    <if test=" sort !='' and sort!=null and order !='' and order!=null ">order by ${sort} ${order}</if>
</select>

<!-- 查询列表 字段采用or格式 -->
<select id="SysArchivesContrastentity_list_or" resultMap="get-SysArchivesContrastEntity-result" parameterType = "com.hzya.frame.sysnew.archivesContrast.entity.SysArchivesContrastEntity">
    select
    <choose>
        <when test="type == '1'.toString()">
            <include refid="SysArchivesContrastEntity_Base_Column_List_personnel" />
        </when>
        <otherwise>
            <include refid="SysArchivesContrastEntity_Base_Column_List" />
        </otherwise>
    </choose>
    from
    <choose>
        <when test="type == '1'.toString()"> sys_personnel_control </when>
        <when test="type == '2'.toString()"> sys_org_control </when>
        <when test="type == '3'.toString()"> sys_stock_control </when>
        <when test="type == '4'.toString()"> sys_merchant_control </when>
        <when test="type == '5'.toString()"> sys_taxrate_control </when>
        <when test="type == '6'.toString()"> sys_project_control </when>
        <when test="type == '7'.toString()"> sys_bank_control </when>
        <when test="type == '8'.toString()"> sys_bankaccount_control </when>
        <when test="type == '9'.toString()"> sys_assets_control </when>
    </choose>
    <trim prefix="where" prefixOverrides="and"> 
         <if test="id != null and id != ''"> or id = #{id} </if>
             <if test="leftAppId != null and leftAppId != ''"> or left_app_id = #{leftAppId} </if>
             <if test="leftAppCode != null and leftAppCode != ''"> or left_app_code = #{leftAppCode} </if>
             <if test="leftAppName != null and leftAppName != ''"> or left_app_name = #{leftAppName} </if>
             <if test="leftApiId != null and leftApiId != ''"> or left_api_id = #{leftApiId} </if>
             <if test="leftId != null and leftId != ''"> or left_id = #{leftId} </if>
             <if test="leftCode != null and leftCode != ''"> or left_code = #{leftCode} </if>
             <if test="leftName != null and leftName != ''"> or left_name = #{leftName} </if>
             <if test="leftTel != null and leftTel != ''"> or left_tel = #{leftTel} </if>
             <if test="leftIc != null and leftIc != ''"> or left_ic = #{leftIc} </if>
             <if test="rightAppId != null and rightAppId != ''"> or right_app_id = #{rightAppId} </if>
             <if test="rightAppCode != null and rightAppCode != ''"> or right_app_code = #{rightAppCode} </if>
             <if test="rightAppName != null and rightAppName != ''"> or right_app_name = #{rightAppName} </if>
             <if test="rightApiId != null and rightApiId != ''"> or right_api_id = #{rightApiId} </if>
             <if test="rightId != null and rightId != ''"> or right_id = #{rightId} </if>
             <if test="rightCode != null and rightCode != ''"> or right_code = #{rightCode} </if>
             <if test="rightName != null and rightName != ''"> or right_name = #{rightName} </if>
             <if test="rightTel != null and rightTel != ''"> or right_tel = #{rightTel} </if>
             <if test="rightIc != null and rightIc != ''"> or right_ic = #{rightIc} </if>
             <if test="sorts != null"> or sorts = #{sorts} </if>
             <if test="create_user_id != null and create_user_id != ''"> or create_user_id = #{create_user_id} </if>
              <if test="create_time != null"> or create_time = #{create_time} </if>
              <if test="modify_user_id != null and modify_user_id != ''"> or modify_user_id = #{modify_user_id} </if>
              <if test="modify_time != null"> or modify_time = #{modify_time} </if>
              <if test="sts != null and sts != ''"> or sts = #{sts} </if>
             <if test="org_id != null and org_id != ''"> or org_id = #{org_id} </if>
              <if test="companyId != null and companyId != ''"> or company_id = #{companyId} </if>
             <if test="leftOrg != null and leftOrg != ''"> or left_org = #{leftOrg} </if>
             <if test="rightOrg != null and rightOrg != ''"> or right_org = #{rightOrg} </if>
            and sts='Y'
    </trim>
    <if test=" sort == null or sort == ''.toString()  "> order by sorts asc</if>
    <if test=" sort !='' and sort!=null and order !='' and order!=null ">order by ${sort} ${order}</if>
</select>

<!--新增所有列-->
<insert id="entity_insert" parameterType = "com.hzya.frame.sysnew.archivesContrast.entity.SysArchivesContrastEntity"  >
    insert into <choose>
    <when test="type == '1'.toString()"> sys_personnel_control </when>
    <when test="type == '2'.toString()"> sys_org_control </when>
    <when test="type == '3'.toString()"> sys_stock_control </when>
    <when test="type == '4'.toString()"> sys_merchant_control </when>
    <when test="type == '5'.toString()"> sys_taxrate_control </when>
    <when test="type == '6'.toString()"> sys_project_control </when>
    <when test="type == '7'.toString()"> sys_bank_control </when>
    <when test="type == '8'.toString()"> sys_bankaccount_control </when>
    <when test="type == '9'.toString()"> sys_assets_control </when>
</choose>
(
  <trim suffix="" suffixOverrides=",">
       <if test="id != null and id != ''"> id , </if>
            <if test="leftAppId != null and leftAppId != ''"> left_app_id , </if>
            <if test="leftAppCode != null and leftAppCode != ''"> left_app_code , </if>
            <if test="leftAppName != null and leftAppName != ''"> left_app_name , </if>
            <if test="leftApiId != null and leftApiId != ''"> left_api_id , </if>
            <if test="leftId != null and leftId != ''"> left_id , </if>
            <if test="leftCode != null and leftCode != ''"> left_code , </if>
            <if test="leftName != null and leftName != ''"> left_name , </if>
            <if test="leftTel != null and leftTel != ''"> left_tel , </if>
            <if test="leftIc != null and leftIc != ''"> left_ic , </if>
            <if test="rightAppId != null and rightAppId != ''"> right_app_id , </if>
            <if test="rightAppCode != null and rightAppCode != ''"> right_app_code , </if>
            <if test="rightAppName != null and rightAppName != ''"> right_app_name , </if>
            <if test="rightApiId != null and rightApiId != ''"> right_api_id , </if>
            <if test="rightId != null and rightId != ''"> right_id , </if>
            <if test="rightCode != null and rightCode != ''"> right_code , </if>
            <if test="rightName != null and rightName != ''"> right_name , </if>
            <if test="rightTel != null and rightTel != ''"> right_tel , </if>
            <if test="rightIc != null and rightIc != ''"> right_ic , </if>
            <if test="sorts != null"> sorts , </if>
            <if test="create_user_id != null and create_user_id != ''"> create_user_id , </if>
            <if test="create_time != null"> create_time , </if>
            <if test="modify_user_id != null and modify_user_id != ''"> modify_user_id , </if>
            <if test="modify_time != null"> modify_time , </if>
            <if test="sts != null and sts != ''"> sts , </if>
            <if test="org_id != null and org_id != ''"> org_id , </if>
            <if test="companyId != null and companyId != ''"> company_id , </if>
            <if test="leftOrg != null and leftOrg != ''"> left_org , </if>
            <if test="rightOrg != null and rightOrg != ''"> right_org , </if>
    <if test="sts == null ">sts,</if>
  </trim>
  )values(
 <trim suffix="" suffixOverrides=",">
       <if test="id != null and id != ''"> #{id} ,</if>
            <if test="leftAppId != null and leftAppId != ''"> #{leftAppId} ,</if>
            <if test="leftAppCode != null and leftAppCode != ''"> #{leftAppCode} ,</if>
            <if test="leftAppName != null and leftAppName != ''"> #{leftAppName} ,</if>
            <if test="leftApiId != null and leftApiId != ''"> #{leftApiId} ,</if>
            <if test="leftId != null and leftId != ''"> #{leftId} ,</if>
            <if test="leftCode != null and leftCode != ''"> #{leftCode} ,</if>
            <if test="leftName != null and leftName != ''"> #{leftName} ,</if>
            <if test="leftTel != null and leftTel != ''"> #{leftTel} ,</if>
            <if test="leftIc != null and leftIc != ''"> #{leftIc} ,</if>
            <if test="rightAppId != null and rightAppId != ''"> #{rightAppId} ,</if>
            <if test="rightAppCode != null and rightAppCode != ''"> #{rightAppCode} ,</if>
            <if test="rightAppName != null and rightAppName != ''"> #{rightAppName} ,</if>
            <if test="rightApiId != null and rightApiId != ''"> #{rightApiId} ,</if>
            <if test="rightId != null and rightId != ''"> #{rightId} ,</if>
            <if test="rightCode != null and rightCode != ''"> #{rightCode} ,</if>
            <if test="rightName != null and rightName != ''"> #{rightName} ,</if>
            <if test="rightTel != null and rightTel != ''"> #{rightTel} ,</if>
            <if test="rightIc != null and rightIc != ''"> #{rightIc} ,</if>
            <if test="sorts != null"> #{sorts} ,</if>
            <if test="create_user_id != null and create_user_id != ''"> #{create_user_id} ,</if>
            <if test="create_time != null"> #{create_time} ,</if>
            <if test="modify_user_id != null and modify_user_id != ''"> #{modify_user_id} ,</if>
            <if test="modify_time != null"> #{modify_time} ,</if>
            <if test="sts != null and sts != ''"> #{sts} ,</if>
            <if test="org_id != null and org_id != ''"> #{org_id} ,</if>
            <if test="companyId != null and companyId != ''"> #{companyId} ,</if>
            <if test="leftOrg != null and leftOrg != ''"> #{leftOrg} ,</if>
            <if test="rightOrg != null and rightOrg != ''"> #{rightOrg} ,</if>
    <if test="sts == null ">'Y',</if>
  </trim>
  )  
</insert>
<!-- 批量新增 -->
<insert id="entityInsertBatch"  >
  insert into <choose>
    <when test="type == '1'.toString()"> sys_personnel_control </when>
    <when test="type == '2'.toString()"> sys_org_control </when>
    <when test="type == '3'.toString()"> sys_stock_control </when>
    <when test="type == '4'.toString()"> sys_merchant_control </when>
    <when test="type == '5'.toString()"> sys_taxrate_control </when>
    <when test="type == '6'.toString()"> sys_project_control </when>
    <when test="type == '7'.toString()"> sys_bank_control </when>
    <when test="type == '8'.toString()"> sys_bankaccount_control </when>
    <when test="type == '9'.toString()"> sys_assets_control </when>
</choose> (left_app_id, left_app_code, left_app_name, left_api_id, left_id, left_code, left_name, left_tel, left_ic, right_app_id, right_app_code, right_app_name, right_api_id, right_id, right_code, right_name, right_tel, right_ic, create_user_id, create_time, modify_user_id, modify_time, sts, org_id, company_id, left_org, right_org,  sts)
    values
    <foreach collection="entities" item="entity" separator=",">
    (#{entity.leftAppId},#{entity.leftAppCode},#{entity.leftAppName},#{entity.leftApiId},#{entity.leftId},#{entity.leftCode},#{entity.leftName},#{entity.leftTel},#{entity.leftIc},#{entity.rightAppId},#{entity.rightAppCode},#{entity.rightAppName},#{entity.rightApiId},#{entity.rightId},#{entity.rightCode},#{entity.rightName},#{entity.rightTel},#{entity.rightIc},#{entity.create_user_id},#{entity.create_time},#{entity.modify_user_id},#{entity.modify_time},#{entity.sts},#{entity.org_id},#{entity.companyId},#{entity.leftOrg},#{entity.rightOrg}, 'Y')
    </foreach>
</insert>
<!-- 批量新增或者修改-->
<insert id="entityInsertOrUpdateBatch"  >
    insert into <choose>
    <when test="type == '1'.toString()"> sys_personnel_control </when>
    <when test="type == '2'.toString()"> sys_org_control </when>
    <when test="type == '3'.toString()"> sys_stock_control </when>
    <when test="type == '4'.toString()"> sys_merchant_control </when>
    <when test="type == '5'.toString()"> sys_taxrate_control </when>
    <when test="type == '6'.toString()"> sys_project_control </when>
    <when test="type == '7'.toString()"> sys_bank_control </when>
    <when test="type == '8'.toString()"> sys_bankaccount_control </when>
    <when test="type == '9'.toString()"> sys_assets_control </when>
</choose> (left_app_id, left_app_code, left_app_name, left_api_id, left_id, left_code, left_name, left_tel, left_ic, right_app_id, right_app_code, right_app_name, right_api_id, right_id, right_code, right_name, right_tel, right_ic, create_user_id, create_time, modify_user_id, modify_time, sts, org_id, company_id, left_org, right_org)
    values
    <foreach collection="entities" item="entity" separator=",">
    (#{entity.leftAppId},#{entity.leftAppCode},#{entity.leftAppName},#{entity.leftApiId},#{entity.leftId},#{entity.leftCode},#{entity.leftName},#{entity.leftTel},#{entity.leftIc},#{entity.rightAppId},#{entity.rightAppCode},#{entity.rightAppName},#{entity.rightApiId},#{entity.rightId},#{entity.rightCode},#{entity.rightName},#{entity.rightTel},#{entity.rightIc},#{entity.create_user_id},#{entity.create_time},#{entity.modify_user_id},#{entity.modify_time},#{entity.sts},#{entity.org_id},#{entity.companyId},#{entity.leftOrg},#{entity.rightOrg})
    </foreach>
    on duplicate key update
    left_app_id = values(left_app_id),
    left_app_code = values(left_app_code),
    left_app_name = values(left_app_name),
    left_api_id = values(left_api_id),
    left_id = values(left_id),
    left_code = values(left_code),
    left_name = values(left_name),
    left_tel = values(left_tel),
    left_ic = values(left_ic),
    right_app_id = values(right_app_id),
    right_app_code = values(right_app_code),
    right_app_name = values(right_app_name),
    right_api_id = values(right_api_id),
    right_id = values(right_id),
    right_code = values(right_code),
    right_name = values(right_name),
    right_tel = values(right_tel),
    right_ic = values(right_ic),
    create_user_id = values(create_user_id),
    create_time = values(create_time),
    modify_user_id = values(modify_user_id),
    modify_time = values(modify_time),
    sts = values(sts),
    org_id = values(org_id),
    company_id = values(company_id),
    left_org = values(left_org),
    right_org = values(right_org)</insert>
<!--通过主键修改方法-->
<update id="entity_update" parameterType = "com.hzya.frame.sysnew.archivesContrast.entity.SysArchivesContrastEntity" >
update <choose>
    <when test="type == '1'.toString()"> sys_personnel_control </when>
    <when test="type == '2'.toString()"> sys_org_control </when>
    <when test="type == '3'.toString()"> sys_stock_control </when>
    <when test="type == '4'.toString()"> sys_merchant_control </when>
    <when test="type == '5'.toString()"> sys_taxrate_control </when>
    <when test="type == '6'.toString()"> sys_project_control </when>
    <when test="type == '7'.toString()"> sys_bank_control </when>
    <when test="type == '8'.toString()"> sys_bankaccount_control </when>
    <when test="type == '9'.toString()"> sys_assets_control </when>
</choose>  set
<trim suffix="" suffixOverrides=",">
  <if test="leftAppId != null and leftAppId != ''"> left_app_id = #{leftAppId},</if>
  <if test="leftAppCode != null and leftAppCode != ''"> left_app_code = #{leftAppCode},</if>
  <if test="leftAppName != null and leftAppName != ''"> left_app_name = #{leftAppName},</if>
  <if test="leftApiId != null and leftApiId != ''"> left_api_id = #{leftApiId},</if>
  <if test="leftId != null and leftId != ''"> left_id = #{leftId},</if>
  <if test="leftCode != null and leftCode != ''"> left_code = #{leftCode},</if>
  <if test="leftName != null and leftName != ''"> left_name = #{leftName},</if>
  <if test="leftTel != null and leftTel != ''"> left_tel = #{leftTel},</if>
  <if test="leftIc != null and leftIc != ''"> left_ic = #{leftIc},</if>
  <if test="rightAppId != null and rightAppId != ''"> right_app_id = #{rightAppId},</if>
  <if test="rightAppCode != null and rightAppCode != ''"> right_app_code = #{rightAppCode},</if>
  <if test="rightAppName != null and rightAppName != ''"> right_app_name = #{rightAppName},</if>
  <if test="rightApiId != null and rightApiId != ''"> right_api_id = #{rightApiId},</if>
  <if test="rightId != null and rightId != ''"> right_id = #{rightId},</if>
  <if test="rightCode != null and rightCode != ''"> right_code = #{rightCode},</if>
  <if test="rightName != null and rightName != ''"> right_name = #{rightName},</if>
  <if test="rightTel != null and rightTel != ''"> right_tel = #{rightTel},</if>
  <if test="rightIc != null and rightIc != ''"> right_ic = #{rightIc},</if>
  <if test="create_user_id != null and create_user_id != ''"> create_user_id = #{create_user_id},</if>
    <if test="create_time != null"> create_time = #{create_time},</if>
    <if test="modify_user_id != null and modify_user_id != ''"> modify_user_id = #{modify_user_id},</if>
    <if test="modify_time != null"> modify_time = #{modify_time},</if>
    <if test="sts != null and sts != ''"> sts = #{sts},</if>
  <if test="org_id != null and org_id != ''"> org_id = #{org_id},</if>
    <if test="companyId != null and companyId != ''"> company_id = #{companyId},</if>
  <if test="leftOrg != null and leftOrg != ''"> left_org = #{leftOrg},</if>
  <if test="rightOrg != null and rightOrg != ''"> right_org = #{rightOrg},</if>
</trim>
where id = #{id}
</update>
<!-- 逻辑删除 -->
<update id="entity_logicDelete" parameterType = "com.hzya.frame.sysnew.archivesContrast.entity.SysArchivesContrastEntity" >
update <choose>
    <when test="type == '1'.toString()"> sys_personnel_control </when>
    <when test="type == '2'.toString()"> sys_org_control </when>
    <when test="type == '3'.toString()"> sys_stock_control </when>
    <when test="type == '4'.toString()"> sys_merchant_control </when>
    <when test="type == '5'.toString()"> sys_taxrate_control </when>
    <when test="type == '6'.toString()"> sys_project_control </when>
    <when test="type == '7'.toString()"> sys_bank_control </when>
    <when test="type == '8'.toString()"> sys_bankaccount_control </when>
    <when test="type == '9'.toString()"> sys_assets_control </when>
</choose>  set sts= 'N' ,modify_time = #{modify_time},modify_user_id = #{modify_user_id}
where id = #{id}
</update>
<!-- 多条件逻辑删除 -->
<update id="entity_logicDelete_Multi_Condition" parameterType = "com.hzya.frame.sysnew.archivesContrast.entity.SysArchivesContrastEntity" >
update <choose>
    <when test="type == '1'.toString()"> sys_personnel_control </when>
    <when test="type == '2'.toString()"> sys_org_control </when>
    <when test="type == '3'.toString()"> sys_stock_control </when>
    <when test="type == '4'.toString()"> sys_merchant_control </when>
    <when test="type == '5'.toString()"> sys_taxrate_control </when>
    <when test="type == '6'.toString()"> sys_project_control </when>
    <when test="type == '7'.toString()"> sys_bank_control </when>
    <when test="type == '8'.toString()"> sys_bankaccount_control </when>
    <when test="type == '9'.toString()"> sys_assets_control </when>
</choose>  set sts= 'N' ,modify_time = #{modify_time},modify_user_id = #{modify_user_id}
 <trim prefix="where" prefixOverrides="and"> 
        <if test="id != null and id != ''"> and id = #{id} </if>
            <if test="leftAppId != null and leftAppId != ''"> and left_app_id = #{leftAppId} </if>
            <if test="leftAppCode != null and leftAppCode != ''"> and left_app_code = #{leftAppCode} </if>
            <if test="leftAppName != null and leftAppName != ''"> and left_app_name = #{leftAppName} </if>
            <if test="leftApiId != null and leftApiId != ''"> and left_api_id = #{leftApiId} </if>
            <if test="leftId != null and leftId != ''"> and left_id = #{leftId} </if>
            <if test="leftCode != null and leftCode != ''"> and left_code = #{leftCode} </if>
            <if test="leftName != null and leftName != ''"> and left_name = #{leftName} </if>
            <if test="leftTel != null and leftTel != ''"> and left_tel = #{leftTel} </if>
            <if test="leftIc != null and leftIc != ''"> and left_ic = #{leftIc} </if>
            <if test="rightAppId != null and rightAppId != ''"> and right_app_id = #{rightAppId} </if>
            <if test="rightAppCode != null and rightAppCode != ''"> and right_app_code = #{rightAppCode} </if>
            <if test="rightAppName != null and rightAppName != ''"> and right_app_name = #{rightAppName} </if>
            <if test="rightApiId != null and rightApiId != ''"> and right_api_id = #{rightApiId} </if>
            <if test="rightId != null and rightId != ''"> and right_id = #{rightId} </if>
            <if test="rightCode != null and rightCode != ''"> and right_code = #{rightCode} </if>
            <if test="rightName != null and rightName != ''"> and right_name = #{rightName} </if>
            <if test="rightTel != null and rightTel != ''"> and right_tel = #{rightTel} </if>
            <if test="rightIc != null and rightIc != ''"> and right_ic = #{rightIc} </if>
            <if test="sorts != null"> and sorts = #{sorts} </if>
                                                                <if test="sts != null and sts != ''"> and sts = #{sts} </if>
                         <if test="companyId != null and companyId != ''"> and company_id = #{companyId} </if>
            <if test="leftOrg != null and leftOrg != ''"> and left_org = #{leftOrg} </if>
            <if test="rightOrg != null and rightOrg != ''"> and right_org = #{rightOrg} </if>
            and sts='Y'
    </trim>
</update>
<!--通过主键删除-->
<delete id="entity_delete">
    delete from <choose>
    <when test="type == '1'.toString()"> sys_personnel_control </when>
    <when test="type == '2'.toString()"> sys_org_control </when>
    <when test="type == '3'.toString()"> sys_stock_control </when>
    <when test="type == '4'.toString()"> sys_merchant_control </when>
    <when test="type == '5'.toString()"> sys_taxrate_control </when>
    <when test="type == '6'.toString()"> sys_project_control </when>
    <when test="type == '7'.toString()"> sys_bank_control </when>
    <when test="type == '8'.toString()"> sys_bankaccount_control </when>
    <when test="type == '9'.toString()"> sys_assets_control </when>
</choose> where id = #{id}
</delete>

</mapper>

