<?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.tofly.spire.mapper.SpireMinGridMapper">

    <resultMap type="com.tofly.spire.entity.SpireMinGrid" id="SpireMinGridMap">
        <result property="id" column="ID" jdbcType="INTEGER"/>
        <result property="accFlow" column="ACC_FLOW" jdbcType="VARCHAR"/>
        <result property="flow" column="FLOW" jdbcType="VARCHAR"/>
        <result property="temp" column="TEMP" jdbcType="VARCHAR"/>
        <result property="meterStatus" column="METER_STATUS" jdbcType="VARCHAR"/>
        <result property="readTime" column="READ_TIME" jdbcType="TIMESTAMP"/>
        <result property="sn" column="SN" jdbcType="VARCHAR"/>
        <result property="uploadTime" column="UPLOAD_TIME" jdbcType="TIMESTAMP"/>
        <result property="createTime" column="CREATE_TIME" jdbcType="TIMESTAMP"/>
        <result property="updateTime" column="UPDATE_TIME" jdbcType="TIMESTAMP"/>
    </resultMap>

    <!-- 批量插入 -->
    <insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
        insert into SPIRE_MIN_GRID(ACC_FLOW, FLOW, TEMP, METER_STATUS, READ_TIME, SN, UPLOAD_TIME, CREATE_TIME,
        UPDATE_TIME)
        values
        <foreach collection="entities" item="entity" separator=",">
            (#{entity.accFlow}, #{entity.flow}, #{entity.temp}, #{entity.meterStatus}, #{entity.readTime}, #{entity.sn},
            #{entity.uploadTime}, #{entity.createTime}, #{entity.updateTime})
        </foreach>
    </insert>
    <!-- 批量插入或按主键更新 -->
    <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
        insert into SPIRE_MIN_GRID(ACC_FLOW, FLOW, TEMP, METER_STATUS, READ_TIME, SN, UPLOAD_TIME, CREATE_TIME,
        UPDATE_TIME)
        values
        <foreach collection="entities" item="entity" separator=",">
            (#{entity.accFlow}, #{entity.flow}, #{entity.temp}, #{entity.meterStatus}, #{entity.readTime}, #{entity.sn},
            #{entity.uploadTime}, #{entity.createTime}, #{entity.updateTime})
        </foreach>
        on duplicate key update
        ACC_FLOW = values(ACC_FLOW) , FLOW = values(FLOW) , TEMP = values(TEMP) , METER_STATUS = values(METER_STATUS) ,
        READ_TIME = values(READ_TIME) , SN = values(SN) , UPLOAD_TIME = values(UPLOAD_TIME) , CREATE_TIME =
        values(CREATE_TIME) , UPDATE_TIME = values(UPDATE_TIME)
    </insert>

</mapper>

