<?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.scada.mapper.TfScadaReportListMapper">

    <resultMap type="com.tofly.scada.entity.TfScadaReportList" id="TfScadaReportListMap">
        <result property="id" column="ID" jdbcType="INTEGER"/>
        <result property="code" column="CODE" jdbcType="VARCHAR"/>
        <result property="value" column="VALUE" jdbcType="VARCHAR"/>
        <result property="scadaTime" column="SCADA_TIME" jdbcType="TIMESTAMP"/>
        <result property="updateTime" column="UPDATE_TIME" jdbcType="TIMESTAMP"/>
        <result property="reportLevel" column="REPORT_LEVEL" jdbcType="VARCHAR"/>
        <result property="reportUpper" column="REPORT_UPPER" jdbcType="VARCHAR"/>
        <result property="reportLower" column="REPORT_LOWER" jdbcType="VARCHAR"/>
        <result property="status" column="STATUS" jdbcType="VARCHAR"/>
        <result property="displayName" column="DISPLAY_NAME" jdbcType="VARCHAR"/>
    </resultMap>

    <!-- 批量插入 -->
    <insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
        insert into TF_SCADA_REPORT_LIST(CODE, VALUE, SCADA_TIME, UPDATE_TIME, REPORT_LEVEL, REPORT_UPPER,
        REPORT_LOWER, STATUS, DISPLAY_NAME)
        values
        <foreach collection="entities" item="entity" separator=",">
            (#{entity.code}, #{entity.value}, #{entity.scadaTime}, #{entity.updateTime}, #{entity.reportLevel},
            #{entity.reportUpper}, #{entity.reportLower}, #{entity.status}, #{entity.displayName})
        </foreach>
    </insert>
    <!-- 批量插入或按主键更新 -->
    <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
        insert into TF_SCADA_REPORT_LIST(CODE, VALUE, SCADA_TIME, UPDATE_TIME, REPORT_LEVEL, REPORT_UPPER,
        REPORT_LOWER, STATUS, DISPLAY_NAME)
        values
        <foreach collection="entities" item="entity" separator=",">
            (#{entity.code}, #{entity.value}, #{entity.scadaTime}, #{entity.updateTime}, #{entity.reportLevel},
            #{entity.reportUpper}, #{entity.reportLower}, #{entity.status}, #{entity.displayName})
        </foreach>
        on duplicate key update
        CODE = values(CODE) , VALUE = values(VALUE) , SCADA_TIME = values(SCADA_TIME) , UPDATE_TIME =
        values(UPDATE_TIME) , REPORT_LEVEL = values(REPORT_LEVEL) , REPORT_UPPER = values(REPORT_UPPER) , REPORT_LOWER =
        values(REPORT_LOWER) , STATUS = values(STATUS) , DISPLAY_NAME = values(DISPLAY_NAME)
    </insert>

</mapper>

