<?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.uml.tech.mapper.YearMapper" >

    <insert id="insertFromList" parameterType="com.uml.tech.bean.Year" >
        replace into ${tb_name} (did, alarm, averageCharge,
            averageChargeTime, averageElectricQuantity, 
            averageEnergy, averageHistory, averageLinkStatus, 
            averageMileage, averageRealtime, averageSpeed, 
            averageTermin, averageTermout, charge, 
            chargeTime, electricQuantity, energy, 
            lastGpsTime, mileage, numSpeed, 
            runDays, runTime, stopDays, 
            sumSpeed, totalHistory, totalLinkStatus, 
            totalMileage, totalRealtime, totalTermin, 
            totalTermout , maxSpeed, cyclingTime, totalCyclingTime)
        values
        <foreach collection="list" item="item" index="index" separator=",">
        (#{item.did},
            #{item.alarm},
            #{item.averageCharge},
            #{item.averageChargeTime},
            #{item.averageElectricQuantity},
            #{item.averageEnergy},
            #{item.averageHistory},
            #{item.averageLinkStatus},
            #{item.averageMileage},
            #{item.averageRealtime},
            #{item.averageSpeed},
            #{item.averageTermin},
            #{item.averageTermout},
            #{item.charge},
            #{item.chargeTime},
            #{item.electricQuantity},
            #{item.energy},#{item.lastGpsTime},
            #{item.mileage},
            #{item.numSpeed},
            #{item.runDays},
            #{item.runTime},
            #{item.stopDays},
            #{item.sumSpeed},
            #{item.totalHistory},
            #{item.totalLinkStatus},
            #{item.totalMileage},
            #{item.totalRealtime},
            #{item.totalTermin},
            #{item.totalTermout},
            #{item.maxSpeed},
            #{item.cyclingTime},
            #{item.totalCyclingTime})
        </foreach>
    </insert>

    <select id="selectTableName" resultType="java.lang.String">
        select * from (select table_name from information_schema.tables where table_schema = 'bigdata' and table_type = 'base table') temp
        where table_name like #{regex}
    </select>

    <select id="selectYear2017" resultType="com.uml.tech.bean.Year">
        select did, alarm,charge,
            chargeTime, electricQuantity, energy,
            mileage, numSpeed,
            runDays, runTime, stopDays,
            sumSpeed, totalHistory, totalLinkStatus,
            totalMileage, totalRealtime, totalTermin,
            totalTermout  from year_2017
    </select>

    <select id="selectAll" resultType="com.uml.tech.bean.Year">
        select did, alarm,charge,
            chargeTime, electricQuantity, energy,
            lastGpsTime, mileage, numSpeed,
            runDays, runTime, stopDays,
            sumSpeed, totalHistory, totalLinkStatus,
            totalMileage, totalRealtime, totalTermin,
            totalTermout, maxSpeed, cyclingTime, totalCyclingTime  from ${tb_name}
    </select>


</mapper>