<?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.emswaterrealtime.mapper.EmsWaterRealtimeMapper">
  <resultMap id="BaseResultMap" type="com.steerinfo.ems.emswaterrealtime.model.EmsWaterRealtime">
    <id column="MeterId" jdbcType="VARCHAR" property="meterid" />
    <result column="PhoneNo" jdbcType="VARCHAR" property="phoneno" />
    <result column="AddressCode" jdbcType="VARCHAR" property="addresscode" />
    <result column="M_UserType" jdbcType="VARCHAR" property="mUsertype" />
    <result column="M_Type" jdbcType="VARCHAR" property="mType" />
    <result column="M_Name" jdbcType="VARCHAR" property="mName" />
    <result column="M_DoorNo" jdbcType="VARCHAR" property="mDoorno" />
    <result column="M_PipeDn" jdbcType="VARCHAR" property="mPipedn" />
    <result column="M_Material" jdbcType="VARCHAR" property="mMaterial" />
    <result column="M_Ratio" jdbcType="VARCHAR" property="mRatio" />
    <result column="CreateTime" jdbcType="TIMESTAMP" property="createtime" />
    <result column="ForValue" jdbcType="DECIMAL" property="forvalue" />
    <result column="RevValue" jdbcType="DECIMAL" property="revvalue" />
    <result column="PressValue" jdbcType="DECIMAL" property="pressvalue" />
    <result column="RealValue" jdbcType="DECIMAL" property="realvalue" />
    <result column="SumValue" jdbcType="DECIMAL" property="sumvalue" />
    <result column="CelVal" jdbcType="DECIMAL" property="celval" />
    <result column="NetVal" jdbcType="DECIMAL" property="netval" />
    <result column="IsStat" jdbcType="CHAR" property="isstat" />
    <result column="DeviceId" jdbcType="VARCHAR" property="deviceid" />
    <result column="ReadTime" jdbcType="TIMESTAMP" property="readtime" />
    <result column="MOSAICID" jdbcType="VARCHAR" property="mosaicid" />
  </resultMap>
  <sql id="columns">
    MeterId, PhoneNo, AddressCode, M_UserType, M_Type, M_Name, M_DoorNo, M_PipeDn, M_Material,
    M_Ratio, CreateTime, ForValue, RevValue, PressValue, RealValue, SumValue, CelVal,
    NetVal, IsStat, DeviceId, ReadTime, MOSAICID
  </sql>
  <sql id="columns_alias">
    t.MeterId, t.PhoneNo, t.AddressCode, t.M_UserType, t.M_Type, t.M_Name, t.M_DoorNo,
    t.M_PipeDn, t.M_Material, t.M_Ratio, t.CreateTime, t.ForValue, t.RevValue, t.PressValue,
    t.RealValue, t.SumValue, t.CelVal, t.NetVal, t.IsStat, t.DeviceId, t.ReadTime, t.MosaicId
  </sql>
  <sql id="select">
    SELECT <include refid="columns"/> FROM EMS_WATER_REALTIME
  </sql>
  <sql id="select_alias">
    SELECT <include refid="columns_alias"/> FROM EMS_WATER_REALTIME t
  </sql>
  <sql id="where">
    <where>
      <if test="meterid != null">
        and MeterId = #{meterid}
      </if>
      <if test="phoneno != null and phoneno != ''">
        and PhoneNo = #{phoneno}
      </if>
      <if test="addresscode != null and addresscode != ''">
        and AddressCode = #{addresscode}
      </if>
      <if test="mUsertype != null and mUsertype != ''">
        and M_UserType = #{mUsertype}
      </if>
      <if test="mType != null and mType != ''">
        and M_Type = #{mType}
      </if>
      <if test="mName != null and mName != ''">
        and M_Name = #{mName}
      </if>
      <if test="mDoorno != null and mDoorno != ''">
        and M_DoorNo = #{mDoorno}
      </if>
      <if test="mPipedn != null and mPipedn != ''">
        and M_PipeDn = #{mPipedn}
      </if>
      <if test="mMaterial != null and mMaterial != ''">
        and M_Material = #{mMaterial}
      </if>
      <if test="mRatio != null and mRatio != ''">
        and M_Ratio = #{mRatio}
      </if>
      <if test="createtime != null">
        and TO_CHAR(CreateTime,'yyyy-MM-dd') = #{createtime}
      </if>
      <if test="forvalue != null">
        and ForValue = #{forvalue}
      </if>
      <if test="revvalue != null">
        and RevValue = #{revvalue}
      </if>
      <if test="pressvalue != null">
        and PressValue = #{pressvalue}
      </if>
      <if test="realvalue != null">
        and RealValue = #{realvalue}
      </if>
      <if test="sumvalue != null">
        and SumValue = #{sumvalue}
      </if>
      <if test="celval != null">
        and CelVal = #{celval}
      </if>
      <if test="netval != null">
        and NetVal = #{netval}
      </if>
      <if test="isstat != null">
        and IsStat = #{isstat}
      </if>
      <if test="deviceid != null and deviceid != ''">
        and DeviceId = #{deviceid}
      </if>
      <if test="readtime != null">
        and TO_CHAR(ReadTime,'yyyy-MM-dd') = #{readtime}
      </if>
    </where>
  </sql>
  <sql id="whereLike">
    <where>
      <if test="meterid != null">
        and MeterId = #{meterid}
      </if>
      <if test="phoneno != null and phoneno != ''">
        and PhoneNo LIKE '%${phoneno}%'
      </if>
      <if test="addresscode != null and addresscode != ''">
        and AddressCode LIKE '%${addresscode}%'
      </if>
      <if test="mUsertype != null and mUsertype != ''">
        and M_UserType LIKE '%${mUsertype}%'
      </if>
      <if test="mType != null and mType != ''">
        and M_Type LIKE '%${mType}%'
      </if>
      <if test="mName != null and mName != ''">
        and M_Name LIKE '%${mName}%'
      </if>
      <if test="mDoorno != null and mDoorno != ''">
        and M_DoorNo LIKE '%${mDoorno}%'
      </if>
      <if test="mPipedn != null and mPipedn != ''">
        and M_PipeDn LIKE '%${mPipedn}%'
      </if>
      <if test="mMaterial != null and mMaterial != ''">
        and M_Material LIKE '%${mMaterial}%'
      </if>
      <if test="mRatio != null and mRatio != ''">
        and M_Ratio LIKE '%${mRatio}%'
      </if>
      <if test="createtime != null">
        and TO_CHAR(CreateTime,'yyyy-MM-dd') = #{createtime}
      </if>
      <if test="forvalue != null">
        and ForValue = #{forvalue}
      </if>
      <if test="revvalue != null">
        and RevValue = #{revvalue}
      </if>
      <if test="pressvalue != null">
        and PressValue = #{pressvalue}
      </if>
      <if test="realvalue != null">
        and RealValue = #{realvalue}
      </if>
      <if test="sumvalue != null">
        and SumValue = #{sumvalue}
      </if>
      <if test="celval != null">
        and CelVal = #{celval}
      </if>
      <if test="netval != null">
        and NetVal = #{netval}
      </if>
      <if test="isstat != null">
        and IsStat = #{isstat}
      </if>
      <if test="deviceid != null and deviceid != ''">
        and DeviceId LIKE '%${deviceid}%'
      </if>
      <if test="readtime != null">
        and TO_CHAR(ReadTime,'yyyy-MM-dd') = #{readtime}
      </if>
    </where>
  </sql>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    delete from EMS_WATER_REALTIME
    where MeterId = #{meterid,jdbcType=DECIMAL}
  </delete>
  <delete id="deleteBySelectiveElement" parameterType="java.util.HashMap">
    delete from EMS_WATER_REALTIME
    where 1!=1
      <if test="phoneno != null and phoneno != ''">
        or PhoneNo = #{phoneno}
      </if>
      <if test="addresscode != null and addresscode != ''">
        or AddressCode = #{addresscode}
      </if>
      <if test="mUsertype != null and mUsertype != ''">
        or M_UserType = #{mUsertype}
      </if>
      <if test="mType != null and mType != ''">
        or M_Type = #{mType}
      </if>
      <if test="mName != null and mName != ''">
        or M_Name = #{mName}
      </if>
      <if test="mDoorno != null and mDoorno != ''">
        or M_DoorNo = #{mDoorno}
      </if>
      <if test="mPipedn != null and mPipedn != ''">
        or M_PipeDn = #{mPipedn}
      </if>
      <if test="mMaterial != null and mMaterial != ''">
        or M_Material = #{mMaterial}
      </if>
      <if test="mRatio != null and mRatio != ''">
        or M_Ratio = #{mRatio}
      </if>
      <if test="createtime != null">
        or TO_CHAR(CreateTime,'yyyy-MM-dd') = '#{createtime}'
      </if>
      <if test="forvalue != null">
        or ForValue = #{forvalue}
      </if>
      <if test="revvalue != null">
        or RevValue = #{revvalue}
      </if>
      <if test="pressvalue != null">
        or PressValue = #{pressvalue}
      </if>
      <if test="realvalue != null">
        or RealValue = #{realvalue}
      </if>
      <if test="sumvalue != null">
        or SumValue = #{sumvalue}
      </if>
      <if test="celval != null">
        or CelVal = #{celval}
      </if>
      <if test="netval != null">
        or NetVal = #{netval}
      </if>
      <if test="isstat != null">
        or IsStat = #{isstat}
      </if>
      <if test="deviceid != null and deviceid != ''">
        or DeviceId = #{deviceid}
      </if>
      <if test="readtime != null">
        or TO_CHAR(ReadTime,'yyyy-MM-dd') = '#{readtime}'
      </if>
  </delete>
  <insert id="insert" parameterType="com.steerinfo.ems.emswaterrealtime.model.EmsWaterRealtime">
    insert into EMS_WATER_REALTIME (MeterId, PhoneNo, AddressCode,
      M_UserType, M_Type, M_Name,
      M_DoorNo, M_PipeDn, M_Material,
      M_Ratio, CreateTime, ForValue,
      RevValue, PressValue, RealValue,
      SumValue, CelVal, NetVal,
      IsStat, DeviceId, ReadTime
      )
    values (#{meterid,jdbcType=DECIMAL}, #{phoneno,jdbcType=VARCHAR}, #{addresscode,jdbcType=VARCHAR},
      #{mUsertype,jdbcType=VARCHAR}, #{mType,jdbcType=VARCHAR}, #{mName,jdbcType=VARCHAR},
      #{mDoorno,jdbcType=VARCHAR}, #{mPipedn,jdbcType=VARCHAR}, #{mMaterial,jdbcType=VARCHAR},
      #{mRatio,jdbcType=VARCHAR},
    to_date (substr( #{createtime,jdbcType=TIME}, 0, INSTR( #{createtime,jdbcType=TIME}, '.', 1, 1 )-1), 'YYYY-MM-DD HH24:MI:SS' ),
    #{forvalue,jdbcType=DECIMAL},
      #{revvalue,jdbcType=DECIMAL}, #{pressvalue,jdbcType=DECIMAL}, #{realvalue,jdbcType=DECIMAL},
      #{sumvalue,jdbcType=DECIMAL}, #{celval,jdbcType=DECIMAL}, #{netval,jdbcType=DECIMAL},
      #{isstat,jdbcType=CHAR}, #{deviceid,jdbcType=VARCHAR}, to_date ( #{readtime,jdbcType=TIME} , 'YYYY-MM-DD HH24:MI:SS' )
      )
  </insert>
  <insert id="insertSelective" parameterType="com.steerinfo.ems.emswaterrealtime.model.EmsWaterRealtime">
    insert into EMS_WATER_REALTIME
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="meterid != null">
        MeterId,
      </if>
      <if test="phoneno != null">
        PhoneNo,
      </if>
      <if test="addresscode != null">
        AddressCode,
      </if>
      <if test="mUsertype != null">
        M_UserType,
      </if>
      <if test="mType != null">
        M_Type,
      </if>
      <if test="mName != null">
        M_Name,
      </if>
      <if test="mDoorno != null">
        M_DoorNo,
      </if>
      <if test="mPipedn != null">
        M_PipeDn,
      </if>
      <if test="mMaterial != null">
        M_Material,
      </if>
      <if test="mRatio != null">
        M_Ratio,
      </if>
      <if test="createtime != null">
        CreateTime,
      </if>
      <if test="forvalue != null">
        ForValue,
      </if>
      <if test="revvalue != null">
        RevValue,
      </if>
      <if test="pressvalue != null">
        PressValue,
      </if>
      <if test="realvalue != null">
        RealValue,
      </if>
      <if test="sumvalue != null">
        SumValue,
      </if>
      <if test="celval != null">
        CelVal,
      </if>
      <if test="netval != null">
        NetVal,
      </if>
      <if test="isstat != null">
        IsStat,
      </if>
      <if test="deviceid != null">
        DeviceId,
      </if>
      <if test="readtime != null">
        ReadTime,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="meterid != null">
        #{meterid,jdbcType=DECIMAL},
      </if>
      <if test="phoneno != null">
        #{phoneno,jdbcType=VARCHAR},
      </if>
      <if test="addresscode != null">
        #{addresscode,jdbcType=VARCHAR},
      </if>
      <if test="mUsertype != null">
        #{mUsertype,jdbcType=VARCHAR},
      </if>
      <if test="mType != null">
        #{mType,jdbcType=VARCHAR},
      </if>
      <if test="mName != null">
        #{mName,jdbcType=VARCHAR},
      </if>
      <if test="mDoorno != null">
        #{mDoorno,jdbcType=VARCHAR},
      </if>
      <if test="mPipedn != null">
        #{mPipedn,jdbcType=VARCHAR},
      </if>
      <if test="mMaterial != null">
        #{mMaterial,jdbcType=VARCHAR},
      </if>
      <if test="mRatio != null">
        #{mRatio,jdbcType=VARCHAR},
      </if>
      <if test="createtime != null">
        #{createtime,jdbcType=TIMESTAMP},
      </if>
      <if test="forvalue != null">
        #{forvalue,jdbcType=DECIMAL},
      </if>
      <if test="revvalue != null">
        #{revvalue,jdbcType=DECIMAL},
      </if>
      <if test="pressvalue != null">
        #{pressvalue,jdbcType=DECIMAL},
      </if>
      <if test="realvalue != null">
        #{realvalue,jdbcType=DECIMAL},
      </if>
      <if test="sumvalue != null">
        #{sumvalue,jdbcType=DECIMAL},
      </if>
      <if test="celval != null">
        #{celval,jdbcType=DECIMAL},
      </if>
      <if test="netval != null">
        #{netval,jdbcType=DECIMAL},
      </if>
      <if test="isstat != null">
        #{isstat,jdbcType=CHAR},
      </if>
      <if test="deviceid != null">
        #{deviceid,jdbcType=VARCHAR},
      </if>
      <if test="readtime != null">
        #{readtime,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.steerinfo.ems.emswaterrealtime.model.EmsWaterRealtime">
    update EMS_WATER_REALTIME
    set PhoneNo = #{phoneno,jdbcType=VARCHAR},
      AddressCode = #{addresscode,jdbcType=VARCHAR},
      M_UserType = #{mUsertype,jdbcType=VARCHAR},
      M_Type = #{mType,jdbcType=VARCHAR},
      M_Name = #{mName,jdbcType=VARCHAR},
      M_DoorNo = #{mDoorno,jdbcType=VARCHAR},
      M_PipeDn = #{mPipedn,jdbcType=VARCHAR},
      M_Material = #{mMaterial,jdbcType=VARCHAR},
      M_Ratio = #{mRatio,jdbcType=VARCHAR},
      CreateTime = to_date (substr( #{createtime,jdbcType=TIME}, 0, INSTR( #{createtime,jdbcType=TIME}, '.', 1, 1 )-1), 'YYYY-MM-DD HH24:MI:SS' ),
      ForValue = #{forvalue,jdbcType=DECIMAL},
      RevValue = #{revvalue,jdbcType=DECIMAL},
      PressValue = #{pressvalue,jdbcType=DECIMAL},
      RealValue = #{realvalue,jdbcType=DECIMAL},
      SumValue = #{sumvalue,jdbcType=DECIMAL},
      CelVal = #{celval,jdbcType=DECIMAL},
      NetVal = #{netval,jdbcType=DECIMAL},
      IsStat = #{isstat,jdbcType=CHAR},
      DeviceId = #{deviceid,jdbcType=VARCHAR},
      ReadTime = to_date (#{readtime,jdbcType=TIME}, 'YYYY-MM-DD HH24:MI:SS' )
    where MeterId = #{meterid,jdbcType=DECIMAL}
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.steerinfo.ems.emswaterrealtime.model.EmsWaterRealtime">
    update EMS_WATER_REALTIME
    <set>
      <if test="phoneno != null">
        PhoneNo = #{phoneno,jdbcType=VARCHAR},
      </if>
      <if test="addresscode != null">
        AddressCode = #{addresscode,jdbcType=VARCHAR},
      </if>
      <if test="mUsertype != null">
        M_UserType = #{mUsertype,jdbcType=VARCHAR},
      </if>
      <if test="mType != null">
        M_Type = #{mType,jdbcType=VARCHAR},
      </if>
      <if test="mName != null">
        M_Name = #{mName,jdbcType=VARCHAR},
      </if>
      <if test="mDoorno != null">
        M_DoorNo = #{mDoorno,jdbcType=VARCHAR},
      </if>
      <if test="mPipedn != null">
        M_PipeDn = #{mPipedn,jdbcType=VARCHAR},
      </if>
      <if test="mMaterial != null">
        M_Material = #{mMaterial,jdbcType=VARCHAR},
      </if>
      <if test="mRatio != null">
        M_Ratio = #{mRatio,jdbcType=VARCHAR},
      </if>
      <if test="createtime != null">
        CreateTime = #{createtime,jdbcType=TIMESTAMP},
      </if>
      <if test="forvalue != null">
        ForValue = #{forvalue,jdbcType=DECIMAL},
      </if>
      <if test="revvalue != null">
        RevValue = #{revvalue,jdbcType=DECIMAL},
      </if>
      <if test="pressvalue != null">
        PressValue = #{pressvalue,jdbcType=DECIMAL},
      </if>
      <if test="realvalue != null">
        RealValue = #{realvalue,jdbcType=DECIMAL},
      </if>
      <if test="sumvalue != null">
        SumValue = #{sumvalue,jdbcType=DECIMAL},
      </if>
      <if test="celval != null">
        CelVal = #{celval,jdbcType=DECIMAL},
      </if>
      <if test="netval != null">
        NetVal = #{netval,jdbcType=DECIMAL},
      </if>
      <if test="isstat != null">
        IsStat = #{isstat,jdbcType=CHAR},
      </if>
      <if test="deviceid != null">
        DeviceId = #{deviceid,jdbcType=VARCHAR},
      </if>
      <if test="readtime != null">
        ReadTime = #{readtime,jdbcType=TIMESTAMP},
      </if>
    </set>
    where MeterId = #{meterid,jdbcType=DECIMAL}
  </update>

  <update id="updateByAddresscodeSelective" parameterType="com.steerinfo.ems.emswaterrealtime.model.EmsWaterRealtime">
    update EMS_WATER_REALTIME
    <set>
      <if test="phoneno != null">
        PhoneNo = #{phoneno,jdbcType=VARCHAR},
      </if>
      <if test="mUsertype != null">
        M_UserType = #{mUsertype,jdbcType=VARCHAR},
      </if>
      <if test="mType != null">
        M_Type = #{mType,jdbcType=VARCHAR},
      </if>
      <if test="mName != null">
        M_Name = #{mName,jdbcType=VARCHAR},
      </if>
      <if test="mDoorno != null">
        M_DoorNo = #{mDoorno,jdbcType=VARCHAR},
      </if>
      <if test="mPipedn != null">
        M_PipeDn = #{mPipedn,jdbcType=VARCHAR},
      </if>
      <if test="mMaterial != null">
        M_Material = #{mMaterial,jdbcType=VARCHAR},
      </if>
      <if test="mRatio != null">
        M_Ratio = #{mRatio,jdbcType=VARCHAR},
      </if>
      <if test="createtime != null">
        CreateTime = #{createtime,jdbcType=TIMESTAMP},
      </if>
      <if test="forvalue != null">
        ForValue = #{forvalue,jdbcType=DECIMAL},
      </if>
      <if test="revvalue != null">
        RevValue = #{revvalue,jdbcType=DECIMAL},
      </if>
      <if test="pressvalue != null">
        PressValue = #{pressvalue,jdbcType=DECIMAL},
      </if>
      <if test="realvalue != null">
        RealValue = #{realvalue,jdbcType=DECIMAL},
      </if>
      <if test="sumvalue != null">
        SumValue = #{sumvalue,jdbcType=DECIMAL},
      </if>
      <if test="celval != null">
        CelVal = #{celval,jdbcType=DECIMAL},
      </if>
      <if test="netval != null">
        NetVal = #{netval,jdbcType=DECIMAL},
      </if>
      <if test="isstat != null">
        IsStat = #{isstat,jdbcType=CHAR},
      </if>
      <if test="deviceid != null">
        DeviceId = #{deviceid,jdbcType=VARCHAR},
      </if>
      <if test="readtime != null">
        ReadTime = #{readtime,jdbcType=TIMESTAMP},
      </if>
      <if test="meterid != null">
        MeterId = #{meterid,jdbcType=DECIMAL},
      </if>
    </set>
    <if test="addresscode != null"> where
        AddressCode = #{addresscode,jdbcType=VARCHAR}
    </if>

  </update>

  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
    <include refid="select"/>
    where MeterId = #{meterid,jdbcType=DECIMAL}
  </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 EMS_WATER_REALTIME
      (MeterId,
      PhoneNo, AddressCode, M_UserType,
      M_Type, M_Name, M_DoorNo,
      M_PipeDn, M_Material, M_Ratio,
      CreateTime, ForValue, RevValue,
      PressValue, RealValue, SumValue,
      CelVal, NetVal, IsStat,
      DeviceId, ReadTime)
    ( <foreach collection="list" item="item" separator="union all">
   select
      #{item.meterid,jdbcType=DECIMAL},
      #{item.phoneno,jdbcType=VARCHAR}, #{item.addresscode,jdbcType=VARCHAR}, #{item.mUsertype,jdbcType=VARCHAR},
      #{item.mType,jdbcType=VARCHAR}, #{item.mName,jdbcType=VARCHAR}, #{item.mDoorno,jdbcType=VARCHAR},
      #{item.mPipedn,jdbcType=VARCHAR}, #{item.mMaterial,jdbcType=VARCHAR}, #{item.mRatio,jdbcType=VARCHAR},
      #{item.createtime,jdbcType=TIMESTAMP}, #{item.forvalue,jdbcType=DECIMAL}, #{item.revvalue,jdbcType=DECIMAL},
      #{item.pressvalue,jdbcType=DECIMAL}, #{item.realvalue,jdbcType=DECIMAL}, #{item.sumvalue,jdbcType=DECIMAL},
      #{item.celval,jdbcType=DECIMAL}, #{item.netval,jdbcType=DECIMAL}, #{item.isstat,jdbcType=CHAR},
      #{item.deviceid,jdbcType=VARCHAR}, #{item.readtime,jdbcType=TIMESTAMP} from dual
   </foreach> )
  </insert>
  <update id="batchUpdate" parameterType="java.util.List">
     update EMS_WATER_REALTIME
     set
       MeterId=
       <foreach collection="list" item="item" index="index" separator=" " open="case MeterId" close="end">
          when #{item.meterid,jdbcType=DECIMAL} then #{item.meterid,jdbcType=DECIMAL}
       </foreach>
       ,PhoneNo=
       <foreach collection="list" item="item" index="index" separator=" " open="case MeterId" close="end">
          when #{item.meterid,jdbcType=DECIMAL} then #{item.phoneno,jdbcType=VARCHAR}
       </foreach>
       ,AddressCode=
       <foreach collection="list" item="item" index="index" separator=" " open="case MeterId" close="end">
          when #{item.meterid,jdbcType=DECIMAL} then #{item.addresscode,jdbcType=VARCHAR}
       </foreach>
       ,M_UserType=
       <foreach collection="list" item="item" index="index" separator=" " open="case MeterId" close="end">
          when #{item.meterid,jdbcType=DECIMAL} then #{item.mUsertype,jdbcType=VARCHAR}
       </foreach>
       ,M_Type=
       <foreach collection="list" item="item" index="index" separator=" " open="case MeterId" close="end">
          when #{item.meterid,jdbcType=DECIMAL} then #{item.mType,jdbcType=VARCHAR}
       </foreach>
       ,M_Name=
       <foreach collection="list" item="item" index="index" separator=" " open="case MeterId" close="end">
          when #{item.meterid,jdbcType=DECIMAL} then #{item.mName,jdbcType=VARCHAR}
       </foreach>
       ,M_DoorNo=
       <foreach collection="list" item="item" index="index" separator=" " open="case MeterId" close="end">
          when #{item.meterid,jdbcType=DECIMAL} then #{item.mDoorno,jdbcType=VARCHAR}
       </foreach>
       ,M_PipeDn=
       <foreach collection="list" item="item" index="index" separator=" " open="case MeterId" close="end">
          when #{item.meterid,jdbcType=DECIMAL} then #{item.mPipedn,jdbcType=VARCHAR}
       </foreach>
       ,M_Material=
       <foreach collection="list" item="item" index="index" separator=" " open="case MeterId" close="end">
          when #{item.meterid,jdbcType=DECIMAL} then #{item.mMaterial,jdbcType=VARCHAR}
       </foreach>
       ,M_Ratio=
       <foreach collection="list" item="item" index="index" separator=" " open="case MeterId" close="end">
          when #{item.meterid,jdbcType=DECIMAL} then #{item.mRatio,jdbcType=VARCHAR}
       </foreach>
       ,CreateTime=
       <foreach collection="list" item="item" index="index" separator=" " open="case MeterId" close="end">
          when #{item.meterid,jdbcType=DECIMAL} then #{item.createtime,jdbcType=TIMESTAMP}
       </foreach>
       ,ForValue=
       <foreach collection="list" item="item" index="index" separator=" " open="case MeterId" close="end">
          when #{item.meterid,jdbcType=DECIMAL} then #{item.forvalue,jdbcType=DECIMAL}
       </foreach>
       ,RevValue=
       <foreach collection="list" item="item" index="index" separator=" " open="case MeterId" close="end">
          when #{item.meterid,jdbcType=DECIMAL} then #{item.revvalue,jdbcType=DECIMAL}
       </foreach>
       ,PressValue=
       <foreach collection="list" item="item" index="index" separator=" " open="case MeterId" close="end">
          when #{item.meterid,jdbcType=DECIMAL} then #{item.pressvalue,jdbcType=DECIMAL}
       </foreach>
       ,RealValue=
       <foreach collection="list" item="item" index="index" separator=" " open="case MeterId" close="end">
          when #{item.meterid,jdbcType=DECIMAL} then #{item.realvalue,jdbcType=DECIMAL}
       </foreach>
       ,SumValue=
       <foreach collection="list" item="item" index="index" separator=" " open="case MeterId" close="end">
          when #{item.meterid,jdbcType=DECIMAL} then #{item.sumvalue,jdbcType=DECIMAL}
       </foreach>
       ,CelVal=
       <foreach collection="list" item="item" index="index" separator=" " open="case MeterId" close="end">
          when #{item.meterid,jdbcType=DECIMAL} then #{item.celval,jdbcType=DECIMAL}
       </foreach>
       ,NetVal=
       <foreach collection="list" item="item" index="index" separator=" " open="case MeterId" close="end">
          when #{item.meterid,jdbcType=DECIMAL} then #{item.netval,jdbcType=DECIMAL}
       </foreach>
       ,IsStat=
       <foreach collection="list" item="item" index="index" separator=" " open="case MeterId" close="end">
          when #{item.meterid,jdbcType=DECIMAL} then #{item.isstat,jdbcType=CHAR}
       </foreach>
       ,DeviceId=
       <foreach collection="list" item="item" index="index" separator=" " open="case MeterId" close="end">
          when #{item.meterid,jdbcType=DECIMAL} then #{item.deviceid,jdbcType=VARCHAR}
       </foreach>
       ,ReadTime=
       <foreach collection="list" item="item" index="index" separator=" " open="case MeterId" close="end">
          when #{item.meterid,jdbcType=DECIMAL} then #{item.readtime,jdbcType=TIMESTAMP}
       </foreach>
     where MeterId in
     <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
    #{item.meterid,jdbcType=DECIMAL}
     </foreach>
  </update>
  <delete id="batchDelete" parameterType="java.util.List">
    delete from EMS_WATER_REALTIME
    where MeterId in
    <foreach collection="list" item="id" open="(" close=")" separator=",">
      #{id}
    </foreach>
  </delete>
  <!-- 友情提示！！！-->
  <!-- 请将自己写的代码放在此标签之下，方便以后粘贴复制。-->
      <select id="getWaterListByArmMeter" resultMap="BaseResultMap"  parameterType="string">
        SELECT MeterId, PhoneNo, AddressCode, M_UserType, M_Type
             , M_Name, M_DoorNo, M_PipeDn, M_Material, M_Ratio, CreateTime
             , ForValue, RevValue, PressValue, RealValue, SumValue, CelVal
             , NetVal, IsStat, DeviceId FROM ARM_Meter WITH (NOLOCK) where CreateTime >= #{clock} and  CreateTime &lt; '2050-01-01'
        <!--        FROM Meter_Base.dbo.ARM_Meter-->
    </select>
  <select id="getcalpoint"
          resultType="com.steerinfo.ems.trmcalpoint.model.TRmCalpoint">
    SELECT * FROM T_RM_CALPOINT WHERE ITEMID  not in
    (SELECT t.ITEMID FROM T_RM_CALPOINT t JOIN FORMULA f ON t.ITEMID =f.CODE)
  </select>
  <select id="getWaterTenMinutes" resultMap="BaseResultMap">
    SELECT c.ITEMID METERID,c.TAG_COL M_NAME,c.TAG_TABLE M_USERTYPE, w.ADDRESSCODE,w.FORVALUE AS SUMVALUE,
<!--(w.FORVALUE - w.REVVALUE) -->
    c.BTYPE2 AS M_TYPE,  c.SOURCE_TYPE AS M_MATERIAL
    FROM T_RM_LOCATION l
    JOIN T_RM_CALPOINT c ON l.ID = c.LOCATEID
    AND c.ENERGYTYPEID = 'W' AND c.ITEMTYPE='AUTO'
    LEFT JOIN EMS_WATER_REALTIME w ON l.BCODE = w.ADDRESSCODE
    WHERE ADDRESSCODE IS NOT NULL
    ORDER BY TO_NUMBER(regexp_substr(l.ID,'[0-9.]+'))
  </select>
  <insert id="insertWaterTenMinutes" parameterType="java.util.HashMap">
    INSERT INTO EMS_WATER_TIMING(TMSTMP, TIM,
    YZGXS_YSX, YLT_ZWATER_ACC2, BWFDZ_CYS_ZYLLJ, LG1_SCXINS_ACC2, SJ2_YRXINS_ACC,
    SJ2_YRXINS_ACC2, JH1_GLXINS_ACC, YLT_HQXINS_ACC, YJ_SC_FOLW1, YSJ_CYS_TO_LG,
    ESJ_CYS_TO_LG, YSJ_CYS_ACC, ESJ_CYS_ACC, BWFDZ_CYWATER_ACC, EJH_XS_HQ_JLS_ACC) VALUES
    (to_date (#{clock1,jdbcType=TIME}, 'YYYY-MM-DD HH24:MI:SS' ),
    to_date (#{clock2,jdbcType=TIME}, 'YYYY-MM-DD HH24:MI:SS' ),
    0.00, 0.00, 0.00, 0.00, 0.00,
    0.00, 0.00, 0.00, 0.00, 0.00,
    0.00, 0.00, 0.00, 0.00, 0.00
    )
  </insert>
  <update id="updateWaterTenMinutes" parameterType="java.util.HashMap">
    update EMS_WATER_TIMING
    <set>
      <if test="clock2 != null and clock2 != ''">
        TIM = to_date (#{clock2,jdbcType=TIME}, 'YYYY-MM-DD HH24:MI:SS' )
      </if>
      ${sql}
    </set>
    where TMSTMP =to_date (#{clock1,jdbcType=TIME}, 'YYYY-MM-DD HH24:MI:SS' )
  </update>
  <update id="updateWaterMinutes" parameterType="java.util.HashMap">
    update ${table}
    <set>
      <if test="clock != null and clock2 != ''">
        TMSTMP = to_date (#{clock,jdbcType=TIME}, 'YYYY-MM-DD HH24:MI:SS' )
      </if>
      ${sql}
    </set>
  </update>
  <select id="getWaterListToMosaic" resultMap="BaseResultMap">
  select ROW_NUMBER() over(order by MeterId asc) as MeterIdNo,MeterId,M_TYPE,SUMVALUE,M_Name,MOSAICID from (
    select MeterId, M_Name, MOSAICID, ForValue as lj, PressValue as yl,RealValue as ss from EMS_WATER_REALTIME) mytable
        unpivot(SUMVALUE for M_TYPE in(lj,yl,ss)) a
  </select>
  <select id="getDYHWaterListToMosaic" resultMap="BaseResultMap">
    select ROW_NUMBER() over(order by MeterId asc) as MeterIdNo,MeterId,M_TYPE,SUMVALUE,M_Name from (
    select  MeterId ,M_Name,
    CAST(isnull(ForValue,0.00) as nvarchar) as 累计流量,
    CAST(isnull(PressValue,0.00) as nvarchar) as 压力,
    CAST(isnull(RealValue,0.00) as nvarchar) as 瞬时流量
    from ARM_Meter
    ) mytable
    unpivot(
    SUMVALUE for M_TYPE in(
    累计流量,压力,瞬时流量
    ))a
    <!--        FROM Meter_Base.dbo.ARM_Meter-->
  </select>
</mapper>
