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

    <resultMap id="get-BdJobbasfilEntity-result" type="com.hzya.frame.plugin.lets.entity.BdJobbasfilEntity" >
       <result property="begindate" column="begindate" jdbcType="VARCHAR"/>
           <result property="cremcode" column="cremcode" jdbcType="VARCHAR"/>
           <result property="def1" column="def1" jdbcType="VARCHAR"/>
           <result property="def10" column="def10" jdbcType="VARCHAR"/>
           <result property="def11" column="def11" jdbcType="VARCHAR"/>
           <result property="def12" column="def12" jdbcType="VARCHAR"/>
           <result property="def13" column="def13" jdbcType="VARCHAR"/>
           <result property="def14" column="def14" jdbcType="VARCHAR"/>
           <result property="def15" column="def15" jdbcType="VARCHAR"/>
           <result property="def16" column="def16" jdbcType="VARCHAR"/>
           <result property="def17" column="def17" jdbcType="VARCHAR"/>
           <result property="def18" column="def18" jdbcType="VARCHAR"/>
           <result property="def19" column="def19" jdbcType="VARCHAR"/>
           <result property="def2" column="def2" jdbcType="VARCHAR"/>
           <result property="def20" column="def20" jdbcType="VARCHAR"/>
           <result property="def3" column="def3" jdbcType="VARCHAR"/>
           <result property="def4" column="def4" jdbcType="VARCHAR"/>
           <result property="def5" column="def5" jdbcType="VARCHAR"/>
           <result property="def6" column="def6" jdbcType="VARCHAR"/>
           <result property="def7" column="def7" jdbcType="VARCHAR"/>
           <result property="def8" column="def8" jdbcType="VARCHAR"/>
           <result property="def9" column="def9" jdbcType="VARCHAR"/>
           <result property="dr" column="dr" jdbcType="INTEGER"/>
           <result property="enddate" column="enddate" jdbcType="VARCHAR"/>
           <result property="finishedflag" column="finishedflag" jdbcType="VARCHAR"/>
           <result property="forecastenddate" column="forecastenddate" jdbcType="VARCHAR"/>
           <result property="jobcode" column="jobcode" jdbcType="VARCHAR"/>
           <result property="jobname" column="jobname" jdbcType="VARCHAR"/>
           <result property="pkCorp" column="pk_corp" jdbcType="VARCHAR"/>
           <result property="pkJobbasfil" column="pk_jobbasfil" jdbcType="VARCHAR"/>
           <result property="pkJobcl" column="pk_jobcl" jdbcType="VARCHAR"/>
           <result property="pkJobtype" column="pk_jobtype" jdbcType="VARCHAR"/>
           <result property="sealflag" column="sealflag" jdbcType="VARCHAR"/>
           <result property="ts" column="ts" jdbcType="VARCHAR"/>
        </resultMap>

    <!-- 查询的字段-->
    <sql id = "BdJobbasfilEntity_Base_Column_List">
        begindate
       ,cremcode
        ,def1
        ,def10
        ,def11
        ,def12
        ,def13
        ,def14
        ,def15
        ,def16
        ,def17
        ,def18
        ,def19
        ,def2
        ,def20
        ,def3
        ,def4
        ,def5
        ,def6
        ,def7
        ,def8
        ,def9
        ,dr
        ,enddate
        ,finishedflag
        ,forecastenddate
        ,jobcode
        ,jobname
        ,pk_corp
        ,pk_jobbasfil
        ,pk_jobcl
        ,pk_jobtype
        ,sealflag
        ,ts
     </sql>

 <!-- 查询 采用==查询 -->
 <select id="entity_list_base" resultMap="get-BdJobbasfilEntity-result" parameterType = "com.hzya.frame.plugin.lets.entity.BdJobbasfilEntity">
    select
    <include refid="BdJobbasfilEntity_Base_Column_List" />
    from bd_jobbasfil
    <trim prefix="where" prefixOverrides="and">
        <if test="begindate != null and begindate != ''"> and begindate = #{begindate} </if>
            <if test="cremcode != null and cremcode != ''"> and cremcode = #{cremcode} </if>
            <if test="def1 != null and def1 != ''"> and def1 = #{def1} </if>
            <if test="def10 != null and def10 != ''"> and def10 = #{def10} </if>
            <if test="def11 != null and def11 != ''"> and def11 = #{def11} </if>
            <if test="def12 != null and def12 != ''"> and def12 = #{def12} </if>
            <if test="def13 != null and def13 != ''"> and def13 = #{def13} </if>
            <if test="def14 != null and def14 != ''"> and def14 = #{def14} </if>
            <if test="def15 != null and def15 != ''"> and def15 = #{def15} </if>
            <if test="def16 != null and def16 != ''"> and def16 = #{def16} </if>
            <if test="def17 != null and def17 != ''"> and def17 = #{def17} </if>
            <if test="def18 != null and def18 != ''"> and def18 = #{def18} </if>
            <if test="def19 != null and def19 != ''"> and def19 = #{def19} </if>
            <if test="def2 != null and def2 != ''"> and def2 = #{def2} </if>
            <if test="def20 != null and def20 != ''"> and def20 = #{def20} </if>
            <if test="def3 != null and def3 != ''"> and def3 = #{def3} </if>
            <if test="def4 != null and def4 != ''"> and def4 = #{def4} </if>
            <if test="def5 != null and def5 != ''"> and def5 = #{def5} </if>
            <if test="def6 != null and def6 != ''"> and def6 = #{def6} </if>
            <if test="def7 != null and def7 != ''"> and def7 = #{def7} </if>
            <if test="def8 != null and def8 != ''"> and def8 = #{def8} </if>
            <if test="def9 != null and def9 != ''"> and def9 = #{def9} </if>
            <if test="dr != null"> and dr = #{dr} </if>
            <if test="enddate != null and enddate != ''"> and enddate = #{enddate} </if>
            <if test="finishedflag != null and finishedflag != ''"> and finishedflag = #{finishedflag} </if>
            <if test="forecastenddate != null and forecastenddate != ''"> and forecastenddate = #{forecastenddate} </if>
            <if test="jobcode != null and jobcode != ''"> and jobcode = #{jobcode} </if>
            <if test="jobname != null and jobname != ''"> and jobname = #{jobname} </if>
            <if test="pkCorp != null and pkCorp != ''"> and pk_corp = #{pkCorp} </if>
            <if test="pkJobbasfil != null and pkJobbasfil != ''"> and pk_jobbasfil = #{pkJobbasfil} </if>
            <if test="pkJobcl != null and pkJobcl != ''"> and pk_jobcl = #{pkJobcl} </if>
            <if test="pkJobtype != null and pkJobtype != ''"> and pk_jobtype = #{pkJobtype} </if>
            <if test="sealflag != null and sealflag != ''"> and sealflag = #{sealflag} </if>
            <if test="ts != null and ts != ''"> and ts = #{ts} </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.BdJobbasfilEntity">
        select  count(1)   from bd_jobbasfil
    <trim prefix="where" prefixOverrides="and">
        <if test="begindate != null and begindate != ''"> and begindate = #{begindate} </if>
            <if test="cremcode != null and cremcode != ''"> and cremcode = #{cremcode} </if>
            <if test="def1 != null and def1 != ''"> and def1 = #{def1} </if>
            <if test="def10 != null and def10 != ''"> and def10 = #{def10} </if>
            <if test="def11 != null and def11 != ''"> and def11 = #{def11} </if>
            <if test="def12 != null and def12 != ''"> and def12 = #{def12} </if>
            <if test="def13 != null and def13 != ''"> and def13 = #{def13} </if>
            <if test="def14 != null and def14 != ''"> and def14 = #{def14} </if>
            <if test="def15 != null and def15 != ''"> and def15 = #{def15} </if>
            <if test="def16 != null and def16 != ''"> and def16 = #{def16} </if>
            <if test="def17 != null and def17 != ''"> and def17 = #{def17} </if>
            <if test="def18 != null and def18 != ''"> and def18 = #{def18} </if>
            <if test="def19 != null and def19 != ''"> and def19 = #{def19} </if>
            <if test="def2 != null and def2 != ''"> and def2 = #{def2} </if>
            <if test="def20 != null and def20 != ''"> and def20 = #{def20} </if>
            <if test="def3 != null and def3 != ''"> and def3 = #{def3} </if>
            <if test="def4 != null and def4 != ''"> and def4 = #{def4} </if>
            <if test="def5 != null and def5 != ''"> and def5 = #{def5} </if>
            <if test="def6 != null and def6 != ''"> and def6 = #{def6} </if>
            <if test="def7 != null and def7 != ''"> and def7 = #{def7} </if>
            <if test="def8 != null and def8 != ''"> and def8 = #{def8} </if>
            <if test="def9 != null and def9 != ''"> and def9 = #{def9} </if>
            <if test="dr != null"> and dr = #{dr} </if>
            <if test="enddate != null and enddate != ''"> and enddate = #{enddate} </if>
            <if test="finishedflag != null and finishedflag != ''"> and finishedflag = #{finishedflag} </if>
            <if test="forecastenddate != null and forecastenddate != ''"> and forecastenddate = #{forecastenddate} </if>
            <if test="jobcode != null and jobcode != ''"> and jobcode = #{jobcode} </if>
            <if test="jobname != null and jobname != ''"> and jobname = #{jobname} </if>
            <if test="pkCorp != null and pkCorp != ''"> and pk_corp = #{pkCorp} </if>
            <if test="pkJobbasfil != null and pkJobbasfil != ''"> and pk_jobbasfil = #{pkJobbasfil} </if>
            <if test="pkJobcl != null and pkJobcl != ''"> and pk_jobcl = #{pkJobcl} </if>
            <if test="pkJobtype != null and pkJobtype != ''"> and pk_jobtype = #{pkJobtype} </if>
            <if test="sealflag != null and sealflag != ''"> and sealflag = #{sealflag} </if>
            <if test="ts != null and ts != ''"> and ts = #{ts} </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>

    <!-- 分页查询列表 采用like格式 -->
