<?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.tcm0350.mapper.TCm0350Mapper">
  <resultMap id="BaseResultMap" type="com.steerinfo.ems.tcm0350.model.TCm0350">
    <id column="PUNISHNO" jdbcType="VARCHAR" property="punishno" />
    <result column="RECORDID" jdbcType="VARCHAR" property="recordid" />
    <result column="CREATTIME" jdbcType="TIMESTAMP" property="creattime" />
    <result column="MEDIUMTYPE" jdbcType="VARCHAR" property="mediumtype" />
    <result column="PUNISHUNIT" jdbcType="VARCHAR" property="punishunit" />
    <result column="TEL" jdbcType="VARCHAR" property="tel" />
    <result column="PUNISHREASON" jdbcType="VARCHAR" property="punishreason" />
    <result column="PUNISHDESC" jdbcType="VARCHAR" property="punishdesc" />
    <result column="NOTE" jdbcType="VARCHAR" property="note" />
    <result column="HANDLEMAN" jdbcType="VARCHAR" property="handleman" />
    <result column="HANDLETIME" jdbcType="VARCHAR" property="handletime" />
    <result column="BILLSTATUS" jdbcType="VARCHAR" property="billstatus" />
  </resultMap>

  <select id="selectByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
    select PUNISHNO, RECORDID, CREATTIME, MEDIUMTYPE, PUNISHUNIT, TEL, PUNISHREASON,
    PUNISHDESC, NOTE, HANDLEMAN, HANDLETIME, BILLSTATUS
    from T_CM_0350
    <where>
      <if test="punishno != null and punishno = ''">
        PUNISHNO like '%${punishno}%'
      </if>
      <if test="mediumtype != null and mediumtype != ''">
        and MEDIUMTYPE = #{mediumtype}
      </if>
      <if test="punishunit != null and punishunit != ''">
        and PUNISHUNIT like '%${punishunit}%'
      </if>
      <if test="handleman != null and handleman != ''">
        and HANDLEMAN like '%${handleman}%'
      </if>
      <if test="billstatus != null and billstatus != ''">
        and BILLSTATUS = #{billstatus}
      </if>
      <if test="creattime != null and creattime != ''">
        and TO_CHAR(CREATTIME,'yyyy-MM-dd') &gt;= #{creattime}
      </if>
      <if test="creattimee != null and creattimee != ''">
        and TO_CHAR(CREATTIME,'yyyy-MM-dd') &lt;= #{creattimee}
      </if>
      <if test="handletime != null and handletime != ''">
        and HANDLETIME &gt;= #{handletime}
      </if>
      <if test="handletimee != null and handletimee != ''">
        and HANDLETIME &lt;= #{handletimee}
      </if>
    </where>
  </select>

  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
    select PUNISHNO, RECORDID, CREATTIME, MEDIUMTYPE, PUNISHUNIT, TEL, PUNISHREASON,
    PUNISHDESC, NOTE, HANDLEMAN, HANDLETIME, BILLSTATUS
    from T_CM_0350
    where PUNISHNO = #{punishno,jdbcType=VARCHAR}
  </select>

  <update id="updateByPrimaryKeySelective" parameterType="com.steerinfo.ems.tcm0350.model.TCm0350">
    update T_CM_0350
    <set>

      <if test="creattime != null">
        CREATTIME = #{creattime,jdbcType=TIMESTAMP},
      </if>
      <if test="mediumtype != null">
        MEDIUMTYPE = #{mediumtype,jdbcType=VARCHAR},
      </if>
      <if test="punishunit != null">
        PUNISHUNIT = #{punishunit,jdbcType=VARCHAR},
      </if>
      <if test="tel != null">
        TEL = #{tel,jdbcType=VARCHAR},
      </if>
      <if test="punishreason != null">
        PUNISHREASON = #{punishreason,jdbcType=VARCHAR},
      </if>
      <if test="punishdesc != null">
        PUNISHDESC = #{punishdesc,jdbcType=VARCHAR},
      </if>
      <if test="note != null">
        NOTE = #{note,jdbcType=VARCHAR},
      </if>
      <if test="handleman != null">
        HANDLEMAN = #{handleman,jdbcType=VARCHAR},
      </if>
      <if test="handletime != null">
        HANDLETIME = #{handletime,jdbcType=VARCHAR},
      </if>
      <if test="billstatus != null">
        BILLSTATUS = #{billstatus,jdbcType=VARCHAR},
      </if>
    </set>
    where PUNISHNO = #{punishno,jdbcType=VARCHAR}
  </update>

  <insert id="insert" parameterType="com.steerinfo.ems.tcm0350.model.TCm0350">
    insert into T_CM_0350 (PUNISHNO, RECORDID, CREATTIME,
      MEDIUMTYPE, PUNISHUNIT, TEL,
      PUNISHREASON, PUNISHDESC, NOTE,
      HANDLEMAN, HANDLETIME, BILLSTATUS
      )
    values (#{punishno,jdbcType=VARCHAR}, #{recordid,jdbcType=VARCHAR}, #{creattime,jdbcType=TIMESTAMP},
      #{mediumtype,jdbcType=VARCHAR}, #{punishunit,jdbcType=VARCHAR}, #{tel,jdbcType=VARCHAR},
      #{punishreason,jdbcType=VARCHAR}, #{punishdesc,jdbcType=VARCHAR}, #{note,jdbcType=VARCHAR},
      #{handleman,jdbcType=VARCHAR}, #{handletime,jdbcType=VARCHAR}, #{billstatus,jdbcType=VARCHAR}
      )
  </insert>

  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    delete from T_CM_0350
    where PUNISHNO = #{punishno,jdbcType=VARCHAR}
  </delete>

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

  <select id="getMaxId" resultType="java.lang.String">
    SELECT MAX(SUBSTR(PUNISHNO, LENGTH(PUNISHNO) - 3)) FROM T_CM_0350
  </select>
  <!--
  <delete id="deleteBySelectiveElement" parameterType="java.util.HashMap">
    delete from T_CM_0350
    where 1!=1 
      <if test="recordid != null">
        and RECORDID = #{recordid}
      </if>
      <if test="creattime != null">
        and TO_CHAR(CREATTIME,'yyyy-MM-dd') = '#{creattime}'
      </if>
      <if test="mediumtype != null and mediumtype != ''">
        and MEDIUMTYPE = #{mediumtype}
      </if>
      <if test="punishunit != null and punishunit != ''">
        and PUNISHUNIT = #{punishunit}
      </if>
      <if test="tel != null and tel != ''">
        and TEL = #{tel}
      </if>
      <if test="punishreason != null and punishreason != ''">
        and PUNISHREASON = #{punishreason}
      </if>
      <if test="punishdesc != null and punishdesc != ''">
        and PUNISHDESC = #{punishdesc}
      </if>
      <if test="note != null and note != ''">
        and NOTE = #{note}
      </if>
      <if test="handleman != null and handleman != ''">
        and HANDLEMAN = #{handleman}
      </if>
      <if test="handletime != null and handletime != ''">
        and HANDLETIME = #{handletime}
      </if>
      <if test="billstatus != null and billstatus != ''">
        and BILLSTATUS = #{billstatus}
      </if>
  </delete>
  <insert id="insertSelective" parameterType="com.steerinfo.ems.tcm0350.model.TCm0350">
    insert into T_CM_0350
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="punishno != null">
        PUNISHNO,
      </if>
      <if test="recordid != null">
        RECORDID,
      </if>
      <if test="creattime != null">
        CREATTIME,
      </if>
      <if test="mediumtype != null">
        MEDIUMTYPE,
      </if>
      <if test="punishunit != null">
        PUNISHUNIT,
      </if>
      <if test="tel != null">
        TEL,
      </if>
      <if test="punishreason != null">
        PUNISHREASON,
      </if>
      <if test="punishdesc != null">
        PUNISHDESC,
      </if>
      <if test="note != null">
        NOTE,
      </if>
      <if test="handleman != null">
        HANDLEMAN,
      </if>
      <if test="handletime != null">
        HANDLETIME,
      </if>
      <if test="billstatus != null">
        BILLSTATUS,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="punishno != null">
        #{punishno,jdbcType=VARCHAR},
      </if>
      <if test="recordid != null">
        #{recordid,jdbcType=VARCHAR},
      </if>
      <if test="creattime != null">
        #{creattime,jdbcType=TIMESTAMP},
      </if>
      <if test="mediumtype != null">
        #{mediumtype,jdbcType=VARCHAR},
      </if>
      <if test="punishunit != null">
        #{punishunit,jdbcType=VARCHAR},
      </if>
      <if test="tel != null">
        #{tel,jdbcType=VARCHAR},
      </if>
      <if test="punishreason != null">
        #{punishreason,jdbcType=VARCHAR},
      </if>
      <if test="punishdesc != null">
        #{punishdesc,jdbcType=VARCHAR},
      </if>
      <if test="note != null">
        #{note,jdbcType=VARCHAR},
      </if>
      <if test="handleman != null">
        #{handleman,jdbcType=VARCHAR},
      </if>
      <if test="handletime != null">
        #{handletime,jdbcType=VARCHAR},
      </if>
      <if test="billstatus != null">
        #{billstatus,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.steerinfo.ems.tcm0350.model.TCm0350">
    update T_CM_0350
    set RECORDID = #{recordid,jdbcType=VARCHAR},
      CREATTIME = #{creattime,jdbcType=TIMESTAMP},
      MEDIUMTYPE = #{mediumtype,jdbcType=VARCHAR},
      PUNISHUNIT = #{punishunit,jdbcType=VARCHAR},
      TEL = #{tel,jdbcType=VARCHAR},
      PUNISHREASON = #{punishreason,jdbcType=VARCHAR},
      PUNISHDESC = #{punishdesc,jdbcType=VARCHAR},
      NOTE = #{note,jdbcType=VARCHAR},
      HANDLEMAN = #{handleman,jdbcType=VARCHAR},
      HANDLETIME = #{handletime,jdbcType=VARCHAR},
      BILLSTATUS = #{billstatus,jdbcType=VARCHAR}
    where PUNISHNO = #{punishno,jdbcType=VARCHAR}
  </update>
  <select id="selectLikeByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
    select PUNISHNO, RECORDID, CREATTIME, MEDIUMTYPE, PUNISHUNIT, TEL, PUNISHREASON, 
    PUNISHDESC, NOTE, HANDLEMAN, HANDLETIME, BILLSTATUS
    from T_CM_0350
    <where> 
      <if test="recordid != null">
        and RECORDID = #{recordid}
      </if>
      <if test="creattime != null">
        and TO_CHAR(CREATTIME,'yyyy-MM-dd') = #{creattime}
      </if>
      <if test="mediumtype != null and mediumtype != ''">
        and MEDIUMTYPE LIKE '%${mediumtype}%'
      </if>
      <if test="punishunit != null and punishunit != ''">
        and PUNISHUNIT LIKE '%${punishunit}%'
      </if>
      <if test="tel != null and tel != ''">
        and TEL LIKE '%${tel}%'
      </if>
      <if test="punishreason != null and punishreason != ''">
        and PUNISHREASON LIKE '%${punishreason}%'
      </if>
      <if test="punishdesc != null and punishdesc != ''">
        and PUNISHDESC LIKE '%${punishdesc}%'
      </if>
      <if test="note != null and note != ''">
        and NOTE LIKE '%${note}%'
      </if>
      <if test="handleman != null and handleman != ''">
        and HANDLEMAN LIKE '%${handleman}%'
      </if>
      <if test="handletime != null and handletime != ''">
        and HANDLETIME LIKE '%${handletime}%'
      </if>
      <if test="billstatus != null and billstatus != ''">
        and BILLSTATUS LIKE '%${billstatus}%'
      </if>
    </where>
  </select>
  <insert id="batchInsert" parameterType="java.util.List">
    insert into T_CM_0350 
      (PUNISHNO, 
      RECORDID, CREATTIME, MEDIUMTYPE, 
      PUNISHUNIT, TEL, PUNISHREASON, 
      PUNISHDESC, NOTE, HANDLEMAN, 
      HANDLETIME, BILLSTATUS)
    ( <foreach collection="list" item="item" separator="union all"> 
   select  
      #{item.punishno,jdbcType=VARCHAR}, 
      #{item.recordid,jdbcType=VARCHAR}, #{item.creattime,jdbcType=TIMESTAMP}, #{item.mediumtype,jdbcType=VARCHAR},
      #{item.punishunit,jdbcType=VARCHAR}, #{item.tel,jdbcType=VARCHAR}, #{item.punishreason,jdbcType=VARCHAR}, 
      #{item.punishdesc,jdbcType=VARCHAR}, #{item.note,jdbcType=VARCHAR}, #{item.handleman,jdbcType=VARCHAR}, 
      #{item.handletime,jdbcType=VARCHAR}, #{item.billstatus,jdbcType=VARCHAR} from dual  
   </foreach> )
  </insert>
  <update id="batchUpdate" parameterType="java.util.List">
     update T_CM_0350
     set
       PUNISHNO=
       <foreach collection="list" item="item" index="index" separator=" " open="case PUNISHNO" close="end">
          when #{item.punishno,jdbcType=VARCHAR} then #{item.punishno,jdbcType=VARCHAR}
       </foreach>
       ,RECORDID=
       <foreach collection="list" item="item" index="index" separator=" " open="case PUNISHNO" close="end">
          when #{item.punishno,jdbcType=VARCHAR} then #{item.recordid,jdbcType=VARCHAR}
       </foreach>
       ,CREATTIME=
       <foreach collection="list" item="item" index="index" separator=" " open="case PUNISHNO" close="end">
          when #{item.punishno,jdbcType=VARCHAR} then #{item.creattime,jdbcType=TIMESTAMP}
       </foreach>
       ,MEDIUMTYPE=
       <foreach collection="list" item="item" index="index" separator=" " open="case PUNISHNO" close="end">
          when #{item.punishno,jdbcType=VARCHAR} then #{item.mediumtype,jdbcType=VARCHAR}
       </foreach>
       ,PUNISHUNIT=
       <foreach collection="list" item="item" index="index" separator=" " open="case PUNISHNO" close="end">
          when #{item.punishno,jdbcType=VARCHAR} then #{item.punishunit,jdbcType=VARCHAR}
       </foreach>
       ,TEL=
       <foreach collection="list" item="item" index="index" separator=" " open="case PUNISHNO" close="end">
          when #{item.punishno,jdbcType=VARCHAR} then #{item.tel,jdbcType=VARCHAR}
       </foreach>
       ,PUNISHREASON=
       <foreach collection="list" item="item" index="index" separator=" " open="case PUNISHNO" close="end">
          when #{item.punishno,jdbcType=VARCHAR} then #{item.punishreason,jdbcType=VARCHAR}
       </foreach>
       ,PUNISHDESC=
       <foreach collection="list" item="item" index="index" separator=" " open="case PUNISHNO" close="end">
          when #{item.punishno,jdbcType=VARCHAR} then #{item.punishdesc,jdbcType=VARCHAR}
       </foreach>
       ,NOTE=
       <foreach collection="list" item="item" index="index" separator=" " open="case PUNISHNO" close="end">
          when #{item.punishno,jdbcType=VARCHAR} then #{item.note,jdbcType=VARCHAR}
       </foreach>
       ,HANDLEMAN=
       <foreach collection="list" item="item" index="index" separator=" " open="case PUNISHNO" close="end">
          when #{item.punishno,jdbcType=VARCHAR} then #{item.handleman,jdbcType=VARCHAR}
       </foreach>
       ,HANDLETIME=
       <foreach collection="list" item="item" index="index" separator=" " open="case PUNISHNO" close="end">
          when #{item.punishno,jdbcType=VARCHAR} then #{item.handletime,jdbcType=VARCHAR}
       </foreach>
       ,BILLSTATUS=
       <foreach collection="list" item="item" index="index" separator=" " open="case PUNISHNO" close="end">
          when #{item.punishno,jdbcType=VARCHAR} then #{item.billstatus,jdbcType=VARCHAR}
       </foreach>
     where PUNISHNO in 
     <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
    #{item.punishno,jdbcType=VARCHAR}
     </foreach> 
  </update>
  -->
</mapper>