<?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.meterworknotice.mapper.MeterWorkNoticeMapper">
  <resultMap id="BaseResultMap" type="com.steerinfo.meterwork.meterworknotice.model.MeterWorkNotice">
    <id column="NOTICE_ID" jdbcType="VARCHAR" property="noticeId" />
    <result column="NOTICE_TYPE_NO" jdbcType="VARCHAR" property="noticeTypeNo" />
    <result column="NOTICE_TYPE_NAME" jdbcType="VARCHAR" property="noticeTypeName" />
    <result column="NOTICE_LEVEL" jdbcType="VARCHAR" property="noticeLevel" />
    <result column="NOTICE_NAME" jdbcType="VARCHAR" property="noticeName" />
    <result column="NOTICE_CONTENT" jdbcType="VARCHAR" property="noticeContent" />
    <result column="READ_MAN_NUM" jdbcType="VARCHAR" property="readManNum" />
    <result column="VALID_FLAG" jdbcType="VARCHAR" property="validFlag" />
    <result column="PUBLISH_MAN" jdbcType="VARCHAR" property="publishMan" />
    <result column="PUBLISH_TIME" jdbcType="VARCHAR" property="publishTime" />
    <result column="EDIT_MAN" jdbcType="VARCHAR" property="editMan" />
    <result column="EDIT_TIME" jdbcType="VARCHAR" property="editTime" />
  </resultMap>
  <sql id="columns">
    NOTICE_ID, NOTICE_TYPE_NO, NOTICE_TYPE_NAME, NOTICE_LEVEL, NOTICE_NAME, NOTICE_CONTENT, 
    READ_MAN_NUM, VALID_FLAG, PUBLISH_MAN, PUBLISH_TIME, EDIT_MAN, EDIT_TIME
  </sql>
  <sql id="columns_alias">
    t.NOTICE_ID, t.NOTICE_TYPE_NO, t.NOTICE_TYPE_NAME, t.NOTICE_LEVEL, t.NOTICE_NAME, 
    t.NOTICE_CONTENT, t.READ_MAN_NUM, t.VALID_FLAG, t.PUBLISH_MAN, t.PUBLISH_TIME, t.EDIT_MAN, 
    t.EDIT_TIME
  </sql>
  <sql id="select">
    SELECT <include refid="columns"/> FROM METER_WORK_NOTICE
  </sql>
  <sql id="select_alias">
    SELECT <include refid="columns_alias"/> FROM METER_WORK_NOTICE t
  </sql>
  <sql id="where">
    <where> 
      <if test="noticeId != null and noticeId != ''">
        and NOTICE_ID = #{noticeId}
      </if>
      <if test="noticeTypeNo != null and noticeTypeNo != ''">
        and NOTICE_TYPE_NO = #{noticeTypeNo}
      </if>
      <if test="noticeTypeName != null and noticeTypeName != ''">
        and NOTICE_TYPE_NAME = #{noticeTypeName}
      </if>
      <if test="noticeLevel != null and noticeLevel != ''">
        and NOTICE_LEVEL = #{noticeLevel}
      </if>
      <if test="noticeName != null and noticeName != ''">
        and NOTICE_NAME = #{noticeName}
      </if>
      <if test="noticeContent != null and noticeContent != ''">
        and NOTICE_CONTENT = #{noticeContent}
      </if>
      <if test="readManNum != null and readManNum != ''">
        and READ_MAN_NUM = #{readManNum}
      </if>
      <if test="validFlag != null and validFlag != ''">
        and VALID_FLAG = #{validFlag}
      </if>
      <if test="publishMan != null and publishMan != ''">
        and PUBLISH_MAN = #{publishMan}
      </if>
      <if test="publishTime != null and publishTime != ''">
        and PUBLISH_TIME = #{publishTime}
      </if>
      <if test="editMan != null and editMan != ''">
        and EDIT_MAN = #{editMan}
      </if>
      <if test="editTime != null and editTime != ''">
        and EDIT_TIME = #{editTime}
      </if>
    </where>
  </sql>
  <sql id="whereLike">
    <where> 
      <if test="noticeId != null and noticeId != ''">
        and NOTICE_ID LIKE '%${noticeId}%'
      </if>
      <if test="noticeTypeNo != null and noticeTypeNo != ''">
        and NOTICE_TYPE_NO LIKE '%${noticeTypeNo}%'
      </if>
      <if test="noticeTypeName != null and noticeTypeName != ''">
        and NOTICE_TYPE_NAME LIKE '%${noticeTypeName}%'
      </if>
      <if test="noticeLevel != null and noticeLevel != ''">
        and NOTICE_LEVEL LIKE '%${noticeLevel}%'
      </if>
      <if test="noticeName != null and noticeName != ''">
        and NOTICE_NAME LIKE '%${noticeName}%'
      </if>
      <if test="noticeContent != null and noticeContent != ''">
        and NOTICE_CONTENT LIKE '%${noticeContent}%'
      </if>
      <if test="readManNum != null and readManNum != ''">
        and READ_MAN_NUM LIKE '%${readManNum}%'
      </if>
      <if test="validFlag != null and validFlag != ''">
        and VALID_FLAG LIKE '%${validFlag}%'
      </if>
      <if test="publishMan != null and publishMan != ''">
        and PUBLISH_MAN LIKE '%${publishMan}%'
      </if>
      <if test="publishTime != null and publishTime != ''">
        and PUBLISH_TIME LIKE '%${publishTime}%'
      </if>
      <if test="editMan != null and editMan != ''">
        and EDIT_MAN LIKE '%${editMan}%'
      </if>
      <if test="editTime != null and editTime != ''">
        and EDIT_TIME LIKE '%${editTime}%'
      </if>
    </where>
  </sql>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    delete from METER_WORK_NOTICE
    where NOTICE_ID = #{noticeId,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteBySelectiveElement" parameterType="java.util.HashMap">
    delete from METER_WORK_NOTICE
    where 1!=1 
      <if test="noticeTypeNo != null and noticeTypeNo != ''">
        or NOTICE_TYPE_NO = #{noticeTypeNo}
      </if>
      <if test="noticeTypeName != null and noticeTypeName != ''">
        or NOTICE_TYPE_NAME = #{noticeTypeName}
      </if>
      <if test="noticeLevel != null and noticeLevel != ''">
        or NOTICE_LEVEL = #{noticeLevel}
      </if>
      <if test="noticeName != null and noticeName != ''">
        or NOTICE_NAME = #{noticeName}
      </if>
      <if test="noticeContent != null and noticeContent != ''">
        or NOTICE_CONTENT = #{noticeContent}
      </if>
      <if test="readManNum != null and readManNum != ''">
        or READ_MAN_NUM = #{readManNum}
      </if>
      <if test="validFlag != null and validFlag != ''">
        or VALID_FLAG = #{validFlag}
      </if>
      <if test="publishMan != null and publishMan != ''">
        or PUBLISH_MAN = #{publishMan}
      </if>
      <if test="publishTime != null and publishTime != ''">
        or PUBLISH_TIME = #{publishTime}
      </if>
      <if test="editMan != null and editMan != ''">
        or EDIT_MAN = #{editMan}
      </if>
      <if test="editTime != null and editTime != ''">
        or EDIT_TIME = #{editTime}
      </if>
  </delete>
  <insert id="insert" parameterType="com.steerinfo.meterwork.meterworknotice.model.MeterWorkNotice">
    insert into METER_WORK_NOTICE (NOTICE_ID, NOTICE_TYPE_NO, NOTICE_TYPE_NAME, 
      NOTICE_LEVEL, NOTICE_NAME, NOTICE_CONTENT, 
      READ_MAN_NUM, VALID_FLAG, PUBLISH_MAN, 
      PUBLISH_TIME, EDIT_MAN, EDIT_TIME
      )
    values (#{noticeId,jdbcType=VARCHAR}, #{noticeTypeNo,jdbcType=VARCHAR}, #{noticeTypeName,jdbcType=VARCHAR}, 
      #{noticeLevel,jdbcType=VARCHAR}, #{noticeName,jdbcType=VARCHAR}, #{noticeContent,jdbcType=VARCHAR}, 
      #{readManNum,jdbcType=VARCHAR}, #{validFlag,jdbcType=VARCHAR}, #{publishMan,jdbcType=VARCHAR}, 
      #{publishTime,jdbcType=VARCHAR}, #{editMan,jdbcType=VARCHAR}, #{editTime,jdbcType=VARCHAR}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.steerinfo.meterwork.meterworknotice.model.MeterWorkNotice">
    insert into METER_WORK_NOTICE
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="noticeId != null">
        NOTICE_ID,
      </if>
      <if test="noticeTypeNo != null">
        NOTICE_TYPE_NO,
      </if>
      <if test="noticeTypeName != null">
        NOTICE_TYPE_NAME,
      </if>
      <if test="noticeLevel != null">
        NOTICE_LEVEL,
      </if>
      <if test="noticeName != null">
        NOTICE_NAME,
      </if>
      <if test="noticeContent != null">
        NOTICE_CONTENT,
      </if>
      <if test="readManNum != null">
        READ_MAN_NUM,
      </if>
      <if test="validFlag != null">
        VALID_FLAG,
      </if>
      <if test="publishMan != null">
        PUBLISH_MAN,
      </if>
      <if test="publishTime != null">
        PUBLISH_TIME,
      </if>
      <if test="editMan != null">
        EDIT_MAN,
      </if>
      <if test="editTime != null">
        EDIT_TIME,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="noticeId != null">
        #{noticeId,jdbcType=VARCHAR},
      </if>
      <if test="noticeTypeNo != null">
        #{noticeTypeNo,jdbcType=VARCHAR},
      </if>
      <if test="noticeTypeName != null">
        #{noticeTypeName,jdbcType=VARCHAR},
      </if>
      <if test="noticeLevel != null">
        #{noticeLevel,jdbcType=VARCHAR},
      </if>
      <if test="noticeName != null">
        #{noticeName,jdbcType=VARCHAR},
      </if>
      <if test="noticeContent != null">
        #{noticeContent,jdbcType=VARCHAR},
      </if>
      <if test="readManNum != null">
        #{readManNum,jdbcType=VARCHAR},
      </if>
      <if test="validFlag != null">
        #{validFlag,jdbcType=VARCHAR},
      </if>
      <if test="publishMan != null">
        #{publishMan,jdbcType=VARCHAR},
      </if>
      <if test="publishTime != null">
        #{publishTime,jdbcType=VARCHAR},
      </if>
      <if test="editMan != null">
        #{editMan,jdbcType=VARCHAR},
      </if>
      <if test="editTime != null">
        #{editTime,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.steerinfo.meterwork.meterworknotice.model.MeterWorkNotice">
    update METER_WORK_NOTICE
    set NOTICE_TYPE_NO = #{noticeTypeNo,jdbcType=VARCHAR},
      NOTICE_TYPE_NAME = #{noticeTypeName,jdbcType=VARCHAR},
      NOTICE_LEVEL = #{noticeLevel,jdbcType=VARCHAR},
      NOTICE_NAME = #{noticeName,jdbcType=VARCHAR},
      NOTICE_CONTENT = #{noticeContent,jdbcType=VARCHAR},
      READ_MAN_NUM = #{readManNum,jdbcType=VARCHAR},
      VALID_FLAG = #{validFlag,jdbcType=VARCHAR},
      PUBLISH_MAN = #{publishMan,jdbcType=VARCHAR},
      PUBLISH_TIME = #{publishTime,jdbcType=VARCHAR},
      EDIT_MAN = #{editMan,jdbcType=VARCHAR},
      EDIT_TIME = #{editTime,jdbcType=VARCHAR}
    where NOTICE_ID = #{noticeId,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.steerinfo.meterwork.meterworknotice.model.MeterWorkNotice">
    update METER_WORK_NOTICE
    <set>
      <if test="noticeTypeNo != null">
        NOTICE_TYPE_NO = #{noticeTypeNo,jdbcType=VARCHAR},
      </if>
      <if test="noticeTypeName != null">
        NOTICE_TYPE_NAME = #{noticeTypeName,jdbcType=VARCHAR},
      </if>
      <if test="noticeLevel != null">
        NOTICE_LEVEL = #{noticeLevel,jdbcType=VARCHAR},
      </if>
      <if test="noticeName != null">
        NOTICE_NAME = #{noticeName,jdbcType=VARCHAR},
      </if>
      <if test="noticeContent != null">
        NOTICE_CONTENT = #{noticeContent,jdbcType=VARCHAR},
      </if>
      <if test="readManNum != null">
        READ_MAN_NUM = #{readManNum,jdbcType=VARCHAR},
      </if>
      <if test="validFlag != null">
        VALID_FLAG = #{validFlag,jdbcType=VARCHAR},
      </if>
      <if test="publishMan != null">
        PUBLISH_MAN = #{publishMan,jdbcType=VARCHAR},
      </if>
      <if test="publishTime != null">
        PUBLISH_TIME = #{publishTime,jdbcType=VARCHAR},
      </if>
      <if test="editMan != null">
        EDIT_MAN = #{editMan,jdbcType=VARCHAR},
      </if>
      <if test="editTime != null">
        EDIT_TIME = #{editTime,jdbcType=VARCHAR},
      </if>
    </set>
    where NOTICE_ID = #{noticeId,jdbcType=VARCHAR}
  </update>
  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
    <include refid="select"/>
    where NOTICE_ID = #{noticeId,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_NOTICE 
      (NOTICE_ID, 
      NOTICE_TYPE_NO, NOTICE_TYPE_NAME, 
      NOTICE_LEVEL, NOTICE_NAME, NOTICE_CONTENT, 
      READ_MAN_NUM, VALID_FLAG, PUBLISH_MAN, 
      PUBLISH_TIME, EDIT_MAN, EDIT_TIME
      )
    ( <foreach collection="list" item="item" separator="union all"> 
   select  
      #{item.noticeId,jdbcType=VARCHAR}, 
      #{item.noticeTypeNo,jdbcType=VARCHAR}, #{item.noticeTypeName,jdbcType=VARCHAR}, 
      #{item.noticeLevel,jdbcType=VARCHAR}, #{item.noticeName,jdbcType=VARCHAR}, #{item.noticeContent,jdbcType=VARCHAR}, 
      #{item.readManNum,jdbcType=VARCHAR}, #{item.validFlag,jdbcType=VARCHAR}, #{item.publishMan,jdbcType=VARCHAR}, 
      #{item.publishTime,jdbcType=VARCHAR}, #{item.editMan,jdbcType=VARCHAR}, #{item.editTime,jdbcType=VARCHAR}
       from dual  
   </foreach> )
  </insert>
  <update id="batchUpdate" parameterType="java.util.List">
     update METER_WORK_NOTICE
     set
       NOTICE_ID=
       <foreach collection="list" item="item" index="index" separator=" " open="case NOTICE_ID" close="end">
          when #{item.noticeId,jdbcType=VARCHAR} then #{item.noticeId,jdbcType=VARCHAR}
       </foreach>
       ,NOTICE_TYPE_NO=
       <foreach collection="list" item="item" index="index" separator=" " open="case NOTICE_ID" close="end">
          when #{item.noticeId,jdbcType=VARCHAR} then #{item.noticeTypeNo,jdbcType=VARCHAR}
       </foreach>
       ,NOTICE_TYPE_NAME=
       <foreach collection="list" item="item" index="index" separator=" " open="case NOTICE_ID" close="end">
          when #{item.noticeId,jdbcType=VARCHAR} then #{item.noticeTypeName,jdbcType=VARCHAR}
       </foreach>
       ,NOTICE_LEVEL=
       <foreach collection="list" item="item" index="index" separator=" " open="case NOTICE_ID" close="end">
          when #{item.noticeId,jdbcType=VARCHAR} then #{item.noticeLevel,jdbcType=VARCHAR}
       </foreach>
       ,NOTICE_NAME=
       <foreach collection="list" item="item" index="index" separator=" " open="case NOTICE_ID" close="end">
          when #{item.noticeId,jdbcType=VARCHAR} then #{item.noticeName,jdbcType=VARCHAR}
       </foreach>
       ,NOTICE_CONTENT=
       <foreach collection="list" item="item" index="index" separator=" " open="case NOTICE_ID" close="end">
          when #{item.noticeId,jdbcType=VARCHAR} then #{item.noticeContent,jdbcType=VARCHAR}
       </foreach>
       ,READ_MAN_NUM=
       <foreach collection="list" item="item" index="index" separator=" " open="case NOTICE_ID" close="end">
          when #{item.noticeId,jdbcType=VARCHAR} then #{item.readManNum,jdbcType=VARCHAR}
       </foreach>
       ,VALID_FLAG=
       <foreach collection="list" item="item" index="index" separator=" " open="case NOTICE_ID" close="end">
          when #{item.noticeId,jdbcType=VARCHAR} then #{item.validFlag,jdbcType=VARCHAR}
       </foreach>
       ,PUBLISH_MAN=
       <foreach collection="list" item="item" index="index" separator=" " open="case NOTICE_ID" close="end">
          when #{item.noticeId,jdbcType=VARCHAR} then #{item.publishMan,jdbcType=VARCHAR}
       </foreach>
       ,PUBLISH_TIME=
       <foreach collection="list" item="item" index="index" separator=" " open="case NOTICE_ID" close="end">
          when #{item.noticeId,jdbcType=VARCHAR} then #{item.publishTime,jdbcType=VARCHAR}
       </foreach>
       ,EDIT_MAN=
       <foreach collection="list" item="item" index="index" separator=" " open="case NOTICE_ID" close="end">
          when #{item.noticeId,jdbcType=VARCHAR} then #{item.editMan,jdbcType=VARCHAR}
       </foreach>
       ,EDIT_TIME=
       <foreach collection="list" item="item" index="index" separator=" " open="case NOTICE_ID" close="end">
          when #{item.noticeId,jdbcType=VARCHAR} then #{item.editTime,jdbcType=VARCHAR}
       </foreach>
     where NOTICE_ID in 
     <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
    #{item.noticeId,jdbcType=VARCHAR}
     </foreach> 
  </update>
  <delete id="batchDelete" parameterType="java.util.List">
    delete from METER_WORK_NOTICE
    where NOTICE_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(NOTICE_ID,9))),0) + 1,4,'0') NOTICE_ID
    FROM METER_WORK_NOTICE where instr(NOTICE_ID,#{afl,jdbcType=VARCHAR})>0
  </select>
</mapper>