<select id="entity_list_like" resultMap="get-BdJobbasfilEntity-result" parameterType = "com.hzya.frame.plugin.lets.entity.BdJobbasfilEntity">
    select
    <include refid="BdJobbasfilEntity_Base_Column_List" />
    from bd_jobbasfil
    <trim prefix="where" prefixOverrides="and">
        <if test="begindate != null and begindate != ''"> and begindate like concat('%',#{begindate},'%') </if>
            <if test="cremcode != null and cremcode != ''"> and cremcode like concat('%',#{cremcode},'%') </if>
            <if test="def1 != null and def1 != ''"> and def1 like concat('%',#{def1},'%') </if>
            <if test="def10 != null and def10 != ''"> and def10 like concat('%',#{def10},'%') </if>
            <if test="def11 != null and def11 != ''"> and def11 like concat('%',#{def11},'%') </if>
            <if test="def12 != null and def12 != ''"> and def12 like concat('%',#{def12},'%') </if>
            <if test="def13 != null and def13 != ''"> and def13 like concat('%',#{def13},'%') </if>
            <if test="def14 != null and def14 != ''"> and def14 like concat('%',#{def14},'%') </if>
            <if test="def15 != null and def15 != ''"> and def15 like concat('%',#{def15},'%') </if>
            <if test="def16 != null and def16 != ''"> and def16 like concat('%',#{def16},'%') </if>
            <if test="def17 != null and def17 != ''"> and def17 like concat('%',#{def17},'%') </if>
            <if test="def18 != null and def18 != ''"> and def18 like concat('%',#{def18},'%') </if>
            <if test="def19 != null and def19 != ''"> and def19 like concat('%',#{def19},'%') </if>
            <if test="def2 != null and def2 != ''"> and def2 like concat('%',#{def2},'%') </if>
            <if test="def20 != null and def20 != ''"> and def20 like concat('%',#{def20},'%') </if>
            <if test="def3 != null and def3 != ''"> and def3 like concat('%',#{def3},'%') </if>
            <if test="def4 != null and def4 != ''"> and def4 like concat('%',#{def4},'%') </if>
            <if test="def5 != null and def5 != ''"> and def5 like concat('%',#{def5},'%') </if>
            <if test="def6 != null and def6 != ''"> and def6 like concat('%',#{def6},'%') </if>
            <if test="def7 != null and def7 != ''"> and def7 like concat('%',#{def7},'%') </if>
            <if test="def8 != null and def8 != ''"> and def8 like concat('%',#{def8},'%') </if>
            <if test="def9 != null and def9 != ''"> and def9 like concat('%',#{def9},'%') </if>
            <if test="dr != null"> and dr like concat('%',#{dr},'%') </if>
            <if test="enddate != null and enddate != ''"> and enddate like concat('%',#{enddate},'%') </if>
            <if test="finishedflag != null and finishedflag != ''"> and finishedflag like concat('%',#{finishedflag},'%') </if>
            <if test="forecastenddate != null and forecastenddate != ''"> and forecastenddate like concat('%',#{forecastenddate},'%') </if>
            <if test="jobcode != null and jobcode != ''"> and jobcode like concat('%',#{jobcode},'%') </if>
            <if test="jobname != null and jobname != ''"> and jobname like concat('%',#{jobname},'%') </if>
            <if test="pkCorp != null and pkCorp != ''"> and pk_corp like concat('%',#{pkCorp},'%') </if>
            <if test="pkJobbasfil != null and pkJobbasfil != ''"> and pk_jobbasfil like concat('%',#{pkJobbasfil},'%') </if>
            <if test="pkJobcl != null and pkJobcl != ''"> and pk_jobcl like concat('%',#{pkJobcl},'%') </if>
            <if test="pkJobtype != null and pkJobtype != ''"> and pk_jobtype like concat('%',#{pkJobtype},'%') </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>
    </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="BdJobbasfilentity_list_or" resultMap="get-BdJobbasfilEntity-result" parameterType = "com.hzya.frame.plugin.lets.entity.BdJobbasfilEntity">
    select
    <include refid="BdJobbasfilEntity_Base_Column_List" />
    from bd_jobbasfil
    <trim prefix="where" prefixOverrides="and">
         <if test="begindate != null and begindate != ''"> or begindate = #{begindate} </if>
             <if test="cremcode != null and cremcode != ''"> or cremcode = #{cremcode} </if>
             <if test="def1 != null and def1 != ''"> or def1 = #{def1} </if>
             <if test="def10 != null and def10 != ''"> or def10 = #{def10} </if>
             <if test="def11 != null and def11 != ''"> or def11 = #{def11} </if>
             <if test="def12 != null and def12 != ''"> or def12 = #{def12} </if>
             <if test="def13 != null and def13 != ''"> or def13 = #{def13} </if>
             <if test="def14 != null and def14 != ''"> or def14 = #{def14} </if>
             <if test="def15 != null and def15 != ''"> or def15 = #{def15} </if>
             <if test="def16 != null and def16 != ''"> or def16 = #{def16} </if>
             <if test="def17 != null and def17 != ''"> or def17 = #{def17} </if>
             <if test="def18 != null and def18 != ''"> or def18 = #{def18} </if>
             <if test="def19 != null and def19 != ''"> or def19 = #{def19} </if>
             <if test="def2 != null and def2 != ''"> or def2 = #{def2} </if>
             <if test="def20 != null and def20 != ''"> or def20 = #{def20} </if>
             <if test="def3 != null and def3 != ''"> or def3 = #{def3} </if>
             <if test="def4 != null and def4 != ''"> or def4 = #{def4} </if>
             <if test="def5 != null and def5 != ''"> or def5 = #{def5} </if>
             <if test="def6 != null and def6 != ''"> or def6 = #{def6} </if>
             <if test="def7 != null and def7 != ''"> or def7 = #{def7} </if>
             <if test="def8 != null and def8 != ''"> or def8 = #{def8} </if>
             <if test="def9 != null and def9 != ''"> or def9 = #{def9} </if>
             <if test="dr != null"> or dr = #{dr} </if>
             <if test="enddate != null and enddate != ''"> or enddate = #{enddate} </if>
             <if test="finishedflag != null and finishedflag != ''"> or finishedflag = #{finishedflag} </if>
             <if test="forecastenddate != null and forecastenddate != ''"> or forecastenddate = #{forecastenddate} </if>
             <if test="jobcode != null and jobcode != ''"> or jobcode = #{jobcode} </if>
             <if test="jobname != null and jobname != ''"> or jobname = #{jobname} </if>
             <if test="pkCorp != null and pkCorp != ''"> or pk_corp = #{pkCorp} </if>
             <if test="pkJobbasfil != null and pkJobbasfil != ''"> or pk_jobbasfil = #{pkJobbasfil} </if>
             <if test="pkJobcl != null and pkJobcl != ''"> or pk_jobcl = #{pkJobcl} </if>
             <if test="pkJobtype != null and pkJobtype != ''"> or pk_jobtype = #{pkJobtype} </if>
             <if test="sealflag != null and sealflag != ''"> or sealflag = #{sealflag} </if>
             <if test="ts != null and ts != ''"> or ts = #{ts} </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>

<!--新增所有列-->
<insert id="entity_insert" parameterType = "com.hzya.frame.plugin.lets.entity.BdJobbasfilEntity" keyProperty="pkJobbasfil" useGeneratedKeys="true">
    insert into bd_jobbasfil(
  <trim suffix="" suffixOverrides=",">
       <if test="begindate != null and begindate != ''"> begindate , </if>
            <if test="cremcode != null and cremcode != ''"> cremcode , </if>
            <if test="def1 != null and def1 != ''"> def1 , </if>
            <if test="def10 != null and def10 != ''"> def10 , </if>
            <if test="def11 != null and def11 != ''"> def11 , </if>
            <if test="def12 != null and def12 != ''"> def12 , </if>
            <if test="def13 != null and def13 != ''"> def13 , </if>
            <if test="def14 != null and def14 != ''"> def14 , </if>
            <if test="def15 != null and def15 != ''"> def15 , </if>
            <if test="def16 != null and def16 != ''"> def16 , </if>
            <if test="def17 != null and def17 != ''"> def17 , </if>
            <if test="def18 != null and def18 != ''"> def18 , </if>
            <if test="def19 != null and def19 != ''"> def19 , </if>
            <if test="def2 != null and def2 != ''"> def2 , </if>
            <if test="def20 != null and def20 != ''"> def20 , </if>
            <if test="def3 != null and def3 != ''"> def3 , </if>
            <if test="def4 != null and def4 != ''"> def4 , </if>
            <if test="def5 != null and def5 != ''"> def5 , </if>
            <if test="def6 != null and def6 != ''"> def6 , </if>
            <if test="def7 != null and def7 != ''"> def7 , </if>
            <if test="def8 != null and def8 != ''"> def8 , </if>
            <if test="def9 != null and def9 != ''"> def9 , </if>
            <if test="dr != null"> dr , </if>
            <if test="enddate != null and enddate != ''"> enddate , </if>
            <if test="finishedflag != null and finishedflag != ''"> finishedflag , </if>
            <if test="forecastenddate != null and forecastenddate != ''"> forecastenddate , </if>
            <if test="jobcode != null and jobcode != ''"> jobcode , </if>
            <if test="jobname != null and jobname != ''"> jobname , </if>
            <if test="pkCorp != null and pkCorp != ''"> pk_corp , </if>
            <if test="pkJobbasfil != null and pkJobbasfil != ''"> pk_jobbasfil , </if>
            <if test="pkJobcl != null and pkJobcl != ''"> pk_jobcl , </if>
            <if test="pkJobtype != null and pkJobtype != ''"> pk_jobtype , </if>
            <if test="sealflag != null and sealflag != ''"> sealflag , </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="begindate != null and begindate != ''"> #{begindate} ,</if>
            <if test="cremcode != null and cremcode != ''"> #{cremcode} ,</if>
            <if test="def1 != null and def1 != ''"> #{def1} ,</if>
            <if test="def10 != null and def10 != ''"> #{def10} ,</if>
            <if test="def11 != null and def11 != ''"> #{def11} ,</if>
            <if test="def12 != null and def12 != ''"> #{def12} ,</if>
            <if test="def13 != null and def13 != ''"> #{def13} ,</if>
            <if test="def14 != null and def14 != ''"> #{def14} ,</if>
            <if test="def15 != null and def15 != ''"> #{def15} ,</if>
            <if test="def16 != null and def16 != ''"> #{def16} ,</if>
            <if test="def17 != null and def17 != ''"> #{def17} ,</if>
            <if test="def18 != null and def18 != ''"> #{def18} ,</if>
            <if test="def19 != null and def19 != ''"> #{def19} ,</if>
            <if test="def2 != null and def2 != ''"> #{def2} ,</if>
            <if test="def20 != null and def20 != ''"> #{def20} ,</if>
            <if test="def3 != null and def3 != ''"> #{def3} ,</if>
            <if test="def4 != null and def4 != ''"> #{def4} ,</if>
            <if test="def5 != null and def5 != ''"> #{def5} ,</if>
            <if test="def6 != null and def6 != ''"> #{def6} ,</if>
            <if test="def7 != null and def7 != ''"> #{def7} ,</if>
            <if test="def8 != null and def8 != ''"> #{def8} ,</if>
            <if test="def9 != null and def9 != ''"> #{def9} ,</if>
            <if test="dr != null"> #{dr} ,</if>
            <if test="enddate != null and enddate != ''"> #{enddate} ,</if>
            <if test="finishedflag != null and finishedflag != ''"> #{finishedflag} ,</if>
            <if test="forecastenddate != null and forecastenddate != ''"> #{forecastenddate} ,</if>
            <if test="jobcode != null and jobcode != ''"> #{jobcode} ,</if>
            <if test="jobname != null and jobname != ''"> #{jobname} ,</if>
            <if test="pkCorp != null and pkCorp != ''"> #{pkCorp} ,</if>
            <if test="pkJobbasfil != null and pkJobbasfil != ''"> #{pkJobbasfil} ,</if>
            <if test="pkJobcl != null and pkJobcl != ''"> #{pkJobcl} ,</if>
            <if test="pkJobtype != null and pkJobtype != ''"> #{pkJobtype} ,</if>
            <if test="sealflag != null and sealflag != ''"> #{sealflag} ,</if>
            <if test="ts != null and ts != ''"> #{ts} ,</if>
            <if test="sorts == null ">(select (max(IFNULL( a.sorts, 0 )) + 1) as sort from bd_jobbasfil a WHERE a.sts = 'Y' ),</if>
    <if test="sts == null ">'Y',</if>
  </trim>
  )
</insert>
<!-- 批量新增 -->
<insert id="entityInsertBatch" keyProperty="pkJobbasfil" useGeneratedKeys="true">
  insert into bd_jobbasfil(begindate, cremcode, def1, def10, def11, def12, def13, def14, def15, def16, def17, def18, def19, def2, def20, def3, def4, def5, def6, def7, def8, def9, dr, enddate, finishedflag, forecastenddate, jobcode, jobname, pk_corp, pk_jobcl, pk_jobtype, sealflag, ts,  sts)
    values
    <foreach collection="entities" item="entity" separator=",">
    (#{entity.begindate},#{entity.cremcode},#{entity.def1},#{entity.def10},#{entity.def11},#{entity.def12},#{entity.def13},#{entity.def14},#{entity.def15},#{entity.def16},#{entity.def17},#{entity.def18},#{entity.def19},#{entity.def2},#{entity.def20},#{entity.def3},#{entity.def4},#{entity.def5},#{entity.def6},#{entity.def7},#{entity.def8},#{entity.def9},#{entity.dr},#{entity.enddate},#{entity.finishedflag},#{entity.forecastenddate},#{entity.jobcode},#{entity.jobname},#{entity.pkCorp},#{entity.pkJobcl},#{entity.pkJobtype},#{entity.sealflag},#{entity.ts}, 'Y')
    </foreach>
</insert>
<!-- 批量新增或者修改-->
<insert id="entityInsertOrUpdateBatch" keyProperty="pkJobbasfil" useGeneratedKeys="true">
    insert into bd_jobbasfil(begindate, cremcode, def1, def10, def11, def12, def13, def14, def15, def16, def17, def18, def19, def2, def20, def3, def4, def5, def6, def7, def8, def9, dr, enddate, finishedflag, forecastenddate, jobcode, jobname, pk_corp, pk_jobcl, pk_jobtype, sealflag, ts)
    values
    <foreach collection="entities" item="entity" separator=",">
    (#{entity.begindate},#{entity.cremcode},#{entity.def1},#{entity.def10},#{entity.def11},#{entity.def12},#{entity.def13},#{entity.def14},#{entity.def15},#{entity.def16},#{entity.def17},#{entity.def18},#{entity.def19},#{entity.def2},#{entity.def20},#{entity.def3},#{entity.def4},#{entity.def5},#{entity.def6},#{entity.def7},#{entity.def8},#{entity.def9},#{entity.dr},#{entity.enddate},#{entity.finishedflag},#{entity.forecastenddate},#{entity.jobcode},#{entity.jobname},#{entity.pkCorp},#{entity.pkJobcl},#{entity.pkJobtype},#{entity.sealflag},#{entity.ts})
    </foreach>
    on duplicate key update
    begindate = values(begindate),
    cremcode = values(cremcode),
    def1 = values(def1),
    def10 = values(def10),
    def11 = values(def11),
    def12 = values(def12),
    def13 = values(def13),
    def14 = values(def14),
    def15 = values(def15),
    def16 = values(def16),
    def17 = values(def17),
    def18 = values(def18),
    def19 = values(def19),
    def2 = values(def2),
    def20 = values(def20),
    def3 = values(def3),
    def4 = values(def4),
    def5 = values(def5),
    def6 = values(def6),
    def7 = values(def7),
    def8 = values(def8),
    def9 = values(def9),
    dr = values(dr),
    enddate = values(enddate),
    finishedflag = values(finishedflag),
    forecastenddate = values(forecastenddate),
    jobcode = values(jobcode),
    jobname = values(jobname),
    pk_corp = values(pk_corp),
    pk_jobcl = values(pk_jobcl),
    pk_jobtype = values(pk_jobtype),
    sealflag = values(sealflag),
    ts = values(ts)</insert>
<!--通过主键修改方法-->
<update id="entity_update" parameterType = "com.hzya.frame.plugin.lets.entity.BdJobbasfilEntity" >
update bd_jobbasfil  set
<trim suffix="" suffixOverrides=",">
  <if test="begindate != null and begindate != ''"> begindate = #{begindate},</if>
  <if test="cremcode != null and cremcode != ''"> cremcode = #{cremcode},</if>
  <if test="def1 != null and def1 != ''"> def1 = #{def1},</if>
  <if test="def10 != null and def10 != ''"> def10 = #{def10},</if>
  <if test="def11 != null and def11 != ''"> def11 = #{def11},</if>
  <if test="def12 != null and def12 != ''"> def12 = #{def12},</if>
  <if test="def13 != null and def13 != ''"> def13 = #{def13},</if>
  <if test="def14 != null and def14 != ''"> def14 = #{def14},</if>
  <if test="def15 != null and def15 != ''"> def15 = #{def15},</if>
  <if test="def16 != null and def16 != ''"> def16 = #{def16},</if>
  <if test="def17 != null and def17 != ''"> def17 = #{def17},</if>
  <if test="def18 != null and def18 != ''"> def18 = #{def18},</if>
  <if test="def19 != null and def19 != ''"> def19 = #{def19},</if>
  <if test="def2 != null and def2 != ''"> def2 = #{def2},</if>
  <if test="def20 != null and def20 != ''"> def20 = #{def20},</if>
  <if test="def3 != null and def3 != ''"> def3 = #{def3},</if>
  <if test="def4 != null and def4 != ''"> def4 = #{def4},</if>
  <if test="def5 != null and def5 != ''"> def5 = #{def5},</if>
  <if test="def6 != null and def6 != ''"> def6 = #{def6},</if>
  <if test="def7 != null and def7 != ''"> def7 = #{def7},</if>
  <if test="def8 != null and def8 != ''"> def8 = #{def8},</if>
  <if test="def9 != null and def9 != ''"> def9 = #{def9},</if>
  <if test="dr != null"> dr = #{dr},</if>
  <if test="enddate != null and enddate != ''"> enddate = #{enddate},</if>
  <if test="finishedflag != null and finishedflag != ''"> finishedflag = #{finishedflag},</if>
  <if test="forecastenddate != null and forecastenddate != ''"> forecastenddate = #{forecastenddate},</if>
  <if test="jobcode != null and jobcode != ''"> jobcode = #{jobcode},</if>
  <if test="jobname != null and jobname != ''"> jobname = #{jobname},</if>
  <if test="pkCorp != null and pkCorp != ''"> pk_corp = #{pkCorp},</if>
  <if test="pkJobcl != null and pkJobcl != ''"> pk_jobcl = #{pkJobcl},</if>
  <if test="pkJobtype != null and pkJobtype != ''"> pk_jobtype = #{pkJobtype},</if>
  <if test="sealflag != null and sealflag != ''"> sealflag = #{sealflag},</if>
  <if test="ts != null and ts != ''"> ts = #{ts},</if>
</trim>
where pk_jobbasfil = #{pkJobbasfil}
</update>
<!-- 逻辑删除 -->
<update id="entity_logicDelete" parameterType = "com.hzya.frame.plugin.lets.entity.BdJobbasfilEntity" >
update bd_jobbasfil  set sts= 'N' ,modify_time = #{modify_time},modify_user_id = #{modify_user_id}
where pk_jobbasfil = #{pkJobbasfil}
</update>
<!-- 多条件逻辑删除 -->
<update id="entity_logicDelete_Multi_Condition" parameterType = "com.hzya.frame.plugin.lets.entity.BdJobbasfilEntity" >
update bd_jobbasfil  set sts= 'N' ,modify_time = #{modify_time},modify_user_id = #{modify_user_id}
 <trim prefix="where" prefixOverrides="and">
        <if test="begindate != null and begindate != ''"> and begindate = #{begindate} </if>
            <if test="cremcode != null and cremcode != ''"> and cremcode = #{cremcode} </if>
            <if test="def1 != null and def1 != ''"> and def1 = #{def1} </if>
            <if test="def10 != null and def10 != ''"> and def10 = #{def10} </if>
            <if test="def11 != null and def11 != ''"> and def11 = #{def11} </if>
            <if test="def12 != null and def12 != ''"> and def12 = #{def12} </if>
            <if test="def13 != null and def13 != ''"> and def13 = #{def13} </if>
            <if test="def14 != null and def14 != ''"> and def14 = #{def14} </if>
            <if test="def15 != null and def15 != ''"> and def15 = #{def15} </if>
            <if test="def16 != null and def16 != ''"> and def16 = #{def16} </if>
            <if test="def17 != null and def17 != ''"> and def17 = #{def17} </if>
            <if test="def18 != null and def18 != ''"> and def18 = #{def18} </if>
            <if test="def19 != null and def19 != ''"> and def19 = #{def19} </if>
            <if test="def2 != null and def2 != ''"> and def2 = #{def2} </if>
            <if test="def20 != null and def20 != ''"> and def20 = #{def20} </if>
            <if test="def3 != null and def3 != ''"> and def3 = #{def3} </if>
            <if test="def4 != null and def4 != ''"> and def4 = #{def4} </if>
            <if test="def5 != null and def5 != ''"> and def5 = #{def5} </if>
            <if test="def6 != null and def6 != ''"> and def6 = #{def6} </if>
            <if test="def7 != null and def7 != ''"> and def7 = #{def7} </if>
            <if test="def8 != null and def8 != ''"> and def8 = #{def8} </if>
            <if test="def9 != null and def9 != ''"> and def9 = #{def9} </if>
            <if test="dr != null"> and dr = #{dr} </if>
            <if test="enddate != null and enddate != ''"> and enddate = #{enddate} </if>
            <if test="finishedflag != null and finishedflag != ''"> and finishedflag = #{finishedflag} </if>
            <if test="forecastenddate != null and forecastenddate != ''"> and forecastenddate = #{forecastenddate} </if>
            <if test="jobcode != null and jobcode != ''"> and jobcode = #{jobcode} </if>
            <if test="jobname != null and jobname != ''"> and jobname = #{jobname} </if>
            <if test="pkCorp != null and pkCorp != ''"> and pk_corp = #{pkCorp} </if>
            <if test="pkJobbasfil != null and pkJobbasfil != ''"> and pk_jobbasfil = #{pkJobbasfil} </if>
            <if test="pkJobcl != null and pkJobcl != ''"> and pk_jobcl = #{pkJobcl} </if>
            <if test="pkJobtype != null and pkJobtype != ''"> and pk_jobtype = #{pkJobtype} </if>
            <if test="sealflag != null and sealflag != ''"> and sealflag = #{sealflag} </if>
            <if test="ts != null and ts != ''"> and ts = #{ts} </if>
            and sts='Y'
    </trim>
</update>
<!--通过主键删除-->
<delete id="entity_delete">
    delete from bd_jobbasfil where pk_jobbasfil = #{pkJobbasfil}
</delete>

    <!--第二个版本-->
    <select id="queryProjectBasicArchivesByTypeDIY" parameterType="com.hzya.frame.plugin.lets.queryvo.ExtBdJobbasfilQueryVo" resultMap="queryProjectBasicArchivesByTypeDIYResultMap">
        SELECT
            bj.begindate,
            bj.cremcode,
            bj.def1,
            bj.def10,--业务中心(项目基本档案主键)
            bd3.docname def10name,--业务中心名称
            bj.def11,--品牌
            bj3.jobname def11name,--品牌名称
            bj.def12,
            bj.def13,
            bj.def14,
            bj.def15,
            bj.def16,
            bj.def17,
            bj.def18,
            bj.def19,
            bj.def2, -- 公司主键
            bj.def20,
            bj.def3,
            bj.def4,-- 店铺对应客商
            bcd0c.custcode shopCorrCustCode,
            bcd0c.custname shopCorrCustName,
            bj.def5,
            bj.def6,--存牌
            bd.docname def6name,--存货品牌名称
            bj.def7,--旺店通店铺主键
            bd2.docname def7name,--旺店通店铺名称
            bd2.doccode def7code,--旺店通店铺名称
            bj.def8,--业务平台
            bj4.jobname def8name,--业务平台名称
            bj.def9,-- 业务模式
            bd4.docname def9name,--业务模式名称
            bj.dr,
            bj.enddate,
            bj.finishedflag,
            bj.forecastenddate,
            bj.jobcode,
            bj.jobname,
            bj.pk_corp,
            bj.pk_jobbasfil,
            bj.pk_jobcl,
            bj.pk_jobtype,
            bj.sealflag,
            bj.ts,
            bj.def20,
            bj.pk_jobbasfil,
            bj2.pk_jobbasfil u8cShopId,--U8C店铺
            bj2.jobcode u8cShopCode,
            bj2.jobname u8cShopName,
            bj2.def2 u8cShopCoptId, -- U8C店铺对应公司主键
            bc.unitcode u8cShopCoptCode, -- U8C店铺对应公司编码
            bc.unitname u8cShopCoptName --U8C店铺对应公司名称
        FROM
            bd_jobbasfil bj
                LEFT JOIN bd_defdoc bd ON bd.pk_defdoc = bj.def6
                LEFT JOIN bd_defdoc bd2 ON bd2.pk_defdoc = bj.def7
                LEFT JOIN bd_defdoc bd3 ON bd3.pk_defdoc = bj.def10
                LEFT JOIN bd_defdoc bd4 ON bd4.pk_defdoc = bj.def9
                LEFT JOIN bd_jobbasfil bj2 ON bj2.jobname = bj.jobname
                AND bj2.dr = 0
                -- 类型：旺店通店铺
                <if test="typeShop!=null and typeShop!=''">
                    AND bj2.pk_jobtype  = #{typeShop}
                </if>
                <if test="filterCode!=null and filterCode!=''">
                    AND bj2.jobcode!= #{filterCode}
                </if>
        LEFT JOIN bd_jobbasfil bj3️ on bj3️.pk_jobbasfil = bj.def11
        AND bj3️.dr = 0
        -- 类型：品牌
        <if test="typeBrand!=null and typeBrand!=''">
            AND bj3.pk_jobtype  = #{typeBrand}
        </if>
        <if test="filterCode!=null and filterCode!=''">
            AND bj3.jobcode!= #{filterCode}
        </if>
        LEFT JOIN bd_jobbasfil bj4 on bj4.pk_jobbasfil = bj.def8
        AND bj4.dr = 0
        <if test="typePlatform!=null and typePlatform!=''">
            AND bj4.pk_jobtype = #{typePlatform} -- 类型：业务平台
        </if>
        left join bd_corp bc on bc.pk_corp = bj2.def2
        AND bc.dr = 0
        LEFT JOIN bd_cubasdoc bcd0c on bcd0c.pk_cubasdoc = bj.def4
        WHERE
        1 = 1
        <if test="typeDiy!=null and typeDiy!=''">
            AND bj.pk_jobtype = #{typeDiy} -- 项目基本档案：自定义档案映射
        </if>
        <if test="typeDiyName!=null and typeDiyName!=''">
            AND bj.jobname = #{typeDiyName}
        </if>
        <if test="def7name!=null and def7name!=''">
            and bd.docname = #{def7name}
        </if>
        <if test="def6name!=null and def6name!=''">
            and bd2.docname = #{def6name}
        </if>
        <if test="jobcode!=null and jobcode!=''">
            and bj.jobcode = #{jobcode}
        </if>
        <if test="pk_jobbasfil!=null and pk_jobbasfil!=''">
            and bj.pk_jobbasfil = #{pk_jobbasfil}
        </if>
            ORDER BY
                bj.jobcode;
    </select>


    <!--第二个版本-->
    <select id="queryProjectBasicArchivesByTypeDIYV2" parameterType="com.hzya.frame.plugin.lets.queryvo.ExtBdJobbasfilQueryVo" resultMap="queryProjectBasicArchivesByTypeDIYResultMap">
        SELECT
        bj.begindate,
        bj.cremcode,
        bj.def1,
        bj.def10,
        bd3.docname def10name,
        bj.def11,
        bj3.jobname def11name,
        bj.def12,
        bj.def13,
        bj.def14,
        bj.def15,
        bj.def16,
        bj.def17,
        bj.def18,
        bj.def19,
        bj.def2,
        bj.def20,
        bj.def3,
        bj.def4,
        bcd0c.custcode shopCorrCustCode,
        bcd0c.custname shopCorrCustName,
        bj.def5,
        bj.def6,
        bd.docname def6name,
        bj.def7,
        bd2.docname def7name,
        bd2.doccode def7code,
        bj.def8,
        bj4.jobname def8name,
        bj.def9,
        bd4.docname def9name,
        bj.dr,
        bj.enddate,
        bj.finishedflag,
        bj.forecastenddate,
        bj.jobcode,
        bj.jobname,
        bj.pk_corp,
        bj.pk_jobbasfil,
        bj.pk_jobcl,
        bj.pk_jobtype,
        bj.sealflag,
        bj.ts,
        bj2.pk_jobbasfil u8cShopId,
        bj2.jobcode u8cShopCode,
        bj2.jobname u8cShopName,
        bj2.def2 u8cShopCoptId,
        bc.unitcode u8cShopCoptCode,
        bc.unitname u8cShopCoptName
        FROM
        bd_jobbasfil bj
        LEFT JOIN bd_defdoc bd ON bd.pk_defdoc = bj.def6
        LEFT JOIN bd_defdoc bd2 ON bd2.pk_defdoc = bj.def7
        LEFT JOIN bd_defdoc bd3 ON bd3.pk_defdoc = bj.def10
        LEFT JOIN bd_defdoc bd4 ON bd4.pk_defdoc = bj.def9
        LEFT JOIN bd_jobbasfil bj2 ON bj2.jobname = bj.jobname
        AND bj2.dr = 0
        <if test="typeShop!=null and typeShop!=''">
            AND bj2.pk_jobtype  = #{typeShop}
        </if>
        <if test="filterCode!=null and filterCode!=''">
            AND bj2.jobcode!= #{filterCode}
        </if>
        LEFT JOIN bd_jobbasfil bj3️ on bj3️.pk_jobbasfil = bj.def11
        AND bj3️.dr = 0
        <if test="typeBrand!=null and typeBrand!=''">
            AND bj3.pk_jobtype  = #{typeBrand}
        </if>
        <if test="filterCode!=null and filterCode!=''">
            AND bj3.jobcode!= #{filterCode}
        </if>
        LEFT JOIN bd_jobbasfil bj4 on bj4.pk_jobbasfil = bj.def8
        AND bj4.dr = 0
        <if test="typePlatform!=null and typePlatform!=''">
            AND bj4.pk_jobtype = #{typePlatform}
        </if>
        left join bd_corp bc on bc.pk_corp = bj2.def2
        AND bc.dr = 0
        LEFT JOIN bd_cubasdoc bcd0c on bcd0c.pk_cubasdoc = bj.def4
        WHERE
        1 = 1
        <if test="typeDiy!=null and typeDiy!=''">
            AND bj.pk_jobtype = #{typeDiy}
        </if>
        <if test="typeDiyName!=null and typeDiyName!=''">
            AND bj.jobname = #{typeDiyName}
        </if>
        <if test="def7name!=null and def7name!=''">
            and bd2.docname = #{def7name}
        </if>
        <if test="def6name!=null and def6name!=''">
            and bd.docname = #{def6name}
        </if>
        <if test="jobcode!=null and jobcode!=''">
            and bj.jobcode = #{jobcode}
        </if>
        <if test="pk_jobbasfil!=null and pk_jobbasfil!=''">
            and bj.pk_jobbasfil = #{pk_jobbasfil}
        </if>
        ORDER BY
        bj.jobcode;
    </select>

    <resultMap id="queryProjectBasicArchivesByTypeDIYResultMap" type="com.hzya.frame.plugin.lets.resultvo.ExtBdJobbasfilResultVo" >
        <result property="begindate" column="begindate" jdbcType="VARCHAR"/>
        <result property="cremcode" column="cremcode" jdbcType="VARCHAR"/>
        <result property="def1" column="def1" jdbcType="VARCHAR"/>
        <result property="def10" column="def10" jdbcType="VARCHAR"/>
        <result property="def11" column="def11" jdbcType="VARCHAR"/>
        <result property="def12" column="def12" jdbcType="VARCHAR"/>
        <result property="def13" column="def13" jdbcType="VARCHAR"/>
        <result property="def14" column="def14" jdbcType="VARCHAR"/>
        <result property="def15" column="def15" jdbcType="VARCHAR"/>
        <result property="def16" column="def16" jdbcType="VARCHAR"/>
        <result property="def17" column="def17" jdbcType="VARCHAR"/>
        <result property="def18" column="def18" jdbcType="VARCHAR"/>
        <result property="def19" column="def19" jdbcType="VARCHAR"/>
        <result property="def2" column="def2" jdbcType="VARCHAR"/>
        <result property="def20" column="def20" jdbcType="VARCHAR"/>
        <result property="def3" column="def3" jdbcType="VARCHAR"/>
        <result property="def4" column="def4" jdbcType="VARCHAR"/>
        <result property="def5" column="def5" jdbcType="VARCHAR"/>
        <result property="def6" column="def6" jdbcType="VARCHAR"/>
        <result property="def7" column="def7" jdbcType="VARCHAR"/>
        <result property="def8" column="def8" jdbcType="VARCHAR"/>
        <result property="def9" column="def9" jdbcType="VARCHAR"/>
        <result property="dr" column="dr" jdbcType="INTEGER"/>
        <result property="enddate" column="enddate" jdbcType="VARCHAR"/>
        <result property="finishedflag" column="finishedflag" jdbcType="VARCHAR"/>
        <result property="forecastenddate" column="forecastenddate" jdbcType="VARCHAR"/>
        <result property="jobcode" column="jobcode" jdbcType="VARCHAR"/>
        <result property="jobname" column="jobname" jdbcType="VARCHAR"/>
        <result property="pkCorp" column="pk_corp" jdbcType="VARCHAR"/>
        <result property="pkJobbasfil" column="pk_jobbasfil" jdbcType="VARCHAR"/>
        <result property="pkJobcl" column="pk_jobcl" jdbcType="VARCHAR"/>
        <result property="pkJobtype" column="pk_jobtype" jdbcType="VARCHAR"/>
        <result property="sealflag" column="sealflag" jdbcType="VARCHAR"/>
        <result property="ts" column="ts" jdbcType="VARCHAR"/>

        <result property="def10name" column="def10name" jdbcType="VARCHAR"/>
        <result property="def11name" column="def11name" jdbcType="VARCHAR"/>
        <result property="def6name" column="def6name" jdbcType="VARCHAR"/>
        <result property="def7name" column="def7name" jdbcType="VARCHAR"/>
        <result property="def7code" column="def7code" jdbcType="VARCHAR"/>
        <result property="def8name" column="def8name" jdbcType="VARCHAR"/>
        <result property="def9name" column="def9name" jdbcType="VARCHAR"/>
        <result property="u8cShopId" column="u8cShopId" jdbcType="VARCHAR"/>
        <result property="u8cShopCode" column="u8cShopCode" jdbcType="VARCHAR"/>
        <result property="u8cShopName" column="u8cShopName" jdbcType="VARCHAR"/>

        <result property="shopCorrCustCode" column="shopCorrCustCode" jdbcType="VARCHAR"/>
        <result property="shopCorrCustName" column="shopCorrCustName" jdbcType="VARCHAR"/>

        <result property="u8cShopCoptId" column="u8cShopCoptId" jdbcType="VARCHAR"/>
        <result property="u8cShopCoptCode" column="u8cShopCoptCode" jdbcType="VARCHAR"/>
        <result property="u8cShopCoptName" column="u8cShopCoptName" jdbcType="VARCHAR"/>
    </resultMap>
</mapper>
