<?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.njcn.harmonic.mapper.RStatPollutionSubstationQPOMapper">
  <resultMap id="BaseResultMap" type="com.njcn.harmonic.pojo.po.RStatPollutionSubstationQPO">
    <!--@mbg.generated-->
    <!--@Table r_stat_pollution_substation_q-->
    <id column="substation_id" jdbcType="VARCHAR" property="substationId" />
    <id column="data_date" jdbcType="TIMESTAMP" property="dataDate" />
    <id column="pollution_type" jdbcType="VARCHAR" property="pollutionType" />
    <result column="value" jdbcType="FLOAT" property="value" />
  </resultMap>
  <sql id="Base_Column_List">
    <!--@mbg.generated-->
    substation_id, data_date, pollution_type, `value`
  </sql>
  <update id="updateBatch" parameterType="java.util.List">
    <!--@mbg.generated-->
    update r_stat_pollution_substation_q
    <trim prefix="set" suffixOverrides=",">
      <trim prefix="`value` = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when substation_id = #{item.substationId,jdbcType=VARCHAR} then #{item.value,jdbcType=FLOAT}
        </foreach>
      </trim>
    </trim>
    where substation_id in
    <foreach close=")" collection="list" item="item" open="(" separator=", ">
      #{item.substationId,jdbcType=VARCHAR}
    </foreach>
  </update>
  <insert id="batchInsert" parameterType="map">
    <!--@mbg.generated-->
    insert into r_stat_pollution_substation_q
    (substation_id, data_date, pollution_type, `value`)
    values
    <foreach collection="list" item="item" separator=",">
      (#{item.substationId,jdbcType=VARCHAR}, #{item.dataDate,jdbcType=TIMESTAMP}, #{item.pollutionType,jdbcType=VARCHAR}, 
        #{item.value,jdbcType=FLOAT})
    </foreach>
  </insert>
  <insert id="insertOrUpdate" parameterType="com.njcn.harmonic.pojo.po.RStatPollutionSubstationQPO">
    <!--@mbg.generated-->
    insert into r_stat_pollution_substation_q
    (substation_id, data_date, pollution_type, `value`)
    values
    (#{substationId,jdbcType=VARCHAR}, #{dataDate,jdbcType=TIMESTAMP}, #{pollutionType,jdbcType=VARCHAR}, 
      #{value,jdbcType=FLOAT})
    on duplicate key update 
    substation_id = #{substationId,jdbcType=VARCHAR}, 
    data_date = #{dataDate,jdbcType=TIMESTAMP}, 
    pollution_type = #{pollutionType,jdbcType=VARCHAR}, 
    `value` = #{value,jdbcType=FLOAT}
  </insert>
  <insert id="insertOrUpdateSelective" parameterType="com.njcn.harmonic.pojo.po.RStatPollutionSubstationQPO">
    <!--@mbg.generated-->
    insert into r_stat_pollution_substation_q
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="substationId != null">
        substation_id,
      </if>
      <if test="dataDate != null">
        data_date,
      </if>
      <if test="pollutionType != null">
        pollution_type,
      </if>
      <if test="value != null">
        `value`,
      </if>
    </trim>
    values
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="substationId != null">
        #{substationId,jdbcType=VARCHAR},
      </if>
      <if test="dataDate != null">
        #{dataDate,jdbcType=TIMESTAMP},
      </if>
      <if test="pollutionType != null">
        #{pollutionType,jdbcType=VARCHAR},
      </if>
      <if test="value != null">
        #{value,jdbcType=FLOAT},
      </if>
    </trim>
    on duplicate key update 
    <trim suffixOverrides=",">
      <if test="substationId != null">
        substation_id = #{substationId,jdbcType=VARCHAR},
      </if>
      <if test="dataDate != null">
        data_date = #{dataDate,jdbcType=TIMESTAMP},
      </if>
      <if test="pollutionType != null">
        pollution_type = #{pollutionType,jdbcType=VARCHAR},
      </if>
      <if test="value != null">
        `value` = #{value,jdbcType=FLOAT},
      </if>
    </trim>
  </insert>
</mapper>