<?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.tcm0349.mapper.TCm0349Mapper">
  <resultMap id="BaseResultMap" type="com.steerinfo.ems.tcm0349.model.TCm0349">
    <id column="CHANGENO" jdbcType="VARCHAR" property="changeno" />
    <result column="RECORDID" jdbcType="VARCHAR" property="recordid" />
    <result column="BILLSTATUS" jdbcType="VARCHAR" property="billstatus" />
    <result column="CHANGEDESC" jdbcType="VARCHAR" property="changedesc" />
    <result column="CHANGEREASON" jdbcType="VARCHAR" property="changereason" />
    <result column="CREATTIME" jdbcType="VARCHAR" property="creattime" />
    <result column="MEDIUMTYPE" jdbcType="VARCHAR" property="mediumtype" />
    <result column="NOTE" jdbcType="VARCHAR" property="note" />
    <result column="RECMAN" jdbcType="VARCHAR" property="recman" />
    <result column="RECTIME" jdbcType="VARCHAR" property="rectime" />
    <result column="RESPMAN" jdbcType="VARCHAR" property="respman" />
    <result column="RESPUNIT" jdbcType="VARCHAR" property="respunit" />
    <result column="TEL" jdbcType="VARCHAR" property="tel" />
  </resultMap>

  <select id="selectByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
    select CHANGENO, RECORDID, BILLSTATUS, CHANGEDESC, CHANGEREASON, CREATTIME, MEDIUMTYPE,
    NOTE, RECMAN, RECTIME, RESPMAN, RESPUNIT, TEL
    from T_CM_0349
    <where>
      <if test="changeno != null and changeno != ''">
        and CHANGENO like '%${changeno}%'
      </if>
      <if test="mediumtype != null and mediumtype != ''">
        and MEDIUMTYPE = #{mediumtype}
      </if>
      <if test="recman != null and recman != ''">
        and RECMAN like '%${recman}%'
      </if>
      <if test="respman != null and respman != ''">
        and RESPMAN like '%${respman}%'
      </if>
      <if test="respunit != null and respunit != ''">
        and RESPUNIT like '%${respunit}%'
      </if>
      <if test="billstatus != null and billstatus != ''">
        and BILLSTATUS = #{billstatus}
      </if>
      <if test="creattime != null and creattime != ''">
        and CREATTIME &gt;= #{creattime}
      </if>
      <if test="creattimee != null and creattimee != ''">
        and CREATTIME &lt;= #{creattimee}
      </if>
      <if test="rectime != null and rectime != ''">
        and RECTIME &gt;= #{rectime}
      </if>
      <if test="rectimee != null and rectimee != ''">
        and RECTIME &lt;= #{rectimee}
      </if>
    </where>
  </select>

  <update id="updateByPrimaryKeySelective" parameterType="com.steerinfo.ems.tcm0349.model.TCm0349">
    update T_CM_0349
    <set>
      <if test="billstatus != null">
        BILLSTATUS = #{billstatus,jdbcType=VARCHAR},
      </if>
      <if test="changedesc != null">
        CHANGEDESC = #{changedesc,jdbcType=VARCHAR},
      </if>
      <if test="changereason != null">
        CHANGEREASON = #{changereason,jdbcType=VARCHAR},
      </if>
      <if test="creattime != null">
        CREATTIME = #{creattime,jdbcType=VARCHAR},
      </if>
      <if test="mediumtype != null">
        MEDIUMTYPE = #{mediumtype,jdbcType=VARCHAR},
      </if>
      <if test="note != null">
        NOTE = #{note,jdbcType=VARCHAR},
      </if>
      <if test="recman != null">
        RECMAN = #{recman,jdbcType=VARCHAR},
      </if>
      <if test="rectime != null">
        RECTIME = #{rectime,jdbcType=VARCHAR},
      </if>
      <if test="respman != null">
        RESPMAN = #{respman,jdbcType=VARCHAR},
      </if>
      <if test="respunit != null">
        RESPUNIT = #{respunit,jdbcType=VARCHAR},
      </if>
      <if test="tel != null">
        TEL = #{tel,jdbcType=VARCHAR},
      </if>
    </set>
    where CHANGENO = #{changeno,jdbcType=VARCHAR}
  </update>

  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
    select CHANGENO, RECORDID, BILLSTATUS, CHANGEDESC, CHANGEREASON, CREATTIME, MEDIUMTYPE,
    NOTE, RECMAN, RECTIME, RESPMAN, RESPUNIT, TEL
    from T_CM_0349
    where CHANGENO = #{changeno,jdbcType=VARCHAR}
  </select>

  <insert id="insert" parameterType="com.steerinfo.ems.tcm0349.model.TCm0349">
    insert into T_CM_0349 (CHANGENO, RECORDID, BILLSTATUS, CHANGEDESC, CHANGEREASON,
        CREATTIME, MEDIUMTYPE, NOTE, RECMAN, RECTIME, RESPMAN, RESPUNIT, TEL)
    values (#{changeno,jdbcType=VARCHAR}, #{recordid,jdbcType=VARCHAR}, #{billstatus,jdbcType=VARCHAR},
      #{changedesc,jdbcType=VARCHAR}, #{changereason,jdbcType=VARCHAR}, #{creattime,jdbcType=VARCHAR},
      #{mediumtype,jdbcType=VARCHAR}, #{note,jdbcType=VARCHAR}, #{recman,jdbcType=VARCHAR},
      #{rectime,jdbcType=VARCHAR}, #{respman,jdbcType=VARCHAR}, #{respunit,jdbcType=VARCHAR}, #{tel,jdbcType=VARCHAR})
  </insert>

  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    delete from T_CM_0349
    where CHANGENO = #{changeno,jdbcType=VARCHAR}
  </delete>

  <delete id="batchDelete" parameterType="java.util.List">
    delete from T_CM_0349
    where CHANGENO in
    <foreach collection="list" item="id" open="(" close=")" separator=",">
      #{id}
    </foreach>
  </delete>

  <select id="getMaxId" resultType="java.lang.String">
    SELECT MAX(SUBSTR(CHANGENO, LENGTH(CHANGENO) - 3)) FROM T_CM_0349
  </select>

  <!--
  <delete id="deleteBySelectiveElement" parameterType="java.util.HashMap">
    delete from T_CM_0349
    where 1!=1 
      <if test="recordid != null">
        and RECORDID = #{recordid}
      </if>
      <if test="billstatus != null and billstatus != ''">
        and BILLSTATUS = #{billstatus}
      </if>
      <if test="changedesc != null and changedesc != ''">
        and CHANGEDESC = #{changedesc}
      </if>
      <if test="changereason != null and changereason != ''">
        and CHANGEREASON = #{changereason}
      </if>
      <if test="creattime != null and creattime != ''">
        and CREATTIME = #{creattime}
      </if>
      <if test="mediumtype != null and mediumtype != ''">
        and MEDIUMTYPE = #{mediumtype}
      </if>
      <if test="note != null and note != ''">
        and NOTE = #{note}
      </if>
      <if test="recman != null and recman != ''">
        and RECMAN = #{recman}
      </if>
      <if test="rectime != null and rectime != ''">
        and RECTIME = #{rectime}
      </if>
      <if test="respman != null and respman != ''">
        and RESPMAN = #{respman}
      </if>
      <if test="respunit != null and respunit != ''">
        and RESPUNIT = #{respunit}
      </if>
      <if test="tel != null and tel != ''">
        and TEL = #{tel}
      </if>
  </delete>
  <insert id="insertSelective" parameterType="com.steerinfo.ems.tcm0349.model.TCm0349">
    insert into T_CM_0349
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="changeno != null">
        CHANGENO,
      </if>
      <if test="recordid != null">
        RECORDID,
      </if>
      <if test="billstatus != null">
        BILLSTATUS,
      </if>
      <if test="changedesc != null">
        CHANGEDESC,
      </if>
      <if test="changereason != null">
        CHANGEREASON,
      </if>
      <if test="creattime != null">
        CREATTIME,
      </if>
      <if test="mediumtype != null">
        MEDIUMTYPE,
      </if>
      <if test="note != null">
        NOTE,
      </if>
      <if test="recman != null">
        RECMAN,
      </if>
      <if test="rectime != null">
        RECTIME,
      </if>
      <if test="respman != null">
        RESPMAN,
      </if>
      <if test="respunit != null">
        RESPUNIT,
      </if>
      <if test="tel != null">
        TEL,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="changeno != null">
        #{changeno,jdbcType=VARCHAR},
      </if>
      <if test="recordid != null">
        #{recordid,jdbcType=VARCHAR},
      </if>
      <if test="billstatus != null">
        #{billstatus,jdbcType=VARCHAR},
      </if>
      <if test="changedesc != null">
        #{changedesc,jdbcType=VARCHAR},
      </if>
      <if test="changereason != null">
        #{changereason,jdbcType=VARCHAR},
      </if>
      <if test="creattime != null">
        #{creattime,jdbcType=VARCHAR},
      </if>
      <if test="mediumtype != null">
        #{mediumtype,jdbcType=VARCHAR},
      </if>
      <if test="note != null">
        #{note,jdbcType=VARCHAR},
      </if>
      <if test="recman != null">
        #{recman,jdbcType=VARCHAR},
      </if>
      <if test="rectime != null">
        #{rectime,jdbcType=VARCHAR},
      </if>
      <if test="respman != null">
        #{respman,jdbcType=VARCHAR},
      </if>
      <if test="respunit != null">
        #{respunit,jdbcType=VARCHAR},
      </if>
      <if test="tel != null">
        #{tel,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.steerinfo.ems.tcm0349.model.TCm0349">
    update T_CM_0349
    set RECORDID = #{recordid,jdbcType=VARCHAR},
      BILLSTATUS = #{billstatus,jdbcType=VARCHAR},
      CHANGEDESC = #{changedesc,jdbcType=VARCHAR},
      CHANGEREASON = #{changereason,jdbcType=VARCHAR},
      CREATTIME = #{creattime,jdbcType=VARCHAR},
      MEDIUMTYPE = #{mediumtype,jdbcType=VARCHAR},
      NOTE = #{note,jdbcType=VARCHAR},
      RECMAN = #{recman,jdbcType=VARCHAR},
      RECTIME = #{rectime,jdbcType=VARCHAR},
      RESPMAN = #{respman,jdbcType=VARCHAR},
      RESPUNIT = #{respunit,jdbcType=VARCHAR},
      TEL = #{tel,jdbcType=VARCHAR}
    where CHANGENO = #{changeno,jdbcType=VARCHAR}
  </update>
  <select id="selectLikeByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
    select CHANGENO, RECORDID, BILLSTATUS, CHANGEDESC, CHANGEREASON, CREATTIME, MEDIUMTYPE, 
    NOTE, RECMAN, RECTIME, RESPMAN, RESPUNIT, TEL
    from T_CM_0349
    <where> 
      <if test="recordid != null">
        and RECORDID = #{recordid}
      </if>
      <if test="billstatus != null and billstatus != ''">
        and BILLSTATUS LIKE '%${billstatus}%'
      </if>
      <if test="changedesc != null and changedesc != ''">
        and CHANGEDESC LIKE '%${changedesc}%'
      </if>
      <if test="changereason != null and changereason != ''">
        and CHANGEREASON LIKE '%${changereason}%'
      </if>
      <if test="creattime != null and creattime != ''">
        and CREATTIME LIKE '%${creattime}%'
      </if>
      <if test="mediumtype != null and mediumtype != ''">
        and MEDIUMTYPE LIKE '%${mediumtype}%'
      </if>
      <if test="note != null and note != ''">
        and NOTE LIKE '%${note}%'
      </if>
      <if test="recman != null and recman != ''">
        and RECMAN LIKE '%${recman}%'
      </if>
      <if test="rectime != null and rectime != ''">
        and RECTIME LIKE '%${rectime}%'
      </if>
      <if test="respman != null and respman != ''">
        and RESPMAN LIKE '%${respman}%'
      </if>
      <if test="respunit != null and respunit != ''">
        and RESPUNIT LIKE '%${respunit}%'
      </if>
      <if test="tel != null and tel != ''">
        and TEL LIKE '%${tel}%'
      </if>
    </where>
  </select>
  <insert id="batchInsert" parameterType="java.util.List">
    insert into T_CM_0349 
      (CHANGENO, 
      RECORDID, BILLSTATUS, CHANGEDESC, 
      CHANGEREASON, CREATTIME, MEDIUMTYPE, 
      NOTE, RECMAN, RECTIME, 
      RESPMAN, RESPUNIT, TEL
      )
    ( <foreach collection="list" item="item" separator="union all"> 
   select  
      #{item.changeno,jdbcType=VARCHAR}, 
      #{item.recordid,jdbcType=VARCHAR}, #{item.billstatus,jdbcType=VARCHAR}, #{item.changedesc,jdbcType=VARCHAR},
      #{item.changereason,jdbcType=VARCHAR}, #{item.creattime,jdbcType=VARCHAR}, #{item.mediumtype,jdbcType=VARCHAR}, 
      #{item.note,jdbcType=VARCHAR}, #{item.recman,jdbcType=VARCHAR}, #{item.rectime,jdbcType=VARCHAR}, 
      #{item.respman,jdbcType=VARCHAR}, #{item.respunit,jdbcType=VARCHAR}, #{item.tel,jdbcType=VARCHAR}
       from dual  
   </foreach> )
  </insert>
  <update id="batchUpdate" parameterType="java.util.List">
     update T_CM_0349
     set
       CHANGENO=
       <foreach collection="list" item="item" index="index" separator=" " open="case CHANGENO" close="end">
          when #{item.changeno,jdbcType=VARCHAR} then #{item.changeno,jdbcType=VARCHAR}
       </foreach>
       ,RECORDID=
       <foreach collection="list" item="item" index="index" separator=" " open="case CHANGENO" close="end">
          when #{item.changeno,jdbcType=VARCHAR} then #{item.recordid,jdbcType=VARCHAR}
       </foreach>
       ,BILLSTATUS=
       <foreach collection="list" item="item" index="index" separator=" " open="case CHANGENO" close="end">
          when #{item.changeno,jdbcType=VARCHAR} then #{item.billstatus,jdbcType=VARCHAR}
       </foreach>
       ,CHANGEDESC=
       <foreach collection="list" item="item" index="index" separator=" " open="case CHANGENO" close="end">
          when #{item.changeno,jdbcType=VARCHAR} then #{item.changedesc,jdbcType=VARCHAR}
       </foreach>
       ,CHANGEREASON=
       <foreach collection="list" item="item" index="index" separator=" " open="case CHANGENO" close="end">
          when #{item.changeno,jdbcType=VARCHAR} then #{item.changereason,jdbcType=VARCHAR}
       </foreach>
       ,CREATTIME=
       <foreach collection="list" item="item" index="index" separator=" " open="case CHANGENO" close="end">
          when #{item.changeno,jdbcType=VARCHAR} then #{item.creattime,jdbcType=VARCHAR}
       </foreach>
       ,MEDIUMTYPE=
       <foreach collection="list" item="item" index="index" separator=" " open="case CHANGENO" close="end">
          when #{item.changeno,jdbcType=VARCHAR} then #{item.mediumtype,jdbcType=VARCHAR}
       </foreach>
       ,NOTE=
       <foreach collection="list" item="item" index="index" separator=" " open="case CHANGENO" close="end">
          when #{item.changeno,jdbcType=VARCHAR} then #{item.note,jdbcType=VARCHAR}
       </foreach>
       ,RECMAN=
       <foreach collection="list" item="item" index="index" separator=" " open="case CHANGENO" close="end">
          when #{item.changeno,jdbcType=VARCHAR} then #{item.recman,jdbcType=VARCHAR}
       </foreach>
       ,RECTIME=
       <foreach collection="list" item="item" index="index" separator=" " open="case CHANGENO" close="end">
          when #{item.changeno,jdbcType=VARCHAR} then #{item.rectime,jdbcType=VARCHAR}
       </foreach>
       ,RESPMAN=
       <foreach collection="list" item="item" index="index" separator=" " open="case CHANGENO" close="end">
          when #{item.changeno,jdbcType=VARCHAR} then #{item.respman,jdbcType=VARCHAR}
       </foreach>
       ,RESPUNIT=
       <foreach collection="list" item="item" index="index" separator=" " open="case CHANGENO" close="end">
          when #{item.changeno,jdbcType=VARCHAR} then #{item.respunit,jdbcType=VARCHAR}
       </foreach>
       ,TEL=
       <foreach collection="list" item="item" index="index" separator=" " open="case CHANGENO" close="end">
          when #{item.changeno,jdbcType=VARCHAR} then #{item.tel,jdbcType=VARCHAR}
       </foreach>
     where CHANGENO in 
     <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
    #{item.changeno,jdbcType=VARCHAR}
     </foreach> 
  </update>
  -->
</mapper>