<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.3//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zw.platform.repository.vas.MobileSourceManageDao">


    <insert id="addMobile" parameterType="com.zw.platform.domain.vas.carbonmgt.form.MobileSourceManageForm">
        INSERT INTO zw_m_energy_consumption (
        id, brand, total_mileage, average_speed, total_oil_wear,hundred_km_oil_wear, total_discharge, hundred_km_discharge, start_time, end_time
        )
        VALUES(
        #{id}, #{brand}, #{totalMileage}, #{speed}, #{totalFuelConsumption}, #{bTotalFuelConsumption}, #{co2}, #{bco2}, #{startTime}, #{endTime})
    </insert>
    <select id="find" parameterType="string" resultType="string">
        SELECT id FROM zw_m_energy_consumption WHERE brand = BINARY #{0} and start_time = #{1} and end_time = #{2} and flag = 1
        ORDER BY create_data_time DESC
    </select>
    <select id="findList" parameterType="string" resultType="com.zw.platform.domain.vas.carbonmgt.form.MobileSourceManageForm">
        SELECT ec.total_mileage,
               ec.average_speed speed,
               ec.total_oil_wear totalFuelConsumption,
               ec.hundred_km_oil_wear bTotalFuelConsumption,
               ec.total_discharge co2,
               ec.hundred_km_discharge bco2,
               ec.start_time,
               ec.end_time,
               ec.brand
        FROM zw_m_energy_consumption ec WHERE flag = 1 and ec.brand = BINARY #{brand}
        ORDER BY create_data_time DESC
    </select>
    <!-- 根据id删除一个 ThingInfo -->
    <delete id="del" parameterType="string">
        UPDATE zw_m_energy_consumption set flag=0 WHERE brand = BINARY #{0} and start_time = #{1} and end_time = #{2}
    </delete>
</mapper>
