<?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.DayMapper">

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


    <insert id="insertSelective">
        replace into ${tb_name}
        (did, alarm, averageSpeed, charge, chargeList, chargeTime, firstCharge, lastCharge,
        electricQuantity, energy, firstMileage, journeyList,journeyMileage, lastMileage, mileage, numSpeed,
        runTime, sumSpeed, totalHistory, totalLinkStatus, totalMileage, totalRealtime, totalTermin,
        totalTermout,totalRepeat, lastGpsTime, maxSpeed, cyclingTime, totalCyclingTime)
        values
        <foreach collection="list" item="item" index="index" separator=",">
            (
            #{item.did},
            #{item.alarm},
            #{item.averageSpeed},
            #{item.charge},
            #{item.chargeList},
            #{item.chargeTime},
            #{item.firstCharge},
            #{item.lastCharge},
            #{item.electricQuantity},
            #{item.energy},
            #{item.firstMileage},
            #{item.journeyList},
            #{item.journeyMileage},
            #{item.lastMileage},
            #{item.mileage},
            #{item.numSpeed},
            #{item.runTime},
            #{item.sumSpeed},
            #{item.totalHistory},
            #{item.totalLinkStatus},
            #{item.totalMileage},
            #{item.totalRealtime},
            #{item.totalTermin},
            #{item.totalTermout},
            #{item.totalRepeat},
            #{item.lastGpsTime},
            #{item.maxSpeed},
            #{item.cyclingTime},
            #{item.totalCyclingTime}
            )
        </foreach>
    </insert>

    <select id="checkTnameExist" resultType="string">
        select TABLE_NAME from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA='bigdata' and TABLE_NAME= #{tb_name} ;
    </select>

    <select id="selectRepeat" resultType="com.uml.tech.bean.Day">
        select did,totalRealtime,totalHistory,totalRepeat from ${tb_name} where totalRepeat > 0
    </select>

    <select id="selectTermIn" resultType="com.uml.tech.bean.Day">
        SELECT did,totalTermin,totalTermout FROM ${tb_name} ORDER BY totalTermin DESC LIMIT 50;
    </select>

    <select id="selectTermOut" resultType="com.uml.tech.bean.Day">
        SELECT did,totalTermin,totalTermout FROM ${tb_name} ORDER BY totalTermout DESC LIMIT 50;
    </select>

</mapper>