<?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.emr.dao.ExportTaskMapper">
  <resultMap id="BaseResultMap" type="com.emr.entity.ExportTask">
    <id column="task_id" jdbcType="INTEGER" property="taskId" />
    <result column="task_name" jdbcType="VARCHAR" property="taskName" />
    <result column="state" jdbcType="INTEGER" property="state" />
    <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
  </resultMap>
  <sql id="Base_Column_List">
    task_id, task_name, state,create_date
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from Export_Task
    where task_id = #{taskId,jdbcType=INTEGER}
  </select>
  <select id="getExportTaskByName" resultType="com.emr.entity.ExportTask">
    select
    <include refid="Base_Column_List" />
    from Export_Task
    where task_name = #{taskName}

  </select>
  <select id="getExportTaskList" resultType="com.emr.vo.ExportTaskVo">
    select
    task_id as taskId,
    task_name as taskName,
    state,
    create_date as createDate
    from Export_Task
    where 1 =1
    <if test="record.taskName != null and record.taskName != ''">
       and task_name  like '%${record.taskName}%'
    </if>
    <if test="startTime != '' and startTime != null">
      AND CONVERT ( VARCHAR ( 100 ), create_date, 23 )  &gt;=  #{startTime}
      <if test="endTime != '' and endTime != null">
        AND CONVERT ( VARCHAR ( 100 ), create_date, 23 )  &lt;= #{endTime}
      </if>
    </if>
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from Export_Task
    where task_id = #{taskId,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.emr.entity.ExportTask">
    insert into Export_Task (task_id, task_name, state,create_date
      )
    values (#{taskId,jdbcType=INTEGER}, #{taskName,jdbcType=VARCHAR}, #{state,jdbcType=INTEGER}, #{createDate,jdbcType=TIMESTAMP}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.emr.entity.ExportTask">
    insert into Export_Task
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="taskId != null">
        task_id,
      </if>
      <if test="taskName != null">
        task_name,
      </if>
      <if test="state != null">
        state,
      </if>
      <if test="state != null">
        create_date,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="taskId != null">
        #{taskId,jdbcType=INTEGER},
      </if>
      <if test="taskName != null">
        #{taskName,jdbcType=VARCHAR},
      </if>
      <if test="state != null">
        #{state,jdbcType=INTEGER},
      </if>
      <if test="createDate != null">
        #{createDate,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.emr.entity.ExportTask">
    update Export_Task
    <set>
      <if test="taskName != null">
        task_name = #{taskName,jdbcType=VARCHAR},
      </if>
      <if test="state != null">
        state = #{state,jdbcType=INTEGER},
      </if>
      <if test="state != null">
        create_date = #{createDate,jdbcType=INTEGER},
      </if>
    </set>
    where task_id = #{taskId,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.emr.entity.ExportTask">
    update Export_Task
    set task_name = #{taskName,jdbcType=VARCHAR},
      state = #{state,jdbcType=INTEGER}
    where task_id = #{taskId,jdbcType=INTEGER}
  </update>
 </mapper>