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

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

</mapper>

