<?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.ggroup.mapper.GSiteIrrigateInfoMapper">

    <resultMap type="GSiteIrrigateInfo" id="GSiteIrrigateInfoResult">
        <result property="id"    column="id"    />
        <result property="projectName"    column="project_name"    />
        <result property="projectCode"    column="project_code"    />
        <result property="scale"    column="scale"    />
        <result property="location"    column="location"    />
        <result property="scope"    column="scope"    />
        <result property="crossCounty"    column="cross_county"    />
        <result property="cultivatedLandarea"    column="cultivated_landArea"    />
        <result property="designedIrrigationArea"    column="designed_irrigation_area"    />
        <result property="totalIrrigationArea"    column="total_irrigation_area"    />
        <result property="adjustedCultivatedLandArea"    column="adjusted_cultivated_land_area"    />
        <result property="gardenGrasslandArea"    column="garden_grassland_area"    />
        <result property="managementUnitName"    column="management_unit_name"    />
        <result property="managementType"    column="management_type"    />
        <result property="mainWaterSource"    column="main_water_source"    />
        <result property="supplementaryWaterSource"    column="supplementary_water_source"    />
        <result property="waterUsersAssociation"    column="water_users_association"    />
        <result property="waterUsersAssociationArea"    column="water_users_association_area"    />
        <result property="specializedStaff"    column="specialized_staff"    />
        <result property="subordination"    column="subordination"    />
        <result property="approvedWaterPrices"    column="approved_water_prices"    />
        <result property="approvedWaterPrice"    column="approved_water_price"    />
        <result property="executedWaterPrice"    column="executed_water_price"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="createTime"    column="create_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="siteId"    column="site_id"    />
    </resultMap>

    <sql id="selectGSiteIrrigateInfoVo">
        select id, project_name, project_code, scale, location, scope, cross_county, cultivated_landArea, designed_irrigation_area, total_irrigation_area, adjusted_cultivated_land_area, garden_grassland_area, management_unit_name, management_type, main_water_source, supplementary_water_source, water_users_association, water_users_association_area, specialized_staff, subordination, approved_water_prices, approved_water_price, executed_water_price, del_flag, create_time, create_by, update_time, update_by, site_id from g_site_irrigate_info
    </sql>

    <select id="selectGSiteIrrigateInfoList" parameterType="GSiteIrrigateInfo" resultMap="GSiteIrrigateInfoResult">
        <include refid="selectGSiteIrrigateInfoVo"/>
        <where>
            <if test="projectName != null  and projectName != ''"> and project_name like concat('%', #{projectName}, '%')</if>
            <if test="projectCode != null  and projectCode != ''"> and project_code = #{projectCode}</if>
            <if test="scale != null  and scale != ''"> and scale = #{scale}</if>
            <if test="location != null  and location != ''"> and location = #{location}</if>
            <if test="scope != null  and scope != ''"> and scope = #{scope}</if>
            <if test="crossCounty != null "> and cross_county = #{crossCounty}</if>
            <if test="cultivatedLandarea != null "> and cultivated_landArea = #{cultivatedLandarea}</if>
            <if test="designedIrrigationArea != null "> and designed_irrigation_area = #{designedIrrigationArea}</if>
            <if test="totalIrrigationArea != null "> and total_irrigation_area = #{totalIrrigationArea}</if>
            <if test="adjustedCultivatedLandArea != null "> and adjusted_cultivated_land_area = #{adjustedCultivatedLandArea}</if>
            <if test="gardenGrasslandArea != null "> and garden_grassland_area = #{gardenGrasslandArea}</if>
            <if test="managementUnitName != null  and managementUnitName != ''"> and management_unit_name like concat('%', #{managementUnitName}, '%')</if>
            <if test="managementType != null  and managementType != ''"> and management_type = #{managementType}</if>
            <if test="mainWaterSource != null  and mainWaterSource != ''"> and main_water_source = #{mainWaterSource}</if>
            <if test="supplementaryWaterSource != null  and supplementaryWaterSource != ''"> and supplementary_water_source = #{supplementaryWaterSource}</if>
            <if test="waterUsersAssociation != null "> and water_users_association = #{waterUsersAssociation}</if>
            <if test="waterUsersAssociationArea != null "> and water_users_association_area = #{waterUsersAssociationArea}</if>
            <if test="specializedStaff != null "> and specialized_staff = #{specializedStaff}</if>
            <if test="subordination != null  and subordination != ''"> and subordination = #{subordination}</if>
            <if test="approvedWaterPrices != null "> and approved_water_prices = #{approvedWaterPrices}</if>
            <if test="approvedWaterPrice != null "> and approved_water_price = #{approvedWaterPrice}</if>
            <if test="executedWaterPrice != null "> and executed_water_price = #{executedWaterPrice}</if>
            <if test="siteId != null "> and site_id = #{siteId}</if>
        </where>
    </select>

    <select id="selectGSiteIrrigateInfoBySiteId" parameterType="Long" resultMap="GSiteIrrigateInfoResult">
        <include refid="selectGSiteIrrigateInfoVo"/>
        where site_id = #{site_id}
    </select>

    <insert id="insertGSiteIrrigateInfo" parameterType="GSiteIrrigateInfo">
        insert into g_site_irrigate_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="projectName != null and projectName != ''">project_name,</if>
            <if test="projectCode != null">project_code,</if>
            <if test="scale != null">scale,</if>
            <if test="location != null">location,</if>
            <if test="scope != null">scope,</if>
            <if test="crossCounty != null">cross_county,</if>
            <if test="cultivatedLandarea != null">cultivated_landArea,</if>
            <if test="designedIrrigationArea != null">designed_irrigation_area,</if>
            <if test="totalIrrigationArea != null">total_irrigation_area,</if>
            <if test="adjustedCultivatedLandArea != null">adjusted_cultivated_land_area,</if>
            <if test="gardenGrasslandArea != null">garden_grassland_area,</if>
            <if test="managementUnitName != null">management_unit_name,</if>
            <if test="managementType != null">management_type,</if>
            <if test="mainWaterSource != null">main_water_source,</if>
            <if test="supplementaryWaterSource != null">supplementary_water_source,</if>
            <if test="waterUsersAssociation != null">water_users_association,</if>
            <if test="waterUsersAssociationArea != null">water_users_association_area,</if>
            <if test="specializedStaff != null">specialized_staff,</if>
            <if test="subordination != null">subordination,</if>
            <if test="approvedWaterPrices != null">approved_water_prices,</if>
            <if test="approvedWaterPrice != null">approved_water_price,</if>
            <if test="executedWaterPrice != null">executed_water_price,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="siteId != null">site_id,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="projectName != null and projectName != ''">#{projectName},</if>
            <if test="projectCode != null">#{projectCode},</if>
            <if test="scale != null">#{scale},</if>
            <if test="location != null">#{location},</if>
            <if test="scope != null">#{scope},</if>
            <if test="crossCounty != null">#{crossCounty},</if>
            <if test="cultivatedLandarea != null">#{cultivatedLandarea},</if>
            <if test="designedIrrigationArea != null">#{designedIrrigationArea},</if>
            <if test="totalIrrigationArea != null">#{totalIrrigationArea},</if>
            <if test="adjustedCultivatedLandArea != null">#{adjustedCultivatedLandArea},</if>
            <if test="gardenGrasslandArea != null">#{gardenGrasslandArea},</if>
            <if test="managementUnitName != null">#{managementUnitName},</if>
            <if test="managementType != null">#{managementType},</if>
            <if test="mainWaterSource != null">#{mainWaterSource},</if>
            <if test="supplementaryWaterSource != null">#{supplementaryWaterSource},</if>
            <if test="waterUsersAssociation != null">#{waterUsersAssociation},</if>
            <if test="waterUsersAssociationArea != null">#{waterUsersAssociationArea},</if>
            <if test="specializedStaff != null">#{specializedStaff},</if>
            <if test="subordination != null">#{subordination},</if>
            <if test="approvedWaterPrices != null">#{approvedWaterPrices},</if>
            <if test="approvedWaterPrice != null">#{approvedWaterPrice},</if>
            <if test="executedWaterPrice != null">#{executedWaterPrice},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="siteId != null">#{siteId},</if>
        </trim>
    </insert>

    <update id="updateGSiteIrrigateInfo" parameterType="GSiteIrrigateInfo">
        update g_site_irrigate_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="projectName != null and projectName != ''">project_name = #{projectName},</if>
            <if test="projectCode != null">project_code = #{projectCode},</if>
            <if test="scale != null">scale = #{scale},</if>
            <if test="location != null">location = #{location},</if>
            <if test="scope != null">scope = #{scope},</if>
            <if test="crossCounty != null">cross_county = #{crossCounty},</if>
            <if test="cultivatedLandarea != null">cultivated_landArea = #{cultivatedLandarea},</if>
            <if test="designedIrrigationArea != null">designed_irrigation_area = #{designedIrrigationArea},</if>
            <if test="totalIrrigationArea != null">total_irrigation_area = #{totalIrrigationArea},</if>
            <if test="adjustedCultivatedLandArea != null">adjusted_cultivated_land_area = #{adjustedCultivatedLandArea},</if>
            <if test="gardenGrasslandArea != null">garden_grassland_area = #{gardenGrasslandArea},</if>
            <if test="managementUnitName != null">management_unit_name = #{managementUnitName},</if>
            <if test="managementType != null">management_type = #{managementType},</if>
            <if test="mainWaterSource != null">main_water_source = #{mainWaterSource},</if>
            <if test="supplementaryWaterSource != null">supplementary_water_source = #{supplementaryWaterSource},</if>
            <if test="waterUsersAssociation != null">water_users_association = #{waterUsersAssociation},</if>
            <if test="waterUsersAssociationArea != null">water_users_association_area = #{waterUsersAssociationArea},</if>
            <if test="specializedStaff != null">specialized_staff = #{specializedStaff},</if>
            <if test="subordination != null">subordination = #{subordination},</if>
            <if test="approvedWaterPrices != null">approved_water_prices = #{approvedWaterPrices},</if>
            <if test="approvedWaterPrice != null">approved_water_price = #{approvedWaterPrice},</if>
            <if test="executedWaterPrice != null">executed_water_price = #{executedWaterPrice},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="siteId != null">site_id = #{siteId},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteGSiteIrrigateInfoById" parameterType="Long">
        delete from g_site_irrigate_info where id = #{id}
    </delete>

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