<?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.steerinfo.ems.tcmtimedefinition.mapper.TCmTimeDefinitionMapper">
  <resultMap id="BaseResultMap" type="com.steerinfo.ems.tcmtimedefinition.model.TCmTimeDefinition">
    <id column="DEFID" jdbcType="VARCHAR" property="defid" />
    <result column="DEFNAME" jdbcType="VARCHAR" property="defname" />
    <result column="TIMEGRANID" jdbcType="VARCHAR" property="timegranid" />
    <result column="STANDUNIT" jdbcType="VARCHAR" property="standunit" />
    <result column="BASEUNIT" jdbcType="VARCHAR" property="baseunit" />
    <result column="CALCTYPE" jdbcType="VARCHAR" property="calctype" />
    <result column="INTERVAL" jdbcType="VARCHAR" property="interval" />
    <result column="STARTFORMAT" jdbcType="VARCHAR" property="startformat" />
    <result column="ENDFORMAT" jdbcType="VARCHAR" property="endformat" />
    <result column="TIMEFORMAT" jdbcType="VARCHAR" property="timeformat" />
    <result column="EXTRAINFO" jdbcType="VARCHAR" property="extrainfo" />
    <result column="GRANDEFAULT" jdbcType="VARCHAR" property="grandefault" />
    <result column="OFFSETINFO" jdbcType="VARCHAR" property="offsetinfo" />
    <result column="CREATEMAN" jdbcType="VARCHAR" property="createman" />
    <result column="CREATETIME" jdbcType="TIMESTAMP" property="createtime" />
    <result column="UPDATEMAN" jdbcType="VARCHAR" property="updateman" />
    <result column="UPDATETIME" jdbcType="TIMESTAMP" property="updatetime" />
  </resultMap>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    delete from T_CM_TIME_DEFINITION
    where DEFID = #{defid,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteBySelectiveElement" parameterType="java.util.HashMap">
    delete from T_CM_TIME_DEFINITION
    where 1=1
      <if test="defname != null and defname != ''">
        and DEFNAME = #{defname}
      </if>
      <if test="timegranid != null and timegranid != ''">
        and TIMEGRANID = #{timegranid}
      </if>
      <if test="standunit != null and standunit != ''">
        and STANDUNIT = #{standunit}
      </if>
      <if test="baseunit != null and baseunit != ''">
        and BASEUNIT = #{baseunit}
      </if>
      <if test="calctype != null and calctype != ''">
        and CALCTYPE = #{calctype}
      </if>
      <if test="interval != null and interval != ''">
        and INTERVAL = #{interval}
      </if>
      <if test="startformat != null and startformat != ''">
        and STARTFORMAT = #{startformat}
      </if>
      <if test="endformat != null and endformat != ''">
        and ENDFORMAT = #{endformat}
      </if>
      <if test="timeformat != null and timeformat != ''">
        and TIMEFORMAT = #{timeformat}
      </if>
      <if test="extrainfo != null and extrainfo != ''">
        and EXTRAINFO = #{extrainfo}
      </if>
      <if test="grandefault != null and grandefault != ''">
        and GRANDEFAULT = #{grandefault}
      </if>
      <if test="offsetinfo != null and offsetinfo != ''">
        and OFFSETINFO = #{offsetinfo}
      </if>
  </delete>
  <insert id="insert" parameterType="com.steerinfo.ems.tcmtimedefinition.model.TCmTimeDefinition">
    insert into T_CM_TIME_DEFINITION (DEFID, DEFNAME, TIMEGRANID, 
      STANDUNIT, BASEUNIT, CALCTYPE, 
      INTERVAL, STARTFORMAT, ENDFORMAT, 
      TIMEFORMAT, EXTRAINFO, GRANDEFAULT, 
      OFFSETINFO, CREATEMAN, CREATETIME)
    values (#{defid,jdbcType=VARCHAR}, #{defname,jdbcType=VARCHAR}, #{timegranid,jdbcType=VARCHAR}, 
      #{standunit,jdbcType=VARCHAR}, #{baseunit,jdbcType=VARCHAR}, #{calctype,jdbcType=VARCHAR}, 
      #{interval,jdbcType=VARCHAR}, #{startformat,jdbcType=VARCHAR}, #{endformat,jdbcType=VARCHAR}, 
      #{timeformat,jdbcType=VARCHAR}, #{extrainfo,jdbcType=VARCHAR}, #{grandefault,jdbcType=VARCHAR}, 
      #{offsetinfo,jdbcType=VARCHAR}, #{createman,jdbcType=VARCHAR}, SYSDATE)
  </insert>
  <insert id="insertSelective" parameterType="com.steerinfo.ems.tcmtimedefinition.model.TCmTimeDefinition">
    insert into T_CM_TIME_DEFINITION
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="defid != null">
        DEFID,
      </if>
      <if test="defname != null">
        DEFNAME,
      </if>
      <if test="timegranid != null">
        TIMEGRANID,
      </if>
      <if test="standunit != null">
        STANDUNIT,
      </if>
      <if test="baseunit != null">
        BASEUNIT,
      </if>
      <if test="calctype != null">
        CALCTYPE,
      </if>
      <if test="interval != null">
        INTERVAL,
      </if>
      <if test="startformat != null">
        STARTFORMAT,
      </if>
      <if test="endformat != null">
        ENDFORMAT,
      </if>
      <if test="timeformat != null">
        TIMEFORMAT,
      </if>
      <if test="extrainfo != null">
        EXTRAINFO,
      </if>
      <if test="grandefault != null">
        GRANDEFAULT,
      </if>
      <if test="offsetinfo != null">
        OFFSETINFO,
      </if>
        CREATEMAN,
        CREATETIME
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="defid != null">
        #{defid,jdbcType=VARCHAR},
      </if>
      <if test="defname != null">
        #{defname,jdbcType=VARCHAR},
      </if>
      <if test="timegranid != null">
        #{timegranid,jdbcType=VARCHAR},
      </if>
      <if test="standunit != null">
        #{standunit,jdbcType=VARCHAR},
      </if>
      <if test="baseunit != null">
        #{baseunit,jdbcType=VARCHAR},
      </if>
      <if test="calctype != null">
        #{calctype,jdbcType=VARCHAR},
      </if>
      <if test="interval != null">
        #{interval,jdbcType=VARCHAR},
      </if>
      <if test="startformat != null">
        #{startformat,jdbcType=VARCHAR},
      </if>
      <if test="endformat != null">
        #{endformat,jdbcType=VARCHAR},
      </if>
      <if test="timeformat != null">
        #{timeformat,jdbcType=VARCHAR},
      </if>
      <if test="extrainfo != null">
        #{extrainfo,jdbcType=VARCHAR},
      </if>
      <if test="grandefault != null">
        #{grandefault,jdbcType=VARCHAR},
      </if>
      <if test="offsetinfo != null">
        #{offsetinfo,jdbcType=VARCHAR},
      </if>
        #{createman,jdbcType=VARCHAR},
        SYSDATE
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.steerinfo.ems.tcmtimedefinition.model.TCmTimeDefinition">
    update T_CM_TIME_DEFINITION
    set DEFNAME = #{defname,jdbcType=VARCHAR},
      TIMEGRANID = #{timegranid,jdbcType=VARCHAR},
      STANDUNIT = #{standunit,jdbcType=VARCHAR},
      BASEUNIT = #{baseunit,jdbcType=VARCHAR},
      CALCTYPE = #{calctype,jdbcType=VARCHAR},
      INTERVAL = #{interval,jdbcType=VARCHAR},
      STARTFORMAT = #{startformat,jdbcType=VARCHAR},
      ENDFORMAT = #{endformat,jdbcType=VARCHAR},
      TIMEFORMAT = #{timeformat,jdbcType=VARCHAR},
      EXTRAINFO = #{extrainfo,jdbcType=VARCHAR},
      GRANDEFAULT = #{grandefault,jdbcType=VARCHAR},
      OFFSETINFO = #{offsetinfo,jdbcType=VARCHAR},
      UPDATEMAN = #{updateman, jdbcType=VARCHAR},
      UPDATETIME = SYSDATE
    where DEFID = #{defid,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.steerinfo.ems.tcmtimedefinition.model.TCmTimeDefinition">
    update T_CM_TIME_DEFINITION
    <set>
      <if test="defname != null">
        DEFNAME = #{defname,jdbcType=VARCHAR},
      </if>
      <if test="timegranid != null">
        TIMEGRANID = #{timegranid,jdbcType=VARCHAR},
      </if>
      <if test="standunit != null">
        STANDUNIT = #{standunit,jdbcType=VARCHAR},
      </if>
      <if test="baseunit != null">
        BASEUNIT = #{baseunit,jdbcType=VARCHAR},
      </if>
      <if test="calctype != null">
        CALCTYPE = #{calctype,jdbcType=VARCHAR},
      </if>
      <if test="interval != null">
        INTERVAL = #{interval,jdbcType=VARCHAR},
      </if>
      <if test="startformat != null">
        STARTFORMAT = #{startformat,jdbcType=VARCHAR},
      </if>
      <if test="endformat != null">
        ENDFORMAT = #{endformat,jdbcType=VARCHAR},
      </if>
      <if test="timeformat != null">
        TIMEFORMAT = #{timeformat,jdbcType=VARCHAR},
      </if>
      <if test="extrainfo != null">
        EXTRAINFO = #{extrainfo,jdbcType=VARCHAR},
      </if>
      <if test="grandefault != null">
        GRANDEFAULT = #{grandefault,jdbcType=VARCHAR},
      </if>
      <if test="offsetinfo != null">
        OFFSETINFO = #{offsetinfo,jdbcType=VARCHAR},
      </if>
        UPDATEMAN = #{updateman, jdbcType=VARCHAR},
        UPDATETIME = SYSDATE
    </set>
    where DEFID = #{defid,jdbcType=VARCHAR}
  </update>
  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
    select DEFID, DEFNAME, TIMEGRANID, STANDUNIT, BASEUNIT, CALCTYPE, INTERVAL, STARTFORMAT, 
    ENDFORMAT, TIMEFORMAT, EXTRAINFO, GRANDEFAULT, OFFSETINFO, CREATEMAN, CREATETIME, UPDATEMAN, UPDATETIME
    from T_CM_TIME_DEFINITION
    where DEFID = #{defid,jdbcType=VARCHAR}
  </select>
  <select id="selectByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
    select DEFID, DEFNAME, TIMEGRANID, STANDUNIT, BASEUNIT, CALCTYPE, INTERVAL, STARTFORMAT, 
    ENDFORMAT, TIMEFORMAT, EXTRAINFO, GRANDEFAULT, OFFSETINFO, CREATEMAN, CREATETIME, UPDATEMAN, UPDATETIME
    from T_CM_TIME_DEFINITION
    <where>
      <if test="defid != null and defid != ''">
        and DEFID = #{defid}
      </if>
      <if test="defname != null and defname != ''">
        and DEFNAME = #{defname}
      </if>
      <if test="timegranid != null and timegranid != ''">
        and TIMEGRANID = #{timegranid}
      </if>
      <if test="standunit != null and standunit != ''">
        and STANDUNIT = #{standunit}
      </if>
      <if test="baseunit != null and baseunit != ''">
        and BASEUNIT = #{baseunit}
      </if>
      <if test="calctype != null and calctype != ''">
        and CALCTYPE = #{calctype}
      </if>
      <if test="interval != null and interval != ''">
        and INTERVAL = #{interval}
      </if>
      <if test="startformat != null and startformat != ''">
        and STARTFORMAT = #{startformat}
      </if>
      <if test="endformat != null and endformat != ''">
        and ENDFORMAT = #{endformat}
      </if>
      <if test="timeformat != null and timeformat != ''">
        and TIMEFORMAT = #{timeformat}
      </if>
      <if test="extrainfo != null and extrainfo != ''">
        and EXTRAINFO = #{extrainfo}
      </if>
      <if test="grandefault != null and grandefault != ''">
        and GRANDEFAULT = #{grandefault}
      </if>
      <if test="offsetinfo != null and offsetinfo != ''">
        and OFFSETINFO = #{offsetinfo}
      </if>
    </where>
  </select>
  <select id="selectLikeByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
    select DEFID, DEFNAME, TIMEGRANID, STANDUNIT, BASEUNIT, CALCTYPE, INTERVAL, STARTFORMAT, 
    ENDFORMAT, TIMEFORMAT, EXTRAINFO, GRANDEFAULT, OFFSETINFO, CREATEMAN, CREATETIME, UPDATEMAN, UPDATETIME
    from T_CM_TIME_DEFINITION
    <where>
      <if test="defid != null and defid != ''">
        and DEFID LIKE '%${defid}%'
      </if>
      <if test="defname != null and defname != ''">
        and DEFNAME LIKE '%${defname}%'
      </if>
      <if test="timegranid != null and timegranid != ''">
        and TIMEGRANID = #{timegranid}
      </if>
      <if test="standunit != null and standunit != ''">
        and STANDUNIT LIKE '%${standunit}%'
      </if>
      <if test="baseunit != null and baseunit != ''">
        and BASEUNIT LIKE '%${baseunit}%'
      </if>
      <if test="calctype != null and calctype != ''">
        and CALCTYPE LIKE '%${calctype}%'
      </if>
      <if test="interval != null and interval != ''">
        and INTERVAL LIKE '%${interval}%'
      </if>
      <if test="startformat != null and startformat != ''">
        and STARTFORMAT LIKE '%${startformat}%'
      </if>
      <if test="endformat != null and endformat != ''">
        and ENDFORMAT LIKE '%${endformat}%'
      </if>
      <if test="timeformat != null and timeformat != ''">
        and TIMEFORMAT LIKE '%${timeformat}%'
      </if>
      <if test="extrainfo != null and extrainfo != ''">
        and EXTRAINFO LIKE '%${extrainfo}%'
      </if>
      <if test="grandefault != null and grandefault != ''">
        and GRANDEFAULT LIKE '%${grandefault}%'
      </if>
      <if test="offsetinfo != null and offsetinfo != ''">
        and OFFSETINFO LIKE '%${offsetinfo}%'
      </if>
    </where>
  </select>
  <insert id="batchInsert" parameterType="java.util.List">
    insert into T_CM_TIME_DEFINITION 
      (DEFID, 
      DEFNAME, TIMEGRANID, STANDUNIT, 
      BASEUNIT, CALCTYPE, INTERVAL, 
      STARTFORMAT, ENDFORMAT, TIMEFORMAT, 
      EXTRAINFO, GRANDEFAULT, OFFSETINFO, CREATEMAN, CREATETIME
      )
    ( <foreach collection="list" item="item" separator="union all"> 
   select  
      #{item.defid,jdbcType=VARCHAR}, 
      #{item.defname,jdbcType=VARCHAR}, #{item.timegranid,jdbcType=VARCHAR}, #{item.standunit,jdbcType=VARCHAR}, 
      #{item.baseunit,jdbcType=VARCHAR}, #{item.calctype,jdbcType=VARCHAR}, #{item.interval,jdbcType=VARCHAR}, 
      #{item.startformat,jdbcType=VARCHAR}, #{item.endformat,jdbcType=VARCHAR}, #{item.timeformat,jdbcType=VARCHAR}, 
      #{item.extrainfo,jdbcType=VARCHAR}, #{item.grandefault,jdbcType=VARCHAR}, #{item.offsetinfo,jdbcType=VARCHAR},
      #{item.createman,jdbcType=VARCHAR}, SYSDATE
       from dual  
   </foreach> )
  </insert>
  <update id="batchUpdate" parameterType="java.util.List">
     update T_CM_TIME_DEFINITION
     set
       DEFID=
       <foreach collection="list" item="item" index="index" separator=" " open="case DEFID" close="end">
          when #{item.defid,jdbcType=VARCHAR} then #{item.defid,jdbcType=VARCHAR}
       </foreach>
       ,DEFNAME=
       <foreach collection="list" item="item" index="index" separator=" " open="case DEFID" close="end">
          when #{item.defid,jdbcType=VARCHAR} then #{item.defname,jdbcType=VARCHAR}
       </foreach>
       ,TIMEGRANID=
       <foreach collection="list" item="item" index="index" separator=" " open="case DEFID" close="end">
          when #{item.defid,jdbcType=VARCHAR} then #{item.timegranid,jdbcType=VARCHAR}
       </foreach>
       ,STANDUNIT=
       <foreach collection="list" item="item" index="index" separator=" " open="case DEFID" close="end">
          when #{item.defid,jdbcType=VARCHAR} then #{item.standunit,jdbcType=VARCHAR}
       </foreach>
       ,BASEUNIT=
       <foreach collection="list" item="item" index="index" separator=" " open="case DEFID" close="end">
          when #{item.defid,jdbcType=VARCHAR} then #{item.baseunit,jdbcType=VARCHAR}
       </foreach>
       ,CALCTYPE=
       <foreach collection="list" item="item" index="index" separator=" " open="case DEFID" close="end">
          when #{item.defid,jdbcType=VARCHAR} then #{item.calctype,jdbcType=VARCHAR}
       </foreach>
       ,INTERVAL=
       <foreach collection="list" item="item" index="index" separator=" " open="case DEFID" close="end">
          when #{item.defid,jdbcType=VARCHAR} then #{item.interval,jdbcType=VARCHAR}
       </foreach>
       ,STARTFORMAT=
       <foreach collection="list" item="item" index="index" separator=" " open="case DEFID" close="end">
          when #{item.defid,jdbcType=VARCHAR} then #{item.startformat,jdbcType=VARCHAR}
       </foreach>
       ,ENDFORMAT=
       <foreach collection="list" item="item" index="index" separator=" " open="case DEFID" close="end">
          when #{item.defid,jdbcType=VARCHAR} then #{item.endformat,jdbcType=VARCHAR}
       </foreach>
       ,TIMEFORMAT=
       <foreach collection="list" item="item" index="index" separator=" " open="case DEFID" close="end">
          when #{item.defid,jdbcType=VARCHAR} then #{item.timeformat,jdbcType=VARCHAR}
       </foreach>
       ,EXTRAINFO=
       <foreach collection="list" item="item" index="index" separator=" " open="case DEFID" close="end">
          when #{item.defid,jdbcType=VARCHAR} then #{item.extrainfo,jdbcType=VARCHAR}
       </foreach>
       ,GRANDEFAULT=
       <foreach collection="list" item="item" index="index" separator=" " open="case DEFID" close="end">
          when #{item.defid,jdbcType=VARCHAR} then #{item.grandefault,jdbcType=VARCHAR}
       </foreach>
       ,OFFSETINFO=
       <foreach collection="list" item="item" index="index" separator=" " open="case DEFID" close="end">
          when #{item.defid,jdbcType=VARCHAR} then #{item.offsetinfo,jdbcType=VARCHAR}
       </foreach>
        ,UPDATEMAN=
        <foreach collection="list" item="item" index="index" separator=" " open="case DEFID" close="end">
            when #{item.defid,jdbcType=VARCHAR} then #{item.updateman,jdbcType=VARCHAR}
        </foreach>
        ,UPDATETIME=
        <foreach collection="list" item="item" index="index" separator=" " open="case DEFID" close="end">
            when #{item.defid,jdbcType=VARCHAR} then SYSDATE
        </foreach>
     where DEFID in 
     <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
        #{item.defid,jdbcType=VARCHAR}
     </foreach> 
  </update>
  <delete id="batchDelete" parameterType="java.util.List">
    delete from T_CM_TIME_DEFINITION
    where DEFID in 
    <foreach collection="list" item="id" open="(" close=")" separator=",">
      #{id}
    </foreach>
  </delete>
</mapper>