<?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="uml.tech.bigdata.tdengineMapper.report.FarmReportMapper">

    <!--        <resultMap id="BaseResultMap" type="map">-->
    <!--            <id column="ts" jdbcType="TIMESTAMP" property="ts"/>-->
    <!--            <result column="temperature" jdbcType="FLOAT" property="temperature"/>-->
    <!--            <result column="humidity" jdbcType="FLOAT" property="humidity"/>-->
    <!--        </resultMap>-->

    <!--    <select id="lastOne" resultType="java.util.Map">-->
    <!--        select last_row(*), location, groupid-->
    <!--        from test.weather-->
    <!--    </select>-->


    <insert id="insertBatch" parameterType="java.util.List">
        insert into
        <foreach collection="list" index="index" item="item" separator=" ">
            report_daily.${item.did} (
            c_day,
            c_del,
            c_job_area,
            c_job_time,
            c_mileage,
            c_total_depth,
            c_total_percent_of_pass,
            c_total_positions_sum,
            c_total_drying_weight,
            c_total_bundle_weight,
            c_total_bundles,
            c_total_dose,
            c_total_fertilization,
            c_total_plot_yield,
            c_total_job_mileage,
            c_total_did_job_mileage,
            c_total_fuel_consumption,
            c_run_time,
            c_total_power_consumption,
            c_total_normal,
            c_total_a,
            c_total_b,
            c_total_c,
            c_total_d,
            c_total_e,
            c_total_f,
            c_total_g,
            c_last_gps_time,
            c_run_state)
            using report_daily.t (did, vin, group_id, group_path, vehicle_type_id)
            tags(
            #{item.did},
            #{item.vin},
            #{item.lpn},
            #{item.groupId},
            #{item.groupPath})
            values (
            #{item.day},
            #{item.del},
            #{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.totalNormal},
            #{item.totalA},
            #{item.totalB},
            #{item.totalC},
            #{item.totalD},
            #{item.totalE},
            #{item.totalF},
            #{item.totalG},
            #{item.lastGpsTime},
            #{item.runState})
        </foreach>
    </insert>

    <insert id="insert" parameterType="uml.tech.bigdata.bean.FarmBean">
        insert into db_nrmv.tb_report_${item.did} (c_day,
                                                   c_del,
                                                   c_job_area,
                                                   c_job_time,
                                                   c_mileage,
                                                   c_total_depth,
                                                   c_total_percent_of_pass,
                                                   c_total_ositions_sum,
                                                   c_total_drying_weight,
                                                   c_total_bundle_weight,
                                                   c_total_bundles,
                                                   c_total_dose,
                                                   c_total_fertilization,
                                                   c_total_plot_yield,
                                                   c_total_job_mileage,
                                                   c_total_did_job_mileage,
                                                   c_total_fuel_consumption,
                                                   c_run_time,
                                                   c_total_power_consumption,
                                                   c_total_normal,
                                                   c_total_a,
                                                   c_total_b,
                                                   c_total_c,
                                                   c_total_d,
                                                   c_total_e,
                                                   c_total_f,
                                                   c_total_g,
                                                   c_last_gps_time,
                                                   c_run_state)
            using stb_report (t_did, t_vin, t_lpn, t_group_id, t_group_path)
            tags( #{item.did},
            #{item.vin},
            #{item.lpn},
            #{item.groupId},
            #{item.groupPath})
        values (
            #{item.day},
            #{item.del},
            #{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}
    </insert>

    <!--    <select id="getSubTables" resultType="String">-->
    <!--        select tbname-->
    <!--        from test.weather-->
    <!--    </select>-->

    <select id="count" resultType="int">
        select count(*)
        from db_nrmv.db_report
    </select>


</mapper>