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

    <resultMap id="get-BdCargdocEntity-result" type="com.hzya.frame.plugin.lets.entity.BdCargdocEntity" >
       <result property="codelev" column="codelev" jdbcType="INTEGER"/>
           <result property="csattr" column="csattr" jdbcType="INTEGER"/>
           <result property="cscode" column="cscode" jdbcType="VARCHAR"/>
           <result property="csname" column="csname" jdbcType="VARCHAR"/>
           <result property="dr" column="dr" jdbcType="INTEGER"/>
           <result property="endflag" column="endflag" jdbcType="VARCHAR"/>
           <result property="inpriority" column="inpriority" jdbcType="INTEGER"/>
           <result property="ischecked" column="ischecked" jdbcType="VARCHAR"/>
           <result property="isrmplace" column="isrmplace" jdbcType="VARCHAR"/>
           <result property="memo" column="memo" jdbcType="VARCHAR"/>
           <result property="outpriority" column="outpriority" jdbcType="INTEGER"/>
           <result property="pkCargdoc" column="pk_cargdoc" jdbcType="VARCHAR"/>
           <result property="pkPsndoc" column="pk_psndoc" jdbcType="VARCHAR"/>
           <result property="pkStordoc" column="pk_stordoc" jdbcType="VARCHAR"/>
           <result property="sealflag" column="sealflag" jdbcType="VARCHAR"/>
           <result property="ts" column="ts" jdbcType="VARCHAR"/>
           <result property="volume" column="volume" jdbcType="NUMERIC"/>
        </resultMap>
    <!-- 查询的字段-->
    <sql id = "BdCargdocEntity_Base_Column_List">
        codelev
       ,csattr 
        ,cscode 
        ,csname 
        ,dr 
        ,endflag 
        ,inpriority 
        ,ischecked 
        ,isrmplace 
        ,memo 
        ,outpriority 
        ,pk_cargdoc 
        ,pk_psndoc 
        ,pk_stordoc 
        ,sealflag 
        ,ts 
        ,volume 
     </sql>
 <!-- 查询 采用==查询 -->
 <select id="entity_list_base" resultMap="get-BdCargdocEntity-result" parameterType = "com.hzya.frame.plugin.lets.entity.BdCargdocEntity">
    select
    <include refid="BdCargdocEntity_Base_Column_List" />
    from bd_cargdoc
    <trim prefix="where" prefixOverrides="and"> 
        <if test="codelev != null"> and codelev = #{codelev} </if>
            <if test="csattr != null"> and csattr = #{csattr} </if>
            <if test="cscode != null and cscode != ''"> and cscode = #{cscode} </if>
            <if test="csname != null and csname != ''"> and csname = #{csname} </if>
            <if test="dr != null"> and dr = #{dr} </if>
            <if test="endflag != null and endflag != ''"> and endflag = #{endflag} </if>
            <if test="inpriority != null"> and inpriority = #{inpriority} </if>
            <if test="ischecked != null and ischecked != ''"> and ischecked = #{ischecked} </if>
            <if test="isrmplace != null and isrmplace != ''"> and isrmplace = #{isrmplace} </if>
            <if test="memo != null and memo != ''"> and memo = #{memo} </if>
            <if test="outpriority != null"> and outpriority = #{outpriority} </if>
            <if test="pkCargdoc != null and pkCargdoc != ''"> and pk_cargdoc = #{pkCargdoc} </if>
            <if test="pkPsndoc != null and pkPsndoc != ''"> and pk_psndoc = #{pkPsndoc} </if>
            <if test="pkStordoc != null and pkStordoc != ''"> and pk_stordoc = #{pkStordoc} </if>
            <if test="sealflag != null and sealflag != ''"> and sealflag = #{sealflag} </if>
            <if test="ts != null and ts != ''"> and ts = #{ts} </if>
            <if test="volume != null"> and volume = #{volume} </if>
    </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.BdCargdocEntity">
        select  count(1)   from bd_cargdoc
    <trim prefix="where" prefixOverrides="and"> 
        <if test="codelev != null"> and codelev = #{codelev} </if>
            <if test="csattr != null"> and csattr = #{csattr} </if>
            <if test="cscode != null and cscode != ''"> and cscode = #{cscode} </if>
            <if test="csname != null and csname != ''"> and csname = #{csname} </if>
            <if test="dr != null"> and dr = #{dr} </if>
            <if test="endflag != null and endflag != ''"> and endflag = #{endflag} </if>
            <if test="inpriority != null"> and inpriority = #{inpriority} </if>
            <if test="ischecked != null and ischecked != ''"> and ischecked = #{ischecked} </if>
            <if test="isrmplace != null and isrmplace != ''"> and isrmplace = #{isrmplace} </if>
            <if test="memo != null and memo != ''"> and memo = #{memo} </if>
            <if test="outpriority != null"> and outpriority = #{outpriority} </if>
            <if test="pkCargdoc != null and pkCargdoc != ''"> and pk_cargdoc = #{pkCargdoc} </if>
            <if test="pkPsndoc != null and pkPsndoc != ''"> and pk_psndoc = #{pkPsndoc} </if>
            <if test="pkStordoc != null and pkStordoc != ''"> and pk_stordoc = #{pkStordoc} </if>
            <if test="sealflag != null and sealflag != ''"> and sealflag = #{sealflag} </if>
            <if test="ts != null and ts != ''"> and ts = #{ts} </if>
            <if test="volume != null"> and volume = #{volume} </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-BdCargdocEntity-result" parameterType = "com.hzya.frame.plugin.lets.entity.BdCargdocEntity">
    select
    <include refid="BdCargdocEntity_Base_Column_List" />
    from bd_cargdoc
    <trim prefix="where" prefixOverrides="and"> 
        <if test="codelev != null"> and codelev like concat('%',#{codelev},'%') </if>
            <if test="csattr != null"> and csattr like concat('%',#{csattr},'%') </if>
            <if test="cscode != null and cscode != ''"> and cscode like concat('%',#{cscode},'%') </if>
            <if test="csname != null and csname != ''"> and csname like concat('%',#{csname},'%') </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="inpriority != null"> and inpriority like concat('%',#{inpriority},'%') </if>
            <if test="ischecked != null and ischecked != ''"> and ischecked like concat('%',#{ischecked},'%') </if>
            <if test="isrmplace != null and isrmplace != ''"> and isrmplace like concat('%',#{isrmplace},'%') </if>
            <if test="memo != null and memo != ''"> and memo like concat('%',#{memo},'%') </if>
            <if test="outpriority != null"> and outpriority like concat('%',#{outpriority},'%') </if>
            <if test="pkCargdoc != null and pkCargdoc != ''"> and pk_cargdoc like concat('%',#{pkCargdoc},'%') </if>
            <if test="pkPsndoc != null and pkPsndoc != ''"> and pk_psndoc like concat('%',#{pkPsndoc},'%') </if>
            <if test="pkStordoc != null and pkStordoc != ''"> and pk_stordoc like concat('%',#{pkStordoc},'%') </if>
            <if test="sealflag != null and sealflag != ''"> and sealflag like concat('%',#{sealflag},'%') </if>
            <if test="ts != null and ts != ''"> and ts like concat('%',#{ts},'%') </if>
            <if test="volume != null"> and volume like concat('%',#{volume},'%') </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="BdCargdocentity_list_or" resultMap="get-BdCargdocEntity-result" parameterType = "com.hzya.frame.plugin.lets.entity.BdCargdocEntity">
    select
    <include refid="BdCargdocEntity_Base_Column_List" />
    from bd_cargdoc
    <trim prefix="where" prefixOverrides="and"> 
         <if test="codelev != null"> or codelev = #{codelev} </if>
             <if test="csattr != null"> or csattr = #{csattr} </if>
             <if test="cscode != null and cscode != ''"> or cscode = #{cscode} </if>
             <if test="csname != null and csname != ''"> or csname = #{csname} </if>
             <if test="dr != null"> or dr = #{dr} </if>
             <if test="endflag != null and endflag != ''"> or endflag = #{endflag} </if>
             <if test="inpriority != null"> or inpriority = #{inpriority} </if>
             <if test="ischecked != null and ischecked != ''"> or ischecked = #{ischecked} </if>
             <if test="isrmplace != null and isrmplace != ''"> or isrmplace = #{isrmplace} </if>
             <if test="memo != null and memo != ''"> or memo = #{memo} </if>
             <if test="outpriority != null"> or outpriority = #{outpriority} </if>
             <if test="pkCargdoc != null and pkCargdoc != ''"> or pk_cargdoc = #{pkCargdoc} </if>
             <if test="pkPsndoc != null and pkPsndoc != ''"> or pk_psndoc = #{pkPsndoc} </if>
             <if test="pkStordoc != null and pkStordoc != ''"> or pk_stordoc = #{pkStordoc} </if>
             <if test="sealflag != null and sealflag != ''"> or sealflag = #{sealflag} </if>
             <if test="ts != null and ts != ''"> or ts = #{ts} </if>
             <if test="volume != null"> or volume = #{volume} </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.BdCargdocEntity" keyProperty="pkCargdoc" useGeneratedKeys="true">
    insert into bd_cargdoc(
  <trim suffix="" suffixOverrides=",">
       <if test="codelev != null"> codelev , </if>
            <if test="csattr != null"> csattr , </if>
            <if test="cscode != null and cscode != ''"> cscode , </if>
            <if test="csname != null and csname != ''"> csname , </if>
            <if test="dr != null"> dr , </if>
            <if test="endflag != null and endflag != ''"> endflag , </if>
            <if test="inpriority != null"> inpriority , </if>
            <if test="ischecked != null and ischecked != ''"> ischecked , </if>
            <if test="isrmplace != null and isrmplace != ''"> isrmplace , </if>
            <if test="memo != null and memo != ''"> memo , </if>
            <if test="outpriority != null"> outpriority , </if>
            <if test="pkCargdoc != null and pkCargdoc != ''"> pk_cargdoc , </if>
            <if test="pkPsndoc != null and pkPsndoc != ''"> pk_psndoc , </if>
            <if test="pkStordoc != null and pkStordoc != ''"> pk_stordoc , </if>
            <if test="sealflag != null and sealflag != ''"> sealflag , </if>
            <if test="ts != null and ts != ''"> ts , </if>
            <if test="volume != null"> volume , </if>
            <if test="sorts == null ">sorts,</if>
    <if test="sts == null ">sts,</if>
  </trim>
  )values(
 <trim suffix="" suffixOverrides=",">
       <if test="codelev != null"> #{codelev} ,</if>
            <if test="csattr != null"> #{csattr} ,</if>
            <if test="cscode != null and cscode != ''"> #{cscode} ,</if>
            <if test="csname != null and csname != ''"> #{csname} ,</if>
            <if test="dr != null"> #{dr} ,</if>
            <if test="endflag != null and endflag != ''"> #{endflag} ,</if>
            <if test="inpriority != null"> #{inpriority} ,</if>
            <if test="ischecked != null and ischecked != ''"> #{ischecked} ,</if>
            <if test="isrmplace != null and isrmplace != ''"> #{isrmplace} ,</if>
            <if test="memo != null and memo != ''"> #{memo} ,</if>
            <if test="outpriority != null"> #{outpriority} ,</if>
            <if test="pkCargdoc != null and pkCargdoc != ''"> #{pkCargdoc} ,</if>
            <if test="pkPsndoc != null and pkPsndoc != ''"> #{pkPsndoc} ,</if>
            <if test="pkStordoc != null and pkStordoc != ''"> #{pkStordoc} ,</if>
            <if test="sealflag != null and sealflag != ''"> #{sealflag} ,</if>
            <if test="ts != null and ts != ''"> #{ts} ,</if>
            <if test="volume != null"> #{volume} ,</if>
            <if test="sorts == null ">(select (max(IFNULL( a.sorts, 0 )) + 1) as sort from bd_cargdoc a WHERE a.sts = 'Y' ),</if>
    <if test="sts == null ">'Y',</if>
  </trim>
  )  
</insert>
<!-- 批量新增 -->
<insert id="entityInsertBatch" keyProperty="pkCargdoc" useGeneratedKeys="true">
  insert into bd_cargdoc(codelev, csattr, cscode, csname, dr, endflag, inpriority, ischecked, isrmplace, memo, outpriority, pk_psndoc, pk_stordoc, sealflag, ts, volume,  sts) 
    values
    <foreach collection="entities" item="entity" separator=",">
    (#{entity.codelev},#{entity.csattr},#{entity.cscode},#{entity.csname},#{entity.dr},#{entity.endflag},#{entity.inpriority},#{entity.ischecked},#{entity.isrmplace},#{entity.memo},#{entity.outpriority},#{entity.pkPsndoc},#{entity.pkStordoc},#{entity.sealflag},#{entity.ts},#{entity.volume}, 'Y')
    </foreach>
</insert>
<!-- 批量新增或者修改-->
<insert id="entityInsertOrUpdateBatch" keyProperty="pkCargdoc" useGeneratedKeys="true">
    insert into bd_cargdoc(codelev, csattr, cscode, csname, dr, endflag, inpriority, ischecked, isrmplace, memo, outpriority, pk_psndoc, pk_stordoc, sealflag, ts, volume)
    values
    <foreach collection="entities" item="entity" separator=",">
    (#{entity.codelev},#{entity.csattr},#{entity.cscode},#{entity.csname},#{entity.dr},#{entity.endflag},#{entity.inpriority},#{entity.ischecked},#{entity.isrmplace},#{entity.memo},#{entity.outpriority},#{entity.pkPsndoc},#{entity.pkStordoc},#{entity.sealflag},#{entity.ts},#{entity.volume})
    </foreach>
    on duplicate key update
    codelev = values(codelev),
    csattr = values(csattr),
    cscode = values(cscode),
    csname = values(csname),
    dr = values(dr),
    endflag = values(endflag),
    inpriority = values(inpriority),
    ischecked = values(ischecked),
    isrmplace = values(isrmplace),
    memo = values(memo),
    outpriority = values(outpriority),
    pk_psndoc = values(pk_psndoc),
    pk_stordoc = values(pk_stordoc),
    sealflag = values(sealflag),
    ts = values(ts),
    volume = values(volume)</insert>
<!--通过主键修改方法-->
<update id="entity_update" parameterType = "com.hzya.frame.plugin.lets.entity.BdCargdocEntity" >
update bd_cargdoc  set
<trim suffix="" suffixOverrides=",">
  <if test="codelev != null"> codelev = #{codelev},</if>
  <if test="csattr != null"> csattr = #{csattr},</if>
  <if test="cscode != null and cscode != ''"> cscode = #{cscode},</if>
  <if test="csname != null and csname != ''"> csname = #{csname},</if>
  <if test="dr != null"> dr = #{dr},</if>
  <if test="endflag != null and endflag != ''"> endflag = #{endflag},</if>
  <if test="inpriority != null"> inpriority = #{inpriority},</if>
  <if test="ischecked != null and ischecked != ''"> ischecked = #{ischecked},</if>
  <if test="isrmplace != null and isrmplace != ''"> isrmplace = #{isrmplace},</if>
  <if test="memo != null and memo != ''"> memo = #{memo},</if>
  <if test="outpriority != null"> outpriority = #{outpriority},</if>
  <if test="pkPsndoc != null and pkPsndoc != ''"> pk_psndoc = #{pkPsndoc},</if>
  <if test="pkStordoc != null and pkStordoc != ''"> pk_stordoc = #{pkStordoc},</if>
  <if test="sealflag != null and sealflag != ''"> sealflag = #{sealflag},</if>
  <if test="ts != null and ts != ''"> ts = #{ts},</if>
  <if test="volume != null"> volume = #{volume},</if>
</trim>
where pk_cargdoc = #{pkCargdoc}
</update>
<!-- 逻辑删除 -->
<update id="entity_logicDelete" parameterType = "com.hzya.frame.plugin.lets.entity.BdCargdocEntity" >
update bd_cargdoc  set sts= 'N' ,modify_time = #{modify_time},modify_user_id = #{modify_user_id}
where pk_cargdoc = #{pkCargdoc}
</update>
<!-- 多条件逻辑删除 -->
<update id="entity_logicDelete_Multi_Condition" parameterType = "com.hzya.frame.plugin.lets.entity.BdCargdocEntity" >
update bd_cargdoc  set sts= 'N' ,modify_time = #{modify_time},modify_user_id = #{modify_user_id}
 <trim prefix="where" prefixOverrides="and"> 
        <if test="codelev != null"> and codelev = #{codelev} </if>
            <if test="csattr != null"> and csattr = #{csattr} </if>
            <if test="cscode != null and cscode != ''"> and cscode = #{cscode} </if>
            <if test="csname != null and csname != ''"> and csname = #{csname} </if>
            <if test="dr != null"> and dr = #{dr} </if>
            <if test="endflag != null and endflag != ''"> and endflag = #{endflag} </if>
            <if test="inpriority != null"> and inpriority = #{inpriority} </if>
            <if test="ischecked != null and ischecked != ''"> and ischecked = #{ischecked} </if>
            <if test="isrmplace != null and isrmplace != ''"> and isrmplace = #{isrmplace} </if>
            <if test="memo != null and memo != ''"> and memo = #{memo} </if>
            <if test="outpriority != null"> and outpriority = #{outpriority} </if>
            <if test="pkCargdoc != null and pkCargdoc != ''"> and pk_cargdoc = #{pkCargdoc} </if>
            <if test="pkPsndoc != null and pkPsndoc != ''"> and pk_psndoc = #{pkPsndoc} </if>
            <if test="pkStordoc != null and pkStordoc != ''"> and pk_stordoc = #{pkStordoc} </if>
            <if test="sealflag != null and sealflag != ''"> and sealflag = #{sealflag} </if>
            <if test="ts != null and ts != ''"> and ts = #{ts} </if>
            <if test="volume != null"> and volume = #{volume} </if>
            and sts='Y'
    </trim>
</update>
<!--通过主键删除-->
<delete id="entity_delete">
    delete from bd_cargdoc where pk_cargdoc = #{pkCargdoc}
</delete>

</mapper>

