<?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.meterworkrailwayscheduledhelp.mapper.MeterWorkRailwayScheduledHelpMapper">
  <resultMap id="BaseResultMap" type="com.steerinfo.meterwork.meterworkrailwayscheduledhelp.model.MeterWorkRailwayScheduledHelp">
    <id column="HELP_ID" jdbcType="VARCHAR" property="helpId" />
    <result column="RAILWAY_NO" jdbcType="VARCHAR" property="railwayNo" />
    <result column="HELP_CONTENT" jdbcType="VARCHAR" property="helpContent" />
    <result column="CREATE_TIME" jdbcType="TIMESTAMP" property="createTime" />
    <result column="END_TIME" jdbcType="TIMESTAMP" property="endTime" />
    <result column="CREATE_NO" jdbcType="VARCHAR" property="createNo" />
    <result column="CREATE_NAME" jdbcType="VARCHAR" property="createName" />
    <result column="RESULT" jdbcType="VARCHAR" property="result" />
    <result column="VALUE_FLAG" jdbcType="VARCHAR" property="valueFlag" />
    <result column="BASE_SPOT_NO" jdbcType="VARCHAR" property="baseSpotNo" />
    <result column="BASE_SPOT_NAME" jdbcType="VARCHAR" property="baseSpotName" />
    <result column="MEASURE_TASK_NUM" jdbcType="VARCHAR" property="measureTaskNum" />
    <result column="WARM_TYPE" jdbcType="VARCHAR" property="warmType" />
    <result column="WARM_TYPE_NAME" jdbcType="VARCHAR" property="warmTypeName" />
  </resultMap>
  <sql id="columns">
    HELP_ID, RAILWAY_NO, HELP_CONTENT, CREATE_TIME, END_TIME, CREATE_NO, CREATE_NAME, 
    RESULT, VALUE_FLAG, BASE_SPOT_NO, BASE_SPOT_NAME, MEASURE_TASK_NUM, WARM_TYPE, WARM_TYPE_NAME
  </sql>
  <sql id="columns_alias">
    t.HELP_ID, t.RAILWAY_NO, t.HELP_CONTENT, t.CREATE_TIME, t.END_TIME, t.CREATE_NO, 
    t.CREATE_NAME, t.RESULT, t.VALUE_FLAG, t.BASE_SPOT_NO, t.BASE_SPOT_NAME, t.MEASURE_TASK_NUM, 
    t.WARM_TYPE, t.WARM_TYPE_NAME
  </sql>
  <sql id="select">
    SELECT <include refid="columns"/> FROM METER_WORK_RAILWAY_SCHEDULED_HELP
  </sql>
  <sql id="select_alias">
    SELECT <include refid="columns_alias"/> FROM METER_WORK_RAILWAY_SCHEDULED_HELP t
  </sql>
  <sql id="where">
    <where> 
      <if test="helpId != null and helpId != ''">
        and HELP_ID = #{helpId}
      </if>
      <if test="railwayNo != null and railwayNo != ''">
        and RAILWAY_NO = #{railwayNo}
      </if>
      <if test="helpContent != null and helpContent != ''">
        and HELP_CONTENT = #{helpContent}
      </if>
      <if test="createTime != null">
        and TO_CHAR(CREATE_TIME,'yyyy-MM-dd') = #{createTime}
      </if>
      <if test="endTime != null">
        and TO_CHAR(END_TIME,'yyyy-MM-dd') = #{endTime}
      </if>
      <if test="createNo != null and createNo != ''">
        and CREATE_NO = #{createNo}
      </if>
      <if test="createName != null and createName != ''">
        and CREATE_NAME = #{createName}
      </if>
      <if test="result != null and result != ''">
        and RESULT = #{result}
      </if>
      <if test="valueFlag != null and valueFlag != ''">
        and VALUE_FLAG = #{valueFlag}
      </if>
      <if test="baseSpotNo != null and baseSpotNo != ''">
        and BASE_SPOT_NO = #{baseSpotNo}
      </if>
      <if test="baseSpotName != null and baseSpotName != ''">
        and BASE_SPOT_NAME = #{baseSpotName}
      </if>
      <if test="measureTaskNum != null and measureTaskNum != ''">
        and MEASURE_TASK_NUM = #{measureTaskNum}
      </if>
      <if test="warmType != null and warmType != ''">
        and WARM_TYPE = #{warmType}
      </if>
      <if test="warmTypeName != null and warmTypeName != ''">
        and WARM_TYPE_NAME = #{warmTypeName}
      </if>
    </where>
  </sql>
  <sql id="whereLike">
    <where> 
      <if test="helpId != null and helpId != ''">
        and HELP_ID LIKE '%${helpId}%'
      </if>
      <if test="railwayNo != null and railwayNo != ''">
        and RAILWAY_NO LIKE '%${railwayNo}%'
      </if>
      <if test="helpContent != null and helpContent != ''">
        and HELP_CONTENT LIKE '%${helpContent}%'
      </if>
      <if test="createTime != null">
        and TO_CHAR(CREATE_TIME,'yyyy-MM-dd') = #{createTime}
      </if>
      <if test="endTime != null">
        and TO_CHAR(END_TIME,'yyyy-MM-dd') = #{endTime}
      </if>
      <if test="createNo != null and createNo != ''">
        and CREATE_NO LIKE '%${createNo}%'
      </if>
      <if test="createName != null and createName != ''">
        and CREATE_NAME LIKE '%${createName}%'
      </if>
      <if test="result != null and result != ''">
        and RESULT LIKE '%${result}%'
      </if>
      <if test="valueFlag != null and valueFlag != ''">
        and VALUE_FLAG LIKE '%${valueFlag}%'
      </if>
      <if test="baseSpotNo != null and baseSpotNo != ''">
        and BASE_SPOT_NO LIKE '%${baseSpotNo}%'
      </if>
      <if test="baseSpotName != null and baseSpotName != ''">
        and BASE_SPOT_NAME LIKE '%${baseSpotName}%'
      </if>
      <if test="measureTaskNum != null and measureTaskNum != ''">
        and MEASURE_TASK_NUM LIKE '%${measureTaskNum}%'
      </if>
      <if test="warmType != null and warmType != ''">
        and WARM_TYPE LIKE '%${warmType}%'
      </if>
      <if test="warmTypeName != null and warmTypeName != ''">
        and WARM_TYPE_NAME LIKE '%${warmTypeName}%'
      </if>
    </where>
  </sql>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    delete from METER_WORK_RAILWAY_SCHEDULED_HELP
    where HELP_ID = #{helpId,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteBySelectiveElement" parameterType="java.util.HashMap">
    delete from METER_WORK_RAILWAY_SCHEDULED_HELP
    where 1!=1 
      <if test="railwayNo != null and railwayNo != ''">
        or RAILWAY_NO = #{railwayNo}
      </if>
      <if test="helpContent != null and helpContent != ''">
        or HELP_CONTENT = #{helpContent}
      </if>
      <if test="createTime != null">
        or TO_CHAR(CREATE_TIME,'yyyy-MM-dd') = '#{createTime}'
      </if>
      <if test="endTime != null">
        or TO_CHAR(END_TIME,'yyyy-MM-dd') = '#{endTime}'
      </if>
      <if test="createNo != null and createNo != ''">
        or CREATE_NO = #{createNo}
      </if>
      <if test="createName != null and createName != ''">
        or CREATE_NAME = #{createName}
      </if>
      <if test="result != null and result != ''">
        or RESULT = #{result}
      </if>
      <if test="valueFlag != null and valueFlag != ''">
        or VALUE_FLAG = #{valueFlag}
      </if>
      <if test="baseSpotNo != null and baseSpotNo != ''">
        or BASE_SPOT_NO = #{baseSpotNo}
      </if>
      <if test="baseSpotName != null and baseSpotName != ''">
        or BASE_SPOT_NAME = #{baseSpotName}
      </if>
      <if test="measureTaskNum != null and measureTaskNum != ''">
        or MEASURE_TASK_NUM = #{measureTaskNum}
      </if>
      <if test="warmType != null and warmType != ''">
        or WARM_TYPE = #{warmType}
      </if>
      <if test="warmTypeName != null and warmTypeName != ''">
        or WARM_TYPE_NAME = #{warmTypeName}
      </if>
  </delete>
  <insert id="insert" parameterType="com.steerinfo.meterwork.meterworkrailwayscheduledhelp.model.MeterWorkRailwayScheduledHelp">
    insert into METER_WORK_RAILWAY_SCHEDULED_HELP (HELP_ID, RAILWAY_NO, HELP_CONTENT, 
      CREATE_TIME, END_TIME, CREATE_NO, 
      CREATE_NAME, RESULT, VALUE_FLAG, 
      BASE_SPOT_NO, BASE_SPOT_NAME, MEASURE_TASK_NUM, 
      WARM_TYPE, WARM_TYPE_NAME)
    values (#{helpId,jdbcType=VARCHAR}, #{railwayNo,jdbcType=VARCHAR}, #{helpContent,jdbcType=VARCHAR}, 
      #{createTime,jdbcType=TIMESTAMP}, #{endTime,jdbcType=TIMESTAMP}, #{createNo,jdbcType=VARCHAR}, 
      #{createName,jdbcType=VARCHAR}, #{result,jdbcType=VARCHAR}, #{valueFlag,jdbcType=VARCHAR}, 
      #{baseSpotNo,jdbcType=VARCHAR}, #{baseSpotName,jdbcType=VARCHAR}, #{measureTaskNum,jdbcType=VARCHAR}, 
      #{warmType,jdbcType=VARCHAR}, #{warmTypeName,jdbcType=VARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.steerinfo.meterwork.meterworkrailwayscheduledhelp.model.MeterWorkRailwayScheduledHelp">
    insert into METER_WORK_RAILWAY_SCHEDULED_HELP
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="helpId != null">
        HELP_ID,
      </if>
      <if test="railwayNo != null">
        RAILWAY_NO,
      </if>
      <if test="helpContent != null">
        HELP_CONTENT,
      </if>
      <if test="createTime != null">
        CREATE_TIME,
      </if>
      <if test="endTime != null">
        END_TIME,
      </if>
      <if test="createNo != null">
        CREATE_NO,
      </if>
      <if test="createName != null">
        CREATE_NAME,
      </if>
      <if test="result != null">
        RESULT,
      </if>
      <if test="valueFlag != null">
        VALUE_FLAG,
      </if>
      <if test="baseSpotNo != null">
        BASE_SPOT_NO,
      </if>
      <if test="baseSpotName != null">
        BASE_SPOT_NAME,
      </if>
      <if test="measureTaskNum != null">
        MEASURE_TASK_NUM,
      </if>
      <if test="warmType != null">
        WARM_TYPE,
      </if>
      <if test="warmTypeName != null">
        WARM_TYPE_NAME,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="helpId != null">
        #{helpId,jdbcType=VARCHAR},
      </if>
      <if test="railwayNo != null">
        #{railwayNo,jdbcType=VARCHAR},
      </if>
      <if test="helpContent != null">
        #{helpContent,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="endTime != null">
        #{endTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createNo != null">
        #{createNo,jdbcType=VARCHAR},
      </if>
      <if test="createName != null">
        #{createName,jdbcType=VARCHAR},
      </if>
      <if test="result != null">
        #{result,jdbcType=VARCHAR},
      </if>
      <if test="valueFlag != null">
        #{valueFlag,jdbcType=VARCHAR},
      </if>
      <if test="baseSpotNo != null">
        #{baseSpotNo,jdbcType=VARCHAR},
      </if>
      <if test="baseSpotName != null">
        #{baseSpotName,jdbcType=VARCHAR},
      </if>
      <if test="measureTaskNum != null">
        #{measureTaskNum,jdbcType=VARCHAR},
      </if>
      <if test="warmType != null">
        #{warmType,jdbcType=VARCHAR},
      </if>
      <if test="warmTypeName != null">
        #{warmTypeName,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.steerinfo.meterwork.meterworkrailwayscheduledhelp.model.MeterWorkRailwayScheduledHelp">
    update METER_WORK_RAILWAY_SCHEDULED_HELP
    set RAILWAY_NO = #{railwayNo,jdbcType=VARCHAR},
      HELP_CONTENT = #{helpContent,jdbcType=VARCHAR},
      CREATE_TIME = #{createTime,jdbcType=TIMESTAMP},
      END_TIME = #{endTime,jdbcType=TIMESTAMP},
      CREATE_NO = #{createNo,jdbcType=VARCHAR},
      CREATE_NAME = #{createName,jdbcType=VARCHAR},
      RESULT = #{result,jdbcType=VARCHAR},
      VALUE_FLAG = #{valueFlag,jdbcType=VARCHAR},
      BASE_SPOT_NO = #{baseSpotNo,jdbcType=VARCHAR},
      BASE_SPOT_NAME = #{baseSpotName,jdbcType=VARCHAR},
      MEASURE_TASK_NUM = #{measureTaskNum,jdbcType=VARCHAR},
      WARM_TYPE = #{warmType,jdbcType=VARCHAR},
      WARM_TYPE_NAME = #{warmTypeName,jdbcType=VARCHAR}
    where HELP_ID = #{helpId,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.steerinfo.meterwork.meterworkrailwayscheduledhelp.model.MeterWorkRailwayScheduledHelp">
    update METER_WORK_RAILWAY_SCHEDULED_HELP
    <set>
      <if test="railwayNo != null">
        RAILWAY_NO = #{railwayNo,jdbcType=VARCHAR},
      </if>
      <if test="helpContent != null">
        HELP_CONTENT = #{helpContent,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        CREATE_TIME = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="endTime != null">
        END_TIME = #{endTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createNo != null">
        CREATE_NO = #{createNo,jdbcType=VARCHAR},
      </if>
      <if test="createName != null">
        CREATE_NAME = #{createName,jdbcType=VARCHAR},
      </if>
      <if test="result != null">
        RESULT = #{result,jdbcType=VARCHAR},
      </if>
      <if test="valueFlag != null">
        VALUE_FLAG = #{valueFlag,jdbcType=VARCHAR},
      </if>
      <if test="baseSpotNo != null">
        BASE_SPOT_NO = #{baseSpotNo,jdbcType=VARCHAR},
      </if>
      <if test="baseSpotName != null">
        BASE_SPOT_NAME = #{baseSpotName,jdbcType=VARCHAR},
      </if>
      <if test="measureTaskNum != null">
        MEASURE_TASK_NUM = #{measureTaskNum,jdbcType=VARCHAR},
      </if>
      <if test="warmType != null">
        WARM_TYPE = #{warmType,jdbcType=VARCHAR},
      </if>
      <if test="warmTypeName != null">
        WARM_TYPE_NAME = #{warmTypeName,jdbcType=VARCHAR},
      </if>
    </set>
    where HELP_ID = #{helpId,jdbcType=VARCHAR}
  </update>
  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
    <include refid="select"/>
    where HELP_ID = #{helpId,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_RAILWAY_SCHEDULED_HELP 
      (HELP_ID, 
      RAILWAY_NO, HELP_CONTENT, CREATE_TIME, 
      END_TIME, CREATE_NO, CREATE_NAME, 
      RESULT, VALUE_FLAG, BASE_SPOT_NO, 
      BASE_SPOT_NAME, MEASURE_TASK_NUM, 
      WARM_TYPE, WARM_TYPE_NAME)
    ( <foreach collection="list" item="item" separator="union all"> 
   select  
      #{item.helpId,jdbcType=VARCHAR}, 
      #{item.railwayNo,jdbcType=VARCHAR}, #{item.helpContent,jdbcType=VARCHAR}, #{item.createTime,jdbcType=TIMESTAMP}, 
      #{item.endTime,jdbcType=TIMESTAMP}, #{item.createNo,jdbcType=VARCHAR}, #{item.createName,jdbcType=VARCHAR}, 
      #{item.result,jdbcType=VARCHAR}, #{item.valueFlag,jdbcType=VARCHAR}, #{item.baseSpotNo,jdbcType=VARCHAR}, 
      #{item.baseSpotName,jdbcType=VARCHAR}, #{item.measureTaskNum,jdbcType=VARCHAR}, 
      #{item.warmType,jdbcType=VARCHAR}, #{item.warmTypeName,jdbcType=VARCHAR} from dual  
   </foreach> )
  </insert>
  <update id="batchUpdate" parameterType="java.util.List">
     update METER_WORK_RAILWAY_SCHEDULED_HELP
     set
       HELP_ID=
       <foreach collection="list" item="item" index="index" separator=" " open="case HELP_ID" close="end">
          when #{item.helpId,jdbcType=VARCHAR} then #{item.helpId,jdbcType=VARCHAR}
       </foreach>
       ,RAILWAY_NO=
       <foreach collection="list" item="item" index="index" separator=" " open="case HELP_ID" close="end">
          when #{item.helpId,jdbcType=VARCHAR} then #{item.railwayNo,jdbcType=VARCHAR}
       </foreach>
       ,HELP_CONTENT=
       <foreach collection="list" item="item" index="index" separator=" " open="case HELP_ID" close="end">
          when #{item.helpId,jdbcType=VARCHAR} then #{item.helpContent,jdbcType=VARCHAR}
       </foreach>
       ,CREATE_TIME=
       <foreach collection="list" item="item" index="index" separator=" " open="case HELP_ID" close="end">
          when #{item.helpId,jdbcType=VARCHAR} then #{item.createTime,jdbcType=TIMESTAMP}
       </foreach>
       ,END_TIME=
       <foreach collection="list" item="item" index="index" separator=" " open="case HELP_ID" close="end">
          when #{item.helpId,jdbcType=VARCHAR} then #{item.endTime,jdbcType=TIMESTAMP}
       </foreach>
       ,CREATE_NO=
       <foreach collection="list" item="item" index="index" separator=" " open="case HELP_ID" close="end">
          when #{item.helpId,jdbcType=VARCHAR} then #{item.createNo,jdbcType=VARCHAR}
       </foreach>
       ,CREATE_NAME=
       <foreach collection="list" item="item" index="index" separator=" " open="case HELP_ID" close="end">
          when #{item.helpId,jdbcType=VARCHAR} then #{item.createName,jdbcType=VARCHAR}
       </foreach>
       ,RESULT=
       <foreach collection="list" item="item" index="index" separator=" " open="case HELP_ID" close="end">
          when #{item.helpId,jdbcType=VARCHAR} then #{item.result,jdbcType=VARCHAR}
       </foreach>
       ,VALUE_FLAG=
       <foreach collection="list" item="item" index="index" separator=" " open="case HELP_ID" close="end">
          when #{item.helpId,jdbcType=VARCHAR} then #{item.valueFlag,jdbcType=VARCHAR}
       </foreach>
       ,BASE_SPOT_NO=
       <foreach collection="list" item="item" index="index" separator=" " open="case HELP_ID" close="end">
          when #{item.helpId,jdbcType=VARCHAR} then #{item.baseSpotNo,jdbcType=VARCHAR}
       </foreach>
       ,BASE_SPOT_NAME=
       <foreach collection="list" item="item" index="index" separator=" " open="case HELP_ID" close="end">
          when #{item.helpId,jdbcType=VARCHAR} then #{item.baseSpotName,jdbcType=VARCHAR}
       </foreach>
       ,MEASURE_TASK_NUM=
       <foreach collection="list" item="item" index="index" separator=" " open="case HELP_ID" close="end">
          when #{item.helpId,jdbcType=VARCHAR} then #{item.measureTaskNum,jdbcType=VARCHAR}
       </foreach>
       ,WARM_TYPE=
       <foreach collection="list" item="item" index="index" separator=" " open="case HELP_ID" close="end">
          when #{item.helpId,jdbcType=VARCHAR} then #{item.warmType,jdbcType=VARCHAR}
       </foreach>
       ,WARM_TYPE_NAME=
       <foreach collection="list" item="item" index="index" separator=" " open="case HELP_ID" close="end">
          when #{item.helpId,jdbcType=VARCHAR} then #{item.warmTypeName,jdbcType=VARCHAR}
       </foreach>
     where HELP_ID in 
     <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
    #{item.helpId,jdbcType=VARCHAR}
     </foreach> 
  </update>
  <delete id="batchDelete" parameterType="java.util.List">
    delete from METER_WORK_RAILWAY_SCHEDULED_HELP
    where HELP_ID in 
    <foreach collection="list" item="id" open="(" close=")" separator=",">
      #{id}
    </foreach>
  </delete>
  <!-- 友情提示！！！-->
  <!-- 请将自己写的代码放在此标签之下，方便以后粘贴复制。-->
  <select id="getNewID" parameterType="java.lang.String" resultType="java.lang.String">
    SELECT LPAD(NVL(MAX(TO_NUMBER(SUBSTR(HELP_ID, LENGTH(HELP_ID) - 3))),0) + 1,4,'0') HELP_ID
    FROM meter_work_railway_scheduled_help where instr(HELP_ID,#{afl,jdbcType=VARCHAR})>0
  </select>
</mapper>