<?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.plugin.lets.dao.impl.BdSetpartDaoImpl">

    <resultMap id="get-BdSetpartEntity-result" type="com.hzya.frame.plugin.lets.entity.BdSetpartEntity" >
       <result property="bdSetpart" column="BD_SETPART" jdbcType="VARCHAR"/>
           <result property="childsnum" column="CHILDSNUM" jdbcType="VARCHAR"/>
           <result property="dr" column="DR" jdbcType="VARCHAR"/>
           <result property="partpercent" column="PARTPERCENT" jdbcType="VARCHAR"/>
           <result property="pkCorp" column="PK_CORP" jdbcType="VARCHAR"/>
           <result property="pkInvmandocpart" column="PK_INVMANDOCPART" jdbcType="VARCHAR"/>
           <result property="pkInvmandocset" column="PK_INVMANDOCSET" jdbcType="VARCHAR"/>
           <result property="ts" column="TS" jdbcType="VARCHAR"/>
        </resultMap>
    <!-- 查询的字段-->
    <sql id = "BdSetpartEntity_Base_Column_List">
        BD_SETPART
       ,CHILDSNUM 
        ,DR 
        ,PARTPERCENT 
        ,PK_CORP 
        ,PK_INVMANDOCPART 
        ,PK_INVMANDOCSET 
        ,TS 
     </sql>
 <!-- 查询 采用==查询 -->
 <select id="entity_list_base" resultMap="get-BdSetpartEntity-result" parameterType = "com.hzya.frame.plugin.lets.entity.BdSetpartEntity">
    select
    <include refid="BdSetpartEntity_Base_Column_List" />
    from BD_SETPART
    <trim prefix="where" prefixOverrides="and"> 
        <if test="bdSetpart != null and bdSetpart != ''"> and BD_SETPART = #{bdSetpart} </if>
            <if test="childsnum != null and childsnum != ''"> and CHILDSNUM = #{childsnum} </if>
            <if test="dr != null and dr != ''"> and DR = #{dr} </if>
            <if test="partpercent != null and partpercent != ''"> and PARTPERCENT = #{partpercent} </if>
            <if test="pkCorp != null and pkCorp != ''"> and PK_CORP = #{pkCorp} </if>
            <if test="pkInvmandocpart != null and pkInvmandocpart != ''"> and PK_INVMANDOCPART = #{pkInvmandocpart} </if>
            <if test="pkInvmandocset != null and pkInvmandocset != ''"> and PK_INVMANDOCSET = #{pkInvmandocset} </if>
            <if test="ts != null and ts != ''"> and TS = #{ts} </if>
            and dr=0
    </trim>
</select>
    
<!-- 查询符合条件的数量 -->
<select id="entity_count" resultType="Integer" parameterType = "com.hzya.frame.plugin.lets.entity.BdSetpartEntity">
        select  count(1)   from BD_SETPART
    <trim prefix="where" prefixOverrides="and"> 
        <if test="bdSetpart != null and bdSetpart != ''"> and BD_SETPART = #{bdSetpart} </if>
            <if test="childsnum != null and childsnum != ''"> and CHILDSNUM = #{childsnum} </if>
            <if test="dr != null and dr != ''"> and DR = #{dr} </if>
            <if test="partpercent != null and partpercent != ''"> and PARTPERCENT = #{partpercent} </if>
            <if test="pkCorp != null and pkCorp != ''"> and PK_CORP = #{pkCorp} </if>
            <if test="pkInvmandocpart != null and pkInvmandocpart != ''"> and PK_INVMANDOCPART = #{pkInvmandocpart} </if>
            <if test="pkInvmandocset != null and pkInvmandocset != ''"> and PK_INVMANDOCSET = #{pkInvmandocset} </if>
            <if test="ts != null and ts != ''"> and TS = #{ts} </if>
            and dr=0
    </trim>
    </select>

    <!-- 分页查询列表 采用like格式 -->
