<?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.tmaintenance.mapper.TMaintenanceMapper">
  <resultMap id="BaseResultMap" type="com.steerinfo.ems.tmaintenance.model.TMaintenance">
    <id column="DECLAREID" jdbcType="VARCHAR" property="declareid" />
    <result column="BILLSTATUS" jdbcType="VARCHAR" property="billstatus" />
    <result column="EQUIPMENTNAME" jdbcType="VARCHAR" property="equipmentname" />
    <result column="CHARGEMAN" jdbcType="VARCHAR" property="chargeman" />
    <result column="APPLAYER" jdbcType="VARCHAR" property="applayer" />
    <result column="REASONCONTENT" jdbcType="VARCHAR" property="reasoncontent" />
    <result column="BZ" jdbcType="VARCHAR" property="bz" />
    <result column="SIGNTIME" jdbcType="VARCHAR" property="signtime" />
    <result column="APPROVER" jdbcType="VARCHAR" property="approver" />
    <result column="CHARGETIME" jdbcType="VARCHAR" property="chargetime" />
    <result column="DECLARETIME" jdbcType="VARCHAR" property="declaretime" />
    <result column="RECORD" jdbcType="DECIMAL" property="record" />
    <result column="FILENAME" jdbcType="VARCHAR" property="filename" />
    <result column="DEVICENAME" jdbcType="VARCHAR" property="devicename" />
    <result column="EQUIPMENT" jdbcType="VARCHAR" property="equipment" />
    <result column="CONSTRUCTIONUNITS" jdbcType="VARCHAR" property="constructionunits" />
    <result column="CONSTRUPEOPLE" jdbcType="VARCHAR" property="construpeople" />
    <result column="CONSTRUDATE" jdbcType="VARCHAR" property="construdate" />
    <result column="CONSTRUCONTENT" jdbcType="VARCHAR" property="construcontent" />
    <result column="CONSTRUFILE" jdbcType="VARCHAR" property="construfile" />
    <result column="RECORDER" jdbcType="VARCHAR" property="recorder" />
  </resultMap>
  <sql id="columns">
    DECLAREID, BILLSTATUS, EQUIPMENTNAME, CHARGEMAN, APPLAYER, REASONCONTENT, BZ, SIGNTIME, 
    APPROVER, CHARGETIME, DECLARETIME, RECORD, FILENAME, DEVICENAME, EQUIPMENT, CONSTRUCTIONUNITS, 
    CONSTRUPEOPLE, CONSTRUDATE, CONSTRUCONTENT, CONSTRUFILE, RECORDER
  </sql>
  <sql id="columns_alias">
    t.DECLAREID, t.BILLSTATUS, t.EQUIPMENTNAME, t.CHARGEMAN, t.APPLAYER, t.REASONCONTENT, 
    t.BZ, t.SIGNTIME, t.APPROVER, t.CHARGETIME, t.DECLARETIME, t.RECORD, t.FILENAME, 
    t.DEVICENAME, t.EQUIPMENT, t.CONSTRUCTIONUNITS, t.CONSTRUPEOPLE, t.CONSTRUDATE,
    t.CONSTRUCONTENT, t.CONSTRUFILE, t.RECORDER
  </sql>
  <sql id="select">
    SELECT <include refid="columns"/> FROM T_MAINTENANCE
  </sql>
  <sql id="select_alias">
    SELECT <include refid="columns_alias"/> FROM T_MAINTENANCE t
  </sql>
  <sql id="where">
    <where> 
      <if test="declareid != null and declareid != ''">
        and DECLAREID = #{declareid}
      </if>
      <if test="billstatus != null and billstatus != ''">
        and BILLSTATUS = #{billstatus}
      </if>
      <if test="equipmentname != null and equipmentname != ''">
        and EQUIPMENTNAME = #{equipmentname}
      </if>
      <if test="chargeman != null and chargeman != ''">
        and CHARGEMAN = #{chargeman}
      </if>
      <if test="applayer != null and applayer != ''">
        and APPLAYER = #{applayer}
      </if>
      <if test="reasoncontent != null and reasoncontent != ''">
        and REASONCONTENT = #{reasoncontent}
      </if>
      <if test="bz != null and bz != ''">
        and BZ = #{bz}
      </if>
      <if test="signtime != null and signtime != ''">
        and SIGNTIME = #{signtime}
      </if>
      <if test="approver != null and approver != ''">
        and APPROVER = #{approver}
      </if>
      <if test="chargetime != null and chargetime != ''">
        and CHARGETIME = #{chargetime}
      </if>
      <if test="declaretime != null and declaretime != ''">
        and DECLARETIME = #{declaretime}
      </if>
      <if test="record != null">
        and RECORD = #{record}
      </if>
      <if test="filename != null and filename != ''">
        and FILENAME = #{filename}
      </if>
      <if test="devicename != null and devicename != ''">
        and DEVICENAME = #{devicename}
      </if>
      <if test="equipment != null and equipment != ''">
        and EQUIPMENT = #{equipment}
      </if>
      <if test="constructionunits != null and constructionunits != ''">
        and CONSTRUCTIONUNITS = #{constructionunits}
      </if>
      <if test="construpeople != null and construpeople != ''">
        and CONSTRUPEOPLE = #{construpeople}
      </if>
      <if test="construdate != null and construdate != ''">
        and CONSTRUDATE = #{construdate}
      </if>
      <if test="construcontent != null and construcontent != ''">
        and CONSTRUCONTENT = #{construcontent}
      </if>
      <if test="construfile != null and construfile != ''">
        and CONSTRUFILE = #{construfile}
      </if>
      <if test="recorder != null and recorder != ''">
        and RECORDER = #{recorder}
      </if>
    </where>
  </sql>
  <sql id="whereLike">
    <where> 
      <if test="declareid != null and declareid != ''">
        and DECLAREID LIKE '%${declareid}%'
      </if>
      <if test="billstatus != null and billstatus != ''">
        and BILLSTATUS LIKE '%${billstatus}%'
      </if>
      <if test="equipmentname != null and equipmentname != ''">
        and EQUIPMENTNAME LIKE '%${equipmentname}%'
      </if>
      <if test="chargeman != null and chargeman != ''">
        and CHARGEMAN LIKE '%${chargeman}%'
      </if>
      <if test="applayer != null and applayer != ''">
        and APPLAYER LIKE '%${applayer}%'
      </if>
      <if test="reasoncontent != null and reasoncontent != ''">
        and REASONCONTENT LIKE '%${reasoncontent}%'
      </if>
      <if test="bz != null and bz != ''">
        and BZ LIKE '%${bz}%'
      </if>
      <if test="signtime != null and signtime != ''">
        and SIGNTIME LIKE '%${signtime}%'
      </if>
      <if test="approver != null and approver != ''">
        and APPROVER LIKE '%${approver}%'
      </if>
      <if test="chargetime != null and chargetime != ''">
        and CHARGETIME LIKE '%${chargetime}%'
      </if>
      <if test="declaretime != null and declaretime != ''">
        and DECLARETIME LIKE '%${declaretime}%'
      </if>
      <if test="record != null">
        and RECORD != 0
      </if>
      <if test="filename != null and filename != ''">
        and FILENAME LIKE '%${filename}%'
      </if>
      <if test="devicename != null and devicename != ''">
        and DEVICENAME LIKE '%${devicename}%'
      </if>
      <if test="equipment != null and equipment != ''">
        and EQUIPMENT LIKE '%${equipment}%'
      </if>
      <if test="constructionunits != null and constructionunits != ''">
        and CONSTRUCTIONUNITS LIKE '%${constructionunits}%'
      </if>
      <if test="construpeople != null and construpeople != ''">
        and CONSTRUPEOPLE LIKE '%${construpeople}%'
      </if>
      <if test="construdate != null and construdate != ''">
        and CONSTRUDATE LIKE '%${construdate}%'
      </if>
      <if test="construcontent != null and construcontent != ''">
        and CONSTRUCONTENT LIKE '%${construcontent}%'
      </if>
      <if test="construfile != null and construfile != ''">
        and CONSTRUFILE LIKE '%${construfile}%'
      </if>
      <if test="recorder != null and recorder != ''">
        and recorder LIKE '%${recorder}%'
      </if>
    </where>
  </sql>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    delete from T_MAINTENANCE
    where DECLAREID = #{declareid,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteBySelectiveElement" parameterType="java.util.HashMap">
    delete from T_MAINTENANCE
    where 1!=1 
      <if test="billstatus != null and billstatus != ''">
        or BILLSTATUS = #{billstatus}
      </if>
      <if test="equipmentname != null and equipmentname != ''">
        or EQUIPMENTNAME = #{equipmentname}
      </if>
      <if test="chargeman != null and chargeman != ''">
        or CHARGEMAN = #{chargeman}
      </if>
      <if test="applayer != null and applayer != ''">
        or APPLAYER = #{applayer}
      </if>
      <if test="reasoncontent != null and reasoncontent != ''">
        or REASONCONTENT = #{reasoncontent}
      </if>
      <if test="bz != null and bz != ''">
        or BZ = #{bz}
      </if>
      <if test="signtime != null and signtime != ''">
        or SIGNTIME = #{signtime}
      </if>
      <if test="approver != null and approver != ''">
        or APPROVER = #{approver}
      </if>
      <if test="chargetime != null and chargetime != ''">
        or CHARGETIME = #{chargetime}
      </if>
      <if test="declaretime != null and declaretime != ''">
        or DECLARETIME = #{declaretime}
      </if>
      <if test="record != null">
        or RECORD = #{record}
      </if>
      <if test="filename != null and filename != ''">
        or FILENAME = #{filename}
      </if>
      <if test="devicename != null and devicename != ''">
        or DEVICENAME = #{devicename}
      </if>
      <if test="equipment != null and equipment != ''">
        or EQUIPMENT = #{equipment}
      </if>
      <if test="constructionunits != null and constructionunits != ''">
        or CONSTRUCTIONUNITS = #{constructionunits}
      </if>
      <if test="construpeople != null and construpeople != ''">
        or CONSTRUPEOPLE = #{construpeople}
      </if>
      <if test="construdate != null and construdate != ''">
        or CONSTRUDATE = #{construdate}
      </if>
      <if test="construcontent != null and construcontent != ''">
        or CONSTRUCONTENT = #{construcontent}
      </if>
      <if test="construfile != null and construfile != ''">
        or CONSTRUFILE = #{construfile}
      </if>
      <if test="recorder != null and recorder != ''">
        or RECORDER = #{recorder}
      </if>
  </delete>
  <insert id="insert" parameterType="com.steerinfo.ems.tmaintenance.model.TMaintenance">
    insert into T_MAINTENANCE (DECLAREID, BILLSTATUS, EQUIPMENTNAME, 
      CHARGEMAN, APPLAYER, REASONCONTENT, 
      BZ, SIGNTIME, APPROVER, 
      CHARGETIME, DECLARETIME, RECORD, 
      FILENAME, DEVICENAME, EQUIPMENT, 
      CONSTRUCTIONUNITS, CONSTRUPEOPLE, CONSTRUDATE,
      CONSTRUCONTENT, CONSTRUFILE, RECORDER
      )
    values (#{declareid,jdbcType=VARCHAR}, #{billstatus,jdbcType=VARCHAR}, #{equipmentname,jdbcType=VARCHAR}, 
      #{chargeman,jdbcType=VARCHAR}, #{applayer,jdbcType=VARCHAR}, #{reasoncontent,jdbcType=VARCHAR}, 
      #{bz,jdbcType=VARCHAR}, #{signtime,jdbcType=VARCHAR}, #{approver,jdbcType=VARCHAR}, 
      #{chargetime,jdbcType=VARCHAR}, #{declaretime,jdbcType=VARCHAR}, #{record,jdbcType=DECIMAL}, 
      #{filename,jdbcType=VARCHAR}, #{devicename,jdbcType=VARCHAR}, #{equipment,jdbcType=VARCHAR}, 
      #{constructionunits,jdbcType=VARCHAR}, #{construpeople,jdbcType=VARCHAR}, #{construdate,jdbcType=VARCHAR}, 
      #{construcontent,jdbcType=VARCHAR}, #{construfile,jdbcType=VARCHAR}, #{recorder,jdbcType=VARCHAR}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.steerinfo.ems.tmaintenance.model.TMaintenance">
    insert into T_MAINTENANCE
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="declareid != null">
        DECLAREID,
      </if>
      <if test="billstatus != null">
        BILLSTATUS,
      </if>
      <if test="equipmentname != null">
        EQUIPMENTNAME,
      </if>
      <if test="chargeman != null">
        CHARGEMAN,
      </if>
      <if test="applayer != null">
        APPLAYER,
      </if>
      <if test="reasoncontent != null">
        REASONCONTENT,
      </if>
      <if test="bz != null">
        BZ,
      </if>
      <if test="signtime != null">
        SIGNTIME,
      </if>
      <if test="approver != null">
        APPROVER,
      </if>
      <if test="chargetime != null">
        CHARGETIME,
      </if>
      <if test="declaretime != null">
        DECLARETIME,
      </if>
      <if test="record != null">
        RECORD,
      </if>
      <if test="filename != null">
        FILENAME,
      </if>
      <if test="devicename != null">
        DEVICENAME,
      </if>
      <if test="equipment != null">
        EQUIPMENT,
      </if>
      <if test="constructionunits != null">
        CONSTRUCTIONUNITS,
      </if>
      <if test="construpeople != null">
        CONSTRUPEOPLE,
      </if>
      <if test="construdate != null">
        CONSTRUDATE,
      </if>
      <if test="construcontent != null">
        CONSTRUCONTENT,
      </if>
      <if test="construfile != null">
        CONSTRUFILE,
      </if>
      <if test="recorder != null">
        RECORDER,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="declareid != null">
        #{declareid,jdbcType=VARCHAR},
      </if>
      <if test="billstatus != null">
        #{billstatus,jdbcType=VARCHAR},
      </if>
      <if test="equipmentname != null">
        #{equipmentname,jdbcType=VARCHAR},
      </if>
      <if test="chargeman != null">
        #{chargeman,jdbcType=VARCHAR},
      </if>
      <if test="applayer != null">
        #{applayer,jdbcType=VARCHAR},
      </if>
      <if test="reasoncontent != null">
        #{reasoncontent,jdbcType=VARCHAR},
      </if>
      <if test="bz != null">
        #{bz,jdbcType=VARCHAR},
      </if>
      <if test="signtime != null">
        #{signtime,jdbcType=VARCHAR},
      </if>
      <if test="approver != null">
        #{approver,jdbcType=VARCHAR},
      </if>
      <if test="chargetime != null">
        #{chargetime,jdbcType=VARCHAR},
      </if>
      <if test="declaretime != null">
        #{declaretime,jdbcType=VARCHAR},
      </if>
      <if test="record != null">
        #{record,jdbcType=DECIMAL},
      </if>
      <if test="filename != null">
        #{filename,jdbcType=VARCHAR},
      </if>
      <if test="devicename != null">
        #{devicename,jdbcType=VARCHAR},
      </if>
      <if test="equipment != null">
        #{equipment,jdbcType=VARCHAR},
      </if>
      <if test="constructionunits != null">
        #{constructionunits,jdbcType=VARCHAR},
      </if>
      <if test="construpeople != null">
        #{construpeople,jdbcType=VARCHAR},
      </if>
      <if test="construdate != null">
        #{construdate,jdbcType=VARCHAR},
      </if>
      <if test="construcontent != null">
        #{construcontent,jdbcType=VARCHAR},
      </if>
      <if test="construfile != null">
        #{construfile,jdbcType=VARCHAR},
      </if>
      <if test="recorder != null">
        #{recorder,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.steerinfo.ems.tmaintenance.model.TMaintenance">
    update T_MAINTENANCE
    set BILLSTATUS = #{billstatus,jdbcType=VARCHAR},
      EQUIPMENTNAME = #{equipmentname,jdbcType=VARCHAR},
      CHARGEMAN = #{chargeman,jdbcType=VARCHAR},
      APPLAYER = #{applayer,jdbcType=VARCHAR},
      REASONCONTENT = #{reasoncontent,jdbcType=VARCHAR},
      BZ = #{bz,jdbcType=VARCHAR},
      SIGNTIME = #{signtime,jdbcType=VARCHAR},
      APPROVER = #{approver,jdbcType=VARCHAR},
      CHARGETIME = #{chargetime,jdbcType=VARCHAR},
      DECLARETIME = #{declaretime,jdbcType=VARCHAR},
      RECORD = #{record,jdbcType=DECIMAL},
      FILENAME = #{filename,jdbcType=VARCHAR},
      DEVICENAME = #{devicename,jdbcType=VARCHAR},
      EQUIPMENT = #{equipment,jdbcType=VARCHAR},
      CONSTRUCTIONUNITS = #{constructionunits,jdbcType=VARCHAR},
      CONSTRUPEOPLE = #{construpeople,jdbcType=VARCHAR},
      CONSTRUDATE = #{construdate,jdbcType=VARCHAR},
      CONSTRUCONTENT = #{construcontent,jdbcType=VARCHAR},
      CONSTRUFILE = #{construfile,jdbcType=VARCHAR},
      RECORDER = #{recorder,jdbcType=VARCHAR}
    where DECLAREID = #{declareid,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.steerinfo.ems.tmaintenance.model.TMaintenance">
    update T_MAINTENANCE
    <set>
      <if test="billstatus != null">
        BILLSTATUS = #{billstatus,jdbcType=VARCHAR},
      </if>
      <if test="equipmentname != null">
        EQUIPMENTNAME = #{equipmentname,jdbcType=VARCHAR},
      </if>
      <if test="chargeman != null">
        CHARGEMAN = #{chargeman,jdbcType=VARCHAR},
      </if>
      <if test="applayer != null">
        APPLAYER = #{applayer,jdbcType=VARCHAR},
      </if>
      <if test="reasoncontent != null">
        REASONCONTENT = #{reasoncontent,jdbcType=VARCHAR},
      </if>
      <if test="bz != null">
        BZ = #{bz,jdbcType=VARCHAR},
      </if>
      <if test="signtime != null">
        SIGNTIME = #{signtime,jdbcType=VARCHAR},
      </if>
      <if test="approver != null">
        APPROVER = #{approver,jdbcType=VARCHAR},
      </if>
      <if test="chargetime != null">
        CHARGETIME = #{chargetime,jdbcType=VARCHAR},
      </if>
      <if test="declaretime != null">
        DECLARETIME = #{declaretime,jdbcType=VARCHAR},
      </if>
      <if test="record != null">
        RECORD = #{record,jdbcType=DECIMAL},
      </if>
      <if test="filename != null">
        FILENAME = #{filename,jdbcType=VARCHAR},
      </if>
      <if test="devicename != null">
        DEVICENAME = #{devicename,jdbcType=VARCHAR},
      </if>
      <if test="equipment != null">
        EQUIPMENT = #{equipment,jdbcType=VARCHAR},
      </if>
      <if test="constructionunits != null">
        CONSTRUCTIONUNITS = #{constructionunits,jdbcType=VARCHAR},
      </if>
      <if test="construpeople != null">
        CONSTRUPEOPLE = #{construpeople,jdbcType=VARCHAR},
      </if>
      <if test="construdate != null">
        CONSTRUDATE = #{construdate,jdbcType=VARCHAR},
      </if>
      <if test="construcontent != null">
        CONSTRUCONTENT = #{construcontent,jdbcType=VARCHAR},
      </if>
      <if test="construfile != null">
        CONSTRUFILE = #{construfile,jdbcType=VARCHAR},
      </if>
      <if test="recorder != null">
        RECORDER = #{recorder,jdbcType=VARCHAR},
      </if>
    </set>
    where DECLAREID = #{declareid,jdbcType=VARCHAR} and RECORD >0
  </update>
  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
    <include refid="select"/>
    where DECLAREID = #{declareid,jdbcType=VARCHAR} and RECORD >0
  </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"/>
    <where>
      <if test="declareid != null and declareid != ''">
        and DECLAREID LIKE '%${declareid}%'
      </if>
      <if test="billstatus != null and billstatus != ''">
        and BILLSTATUS LIKE '%${billstatus}%'
      </if>
      <if test="equipmentname != null and equipmentname != ''">
        and EQUIPMENTNAME LIKE '%${equipmentname}%'
      </if>
      <if test="chargeman != null and chargeman != ''">
        and CHARGEMAN LIKE '%${chargeman}%'
      </if>
      <if test="applayer != null and applayer != ''">
        and APPLAYER LIKE '%${applayer}%'
      </if>
      <if test="reasoncontent != null and reasoncontent != ''">
        and REASONCONTENT LIKE '%${reasoncontent}%'
      </if>
      <if test="bz != null and bz != ''">
        and BZ LIKE '%${bz}%'
      </if>
      <if test="signtime != null and signtime != ''">
        and SIGNTIME LIKE '%${signtime}%'
      </if>
      <if test="approver != null and approver != ''">
        and APPROVER LIKE '%${approver}%'
      </if>
      <if test="chargetime != null and chargetime != ''">
        and CHARGETIME LIKE '%${chargetime}%'
      </if>
      <if test="declaretime != null and declaretime != ''">
        and DECLARETIME >= #{declaretime}
      </if>
      <if test="declaretime1 != null and declaretime1 != ''">
        and DECLARETIME &lt;= #{declaretime1}
      </if>
      <if test="record != null">
        and RECORD != 0
      </if>
      <if test="filename != null and filename != ''">
        and FILENAME LIKE '%${filename}%'
      </if>
      <if test="devicename != null and devicename != ''">
        and DEVICENAME LIKE '%${devicename}%'
      </if>
      <if test="equipment != null and equipment != ''">
        and EQUIPMENT LIKE '%${equipment}%'
      </if>
      <if test="constructionunits != null and constructionunits != ''">
        and CONSTRUCTIONUNITS LIKE '%${constructionunits}%'
      </if>
      <if test="construpeople != null and construpeople != ''">
        and CONSTRUPEOPLE LIKE '%${construpeople}%'
      </if>
      <if test="construdate != null and construdate != ''">
        and CONSTRUDATE LIKE '%${construdate}%'
      </if>
      <if test="construcontent != null and construcontent != ''">
        and CONSTRUCONTENT LIKE '%${construcontent}%'
      </if>
      <if test="construfile != null and construfile != ''">
        and CONSTRUFILE LIKE '%${construfile}%'
      </if>
      <if test="recorder != null and recorder != ''">
        and recorder LIKE '%${recorder}%'
      </if>
    </where>
  </select>
  <insert id="batchInsert" parameterType="java.util.List">
    insert into T_MAINTENANCE 
      (DECLAREID, 
      BILLSTATUS, EQUIPMENTNAME, CHARGEMAN, 
      APPLAYER, REASONCONTENT, BZ, 
      SIGNTIME, APPROVER, CHARGETIME, 
      DECLARETIME, RECORD, FILENAME, 
      DEVICENAME, EQUIPMENT, CONSTRUCTIONUNITS, 
      CONSTRUPEOPLE, CONSTRUDATE, CONSTRUCONTENT,
      CONSTRUFILE, RECORDER)
    ( <foreach collection="list" item="item" separator="union all"> 
   select  
      #{item.declareid,jdbcType=VARCHAR}, 
      #{item.billstatus,jdbcType=VARCHAR}, #{item.equipmentname,jdbcType=VARCHAR}, #{item.chargeman,jdbcType=VARCHAR}, 
      #{item.applayer,jdbcType=VARCHAR}, #{item.reasoncontent,jdbcType=VARCHAR}, #{item.bz,jdbcType=VARCHAR}, 
      #{item.signtime,jdbcType=VARCHAR}, #{item.approver,jdbcType=VARCHAR}, #{item.chargetime,jdbcType=VARCHAR}, 
      #{item.declaretime,jdbcType=VARCHAR}, #{item.record,jdbcType=DECIMAL}, #{item.filename,jdbcType=VARCHAR}, 
      #{item.devicename,jdbcType=VARCHAR}, #{item.equipment,jdbcType=VARCHAR}, #{item.constructionunits,jdbcType=VARCHAR}, 
      #{item.construpeople,jdbcType=VARCHAR}, #{item.construdate,jdbcType=VARCHAR}, #{item.construcontent,jdbcType=VARCHAR}, 
      #{item.construfile,jdbcType=VARCHAR}, #{item.recorder,jdbcType=VARCHAR} from dual  
   </foreach> )
  </insert>
  <update id="batchUpdate" parameterType="java.util.List">
     update T_MAINTENANCE
     set
       DECLAREID=
       <foreach collection="list" item="item" index="index" separator=" " open="case DECLAREID" close="end">
          when #{item.declareid,jdbcType=VARCHAR} then #{item.declareid,jdbcType=VARCHAR}
       </foreach>
       ,BILLSTATUS=
       <foreach collection="list" item="item" index="index" separator=" " open="case DECLAREID" close="end">
          when #{item.declareid,jdbcType=VARCHAR} then #{item.billstatus,jdbcType=VARCHAR}
       </foreach>
       ,EQUIPMENTNAME=
       <foreach collection="list" item="item" index="index" separator=" " open="case DECLAREID" close="end">
          when #{item.declareid,jdbcType=VARCHAR} then #{item.equipmentname,jdbcType=VARCHAR}
       </foreach>
       ,CHARGEMAN=
       <foreach collection="list" item="item" index="index" separator=" " open="case DECLAREID" close="end">
          when #{item.declareid,jdbcType=VARCHAR} then #{item.chargeman,jdbcType=VARCHAR}
       </foreach>
       ,APPLAYER=
       <foreach collection="list" item="item" index="index" separator=" " open="case DECLAREID" close="end">
          when #{item.declareid,jdbcType=VARCHAR} then #{item.applayer,jdbcType=VARCHAR}
       </foreach>
       ,REASONCONTENT=
       <foreach collection="list" item="item" index="index" separator=" " open="case DECLAREID" close="end">
          when #{item.declareid,jdbcType=VARCHAR} then #{item.reasoncontent,jdbcType=VARCHAR}
       </foreach>
       ,BZ=
       <foreach collection="list" item="item" index="index" separator=" " open="case DECLAREID" close="end">
          when #{item.declareid,jdbcType=VARCHAR} then #{item.bz,jdbcType=VARCHAR}
       </foreach>
       ,SIGNTIME=
       <foreach collection="list" item="item" index="index" separator=" " open="case DECLAREID" close="end">
          when #{item.declareid,jdbcType=VARCHAR} then #{item.signtime,jdbcType=VARCHAR}
       </foreach>
       ,APPROVER=
       <foreach collection="list" item="item" index="index" separator=" " open="case DECLAREID" close="end">
          when #{item.declareid,jdbcType=VARCHAR} then #{item.approver,jdbcType=VARCHAR}
       </foreach>
       ,CHARGETIME=
       <foreach collection="list" item="item" index="index" separator=" " open="case DECLAREID" close="end">
          when #{item.declareid,jdbcType=VARCHAR} then #{item.chargetime,jdbcType=VARCHAR}
       </foreach>
       ,DECLARETIME=
       <foreach collection="list" item="item" index="index" separator=" " open="case DECLAREID" close="end">
          when #{item.declareid,jdbcType=VARCHAR} then #{item.declaretime,jdbcType=VARCHAR}
       </foreach>
       ,RECORD=
       <foreach collection="list" item="item" index="index" separator=" " open="case DECLAREID" close="end">
          when #{item.declareid,jdbcType=VARCHAR} then #{item.record,jdbcType=DECIMAL}
       </foreach>
       ,FILENAME=
       <foreach collection="list" item="item" index="index" separator=" " open="case DECLAREID" close="end">
          when #{item.declareid,jdbcType=VARCHAR} then #{item.filename,jdbcType=VARCHAR}
       </foreach>
       ,DEVICENAME=
       <foreach collection="list" item="item" index="index" separator=" " open="case DECLAREID" close="end">
          when #{item.declareid,jdbcType=VARCHAR} then #{item.devicename,jdbcType=VARCHAR}
       </foreach>
       ,EQUIPMENT=
       <foreach collection="list" item="item" index="index" separator=" " open="case DECLAREID" close="end">
          when #{item.declareid,jdbcType=VARCHAR} then #{item.equipment,jdbcType=VARCHAR}
       </foreach>
       ,CONSTRUCTIONUNITS=
       <foreach collection="list" item="item" index="index" separator=" " open="case DECLAREID" close="end">
          when #{item.declareid,jdbcType=VARCHAR} then #{item.constructionunits,jdbcType=VARCHAR}
       </foreach>
       ,CONSTRUPEOPLE=
       <foreach collection="list" item="item" index="index" separator=" " open="case DECLAREID" close="end">
          when #{item.declareid,jdbcType=VARCHAR} then #{item.construpeople,jdbcType=VARCHAR}
       </foreach>
       ,CONSTRUDATE=
       <foreach collection="list" item="item" index="index" separator=" " open="case DECLAREID" close="end">
          when #{item.declareid,jdbcType=VARCHAR} then #{item.construdate,jdbcType=VARCHAR}
       </foreach>
       ,CONSTRUCONTENT=
       <foreach collection="list" item="item" index="index" separator=" " open="case DECLAREID" close="end">
          when #{item.declareid,jdbcType=VARCHAR} then #{item.construcontent,jdbcType=VARCHAR}
       </foreach>
       ,CONSTRUFILE=
       <foreach collection="list" item="item" index="index" separator=" " open="case DECLAREID" close="end">
          when #{item.declareid,jdbcType=VARCHAR} then #{item.construfile,jdbcType=VARCHAR}
       </foreach>
       ,RECORDER=
       <foreach collection="list" item="item" index="index" separator=" " open="case DECLAREID" close="end">
          when #{item.declareid,jdbcType=VARCHAR} then #{item.recorder,jdbcType=VARCHAR}
       </foreach>
     where DECLAREID in 
     <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
    #{item.declareid,jdbcType=VARCHAR}
     </foreach> 
  </update>
  <delete id="batchDelete" parameterType="java.util.List">
    delete from T_MAINTENANCE
    where DECLAREID in 
    <foreach collection="list" item="id" open="(" close=")" separator=",">
      #{id}
    </foreach>
  </delete>
  <!-- 友情提示！！！-->
  <!-- 请将自己写的代码放在此标签之下，方便以后粘贴复制。-->
  <select id="selectMaxId" resultType="java.lang.Integer" >
    SELECT MAX(RECORD) FROM T_MAINTENANCE where DECLARETIME LIKE '%${declaretime}%'
  </select>

  <select id="selectAll" resultMap="BaseResultMap" parameterType="string">
    SELECT * FROM T_MAINTENANCE where record > 0
  </select>

  <update id="deleMes" parameterType="string">
    update T_MAINTENANCE set
    RECORD = 0
    <where>
      declareid in
      #{declareid,jdbcType=VARCHAR}
    </where>
  </update>
  <update id="pusMes" parameterType ="com.steerinfo.ems.tmaintenance.model.TMaintenance">
    update T_MAINTENANCE set
    EQUIPMENTNAME = #{equipmentname,jdbcType=VARCHAR}, CHARGEMAN =#{chargeman,jdbcType=VARCHAR},
    REASONCONTENT=#{reasoncontent,jdbcType=VARCHAR}, BZ=#{bz,jdbcType=VARCHAR},
    DECLARETIME = #{declaretime,jdbcType=VARCHAR},BILLSTATUS = #{billstatus,jdbcType=VARCHAR}
    <where>
      declareid in #{declareid,jdbcType=VARCHAR}
    </where>
  </update>

  <select id="select" resultMap="BaseResultMap" parameterType="string">
    SELECT * FROM T_MAINTENANCE
  </select>

  <update id="pusMesAll" parameterType ="String">
    update T_MAINTENANCE set
    BILLSTATUS = #{billstatus,jdbcType=VARCHAR}
    <where>
      declareid in #{declareid,jdbcType=VARCHAR}
    </where>
  </update>

  <select id="selectLike" parameterType="java.util.HashMap" resultMap="BaseResultMap">
    select DECLAREID, BILLSTATUS, EQUIPMENTNAME, CHARGEMAN, APPLAYER, REASONCONTENT, BZ, SIGNTIME,
    APPROVER, CHARGETIME, DECLARETIME,FILENAME, RECORD,DEVICENAME, EQUIPMENT, CONSTRUCTIONUNITS,
    CONSTRUPEOPLE from T_MAINTENANCE
    <where>
      BILLSTATUS in ('已通过','已驳回','审核中','已完成','进行中') and RECORD != 0
    </where>
  </select>

  <update id="pusMesAlla" parameterType ="String">
    update T_MAINTENANCE set
    BILLSTATUS = #{billstatus,jdbcType=VARCHAR},
    APPROVER = #{approver,jdbcType=VARCHAR},
    SIGNTIME = #{signtime,jdbcType=VARCHAR}
    <where>
      declareid in #{declareid,jdbcType=VARCHAR}
    </where>
  </update>
  <select id="selectLikes" parameterType="java.util.HashMap" resultMap="BaseResultMap">
    select DECLAREID, BILLSTATUS, EQUIPMENTNAME, CHARGEMAN, APPLAYER, REASONCONTENT, BZ, SIGNTIME,
    APPROVER, CHARGETIME, DECLARETIME,FILENAME, RECORD,DEVICENAME, EQUIPMENT, CONSTRUCTIONUNITS,
    CONSTRUPEOPLE from T_MAINTENANCE
    <where>
      <if test="declareid != null and declareid != ''">
        and DECLAREID LIKE '%${declareid}%'
      </if>
      <if test="billstatus != null and billstatus != ''">
        and BILLSTATUS LIKE '%${billstatus}%'
      </if>
      <if test="equipmentname != null and equipmentname != ''">
        and EQUIPMENTNAME LIKE '%${equipmentname}%'
      </if>
      <if test="chargeman != null and chargeman != ''">
        and CHARGEMAN LIKE '%${chargeman}%'
      </if>
      <if test="applayer != null and applayer != ''">
        and APPLAYER LIKE '%${applayer}%'
      </if>
      <if test="reasoncontent != null and reasoncontent != ''">
        and REASONCONTENT LIKE '%${reasoncontent}%'
      </if>
      <if test="bz != null and bz != ''">
        and BZ LIKE '%${bz}%'
      </if>
      <if test="signtime != null and signtime != ''">
        and SIGNTIME LIKE '%${signtime}%'
      </if>
      <if test="approver != null and approver != ''">
        and APPROVER LIKE '%${approver}%'
      </if>
      <if test="chargetime != null and chargetime != ''">
        and CHARGETIME LIKE '%${chargetime}%'
      </if>
      <if test="declaretime != null and declaretime != ''">
        and DECLARETIME >= #{declaretime}
      </if>
      <if test="declaretime1 != null and declaretime1 != ''">
        and DECLARETIME &lt;= #{declaretime1}
      </if>
      <if test="record != null">
        and RECORD != 0
      </if>
      <if test="filename != null and filename != ''">
        and FILENAME LIKE '%${filename}%'
      </if>
      <if test="devicename != null and devicename != ''">
        and DEVICENAME LIKE '%${devicename}%'
      </if>
      <if test="equipment != null and equipment != ''">
        and EQUIPMENT LIKE '%${equipment}%'
      </if>
      <if test="constructionunits != null and constructionunits != ''">
        and CONSTRUCTIONUNITS LIKE '%${constructionunits}%'
      </if>
      <if test="construpeople != null and construpeople != ''">
        and CONSTRUPEOPLE LIKE '%${construpeople}%'
      </if>
      <if test="construdate != null and construdate != ''">
        and CONSTRUDATE LIKE '%${construdate}%'
      </if>
      <if test="construcontent != null and construcontent != ''">
        and CONSTRUCONTENT LIKE '%${construcontent}%'
      </if>
      <if test="construfile != null and construfile != ''">
        and CONSTRUFILE LIKE '%${construfile}%'
      </if>
      <if test="recorder != null and recorder != ''">
        and recorder LIKE '%${recorder}%'
      </if>
    </where>
  </select>
  <select id="approval" parameterType="java.util.HashMap" resultMap="BaseResultMap">
    select DECLAREID, BILLSTATUS, EQUIPMENTNAME, CHARGEMAN, APPLAYER, REASONCONTENT, BZ, SIGNTIME,
    APPROVER, CHARGETIME, DECLARETIME,FILENAME, RECORD,DEVICENAME, EQUIPMENT, CONSTRUCTIONUNITS,
    CONSTRUPEOPLE from T_MAINTENANCE
    <where>
      <if test="declareid != null and declareid != ''">
        and DECLAREID LIKE '%${declareid}%'
      </if>
      <if test="billstatus != null and billstatus != ''">
        and BILLSTATUS LIKE '%${billstatus}%'
      </if>
      <if test="equipmentname != null and equipmentname != ''">
        and EQUIPMENTNAME LIKE '%${equipmentname}%'
      </if>
      <if test="chargeman != null and chargeman != ''">
        and CHARGEMAN LIKE '%${chargeman}%'
      </if>
      <if test="applayer != null and applayer != ''">
        and APPLAYER LIKE '%${applayer}%'
      </if>
      <if test="reasoncontent != null and reasoncontent != ''">
        and REASONCONTENT LIKE '%${reasoncontent}%'
      </if>
      <if test="bz != null and bz != ''">
        and BZ LIKE '%${bz}%'
      </if>
      <if test="signtime != null and signtime != ''">
        and SIGNTIME LIKE '%${signtime}%'
      </if>
      <if test="approver != null and approver != ''">
        and APPROVER LIKE '%${approver}%'
      </if>
      <if test="chargetime != null and chargetime != ''">
        and CHARGETIME LIKE '%${chargetime}%'
      </if>
      <if test="declaretime != null and declaretime != ''">
        and DECLARETIME >= #{declaretime}
      </if>
      <if test="declaretime1 != null and declaretime1 != ''">
        and DECLARETIME &lt;= #{declaretime1}
      </if>
      <if test="record != null">
        and RECORD != 0
      </if>
      <if test="filename != null and filename != ''">
        and FILENAME LIKE '%${filename}%'
      </if>
      <if test="devicename != null and devicename != ''">
        and DEVICENAME LIKE '%${devicename}%'
      </if>
      <if test="equipment != null and equipment != ''">
        and EQUIPMENT LIKE '%${equipment}%'
      </if>
      <if test="constructionunits != null and constructionunits != ''">
        and CONSTRUCTIONUNITS LIKE '%${constructionunits}%'
      </if>
      <if test="construpeople != null and construpeople != ''">
        and CONSTRUPEOPLE LIKE '%${construpeople}%'
      </if>
      <if test="construdate != null and construdate != ''">
        and CONSTRUDATE LIKE '%${construdate}%'
      </if>
      <if test="construcontent != null and construcontent != ''">
        and CONSTRUCONTENT LIKE '%${construcontent}%'
      </if>
      <if test="construfile != null and construfile != ''">
        and CONSTRUFILE LIKE '%${construfile}%'
      </if>
      <if test="recorder != null and recorder != ''">
        and recorder LIKE '%${recorder}%'
      </if>
    </where>
  </select>
  <update id="updatecheck" parameterType="string">
    update T_MAINTENANCE set
    BILLSTATUS = '编辑中'
    <where>
      declareid in
      #{declareid,jdbcType=VARCHAR} and RECORD>0
    </where>
  </update>
  <select id="selectfilename" parameterType = "string" resultType="string">
    SELECT
      listagg (filename, ',')within group ( ORDER BY filename)
    FROM
      (
      SELECT
      distinct
      t.DECLAREID,
      t1.filename,
      t1.id
      FROM
      T_MAINTENANCE t
      LEFT JOIN T_MAINTENANCE_FILE t1 ON t.declareid = t1.id
      WHERE
      t.record > 0 and t.declareid =#{declareid,jdbcType=VARCHAR}
      )
    GROUP BY id
  </select>
</mapper>