<?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.FarmBeanMapper" >
    <insert id = "insertFarmBean" >
        insert into  ${tb_name}
        (did, jobArea, jobTime, mileage, totalDepth, totalPercentOfPass, totalPositionsSum,
        totalDryingWeight,
        totalBundleWeight,
        totalBundles,
        totalDose,
        totalFertilization,
        totalPlotYield,
        totalJobMileage,
        totalDidJobMileage,
        totalFuelConsumption,
        runTime,
        totalPowerConsumption,
        totalData,
        totalNormal,
        totalA,
        totalB,
        totalC,
        totalD,
        totalE,
        totalF,
        totalG,
        lastGpsTime,
        runState)
        values
        <foreach collection="list" index="index" item="item" separator=",">
             (
            #{item.did},
            #{item.jobArea},
            #{item.jobTime},
            #{item.mileage},
            #{item.totalDepth},
            #{item.totalPercentOfPass},
            #{item.totalPositionsSum},
            #{item.totalDryingWeight},
            #{item.totalBundleWeight},
            #{item.totalBundles},
            #{item.totalDose},
            #{item.totalFertilization},
            #{item.totalPlotYield},
            #{item.totalJobMileage},
            #{item.totalDidJobMileage},
            #{item.totalFuelConsumption},
            #{item.runTime},
            #{item.totalPowerConsumption},
            #{item.totalData},
            #{item.totalNormal},
            #{item.totalA},
            #{item.totalB},
            #{item.totalC},
            #{item.totalD},
            #{item.totalE},
            #{item.totalF},
            #{item.totalG},
            #{item.lastGpsTime},
            #{item.runState}
            )
        </foreach>
    </insert>

    <insert id="insertFarmDay">
        replace into  ${tb_name}
        (did, jobArea, jobTime, mileage, totalDepth, totalPercentOfPass, totalPositionsSum,
        totalDryingWeight,
        totalBundleWeight,
        totalBundles,
        totalDose,
        totalFertilization,
        totalPlotYield,
        totalJobMileage,
        totalDidJobMileage,
        totalFuelConsumption,
        runTime,
        totalPowerConsumption,
        totalRealTime,
        totalHistory,
        totalRepeat,
        totalData,
        totalNormal,
        totalA,
        totalB,
        totalC,
        totalD,
        totalE,
        totalF,
        totalG,
        lastGpsTime,
        runState)
        values
        <foreach collection="list" index="index" item="item" separator=",">
            (
            #{item.did},
            #{item.jobArea},
            #{item.jobTime},
            #{item.mileage},
            #{item.totalDepth},
            #{item.totalPercentOfPass},
            #{item.totalPositionsSum},
            #{item.totalDryingWeight},
            #{item.totalBundleWeight},
            #{item.totalBundles},
            #{item.totalDose},
            #{item.totalFertilization},
            #{item.totalPlotYield},
            #{item.totalJobMileage},
            #{item.totalDidJobMileage},
            #{item.totalFuelConsumption},
            #{item.runTime},
            #{item.totalPowerConsumption},
            #{item.totalRealTime},
            #{item.totalHistory},
            #{item.totalRepeat},
            #{item.totalData},
            #{item.totalNormal},
            #{item.totalA},
            #{item.totalB},
            #{item.totalC},
            #{item.totalD},
            #{item.totalE},
            #{item.totalF},
            #{item.totalG},
            #{item.lastGpsTime},
            #{item.runState}
            )
        </foreach>
    </insert>

    <select id="checkTableExist" resultType="java.lang.String">
        select TABLE_NAME from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA='bigdata' and TABLE_NAME= #{tb_name} ;
    </select>

    <select id="selectYearTable" 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="selectAll" resultType="com.uml.tech.bean.FarmBean">
        select * from ${tb_name}
    </select>
    <select id="selectRepeat" resultType="com.uml.tech.bean.FarmBean">
        select did,totalRealTime,totalHistory,totalRepeat from ${tb_name} where totalRepeat > 0
    </select>

</mapper>