<select id="entity_list_like" resultMap="get-BdSetpartEntity-result" parameterType = "com.hzya.frame.plugin.lets.entity.BdSetpartEntity">
    select
    <include refid="BdSetpartEntity_Base_Column_List" />
    from BD_SETPART
    <trim prefix="where" prefixOverrides="and"> 
        <if test="bdSetpart != null and bdSetpart != ''"> and BD_SETPART like concat('%',#{bdSetpart},'%') </if>
            <if test="childsnum != null and childsnum != ''"> and CHILDSNUM like concat('%',#{childsnum},'%') </if>
            <if test="dr != null and dr != ''"> and DR like concat('%',#{dr},'%') </if>
            <if test="partpercent != null and partpercent != ''"> and PARTPERCENT like concat('%',#{partpercent},'%') </if>
            <if test="pkCorp != null and pkCorp != ''"> and PK_CORP like concat('%',#{pkCorp},'%') </if>
            <if test="pkInvmandocpart != null and pkInvmandocpart != ''"> and PK_INVMANDOCPART like concat('%',#{pkInvmandocpart},'%') </if>
            <if test="pkInvmandocset != null and pkInvmandocset != ''"> and PK_INVMANDOCSET like concat('%',#{pkInvmandocset},'%') </if>
            <if test="ts != null and ts != ''"> and TS like concat('%',#{ts},'%') </if>
            and dr=0
    </trim>
</select>

<!-- 查询列表 字段采用or格式 -->
<select id="BdSetpartentity_list_or" resultMap="get-BdSetpartEntity-result" parameterType = "com.hzya.frame.plugin.lets.entity.BdSetpartEntity">
    select
    <include refid="BdSetpartEntity_Base_Column_List" />
    from BD_SETPART
    <trim prefix="where" prefixOverrides="and"> 
         <if test="bdSetpart != null and bdSetpart != ''"> or BD_SETPART = #{bdSetpart} </if>
             <if test="childsnum != null and childsnum != ''"> or CHILDSNUM = #{childsnum} </if>
             <if test="dr != null and dr != ''"> or DR = #{dr} </if>
             <if test="partpercent != null and partpercent != ''"> or PARTPERCENT = #{partpercent} </if>
             <if test="pkCorp != null and pkCorp != ''"> or PK_CORP = #{pkCorp} </if>
             <if test="pkInvmandocpart != null and pkInvmandocpart != ''"> or PK_INVMANDOCPART = #{pkInvmandocpart} </if>
             <if test="pkInvmandocset != null and pkInvmandocset != ''"> or PK_INVMANDOCSET = #{pkInvmandocset} </if>
             <if test="ts != null and ts != ''"> or TS = #{ts} </if>
            and dr=0
    </trim>
</select>

<!--新增所有列-->
<insert id="entity_insert" parameterType = "com.hzya.frame.plugin.lets.entity.BdSetpartEntity" keyProperty="bdSetpart" useGeneratedKeys="true">
    insert into BD_SETPART(
  <trim suffix="" suffixOverrides=",">
       <if test="bdSetpart != null and bdSetpart != ''"> BD_SETPART , </if>
            <if test="childsnum != null and childsnum != ''"> CHILDSNUM , </if>
            <if test="dr != null and dr != ''"> DR , </if>
            <if test="partpercent != null and partpercent != ''"> PARTPERCENT , </if>
            <if test="pkCorp != null and pkCorp != ''"> PK_CORP , </if>
            <if test="pkInvmandocpart != null and pkInvmandocpart != ''"> PK_INVMANDOCPART , </if>
            <if test="pkInvmandocset != null and pkInvmandocset != ''"> PK_INVMANDOCSET , </if>
            <if test="ts != null and ts != ''"> TS , </if>
            <if test="sorts == null ">sorts,</if>
    <if test="sts == null ">sts,</if>
  </trim>
  )values(
 <trim suffix="" suffixOverrides=",">
       <if test="bdSetpart != null and bdSetpart != ''"> #{bdSetpart} ,</if>
            <if test="childsnum != null and childsnum != ''"> #{childsnum} ,</if>
            <if test="dr != null and dr != ''"> #{dr} ,</if>
            <if test="partpercent != null and partpercent != ''"> #{partpercent} ,</if>
            <if test="pkCorp != null and pkCorp != ''"> #{pkCorp} ,</if>
            <if test="pkInvmandocpart != null and pkInvmandocpart != ''"> #{pkInvmandocpart} ,</if>
            <if test="pkInvmandocset != null and pkInvmandocset != ''"> #{pkInvmandocset} ,</if>
            <if test="ts != null and ts != ''"> #{ts} ,</if>
            <if test="sorts == null ">(select (max(IFNULL( a.sorts, 0 )) + 1) as sort from BD_SETPART a WHERE a.sts = 'Y' ),</if>
    <if test="sts == null ">'Y',</if>
  </trim>
  )  
</insert>
<!-- 批量新增 -->
<insert id="entityInsertBatch" keyProperty="bdSetpart" useGeneratedKeys="true">
  insert into BD_SETPART(CHILDSNUM, DR, PARTPERCENT, PK_CORP, PK_INVMANDOCPART, PK_INVMANDOCSET, TS,  sts) 
    values
    <foreach collection="entities" item="entity" separator=",">
    (#{entity.childsnum},#{entity.dr},#{entity.partpercent},#{entity.pkCorp},#{entity.pkInvmandocpart},#{entity.pkInvmandocset},#{entity.ts}, 'Y')
    </foreach>
</insert>
<!-- 批量新增或者修改-->
<insert id="entityInsertOrUpdateBatch" keyProperty="bdSetpart" useGeneratedKeys="true">
    insert into BD_SETPART(CHILDSNUM, DR, PARTPERCENT, PK_CORP, PK_INVMANDOCPART, PK_INVMANDOCSET, TS)
    values
    <foreach collection="entities" item="entity" separator=",">
    (#{entity.childsnum},#{entity.dr},#{entity.partpercent},#{entity.pkCorp},#{entity.pkInvmandocpart},#{entity.pkInvmandocset},#{entity.ts})
    </foreach>
    on duplicate key update
    CHILDSNUM = values(CHILDSNUM),
    DR = values(DR),
    PARTPERCENT = values(PARTPERCENT),
    PK_CORP = values(PK_CORP),
    PK_INVMANDOCPART = values(PK_INVMANDOCPART),
    PK_INVMANDOCSET = values(PK_INVMANDOCSET),
    TS = values(TS)</insert>
<!--通过主键修改方法-->
<update id="entity_update" parameterType = "com.hzya.frame.plugin.lets.entity.BdSetpartEntity" >
update BD_SETPART  set
<trim suffix="" suffixOverrides=",">
  <if test="childsnum != null and childsnum != ''"> CHILDSNUM = #{childsnum},</if>
  <if test="dr != null and dr != ''"> DR = #{dr},</if>
  <if test="partpercent != null and partpercent != ''"> PARTPERCENT = #{partpercent},</if>
  <if test="pkCorp != null and pkCorp != ''"> PK_CORP = #{pkCorp},</if>
  <if test="pkInvmandocpart != null and pkInvmandocpart != ''"> PK_INVMANDOCPART = #{pkInvmandocpart},</if>
  <if test="pkInvmandocset != null and pkInvmandocset != ''"> PK_INVMANDOCSET = #{pkInvmandocset},</if>
  <if test="ts != null and ts != ''"> TS = #{ts},</if>
</trim>
where BD_SETPART = #{bdSetpart}
</update>
<!-- 逻辑删除 -->
<update id="entity_logicDelete" parameterType = "com.hzya.frame.plugin.lets.entity.BdSetpartEntity" >
update BD_SETPART  set sts= 'N' ,modify_time = #{modify_time},modify_user_id = #{modify_user_id}
where BD_SETPART = #{bdSetpart}
</update>
<!-- 多条件逻辑删除 -->
<update id="entity_logicDelete_Multi_Condition" parameterType = "com.hzya.frame.plugin.lets.entity.BdSetpartEntity" >
update BD_SETPART  set sts= 'N' ,modify_time = #{modify_time},modify_user_id = #{modify_user_id}
 <trim prefix="where" prefixOverrides="and"> 
        <if test="bdSetpart != null and bdSetpart != ''"> and BD_SETPART = #{bdSetpart} </if>
            <if test="childsnum != null and childsnum != ''"> and CHILDSNUM = #{childsnum} </if>
            <if test="dr != null and dr != ''"> and DR = #{dr} </if>
            <if test="partpercent != null and partpercent != ''"> and PARTPERCENT = #{partpercent} </if>
            <if test="pkCorp != null and pkCorp != ''"> and PK_CORP = #{pkCorp} </if>
            <if test="pkInvmandocpart != null and pkInvmandocpart != ''"> and PK_INVMANDOCPART = #{pkInvmandocpart} </if>
            <if test="pkInvmandocset != null and pkInvmandocset != ''"> and PK_INVMANDOCSET = #{pkInvmandocset} </if>
            <if test="ts != null and ts != ''"> and TS = #{ts} </if>
            and dr=0
    </trim>
</update>
<!--通过主键删除-->
<delete id="entity_delete">
    delete from BD_SETPART where BD_SETPART = #{bdSetpart}
</delete>

</mapper>

