<?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.GSiteSluiceInfoMapper">

    <resultMap type="GSiteSluiceInfo" id="GSiteSluiceInfoResult">
        <result property="id"    column="id"    />
        <result property="projectName"    column="project_name"    />
        <result property="projectCode"    column="project_code"    />
        <result property="geographicalCoordinatesLongitude"    column="geographical_coordinates_longitude"    />
        <result property="geographicalCoordinatesLatitude"    column="geographical_coordinates_latitude"    />
        <result property="riverName"    column="river_name"    />
        <result property="agriculturalIrrigationArea"    column="agricultural_irrigation_area"    />
        <result property="constructionDate"    column="construction_date"    />
        <result property="isHubProject"    column="is_hub_project"    />
        <result property="isSluiceStationProject"    column="is_sluice_station_project"    />
        <result property="isNestedSluiceProject"    column="is_nested_sluice_project"    />
        <result property="projectGrade"    column="project_grade"    />
        <result property="mainBuildingGrade"    column="main_building_grade"    />
        <result property="waterSluiceInfoGatesNumber"    column="water_sluice_info_gates_number"    />
        <result property="waterSluiceInfoGatesWide"    column="water_sluice_info_gates_wide"    />
        <result property="projectLocation"    column="project_location"    />
        <result property="designStandard"    column="design_standard"    />
        <result property="checkCriteria"    column="check_criteria"    />
        <result property="organizationName"    column="organization_name"    />
        <result property="ownership"    column="ownership"    />
        <result property="responsiblePerson"    column="responsible_person"    />
        <result property="position"    column="position"    />
        <result property="phoneNumber"    column="phone_number"    />
        <result property="manageResponsiblePerson"    column="manage_responsible_person"    />
        <result property="managePhonePosts"    column="manage_phone_posts"    />
        <result property="managePhoneNumber"    column="manage_phone_number"    />
        <result property="administrativeResponsiblePerson"    column="administrative_responsible_person"    />
        <result property="administrativePhoneNumber"    column="administrative_phone_number"    />
        <result property="technologyResponsiblePerson"    column="technology_responsible_person"    />
        <result property="technologyPhoneNumber"    column="technology_phone_number"    />
        <result property="inspectionResponsiblePerson"    column="inspection_responsible_person"    />
        <result property="inspectionPhoneNumber"    column="inspection_phone_number"    />
        <result property="isBoundaryDelineationCompleted"    column="is_boundary_delineation_completed"    />
        <result property="isPropertyRightsConfirmationCompleted"    column="is_property_rights_confirmation_completed"    />
        <result property="floodControlMaterials"    column="flood_control_materials"    />
        <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="selectGSiteSluiceInfoVo">
        select id, project_name, project_code, geographical_coordinates_longitude, geographical_coordinates_latitude, river_name, agricultural_irrigation_area, construction_date, is_hub_project, is_sluice_station_project, is_nested_sluice_project, project_grade, main_building_grade, water_sluice_info_gates_number, water_sluice_info_gates_wide, project_location, design_standard, check_criteria, organization_name, ownership, responsible_person, position, phone_number, manage_responsible_person, manage_phone_posts, manage_phone_number, administrative_responsible_person, administrative_phone_number, technology_responsible_person, technology_phone_number, inspection_responsible_person, inspection_phone_number, is_boundary_delineation_completed, is_property_rights_confirmation_completed, flood_control_materials, del_flag, create_time, create_by, update_time, update_by, site_id from g_site_sluice_info
    </sql>

    <select id="selectGSiteSluiceInfoList" parameterType="GSiteSluiceInfo" resultMap="GSiteSluiceInfoResult">
        <include refid="selectGSiteSluiceInfoVo"/>
        <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="geographicalCoordinatesLongitude != null "> and geographical_coordinates_longitude = #{geographicalCoordinatesLongitude}</if>
            <if test="geographicalCoordinatesLatitude != null "> and geographical_coordinates_latitude = #{geographicalCoordinatesLatitude}</if>
            <if test="riverName != null  and riverName != ''"> and river_name like concat('%', #{riverName}, '%')</if>
            <if test="agriculturalIrrigationArea != null  and agriculturalIrrigationArea != ''"> and agricultural_irrigation_area = #{agriculturalIrrigationArea}</if>
            <if test="constructionDate != null "> and construction_date = #{constructionDate}</if>
            <if test="isHubProject != null "> and is_hub_project = #{isHubProject}</if>
            <if test="isSluiceStationProject != null "> and is_sluice_station_project = #{isSluiceStationProject}</if>
            <if test="isNestedSluiceProject != null "> and is_nested_sluice_project = #{isNestedSluiceProject}</if>
            <if test="projectGrade != null "> and project_grade = #{projectGrade}</if>
            <if test="mainBuildingGrade != null "> and main_building_grade = #{mainBuildingGrade}</if>
            <if test="waterSluiceInfoGatesNumber != null "> and water_sluice_info_gates_number = #{waterSluiceInfoGatesNumber}</if>
            <if test="waterSluiceInfoGatesWide != null "> and water_sluice_info_gates_wide = #{waterSluiceInfoGatesWide}</if>
            <if test="projectLocation != null  and projectLocation != ''"> and project_location = #{projectLocation}</if>
            <if test="designStandard != null "> and design_standard = #{designStandard}</if>
            <if test="checkCriteria != null "> and check_criteria = #{checkCriteria}</if>
            <if test="organizationName != null  and organizationName != ''"> and organization_name like concat('%', #{organizationName}, '%')</if>
            <if test="ownership != null  and ownership != ''"> and ownership = #{ownership}</if>
            <if test="responsiblePerson != null  and responsiblePerson != ''"> and responsible_person = #{responsiblePerson}</if>
            <if test="position != null  and position != ''"> and position = #{position}</if>
            <if test="phoneNumber != null  and phoneNumber != ''"> and phone_number = #{phoneNumber}</if>
            <if test="manageResponsiblePerson != null  and manageResponsiblePerson != ''"> and manage_responsible_person = #{manageResponsiblePerson}</if>
            <if test="managePhonePosts != null  and managePhonePosts != ''"> and manage_phone_posts = #{managePhonePosts}</if>
            <if test="managePhoneNumber != null  and managePhoneNumber != ''"> and manage_phone_number = #{managePhoneNumber}</if>
            <if test="administrativeResponsiblePerson != null  and administrativeResponsiblePerson != ''"> and administrative_responsible_person = #{administrativeResponsiblePerson}</if>
            <if test="administrativePhoneNumber != null  and administrativePhoneNumber != ''"> and administrative_phone_number = #{administrativePhoneNumber}</if>
            <if test="technologyResponsiblePerson != null  and technologyResponsiblePerson != ''"> and technology_responsible_person = #{technologyResponsiblePerson}</if>
            <if test="technologyPhoneNumber != null  and technologyPhoneNumber != ''"> and technology_phone_number = #{technologyPhoneNumber}</if>
            <if test="inspectionResponsiblePerson != null  and inspectionResponsiblePerson != ''"> and inspection_responsible_person = #{inspectionResponsiblePerson}</if>
            <if test="inspectionPhoneNumber != null  and inspectionPhoneNumber != ''"> and inspection_phone_number = #{inspectionPhoneNumber}</if>
            <if test="isBoundaryDelineationCompleted != null "> and is_boundary_delineation_completed = #{isBoundaryDelineationCompleted}</if>
            <if test="isPropertyRightsConfirmationCompleted != null "> and is_property_rights_confirmation_completed = #{isPropertyRightsConfirmationCompleted}</if>
            <if test="floodControlMaterials != null  and floodControlMaterials != ''"> and flood_control_materials = #{floodControlMaterials}</if>
            <if test="siteId != null "> and site_id = #{siteId}</if>
        </where>
    </select>

    <select id="selectGSiteSluiceInfoById" parameterType="Long" resultMap="GSiteSluiceInfoResult">
        <include refid="selectGSiteSluiceInfoVo"/>
        where id = #{id}
    </select>
    <select id="selectGSiteSluiceInfoBySiteId" parameterType="Long" resultMap="GSiteSluiceInfoResult">
        <include refid="selectGSiteSluiceInfoVo"/>
        where site_id = #{site_id}
    </select>
    <insert id="insertGSiteSluiceInfo" parameterType="GSiteSluiceInfo" useGeneratedKeys="true" keyProperty="id">
        insert into g_site_sluice_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="projectName != null">project_name,</if>
            <if test="projectCode != null">project_code,</if>
            <if test="geographicalCoordinatesLongitude != null">geographical_coordinates_longitude,</if>
            <if test="geographicalCoordinatesLatitude != null">geographical_coordinates_latitude,</if>
            <if test="riverName != null">river_name,</if>
            <if test="agriculturalIrrigationArea != null">agricultural_irrigation_area,</if>
            <if test="constructionDate != null">construction_date,</if>
            <if test="isHubProject != null">is_hub_project,</if>
            <if test="isSluiceStationProject != null">is_sluice_station_project,</if>
            <if test="isNestedSluiceProject != null">is_nested_sluice_project,</if>
            <if test="projectGrade != null">project_grade,</if>
            <if test="mainBuildingGrade != null">main_building_grade,</if>
            <if test="waterSluiceInfoGatesNumber != null">water_sluice_info_gates_number,</if>
            <if test="waterSluiceInfoGatesWide != null">water_sluice_info_gates_wide,</if>
            <if test="projectLocation != null">project_location,</if>
            <if test="designStandard != null">design_standard,</if>
            <if test="checkCriteria != null">check_criteria,</if>
            <if test="organizationName != null">organization_name,</if>
            <if test="ownership != null">ownership,</if>
            <if test="responsiblePerson != null">responsible_person,</if>
            <if test="position != null">position,</if>
            <if test="phoneNumber != null">phone_number,</if>
            <if test="manageResponsiblePerson != null">manage_responsible_person,</if>
            <if test="managePhonePosts != null">manage_phone_posts,</if>
            <if test="managePhoneNumber != null">manage_phone_number,</if>
            <if test="administrativeResponsiblePerson != null">administrative_responsible_person,</if>
            <if test="administrativePhoneNumber != null">administrative_phone_number,</if>
            <if test="technologyResponsiblePerson != null">technology_responsible_person,</if>
            <if test="technologyPhoneNumber != null">technology_phone_number,</if>
            <if test="inspectionResponsiblePerson != null">inspection_responsible_person,</if>
            <if test="inspectionPhoneNumber != null">inspection_phone_number,</if>
            <if test="isBoundaryDelineationCompleted != null">is_boundary_delineation_completed,</if>
            <if test="isPropertyRightsConfirmationCompleted != null">is_property_rights_confirmation_completed,</if>
            <if test="floodControlMaterials != null">flood_control_materials,</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="projectName != null">#{projectName},</if>
            <if test="projectCode != null">#{projectCode},</if>
            <if test="geographicalCoordinatesLongitude != null">#{geographicalCoordinatesLongitude},</if>
            <if test="geographicalCoordinatesLatitude != null">#{geographicalCoordinatesLatitude},</if>
            <if test="riverName != null">#{riverName},</if>
            <if test="agriculturalIrrigationArea != null">#{agriculturalIrrigationArea},</if>
            <if test="constructionDate != null">#{constructionDate},</if>
            <if test="isHubProject != null">#{isHubProject},</if>
            <if test="isSluiceStationProject != null">#{isSluiceStationProject},</if>
            <if test="isNestedSluiceProject != null">#{isNestedSluiceProject},</if>
            <if test="projectGrade != null">#{projectGrade},</if>
            <if test="mainBuildingGrade != null">#{mainBuildingGrade},</if>
            <if test="waterSluiceInfoGatesNumber != null">#{waterSluiceInfoGatesNumber},</if>
            <if test="waterSluiceInfoGatesWide != null">#{waterSluiceInfoGatesWide},</if>
            <if test="projectLocation != null">#{projectLocation},</if>
            <if test="designStandard != null">#{designStandard},</if>
            <if test="checkCriteria != null">#{checkCriteria},</if>
            <if test="organizationName != null">#{organizationName},</if>
            <if test="ownership != null">#{ownership},</if>
            <if test="responsiblePerson != null">#{responsiblePerson},</if>
            <if test="position != null">#{position},</if>
            <if test="phoneNumber != null">#{phoneNumber},</if>
            <if test="manageResponsiblePerson != null">#{manageResponsiblePerson},</if>
            <if test="managePhonePosts != null">#{managePhonePosts},</if>
            <if test="managePhoneNumber != null">#{managePhoneNumber},</if>
            <if test="administrativeResponsiblePerson != null">#{administrativeResponsiblePerson},</if>
            <if test="administrativePhoneNumber != null">#{administrativePhoneNumber},</if>
            <if test="technologyResponsiblePerson != null">#{technologyResponsiblePerson},</if>
            <if test="technologyPhoneNumber != null">#{technologyPhoneNumber},</if>
            <if test="inspectionResponsiblePerson != null">#{inspectionResponsiblePerson},</if>
            <if test="inspectionPhoneNumber != null">#{inspectionPhoneNumber},</if>
            <if test="isBoundaryDelineationCompleted != null">#{isBoundaryDelineationCompleted},</if>
            <if test="isPropertyRightsConfirmationCompleted != null">#{isPropertyRightsConfirmationCompleted},</if>
            <if test="floodControlMaterials != null">#{floodControlMaterials},</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="updateGSiteSluiceInfo" parameterType="GSiteSluiceInfo">
        update g_site_sluice_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="projectName != null">project_name = #{projectName},</if>
            <if test="projectCode != null">project_code = #{projectCode},</if>
            <if test="geographicalCoordinatesLongitude != null">geographical_coordinates_longitude = #{geographicalCoordinatesLongitude},</if>
            <if test="geographicalCoordinatesLatitude != null">geographical_coordinates_latitude = #{geographicalCoordinatesLatitude},</if>
            <if test="riverName != null">river_name = #{riverName},</if>
            <if test="agriculturalIrrigationArea != null">agricultural_irrigation_area = #{agriculturalIrrigationArea},</if>
            <if test="constructionDate != null">construction_date = #{constructionDate},</if>
            <if test="isHubProject != null">is_hub_project = #{isHubProject},</if>
            <if test="isSluiceStationProject != null">is_sluice_station_project = #{isSluiceStationProject},</if>
            <if test="isNestedSluiceProject != null">is_nested_sluice_project = #{isNestedSluiceProject},</if>
            <if test="projectGrade != null">project_grade = #{projectGrade},</if>
            <if test="mainBuildingGrade != null">main_building_grade = #{mainBuildingGrade},</if>
            <if test="waterSluiceInfoGatesNumber != null">water_sluice_info_gates_number = #{waterSluiceInfoGatesNumber},</if>
            <if test="waterSluiceInfoGatesWide != null">water_sluice_info_gates_wide = #{waterSluiceInfoGatesWide},</if>
            <if test="projectLocation != null">project_location = #{projectLocation},</if>
            <if test="designStandard != null">design_standard = #{designStandard},</if>
            <if test="checkCriteria != null">check_criteria = #{checkCriteria},</if>
            <if test="organizationName != null">organization_name = #{organizationName},</if>
            <if test="ownership != null">ownership = #{ownership},</if>
            <if test="responsiblePerson != null">responsible_person = #{responsiblePerson},</if>
            <if test="position != null">position = #{position},</if>
            <if test="phoneNumber != null">phone_number = #{phoneNumber},</if>
            <if test="manageResponsiblePerson != null">manage_responsible_person = #{manageResponsiblePerson},</if>
            <if test="managePhonePosts != null">manage_phone_posts = #{managePhonePosts},</if>
            <if test="managePhoneNumber != null">manage_phone_number = #{managePhoneNumber},</if>
            <if test="administrativeResponsiblePerson != null">administrative_responsible_person = #{administrativeResponsiblePerson},</if>
            <if test="administrativePhoneNumber != null">administrative_phone_number = #{administrativePhoneNumber},</if>
            <if test="technologyResponsiblePerson != null">technology_responsible_person = #{technologyResponsiblePerson},</if>
            <if test="technologyPhoneNumber != null">technology_phone_number = #{technologyPhoneNumber},</if>
            <if test="inspectionResponsiblePerson != null">inspection_responsible_person = #{inspectionResponsiblePerson},</if>
            <if test="inspectionPhoneNumber != null">inspection_phone_number = #{inspectionPhoneNumber},</if>
            <if test="isBoundaryDelineationCompleted != null">is_boundary_delineation_completed = #{isBoundaryDelineationCompleted},</if>
            <if test="isPropertyRightsConfirmationCompleted != null">is_property_rights_confirmation_completed = #{isPropertyRightsConfirmationCompleted},</if>
            <if test="floodControlMaterials != null">flood_control_materials = #{floodControlMaterials},</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="deleteGSiteSluiceInfoById" parameterType="Long">
        delete from g_site_sluice_info where id = #{id}
    </delete>

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