<?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.project.zcustom.mapper.unit.PlatBuildingMapper">

    <select id="getCount" resultType="int">
        select count(*) from large_building
    </select>

    <select id="getPowerAndWaterMonth" resultType="String">
        select json_power_water_month from large_building
    </select>

    <select id="getAirCondition" resultType="String">
        select json_air from large_building
    </select>

    <select id="getTarget" resultType="String">
        select json_target from large_building
    </select>

    <select id="useElectricity" resultType="String">
        select json_use_electricity from large_building
    </select>

    <select id="greenElectricity" resultType="String">
        select json_green_electricity from large_building
    </select>

    <select id="carbon" resultType="String">
        select json_carbon from large_building
    </select>

    <select id="energyYear" resultType="String">
        select json_energy_year from large_building
    </select>

    <select id="powerYear" resultType="String">
        select json_power_year from large_building
    </select>

    <select id="waterYear" resultType="String">
        select json_water_year from large_building
    </select>

    <select id="frequency" resultType="String">
        select json_frequency from large_building
    </select>

    <select id="patrol" resultType="String">
        select json_patrol from large_building
    </select>

    <select id="patrolPoint" resultType="String">
        select json_patrol_point from large_building
    </select>




    <update id="updatePowerAndWaterMonth" parameterType="String">
        update large_building
        set json_power_water_month = #{res}
    </update>

    <update id="updateAirCondition" parameterType="String">
        update large_building
        set json_air = #{res}
    </update>

    <update id="updateTarget" parameterType="String">
        update large_building
        set json_target = #{res}
    </update>

    <update id="updateUseElectricity" parameterType="String">
        update large_building
        set json_use_electricity = #{res}
    </update>

    <update id="updateGreenElectricity" parameterType="String">
        update large_building
        set json_green_electricity = #{res}
    </update>

    <update id="updateCarbon" parameterType="String">
        update large_building
        set json_carbon = #{res}
    </update>

    <update id="updateEnergyYear" parameterType="String">
        update large_building
        set json_energy_year = #{res}
    </update>

    <update id="updatePowerYear" parameterType="String">
        update large_building
        set json_power_year = #{res}
    </update>

    <update id="updateWaterYear" parameterType="String">
        update large_building
        set json_water_year = #{res}
    </update>

    <update id="updateFrequency" parameterType="String">
        update large_building
        set json_frequency = #{res}
    </update>

    <update id="updatePatrol" parameterType="String">
        update large_building
        set json_patrol = #{res}
    </update>

    <update id="updatePatrolPoint" parameterType="String">
        update large_building
        set json_patrol_point = #{res}
    </update>

    <update id="updateBuilding" parameterType="LargeBuilding">
        update large_building
        <set>
            <if test="jsonFrequency != null and jsonFrequency != '' ">json_frequency = #{jsonFrequency},</if>
            <if test="jsonPatrol != null and jsonPatrol != '' ">json_patrol = #{jsonPatrol},</if>
            <if test="jsonPatrolPoint != null and jsonPatrolPoint != '' ">json_patrol_point = #{jsonPatrolPoint},</if>
            <if test="jsonPowerWaterMonth != null and jsonPowerWaterMonth != '' ">json_power_water_month = #{jsonPowerWaterMonth},</if>
            <if test="jsonAir != null and jsonAir != ''">json_air = #{jsonAir},</if>
            <if test="jsonTarget != null and jsonTarget != ''">json_target = #{jsonTarget},</if>
            <if test="jsonUseElectricity != null and jsonUseElectricity != '' ">json_use_electricity = #{jsonUseElectricity},</if>
            <if test="jsonGreenElectricity != null and jsonGreenElectricity != '' ">json_green_electricity = #{jsonGreenElectricity},</if>
            <if test="jsonCarbon != null and jsonCarbon != ''">json_carbon = #{jsonCarbon},</if>
            <if test="jsonEnergyYear != null and jsonEnergyYear != ''">json_energy_year = #{jsonEnergyYear},</if>
            <if test="jsonPowerYear != null and jsonPowerYear != ''">json_power_year = #{jsonPowerYear},</if>
            <if test="jsonWaterYear != null and jsonWaterYear != ''">json_water_year = #{jsonWaterYear},</if>
            update_time = sysdate()
        </set>
        where del_flag = '0'
    </update>


    <insert id="insertBuilding" parameterType="LargeBuilding">
        insert into large_building (
        <if test="jsonFrequency != null and jsonFrequency != '' ">json_frequency,</if>
        <if test="jsonPatrol != null and jsonPatrol != '' ">json_patrol,</if>
        <if test="jsonPatrolPoint != null and jsonPatrolPoint != '' ">json_patrol_point,</if>
        <if test="jsonPowerWaterMonth != null and jsonPowerWaterMonth != '' ">json_power_water_month,</if>
        <if test="jsonAir != null and jsonAir != ''">json_air,</if>
        <if test="jsonTarget != null and jsonTarget != ''">json_target,</if>
        <if test="jsonUseElectricity != null and jsonUseElectricity != '' ">json_use_electricity,</if>
        <if test="jsonGreenElectricity != null and jsonGreenElectricity != '' ">json_green_electricity,</if>
        <if test="jsonCarbon != null and jsonCarbon != ''">json_carbon,</if>
        <if test="jsonEnergyYear != null and jsonEnergyYear != ''">json_energy_year,</if>
        <if test="jsonPowerYear != null and jsonPowerYear != ''">json_power_year,</if>
        <if test="jsonWaterYear != null and jsonWaterYear != ''">json_water_year,</if>
        del_flag, create_time
        )values(
        <if test="jsonFrequency != null and jsonFrequency != '' ">#{jsonFrequency},</if>
        <if test="jsonPatrol != null and jsonPatrol != '' ">#{jsonPatrol},</if>
        <if test="jsonPatrolPoint != null and jsonPatrolPoint != '' ">#{jsonPatrolPoint},</if>
        <if test="jsonPowerWaterMonth != null and jsonPowerWaterMonth != '' ">#{jsonPowerWaterMonth},</if>
        <if test="jsonAir != null and jsonAir != ''">#{jsonAir},</if>
        <if test="jsonTarget != null and jsonTarget != ''">#{jsonTarget},</if>
        <if test="jsonUseElectricity != null and jsonUseElectricity != '' ">#{jsonUseElectricity},</if>
        <if test="jsonGreenElectricity != null and jsonGreenElectricity != '' ">#{jsonGreenElectricity},</if>
        <if test="jsonCarbon != null and jsonCarbon != ''">#{jsonCarbon},</if>
        <if test="jsonEnergyYear != null and jsonEnergyYear != ''">#{jsonEnergyYear},</if>
        <if test="jsonPowerYear != null and jsonPowerYear != ''">#{jsonPowerYear},</if>
        <if test="jsonWaterYear != null and jsonWaterYear != ''">#{jsonWaterYear},</if>
        '0', sysdate()
        )
    </insert>
</mapper>
