<?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.meterwork.meterworktask.mapper.MeterWorkTaskMapper">
  <resultMap id="BaseResultMap" type="com.steerinfo.meterwork.meterworktask.model.MeterWorkTask">
    <id column="TASK_ID" jdbcType="VARCHAR" property="taskId" />
    <result column="TASK_TYPE_NO" jdbcType="VARCHAR" property="taskTypeNo" />
    <result column="TASK_TYPE_NAME" jdbcType="VARCHAR" property="taskTypeName" />
    <result column="TASK_CONTENT" jdbcType="VARCHAR" property="taskContent" />
    <result column="RECEIVER" jdbcType="VARCHAR" property="receiver" />
    <result column="PUBLISH_TIME" jdbcType="TIMESTAMP" property="publishTime" />
    <result column="STATE" jdbcType="VARCHAR" property="state" />
    <result column="HANDLE_RESULT" jdbcType="VARCHAR" property="handleResult" />
    <result column="HANDLE_TIME" jdbcType="TIMESTAMP" property="handleTime" />
  </resultMap>
  <sql id="columns">
    TASK_ID, TASK_TYPE_NO, TASK_TYPE_NAME, TASK_CONTENT, RECEIVER, PUBLISH_TIME, STATE, 
    HANDLE_RESULT, HANDLE_TIME
  </sql>
  <sql id="columns_alias">
    t.TASK_ID, t.TASK_TYPE_NO, t.TASK_TYPE_NAME, t.TASK_CONTENT, t.RECEIVER, t.PUBLISH_TIME, 
    t.STATE, t.HANDLE_RESULT, t.HANDLE_TIME
  </sql>
  <sql id="select">
    SELECT <include refid="columns"/> FROM METER_WORK_TASK
  </sql>
  <sql id="select_alias">
    SELECT <include refid="columns_alias"/> FROM METER_WORK_TASK t
  </sql>
  <sql id="where">
    <where> 
      <if test="taskId != null and taskId != ''">
        and TASK_ID = #{taskId}
      </if>
      <if test="taskTypeNo != null and taskTypeNo != ''">
        and TASK_TYPE_NO = #{taskTypeNo}
      </if>
      <if test="taskTypeName != null and taskTypeName != ''">
        and TASK_TYPE_NAME = #{taskTypeName}
      </if>
      <if test="taskContent != null and taskContent != ''">
        and TASK_CONTENT = #{taskContent}
      </if>
      <if test="receiver != null and receiver != ''">
        and RECEIVER = #{receiver}
      </if>
      <if test="publishTime != null">
        and TO_CHAR(PUBLISH_TIME,'yyyy-MM-dd') = #{publishTime}
      </if>
      <if test="state != null and state != ''">
        and STATE = #{state}
      </if>
      <if test="handleResult != null and handleResult != ''">
        and HANDLE_RESULT = #{handleResult}
      </if>
      <if test="handleTime != null">
        and TO_CHAR(HANDLE_TIME,'yyyy-MM-dd') = #{handleTime}
      </if>
    </where>
  </sql>
  <sql id="whereLike">
    <where> 
      <if test="taskId != null and taskId != ''">
        and TASK_ID LIKE '%${taskId}%'
      </if>
      <if test="taskTypeNo != null and taskTypeNo != ''">
        and TASK_TYPE_NO LIKE '%${taskTypeNo}%'
      </if>
      <if test="taskTypeName != null and taskTypeName != ''">
        and TASK_TYPE_NAME LIKE '%${taskTypeName}%'
      </if>
      <if test="taskContent != null and taskContent != ''">
        and TASK_CONTENT LIKE '%${taskContent}%'
      </if>
      <if test="receiver != null and receiver != ''">
        and RECEIVER LIKE '%${receiver}%'
      </if>
      <if test="publishTime != null">
        and TO_CHAR(PUBLISH_TIME,'yyyy-MM-dd') = #{publishTime}
      </if>
      <if test="state != null and state != ''">
        and STATE LIKE '%${state}%'
      </if>
      <if test="handleResult != null and handleResult != ''">
        and HANDLE_RESULT LIKE '%${handleResult}%'
      </if>
      <if test="handleTime != null">
        and TO_CHAR(HANDLE_TIME,'yyyy-MM-dd') = #{handleTime}
      </if>
    </where>
  </sql>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    delete from METER_WORK_TASK
    where TASK_ID = #{taskId,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteBySelectiveElement" parameterType="java.util.HashMap">
    delete from METER_WORK_TASK
    where 1!=1 
      <if test="taskTypeNo != null and taskTypeNo != ''">
        or TASK_TYPE_NO = #{taskTypeNo}
      </if>
      <if test="taskTypeName != null and taskTypeName != ''">
        or TASK_TYPE_NAME = #{taskTypeName}
      </if>
      <if test="taskContent != null and taskContent != ''">
        or TASK_CONTENT = #{taskContent}
      </if>
      <if test="receiver != null and receiver != ''">
        or RECEIVER = #{receiver}
      </if>
      <if test="publishTime != null">
        or TO_CHAR(PUBLISH_TIME,'yyyy-MM-dd') = '#{publishTime}'
      </if>
      <if test="state != null and state != ''">
        or STATE = #{state}
      </if>
      <if test="handleResult != null and handleResult != ''">
        or HANDLE_RESULT = #{handleResult}
      </if>
      <if test="handleTime != null">
        or TO_CHAR(HANDLE_TIME,'yyyy-MM-dd') = '#{handleTime}'
      </if>
  </delete>
  <insert id="insert" parameterType="com.steerinfo.meterwork.meterworktask.model.MeterWorkTask">
    insert into METER_WORK_TASK (TASK_ID, TASK_TYPE_NO, TASK_TYPE_NAME, 
      TASK_CONTENT, RECEIVER, PUBLISH_TIME, 
      STATE, HANDLE_RESULT, HANDLE_TIME
      )
    values (#{taskId,jdbcType=VARCHAR}, #{taskTypeNo,jdbcType=VARCHAR}, #{taskTypeName,jdbcType=VARCHAR}, 
      #{taskContent,jdbcType=VARCHAR}, #{receiver,jdbcType=VARCHAR}, #{publishTime,jdbcType=TIMESTAMP}, 
      #{state,jdbcType=VARCHAR}, #{handleResult,jdbcType=VARCHAR}, #{handleTime,jdbcType=TIMESTAMP}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.steerinfo.meterwork.meterworktask.model.MeterWorkTask">
    insert into METER_WORK_TASK
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="taskId != null">
        TASK_ID,
      </if>
      <if test="taskTypeNo != null">
        TASK_TYPE_NO,
      </if>
      <if test="taskTypeName != null">
        TASK_TYPE_NAME,
      </if>
      <if test="taskContent != null">
        TASK_CONTENT,
      </if>
      <if test="receiver != null">
        RECEIVER,
      </if>
      <if test="publishTime != null">
        PUBLISH_TIME,
      </if>
      <if test="state != null">
        STATE,
      </if>
      <if test="handleResult != null">
        HANDLE_RESULT,
      </if>
      <if test="handleTime != null">
        HANDLE_TIME,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="taskId != null">
        #{taskId,jdbcType=VARCHAR},
      </if>
      <if test="taskTypeNo != null">
        #{taskTypeNo,jdbcType=VARCHAR},
      </if>
      <if test="taskTypeName != null">
        #{taskTypeName,jdbcType=VARCHAR},
      </if>
      <if test="taskContent != null">
        #{taskContent,jdbcType=VARCHAR},
      </if>
      <if test="receiver != null">
        #{receiver,jdbcType=VARCHAR},
      </if>
      <if test="publishTime != null">
        #{publishTime,jdbcType=TIMESTAMP},
      </if>
      <if test="state != null">
        #{state,jdbcType=VARCHAR},
      </if>
      <if test="handleResult != null">
        #{handleResult,jdbcType=VARCHAR},
      </if>
      <if test="handleTime != null">
        #{handleTime,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.steerinfo.meterwork.meterworktask.model.MeterWorkTask">
    update METER_WORK_TASK
    set TASK_TYPE_NO = #{taskTypeNo,jdbcType=VARCHAR},
      TASK_TYPE_NAME = #{taskTypeName,jdbcType=VARCHAR},
      TASK_CONTENT = #{taskContent,jdbcType=VARCHAR},
      RECEIVER = #{receiver,jdbcType=VARCHAR},
      PUBLISH_TIME = #{publishTime,jdbcType=TIMESTAMP},
      STATE = #{state,jdbcType=VARCHAR},
      HANDLE_RESULT = #{handleResult,jdbcType=VARCHAR},
      HANDLE_TIME = #{handleTime,jdbcType=TIMESTAMP}
    where TASK_ID = #{taskId,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.steerinfo.meterwork.meterworktask.model.MeterWorkTask">
    update METER_WORK_TASK
    <set>
      <if test="taskTypeNo != null">
        TASK_TYPE_NO = #{taskTypeNo,jdbcType=VARCHAR},
      </if>
      <if test="taskTypeName != null">
        TASK_TYPE_NAME = #{taskTypeName,jdbcType=VARCHAR},
      </if>
      <if test="taskContent != null">
        TASK_CONTENT = #{taskContent,jdbcType=VARCHAR},
      </if>
      <if test="receiver != null">
        RECEIVER = #{receiver,jdbcType=VARCHAR},
      </if>
      <if test="publishTime != null">
        PUBLISH_TIME = #{publishTime,jdbcType=TIMESTAMP},
      </if>
      <if test="state != null">
        STATE = #{state,jdbcType=VARCHAR},
      </if>
      <if test="handleResult != null">
        HANDLE_RESULT = #{handleResult,jdbcType=VARCHAR},
      </if>
      <if test="handleTime != null">
        HANDLE_TIME = #{handleTime,jdbcType=TIMESTAMP},
      </if>
    </set>
    where TASK_ID = #{taskId,jdbcType=VARCHAR}
  </update>
  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
    <include refid="select"/>
    where TASK_ID = #{taskId,jdbcType=VARCHAR}
  </select>
  <select id="selectByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
    <include refid="select"/>
    <include refid="where"/>
  </select>
  <select id="selectLikeByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
    <include refid="select"/>
    <include refid="whereLike"/>
  </select>
  <insert id="batchInsert" parameterType="java.util.List">
    insert into METER_WORK_TASK 
      (TASK_ID, 
      TASK_TYPE_NO, TASK_TYPE_NAME, TASK_CONTENT, 
      RECEIVER, PUBLISH_TIME, STATE, 
      HANDLE_RESULT, HANDLE_TIME)
    ( <foreach collection="list" item="item" separator="union all"> 
   select  
      #{item.taskId,jdbcType=VARCHAR}, 
      #{item.taskTypeNo,jdbcType=VARCHAR}, #{item.taskTypeName,jdbcType=VARCHAR}, #{item.taskContent,jdbcType=VARCHAR}, 
      #{item.receiver,jdbcType=VARCHAR}, #{item.publishTime,jdbcType=TIMESTAMP}, #{item.state,jdbcType=VARCHAR}, 
      #{item.handleResult,jdbcType=VARCHAR}, #{item.handleTime,jdbcType=TIMESTAMP} from dual  
   </foreach> )
  </insert>
  <update id="batchUpdate" parameterType="java.util.List">
     update METER_WORK_TASK
     set
       TASK_ID=
       <foreach collection="list" item="item" index="index" separator=" " open="case TASK_ID" close="end">
          when #{item.taskId,jdbcType=VARCHAR} then #{item.taskId,jdbcType=VARCHAR}
       </foreach>
       ,TASK_TYPE_NO=
       <foreach collection="list" item="item" index="index" separator=" " open="case TASK_ID" close="end">
          when #{item.taskId,jdbcType=VARCHAR} then #{item.taskTypeNo,jdbcType=VARCHAR}
       </foreach>
       ,TASK_TYPE_NAME=
       <foreach collection="list" item="item" index="index" separator=" " open="case TASK_ID" close="end">
          when #{item.taskId,jdbcType=VARCHAR} then #{item.taskTypeName,jdbcType=VARCHAR}
       </foreach>
       ,TASK_CONTENT=
       <foreach collection="list" item="item" index="index" separator=" " open="case TASK_ID" close="end">
          when #{item.taskId,jdbcType=VARCHAR} then #{item.taskContent,jdbcType=VARCHAR}
       </foreach>
       ,RECEIVER=
       <foreach collection="list" item="item" index="index" separator=" " open="case TASK_ID" close="end">
          when #{item.taskId,jdbcType=VARCHAR} then #{item.receiver,jdbcType=VARCHAR}
       </foreach>
       ,PUBLISH_TIME=
       <foreach collection="list" item="item" index="index" separator=" " open="case TASK_ID" close="end">
          when #{item.taskId,jdbcType=VARCHAR} then #{item.publishTime,jdbcType=TIMESTAMP}
       </foreach>
       ,STATE=
       <foreach collection="list" item="item" index="index" separator=" " open="case TASK_ID" close="end">
          when #{item.taskId,jdbcType=VARCHAR} then #{item.state,jdbcType=VARCHAR}
       </foreach>
       ,HANDLE_RESULT=
       <foreach collection="list" item="item" index="index" separator=" " open="case TASK_ID" close="end">
          when #{item.taskId,jdbcType=VARCHAR} then #{item.handleResult,jdbcType=VARCHAR}
       </foreach>
       ,HANDLE_TIME=
       <foreach collection="list" item="item" index="index" separator=" " open="case TASK_ID" close="end">
          when #{item.taskId,jdbcType=VARCHAR} then #{item.handleTime,jdbcType=TIMESTAMP}
       </foreach>
     where TASK_ID in 
     <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
    #{item.taskId,jdbcType=VARCHAR}
     </foreach> 
  </update>
  <delete id="batchDelete" parameterType="java.util.List">
    delete from METER_WORK_TASK
    where TASK_ID in 
    <foreach collection="list" item="id" open="(" close=")" separator=",">
      #{id}
    </foreach>
  </delete>
  <!-- 友情提示！！！-->
  <!-- 请将自己写的代码放在此标签之下，方便以后粘贴复制。-->
  
</mapper>