<?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.fastbee.deviceData.mapper.DeviceRealtimedataMoistureMapper">

    <resultMap type="DeviceRealtimedataMoisture" id="DeviceRealtimedataMoistureResult">
        <result property="id"    column="id"    />
        <result property="deviceId"    column="device_id"    />
        <result property="soilTemp"    column="soil_temp"    />
        <result property="soilHumi"    column="soil_humi"    />
        <result property="soilEc"    column="soil_ec"    />
        <result property="soilPh"    column="soil_ph"    />
        <result property="soilTemp1"    column="soil_temp_1"    />
        <result property="soilHumi1"    column="soil_humi_1"    />
        <result property="soilTemp2"    column="soil_temp_2"    />
        <result property="soilHumi2"    column="soil_humi_2"    />
        <result property="soilTemp3"    column="soil_temp_3"    />
        <result property="soilHumi3"    column="soil_humi_3"    />
        <result property="soilTemp4"    column="soil_temp_4"    />
        <result property="soilHumi4"    column="soil_humi_4"    />
        <result property="airTemp"    column="air_temp"    />
        <result property="mppTemp"    column="mpp_temp"    />
        <result property="batteryCap"    column="battery_cap"    />
        <result property="batteryVolt"    column="battery_volt"    />
        <result property="batteryCur"    column="battery_cur"    />
        <result property="batteryPower"    column="battery_power"    />
        <result property="loadVolt"    column="load_volt"    />
        <result property="loadCur"    column="load_cur"    />
        <result property="loadPower"    column="load_power"    />
        <result property="photVolt"    column="phot_volt"    />
        <result property="photCur"    column="phot_cur"    />
        <result property="photPower"    column="phot_power"    />
        <result property="cumChargeDay"    column="cum_charge_day"    />
        <result property="cumChargeMon"    column="cum_charge_mon"    />
        <result property="cumChargeYear"    column="cum_charge_year"    />
        <result property="cumChargeAll"    column="cum_charge_all"    />
        <result property="cumEleDay"    column="cum_ele_day"    />
        <result property="cumEleMon"    column="cum_ele_mon"    />
        <result property="cumEleYear"    column="cum_ele_year"    />
        <result property="cumEleAll"    column="cum_ele_all"    />
        <result property="shoudong"    column="shoudong"    />
        <result property="control"    column="control"    />
        <result property="saveTime"    column="save_time"    />
        <result property="realTime"    column="real_time"    />
    </resultMap>

    <sql id="selectDeviceRealtimedataMoistureVo">
        select id, device_id, soil_temp, soil_humi, soil_ec, soil_ph, soil_temp_1, soil_humi_1, soil_temp_2, soil_humi_2, soil_temp_3, soil_humi_3, soil_temp_4, soil_humi_4, air_temp, mpp_temp, battery_cap, battery_volt, battery_cur, battery_power, load_volt, load_cur, load_power, phot_volt, phot_cur, phot_power, cum_charge_day, cum_charge_mon, cum_charge_year, cum_charge_all, cum_ele_day, cum_ele_mon, cum_ele_year, cum_ele_all, shoudong, control, save_time, real_time from iot_device_realtimedata_moisture
    </sql>

    <select id="selectDeviceRealtimedataMoistureList" parameterType="DeviceRealtimedataMoisture" resultMap="DeviceRealtimedataMoistureResult">
        <include refid="selectDeviceRealtimedataMoistureVo"/>
        <where>
            <if test="deviceId != null  and deviceId != ''"> and device_id = #{deviceId}</if>
            <if test="soilTemp != null "> and soil_temp = #{soilTemp}</if>
            <if test="soilHumi != null "> and soil_humi = #{soilHumi}</if>
            <if test="soilEc != null "> and soil_ec = #{soilEc}</if>
            <if test="soilPh != null "> and soil_ph = #{soilPh}</if>
            <if test="soilTemp1 != null "> and soil_temp_1 = #{soilTemp1}</if>
            <if test="soilHumi1 != null "> and soil_humi_1 = #{soilHumi1}</if>
            <if test="soilTemp2 != null "> and soil_temp_2 = #{soilTemp2}</if>
            <if test="soilHumi2 != null "> and soil_humi_2 = #{soilHumi2}</if>
            <if test="soilTemp3 != null "> and soil_temp_3 = #{soilTemp3}</if>
            <if test="soilHumi3 != null "> and soil_humi_3 = #{soilHumi3}</if>
            <if test="soilTemp4 != null "> and soil_temp_4 = #{soilTemp4}</if>
            <if test="soilHumi4 != null "> and soil_humi_4 = #{soilHumi4}</if>
            <if test="airTemp != null "> and air_temp = #{airTemp}</if>
            <if test="mppTemp != null "> and mpp_temp = #{mppTemp}</if>
            <if test="batteryCap != null "> and battery_cap = #{batteryCap}</if>
            <if test="batteryVolt != null "> and battery_volt = #{batteryVolt}</if>
            <if test="batteryCur != null "> and battery_cur = #{batteryCur}</if>
            <if test="batteryPower != null "> and battery_power = #{batteryPower}</if>
            <if test="loadVolt != null "> and load_volt = #{loadVolt}</if>
            <if test="loadCur != null "> and load_cur = #{loadCur}</if>
            <if test="loadPower != null "> and load_power = #{loadPower}</if>
            <if test="photVolt != null "> and phot_volt = #{photVolt}</if>
            <if test="photCur != null "> and phot_cur = #{photCur}</if>
            <if test="photPower != null "> and phot_power = #{photPower}</if>
            <if test="cumChargeDay != null "> and cum_charge_day = #{cumChargeDay}</if>
            <if test="cumChargeMon != null "> and cum_charge_mon = #{cumChargeMon}</if>
            <if test="cumChargeYear != null "> and cum_charge_year = #{cumChargeYear}</if>
            <if test="cumChargeAll != null "> and cum_charge_all = #{cumChargeAll}</if>
            <if test="cumEleDay != null "> and cum_ele_day = #{cumEleDay}</if>
            <if test="cumEleMon != null "> and cum_ele_mon = #{cumEleMon}</if>
            <if test="cumEleYear != null "> and cum_ele_year = #{cumEleYear}</if>
            <if test="cumEleAll != null "> and cum_ele_all = #{cumEleAll}</if>
            <if test="shoudong != null "> and shoudong = #{shoudong}</if>
            <if test="control != null "> and control = #{control}</if>
            <if test="saveTime != null "> and save_time = #{saveTime}</if>
            <if test="realTime != null "> and real_time = #{realTime}</if>
        </where>
    </select>

    <select id="selectDeviceRealtimedataMoistureById" parameterType="Long" resultMap="DeviceRealtimedataMoistureResult">
        <include refid="selectDeviceRealtimedataMoistureVo"/>
        where id = #{id}
    </select>

    <insert id="insertDeviceRealtimedataMoisture" parameterType="DeviceRealtimedataMoisture" useGeneratedKeys="true" keyProperty="id">
        insert into iot_device_realtimedata_moisture
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="deviceId != null">device_id,</if>
            <if test="soilTemp != null">soil_temp,</if>
            <if test="soilHumi != null">soil_humi,</if>
            <if test="soilEc != null">soil_ec,</if>
            <if test="soilPh != null">soil_ph,</if>
            <if test="soilTemp1 != null">soil_temp_1,</if>
            <if test="soilHumi1 != null">soil_humi_1,</if>
            <if test="soilTemp2 != null">soil_temp_2,</if>
            <if test="soilHumi2 != null">soil_humi_2,</if>
            <if test="soilTemp3 != null">soil_temp_3,</if>
            <if test="soilHumi3 != null">soil_humi_3,</if>
            <if test="soilTemp4 != null">soil_temp_4,</if>
            <if test="soilHumi4 != null">soil_humi_4,</if>
            <if test="airTemp != null">air_temp,</if>
            <if test="mppTemp != null">mpp_temp,</if>
            <if test="batteryCap != null">battery_cap,</if>
            <if test="batteryVolt != null">battery_volt,</if>
            <if test="batteryCur != null">battery_cur,</if>
            <if test="batteryPower != null">battery_power,</if>
            <if test="loadVolt != null">load_volt,</if>
            <if test="loadCur != null">load_cur,</if>
            <if test="loadPower != null">load_power,</if>
            <if test="photVolt != null">phot_volt,</if>
            <if test="photCur != null">phot_cur,</if>
            <if test="photPower != null">phot_power,</if>
            <if test="cumChargeDay != null">cum_charge_day,</if>
            <if test="cumChargeMon != null">cum_charge_mon,</if>
            <if test="cumChargeYear != null">cum_charge_year,</if>
            <if test="cumChargeAll != null">cum_charge_all,</if>
            <if test="cumEleDay != null">cum_ele_day,</if>
            <if test="cumEleMon != null">cum_ele_mon,</if>
            <if test="cumEleYear != null">cum_ele_year,</if>
            <if test="cumEleAll != null">cum_ele_all,</if>
            <if test="shoudong != null">shoudong,</if>
            <if test="control != null">control,</if>
            <if test="saveTime != null">save_time,</if>
            <if test="realTime != null">real_time,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="deviceId != null">#{deviceId},</if>
            <if test="soilTemp != null">#{soilTemp},</if>
            <if test="soilHumi != null">#{soilHumi},</if>
            <if test="soilEc != null">#{soilEc},</if>
            <if test="soilPh != null">#{soilPh},</if>
            <if test="soilTemp1 != null">#{soilTemp1},</if>
            <if test="soilHumi1 != null">#{soilHumi1},</if>
            <if test="soilTemp2 != null">#{soilTemp2},</if>
            <if test="soilHumi2 != null">#{soilHumi2},</if>
            <if test="soilTemp3 != null">#{soilTemp3},</if>
            <if test="soilHumi3 != null">#{soilHumi3},</if>
            <if test="soilTemp4 != null">#{soilTemp4},</if>
            <if test="soilHumi4 != null">#{soilHumi4},</if>
            <if test="airTemp != null">#{airTemp},</if>
            <if test="mppTemp != null">#{mppTemp},</if>
            <if test="batteryCap != null">#{batteryCap},</if>
            <if test="batteryVolt != null">#{batteryVolt},</if>
            <if test="batteryCur != null">#{batteryCur},</if>
            <if test="batteryPower != null">#{batteryPower},</if>
            <if test="loadVolt != null">#{loadVolt},</if>
            <if test="loadCur != null">#{loadCur},</if>
            <if test="loadPower != null">#{loadPower},</if>
            <if test="photVolt != null">#{photVolt},</if>
            <if test="photCur != null">#{photCur},</if>
            <if test="photPower != null">#{photPower},</if>
            <if test="cumChargeDay != null">#{cumChargeDay},</if>
            <if test="cumChargeMon != null">#{cumChargeMon},</if>
            <if test="cumChargeYear != null">#{cumChargeYear},</if>
            <if test="cumChargeAll != null">#{cumChargeAll},</if>
            <if test="cumEleDay != null">#{cumEleDay},</if>
            <if test="cumEleMon != null">#{cumEleMon},</if>
            <if test="cumEleYear != null">#{cumEleYear},</if>
            <if test="cumEleAll != null">#{cumEleAll},</if>
            <if test="shoudong != null">#{shoudong},</if>
            <if test="control != null">#{control},</if>
            <if test="saveTime != null">#{saveTime},</if>
            <if test="realTime != null">#{realTime},</if>
        </trim>
    </insert>

    <update id="updateDeviceRealtimedataMoisture" parameterType="DeviceRealtimedataMoisture">
        update iot_device_realtimedata_moisture
        <trim prefix="SET" suffixOverrides=",">
            <if test="deviceId != null">device_id = #{deviceId},</if>
            <if test="soilTemp != null">soil_temp = #{soilTemp},</if>
            <if test="soilHumi != null">soil_humi = #{soilHumi},</if>
            <if test="soilEc != null">soil_ec = #{soilEc},</if>
            <if test="soilPh != null">soil_ph = #{soilPh},</if>
            <if test="soilTemp1 != null">soil_temp_1 = #{soilTemp1},</if>
            <if test="soilHumi1 != null">soil_humi_1 = #{soilHumi1},</if>
            <if test="soilTemp2 != null">soil_temp_2 = #{soilTemp2},</if>
            <if test="soilHumi2 != null">soil_humi_2 = #{soilHumi2},</if>
            <if test="soilTemp3 != null">soil_temp_3 = #{soilTemp3},</if>
            <if test="soilHumi3 != null">soil_humi_3 = #{soilHumi3},</if>
            <if test="soilTemp4 != null">soil_temp_4 = #{soilTemp4},</if>
            <if test="soilHumi4 != null">soil_humi_4 = #{soilHumi4},</if>
            <if test="airTemp != null">air_temp = #{airTemp},</if>
            <if test="mppTemp != null">mpp_temp = #{mppTemp},</if>
            <if test="batteryCap != null">battery_cap = #{batteryCap},</if>
            <if test="batteryVolt != null">battery_volt = #{batteryVolt},</if>
            <if test="batteryCur != null">battery_cur = #{batteryCur},</if>
            <if test="batteryPower != null">battery_power = #{batteryPower},</if>
            <if test="loadVolt != null">load_volt = #{loadVolt},</if>
            <if test="loadCur != null">load_cur = #{loadCur},</if>
            <if test="loadPower != null">load_power = #{loadPower},</if>
            <if test="photVolt != null">phot_volt = #{photVolt},</if>
            <if test="photCur != null">phot_cur = #{photCur},</if>
            <if test="photPower != null">phot_power = #{photPower},</if>
            <if test="cumChargeDay != null">cum_charge_day = #{cumChargeDay},</if>
            <if test="cumChargeMon != null">cum_charge_mon = #{cumChargeMon},</if>
            <if test="cumChargeYear != null">cum_charge_year = #{cumChargeYear},</if>
            <if test="cumChargeAll != null">cum_charge_all = #{cumChargeAll},</if>
            <if test="cumEleDay != null">cum_ele_day = #{cumEleDay},</if>
            <if test="cumEleMon != null">cum_ele_mon = #{cumEleMon},</if>
            <if test="cumEleYear != null">cum_ele_year = #{cumEleYear},</if>
            <if test="cumEleAll != null">cum_ele_all = #{cumEleAll},</if>
            <if test="shoudong != null">shoudong = #{shoudong},</if>
            <if test="control != null">control = #{control},</if>
            <if test="saveTime != null">save_time = #{saveTime},</if>
            <if test="realTime != null">real_time = #{realTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteDeviceRealtimedataMoistureById" parameterType="Long">
        delete from iot_device_realtimedata_moisture where id = #{id}
    </delete>

    <delete id="deleteDeviceRealtimedataMoistureByIds" parameterType="String">
        delete from iot_device_realtimedata_moisture where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>