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

    <resultMap id="get-BdInvclEntity-result" type="com.hzya.frame.plugin.lets.entity.BdInvclEntity" >
       <result property="averagecost" column="averagecost" jdbcType="NUMERIC"/>
           <result property="averagemmahead" column="averagemmahead" jdbcType="INTEGER"/>
           <result property="averagepurahead" column="averagepurahead" jdbcType="INTEGER"/>
           <result property="avgprice" column="avgprice" jdbcType="NUMERIC"/>
           <result property="dr" column="dr" jdbcType="INTEGER"/>
           <result property="endflag" column="endflag" jdbcType="VARCHAR"/>
           <result property="forinvname" column="forinvname" jdbcType="VARCHAR"/>
           <result property="invclasscode" column="invclasscode" jdbcType="VARCHAR"/>
           <result property="invclasslev" column="invclasslev" jdbcType="INTEGER"/>
           <result property="invclassname" column="invclassname" jdbcType="VARCHAR"/>
           <result property="iselectrans" column="iselectrans" jdbcType="VARCHAR"/>
           <result property="ishuo" column="ishuo" jdbcType="VARCHAR"/>
           <result property="pkCorp" column="pk_corp" jdbcType="VARCHAR"/>
           <result property="pkInvcl" column="pk_invcl" jdbcType="VARCHAR"/>
           <result property="sealdate" column="sealdate" jdbcType="VARCHAR"/>
           <result property="ts" column="ts" jdbcType="VARCHAR"/>
        </resultMap>
    <!-- 查询的字段-->
    <sql id = "BdInvclEntity_Base_Column_List">
        averagecost
       ,averagemmahead 
        ,averagepurahead 
        ,avgprice 
        ,dr 
        ,endflag 
        ,forinvname 
        ,invclasscode 
        ,invclasslev 
        ,invclassname 
        ,iselectrans 
        ,ishuo 
        ,pk_corp 
        ,pk_invcl 
        ,sealdate 
        ,ts 
     </sql>
 <!-- 查询 采用==查询 -->
 <select id="entity_list_base" resultMap="get-BdInvclEntity-result" parameterType = "com.hzya.frame.plugin.lets.entity.BdInvclEntity">
    select
    <include refid="BdInvclEntity_Base_Column_List" />
    from bd_invcl
    <trim prefix="where" prefixOverrides="and"> 
        <if test="averagecost != null"> and averagecost = #{averagecost} </if>
            <if test="averagemmahead != null"> and averagemmahead = #{averagemmahead} </if>
            <if test="averagepurahead != null"> and averagepurahead = #{averagepurahead} </if>
            <if test="avgprice != null"> and avgprice = #{avgprice} </if>
            <if test="dr != null"> and dr = #{dr} </if>
            <if test="endflag != null and endflag != ''"> and endflag = #{endflag} </if>
            <if test="forinvname != null and forinvname != ''"> and forinvname = #{forinvname} </if>
            <if test="invclasscode != null and invclasscode != ''"> and invclasscode = #{invclasscode} </if>
            <if test="invclasslev != null"> and invclasslev = #{invclasslev} </if>
            <if test="invclassname != null and invclassname != ''"> and invclassname = #{invclassname} </if>
            <if test="iselectrans != null and iselectrans != ''"> and iselectrans = #{iselectrans} </if>
            <if test="ishuo != null and ishuo != ''"> and ishuo = #{ishuo} </if>
            <if test="pkCorp != null and pkCorp != ''"> and pk_corp = #{pkCorp} </if>
            <if test="pkInvcl != null and pkInvcl != ''"> and pk_invcl = #{pkInvcl} </if>
            <if test="sealdate != null and sealdate != ''"> and sealdate = #{sealdate} </if>
            <if test="ts != null and ts != ''"> and ts = #{ts} </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.plugin.lets.entity.BdInvclEntity">
        select  count(1)   from bd_invcl
    <trim prefix="where" prefixOverrides="and"> 
        <if test="averagecost != null"> and averagecost = #{averagecost} </if>
            <if test="averagemmahead != null"> and averagemmahead = #{averagemmahead} </if>
            <if test="averagepurahead != null"> and averagepurahead = #{averagepurahead} </if>
            <if test="avgprice != null"> and avgprice = #{avgprice} </if>
            <if test="dr != null"> and dr = #{dr} </if>
            <if test="endflag != null and endflag != ''"> and endflag = #{endflag} </if>
            <if test="forinvname != null and forinvname != ''"> and forinvname = #{forinvname} </if>
            <if test="invclasscode != null and invclasscode != ''"> and invclasscode = #{invclasscode} </if>
            <if test="invclasslev != null"> and invclasslev = #{invclasslev} </if>
            <if test="invclassname != null and invclassname != ''"> and invclassname = #{invclassname} </if>
            <if test="iselectrans != null and iselectrans != ''"> and iselectrans = #{iselectrans} </if>
            <if test="ishuo != null and ishuo != ''"> and ishuo = #{ishuo} </if>
            <if test="pkCorp != null and pkCorp != ''"> and pk_corp = #{pkCorp} </if>
            <if test="pkInvcl != null and pkInvcl != ''"> and pk_invcl = #{pkInvcl} </if>
            <if test="sealdate != null and sealdate != ''"> and sealdate = #{sealdate} </if>
            <if test="ts != null and ts != ''"> and ts = #{ts} </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-BdInvclEntity-result" parameterType = "com.hzya.frame.plugin.lets.entity.BdInvclEntity">
    select
    <include refid="BdInvclEntity_Base_Column_List" />
    from bd_invcl
    <trim prefix="where" prefixOverrides="and"> 
        <if test="averagecost != null"> and averagecost like concat('%',#{averagecost},'%') </if>
            <if test="averagemmahead != null"> and averagemmahead like concat('%',#{averagemmahead},'%') </if>
            <if test="averagepurahead != null"> and averagepurahead like concat('%',#{averagepurahead},'%') </if>
            <if test="avgprice != null"> and avgprice like concat('%',#{avgprice},'%') </if>
            <if test="dr != null"> and dr like concat('%',#{dr},'%') </if>
            <if test="endflag != null and endflag != ''"> and endflag like concat('%',#{endflag},'%') </if>
            <if test="forinvname != null and forinvname != ''"> and forinvname like concat('%',#{forinvname},'%') </if>
            <if test="invclasscode != null and invclasscode != ''"> and invclasscode like concat('%',#{invclasscode},'%') </if>
            <if test="invclasslev != null"> and invclasslev like concat('%',#{invclasslev},'%') </if>
            <if test="invclassname != null and invclassname != ''"> and invclassname like concat('%',#{invclassname},'%') </if>
            <if test="iselectrans != null and iselectrans != ''"> and iselectrans like concat('%',#{iselectrans},'%') </if>
            <if test="ishuo != null and ishuo != ''"> and ishuo like concat('%',#{ishuo},'%') </if>
            <if test="pkCorp != null and pkCorp != ''"> and pk_corp like concat('%',#{pkCorp},'%') </if>
            <if test="pkInvcl != null and pkInvcl != ''"> and pk_invcl like concat('%',#{pkInvcl},'%') </if>
            <if test="sealdate != null and sealdate != ''"> and sealdate like concat('%',#{sealdate},'%') </if>
            <if test="ts != null and ts != ''"> and ts like concat('%',#{ts},'%') </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="BdInvclentity_list_or" resultMap="get-BdInvclEntity-result" parameterType = "com.hzya.frame.plugin.lets.entity.BdInvclEntity">
    select
    <include refid="BdInvclEntity_Base_Column_List" />
    from bd_invcl
    <trim prefix="where" prefixOverrides="and"> 
         <if test="averagecost != null"> or averagecost = #{averagecost} </if>
             <if test="averagemmahead != null"> or averagemmahead = #{averagemmahead} </if>
             <if test="averagepurahead != null"> or averagepurahead = #{averagepurahead} </if>
             <if test="avgprice != null"> or avgprice = #{avgprice} </if>
             <if test="dr != null"> or dr = #{dr} </if>
             <if test="endflag != null and endflag != ''"> or endflag = #{endflag} </if>
             <if test="forinvname != null and forinvname != ''"> or forinvname = #{forinvname} </if>
             <if test="invclasscode != null and invclasscode != ''"> or invclasscode = #{invclasscode} </if>
             <if test="invclasslev != null"> or invclasslev = #{invclasslev} </if>
             <if test="invclassname != null and invclassname != ''"> or invclassname = #{invclassname} </if>
             <if test="iselectrans != null and iselectrans != ''"> or iselectrans = #{iselectrans} </if>
             <if test="ishuo != null and ishuo != ''"> or ishuo = #{ishuo} </if>
             <if test="pkCorp != null and pkCorp != ''"> or pk_corp = #{pkCorp} </if>
             <if test="pkInvcl != null and pkInvcl != ''"> or pk_invcl = #{pkInvcl} </if>
             <if test="sealdate != null and sealdate != ''"> or sealdate = #{sealdate} </if>
             <if test="ts != null and ts != ''"> or ts = #{ts} </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.plugin.lets.entity.BdInvclEntity" keyProperty="pkInvcl" useGeneratedKeys="true">
    insert into bd_invcl(
  <trim suffix="" suffixOverrides=",">
       <if test="averagecost != null"> averagecost , </if>
            <if test="averagemmahead != null"> averagemmahead , </if>
            <if test="averagepurahead != null"> averagepurahead , </if>
            <if test="avgprice != null"> avgprice , </if>
            <if test="dr != null"> dr , </if>
            <if test="endflag != null and endflag != ''"> endflag , </if>
            <if test="forinvname != null and forinvname != ''"> forinvname , </if>
            <if test="invclasscode != null and invclasscode != ''"> invclasscode , </if>
            <if test="invclasslev != null"> invclasslev , </if>
            <if test="invclassname != null and invclassname != ''"> invclassname , </if>
            <if test="iselectrans != null and iselectrans != ''"> iselectrans , </if>
            <if test="ishuo != null and ishuo != ''"> ishuo , </if>
            <if test="pkCorp != null and pkCorp != ''"> pk_corp , </if>
            <if test="pkInvcl != null and pkInvcl != ''"> pk_invcl , </if>
            <if test="sealdate != null and sealdate != ''"> sealdate , </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="averagecost != null"> #{averagecost} ,</if>
            <if test="averagemmahead != null"> #{averagemmahead} ,</if>
            <if test="averagepurahead != null"> #{averagepurahead} ,</if>
            <if test="avgprice != null"> #{avgprice} ,</if>
            <if test="dr != null"> #{dr} ,</if>
            <if test="endflag != null and endflag != ''"> #{endflag} ,</if>
            <if test="forinvname != null and forinvname != ''"> #{forinvname} ,</if>
            <if test="invclasscode != null and invclasscode != ''"> #{invclasscode} ,</if>
            <if test="invclasslev != null"> #{invclasslev} ,</if>
            <if test="invclassname != null and invclassname != ''"> #{invclassname} ,</if>
            <if test="iselectrans != null and iselectrans != ''"> #{iselectrans} ,</if>
            <if test="ishuo != null and ishuo != ''"> #{ishuo} ,</if>
            <if test="pkCorp != null and pkCorp != ''"> #{pkCorp} ,</if>
            <if test="pkInvcl != null and pkInvcl != ''"> #{pkInvcl} ,</if>
            <if test="sealdate != null and sealdate != ''"> #{sealdate} ,</if>
            <if test="ts != null and ts != ''"> #{ts} ,</if>
            <if test="sorts == null ">(select (max(IFNULL( a.sorts, 0 )) + 1) as sort from bd_invcl a WHERE a.sts = 'Y' ),</if>
    <if test="sts == null ">'Y',</if>
  </trim>
  )  
</insert>
<!-- 批量新增 -->
<insert id="entityInsertBatch" keyProperty="pkInvcl" useGeneratedKeys="true">
  insert into bd_invcl(averagecost, averagemmahead, averagepurahead, avgprice, dr, endflag, forinvname, invclasscode, invclasslev, invclassname, iselectrans, ishuo, pk_corp, sealdate, ts,  sts) 
    values
    <foreach collection="entities" item="entity" separator=",">
    (#{entity.averagecost},#{entity.averagemmahead},#{entity.averagepurahead},#{entity.avgprice},#{entity.dr},#{entity.endflag},#{entity.forinvname},#{entity.invclasscode},#{entity.invclasslev},#{entity.invclassname},#{entity.iselectrans},#{entity.ishuo},#{entity.pkCorp},#{entity.sealdate},#{entity.ts}, 'Y')
    </foreach>
</insert>
<!-- 批量新增或者修改-->
<insert id="entityInsertOrUpdateBatch" keyProperty="pkInvcl" useGeneratedKeys="true">
    insert into bd_invcl(averagecost, averagemmahead, averagepurahead, avgprice, dr, endflag, forinvname, invclasscode, invclasslev, invclassname, iselectrans, ishuo, pk_corp, sealdate, ts)
    values
    <foreach collection="entities" item="entity" separator=",">
    (#{entity.averagecost},#{entity.averagemmahead},#{entity.averagepurahead},#{entity.avgprice},#{entity.dr},#{entity.endflag},#{entity.forinvname},#{entity.invclasscode},#{entity.invclasslev},#{entity.invclassname},#{entity.iselectrans},#{entity.ishuo},#{entity.pkCorp},#{entity.sealdate},#{entity.ts})
    </foreach>
    on duplicate key update
    averagecost = values(averagecost),
    averagemmahead = values(averagemmahead),
    averagepurahead = values(averagepurahead),
    avgprice = values(avgprice),
    dr = values(dr),
    endflag = values(endflag),
    forinvname = values(forinvname),
    invclasscode = values(invclasscode),
    invclasslev = values(invclasslev),
    invclassname = values(invclassname),
    iselectrans = values(iselectrans),
    ishuo = values(ishuo),
    pk_corp = values(pk_corp),
    sealdate = values(sealdate),
    ts = values(ts)</insert>
<!--通过主键修改方法-->
<update id="entity_update" parameterType = "com.hzya.frame.plugin.lets.entity.BdInvclEntity" >
update bd_invcl  set
<trim suffix="" suffixOverrides=",">
  <if test="averagecost != null"> averagecost = #{averagecost},</if>
  <if test="averagemmahead != null"> averagemmahead = #{averagemmahead},</if>
  <if test="averagepurahead != null"> averagepurahead = #{averagepurahead},</if>
  <if test="avgprice != null"> avgprice = #{avgprice},</if>
  <if test="dr != null"> dr = #{dr},</if>
  <if test="endflag != null and endflag != ''"> endflag = #{endflag},</if>
  <if test="forinvname != null and forinvname != ''"> forinvname = #{forinvname},</if>
  <if test="invclasscode != null and invclasscode != ''"> invclasscode = #{invclasscode},</if>
  <if test="invclasslev != null"> invclasslev = #{invclasslev},</if>
  <if test="invclassname != null and invclassname != ''"> invclassname = #{invclassname},</if>
  <if test="iselectrans != null and iselectrans != ''"> iselectrans = #{iselectrans},</if>
  <if test="ishuo != null and ishuo != ''"> ishuo = #{ishuo},</if>
  <if test="pkCorp != null and pkCorp != ''"> pk_corp = #{pkCorp},</if>
  <if test="sealdate != null and sealdate != ''"> sealdate = #{sealdate},</if>
  <if test="ts != null and ts != ''"> ts = #{ts},</if>
</trim>
where pk_invcl = #{pkInvcl}
</update>
<!-- 逻辑删除 -->
<update id="entity_logicDelete" parameterType = "com.hzya.frame.plugin.lets.entity.BdInvclEntity" >
update bd_invcl  set sts= 'N' ,modify_time = #{modify_time},modify_user_id = #{modify_user_id}
where pk_invcl = #{pkInvcl}
</update>
<!-- 多条件逻辑删除 -->
<update id="entity_logicDelete_Multi_Condition" parameterType = "com.hzya.frame.plugin.lets.entity.BdInvclEntity" >
update bd_invcl  set sts= 'N' ,modify_time = #{modify_time},modify_user_id = #{modify_user_id}
 <trim prefix="where" prefixOverrides="and"> 
        <if test="averagecost != null"> and averagecost = #{averagecost} </if>
            <if test="averagemmahead != null"> and averagemmahead = #{averagemmahead} </if>
            <if test="averagepurahead != null"> and averagepurahead = #{averagepurahead} </if>
            <if test="avgprice != null"> and avgprice = #{avgprice} </if>
            <if test="dr != null"> and dr = #{dr} </if>
            <if test="endflag != null and endflag != ''"> and endflag = #{endflag} </if>
            <if test="forinvname != null and forinvname != ''"> and forinvname = #{forinvname} </if>
            <if test="invclasscode != null and invclasscode != ''"> and invclasscode = #{invclasscode} </if>
            <if test="invclasslev != null"> and invclasslev = #{invclasslev} </if>
            <if test="invclassname != null and invclassname != ''"> and invclassname = #{invclassname} </if>
            <if test="iselectrans != null and iselectrans != ''"> and iselectrans = #{iselectrans} </if>
            <if test="ishuo != null and ishuo != ''"> and ishuo = #{ishuo} </if>
            <if test="pkCorp != null and pkCorp != ''"> and pk_corp = #{pkCorp} </if>
            <if test="pkInvcl != null and pkInvcl != ''"> and pk_invcl = #{pkInvcl} </if>
            <if test="sealdate != null and sealdate != ''"> and sealdate = #{sealdate} </if>
            <if test="ts != null and ts != ''"> and ts = #{ts} </if>
            and sts='Y'
    </trim>
</update>
<!--通过主键删除-->
<delete id="entity_delete">
    delete from bd_invcl where pk_invcl = #{pkInvcl}
</delete>

</mapper>

