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

    <resultMap type="GSiteReservoirInfo" id="GSiteReservoirInfoResult">
        <result property="id"    column="id"    />
        <result property="projectName"    column="project_name"    />
        <result property="geoCoordinates"    column="geo_coordinates"    />
        <result property="projectLocation"    column="project_location"    />
        <result property="drainageBasin"    column="drainage_basin"    />
        <result property="drainageSystem"    column="drainage_system"    />
        <result property="river"    column="river"    />
        <result property="townVillage"    column="town_village"    />
        <result property="reservoirType"    column="reservoir_type"    />
        <result property="reservoirFunction"    column="reservoir_function"    />
        <result property="constructionStatus"    column="construction_status"    />
        <result property="reservoirLevel"    column="reservoir_level"    />
        <result property="mainDamLevel"    column="main_dam_level"    />
        <result property="mainDamHeight"    column="main_dam_height"    />
        <result property="mainDamLength"    column="main_dam_length"    />
        <result property="damCrestElevation"    column="dam_crest_elevation"    />
        <result property="normalStorageLevel"    column="normal_storage_level"    />
        <result property="deadWaterLevel"    column="dead_water_level"    />
        <result property="totalCapacity"    column="total_capacity"    />
        <result property="beneficialCapacity"    column="beneficial_capacity"    />
        <result property="deadStorage"    column="dead_storage"    />
        <result property="normalStorageArea"    column="normal_storage_area"    />
        <result property="annualSupplyCapacity"    column="annual_supply_capacity"    />
        <result property="administrativeResponsible"    column="administrative_responsible"    />
        <result property="administrativeUnitName"    column="administrative_unit_name"    />
        <result property="administrativePosition"    column="administrative_position"    />
        <result property="administrativePhone"    column="administrative_phone"    />
        <result property="technicalResponsible"    column="technical_responsible"    />
        <result property="technicalUnitName"    column="technical_unit_name"    />
        <result property="technicalPosition"    column="technical_position"    />
        <result property="technicalPhone"    column="technical_phone"    />
        <result property="inspectionResponsible"    column="inspection_responsible"    />
        <result property="inspectionUnitName"    column="inspection_unit_name"    />
        <result property="inspectionPosition"    column="inspection_position"    />
        <result property="inspectionPhone"    column="inspection_phone"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="createdBy"    column="created_by"    />
        <result property="updatedBy"    column="updated_by"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="siteId"    column="site_id"    />
    </resultMap>

    <sql id="selectGSiteReservoirInfoVo">
        select id, project_name, geo_coordinates, project_location, drainage_basin, drainage_system, river, town_village, reservoir_type, reservoir_function, construction_status, reservoir_level, main_dam_level, main_dam_height, main_dam_length, dam_crest_elevation, normal_storage_level, dead_water_level, total_capacity, beneficial_capacity, dead_storage, normal_storage_area, annual_supply_capacity, administrative_responsible, administrative_unit_name, administrative_position, administrative_phone, technical_responsible, technical_unit_name, technical_position, technical_phone, inspection_responsible, inspection_unit_name, inspection_position, inspection_phone, create_time, update_time, created_by, updated_by, del_flag, site_id from g_site_reservoir_info
    </sql>

    <select id="selectGSiteReservoirInfoList" parameterType="GSiteReservoirInfo" resultMap="GSiteReservoirInfoResult">
        <include refid="selectGSiteReservoirInfoVo"/>
        <where>
            <if test="projectName != null  and projectName != ''"> and project_name like concat('%', #{projectName}, '%')</if>
            <if test="geoCoordinates != null  and geoCoordinates != ''"> and geo_coordinates = #{geoCoordinates}</if>
            <if test="projectLocation != null  and projectLocation != ''"> and project_location = #{projectLocation}</if>
            <if test="drainageBasin != null  and drainageBasin != ''"> and drainage_basin = #{drainageBasin}</if>
            <if test="drainageSystem != null  and drainageSystem != ''"> and drainage_system = #{drainageSystem}</if>
            <if test="river != null  and river != ''"> and river = #{river}</if>
            <if test="townVillage != null  and townVillage != ''"> and town_village = #{townVillage}</if>
            <if test="reservoirType != null  and reservoirType != ''"> and reservoir_type = #{reservoirType}</if>
            <if test="reservoirFunction != null  and reservoirFunction != ''"> and reservoir_function = #{reservoirFunction}</if>
            <if test="constructionStatus != null  and constructionStatus != ''"> and construction_status = #{constructionStatus}</if>
            <if test="reservoirLevel != null  and reservoirLevel != ''"> and reservoir_level = #{reservoirLevel}</if>
            <if test="mainDamLevel != null  and mainDamLevel != ''"> and main_dam_level = #{mainDamLevel}</if>
            <if test="mainDamHeight != null "> and main_dam_height = #{mainDamHeight}</if>
            <if test="mainDamLength != null "> and main_dam_length = #{mainDamLength}</if>
            <if test="damCrestElevation != null "> and dam_crest_elevation = #{damCrestElevation}</if>
            <if test="normalStorageLevel != null "> and normal_storage_level = #{normalStorageLevel}</if>
            <if test="deadWaterLevel != null "> and dead_water_level = #{deadWaterLevel}</if>
            <if test="totalCapacity != null "> and total_capacity = #{totalCapacity}</if>
            <if test="beneficialCapacity != null "> and beneficial_capacity = #{beneficialCapacity}</if>
            <if test="deadStorage != null "> and dead_storage = #{deadStorage}</if>
            <if test="normalStorageArea != null "> and normal_storage_area = #{normalStorageArea}</if>
            <if test="annualSupplyCapacity != null "> and annual_supply_capacity = #{annualSupplyCapacity}</if>
            <if test="administrativeResponsible != null  and administrativeResponsible != ''"> and administrative_responsible = #{administrativeResponsible}</if>
            <if test="administrativeUnitName != null  and administrativeUnitName != ''"> and administrative_unit_name like concat('%', #{administrativeUnitName}, '%')</if>
            <if test="administrativePosition != null  and administrativePosition != ''"> and administrative_position = #{administrativePosition}</if>
            <if test="administrativePhone != null  and administrativePhone != ''"> and administrative_phone = #{administrativePhone}</if>
            <if test="technicalResponsible != null  and technicalResponsible != ''"> and technical_responsible = #{technicalResponsible}</if>
            <if test="technicalUnitName != null  and technicalUnitName != ''"> and technical_unit_name like concat('%', #{technicalUnitName}, '%')</if>
            <if test="technicalPosition != null  and technicalPosition != ''"> and technical_position = #{technicalPosition}</if>
            <if test="technicalPhone != null  and technicalPhone != ''"> and technical_phone = #{technicalPhone}</if>
            <if test="inspectionResponsible != null  and inspectionResponsible != ''"> and inspection_responsible = #{inspectionResponsible}</if>
            <if test="inspectionUnitName != null  and inspectionUnitName != ''"> and inspection_unit_name like concat('%', #{inspectionUnitName}, '%')</if>
            <if test="inspectionPosition != null  and inspectionPosition != ''"> and inspection_position = #{inspectionPosition}</if>
            <if test="inspectionPhone != null  and inspectionPhone != ''"> and inspection_phone = #{inspectionPhone}</if>
            <if test="createdBy != null  and createdBy != ''"> and created_by = #{createdBy}</if>
            <if test="updatedBy != null  and updatedBy != ''"> and updated_by = #{updatedBy}</if>
            <if test="siteId != null "> and site_id = #{siteId}</if>
        </where>
    </select>

    <select id="selectGSiteReservoirInfoBySiteId" parameterType="Long" resultMap="GSiteReservoirInfoResult">
        <include refid="selectGSiteReservoirInfoVo"/>
        where site_id = #{siteId}
    </select>

    <insert id="insertGSiteReservoirInfo" parameterType="GSiteReservoirInfo" useGeneratedKeys="true" keyProperty="id">
        insert into g_site_reservoir_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="projectName != null">project_name,</if>
            <if test="geoCoordinates != null">geo_coordinates,</if>
            <if test="projectLocation != null">project_location,</if>
            <if test="drainageBasin != null">drainage_basin,</if>
            <if test="drainageSystem != null">drainage_system,</if>
            <if test="river != null">river,</if>
            <if test="townVillage != null">town_village,</if>
            <if test="reservoirType != null">reservoir_type,</if>
            <if test="reservoirFunction != null">reservoir_function,</if>
            <if test="constructionStatus != null">construction_status,</if>
            <if test="reservoirLevel != null">reservoir_level,</if>
            <if test="mainDamLevel != null">main_dam_level,</if>
            <if test="mainDamHeight != null">main_dam_height,</if>
            <if test="mainDamLength != null">main_dam_length,</if>
            <if test="damCrestElevation != null">dam_crest_elevation,</if>
            <if test="normalStorageLevel != null">normal_storage_level,</if>
            <if test="deadWaterLevel != null">dead_water_level,</if>
            <if test="totalCapacity != null">total_capacity,</if>
            <if test="beneficialCapacity != null">beneficial_capacity,</if>
            <if test="deadStorage != null">dead_storage,</if>
            <if test="normalStorageArea != null">normal_storage_area,</if>
            <if test="annualSupplyCapacity != null">annual_supply_capacity,</if>
            <if test="administrativeResponsible != null">administrative_responsible,</if>
            <if test="administrativeUnitName != null">administrative_unit_name,</if>
            <if test="administrativePosition != null">administrative_position,</if>
            <if test="administrativePhone != null">administrative_phone,</if>
            <if test="technicalResponsible != null">technical_responsible,</if>
            <if test="technicalUnitName != null">technical_unit_name,</if>
            <if test="technicalPosition != null">technical_position,</if>
            <if test="technicalPhone != null">technical_phone,</if>
            <if test="inspectionResponsible != null">inspection_responsible,</if>
            <if test="inspectionUnitName != null">inspection_unit_name,</if>
            <if test="inspectionPosition != null">inspection_position,</if>
            <if test="inspectionPhone != null">inspection_phone,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="createdBy != null">created_by,</if>
            <if test="updatedBy != null">updated_by,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="siteId != null">site_id,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="projectName != null">#{projectName},</if>
            <if test="geoCoordinates != null">#{geoCoordinates},</if>
            <if test="projectLocation != null">#{projectLocation},</if>
            <if test="drainageBasin != null">#{drainageBasin},</if>
            <if test="drainageSystem != null">#{drainageSystem},</if>
            <if test="river != null">#{river},</if>
            <if test="townVillage != null">#{townVillage},</if>
            <if test="reservoirType != null">#{reservoirType},</if>
            <if test="reservoirFunction != null">#{reservoirFunction},</if>
            <if test="constructionStatus != null">#{constructionStatus},</if>
            <if test="reservoirLevel != null">#{reservoirLevel},</if>
            <if test="mainDamLevel != null">#{mainDamLevel},</if>
            <if test="mainDamHeight != null">#{mainDamHeight},</if>
            <if test="mainDamLength != null">#{mainDamLength},</if>
            <if test="damCrestElevation != null">#{damCrestElevation},</if>
            <if test="normalStorageLevel != null">#{normalStorageLevel},</if>
            <if test="deadWaterLevel != null">#{deadWaterLevel},</if>
            <if test="totalCapacity != null">#{totalCapacity},</if>
            <if test="beneficialCapacity != null">#{beneficialCapacity},</if>
            <if test="deadStorage != null">#{deadStorage},</if>
            <if test="normalStorageArea != null">#{normalStorageArea},</if>
            <if test="annualSupplyCapacity != null">#{annualSupplyCapacity},</if>
            <if test="administrativeResponsible != null">#{administrativeResponsible},</if>
            <if test="administrativeUnitName != null">#{administrativeUnitName},</if>
            <if test="administrativePosition != null">#{administrativePosition},</if>
            <if test="administrativePhone != null">#{administrativePhone},</if>
            <if test="technicalResponsible != null">#{technicalResponsible},</if>
            <if test="technicalUnitName != null">#{technicalUnitName},</if>
            <if test="technicalPosition != null">#{technicalPosition},</if>
            <if test="technicalPhone != null">#{technicalPhone},</if>
            <if test="inspectionResponsible != null">#{inspectionResponsible},</if>
            <if test="inspectionUnitName != null">#{inspectionUnitName},</if>
            <if test="inspectionPosition != null">#{inspectionPosition},</if>
            <if test="inspectionPhone != null">#{inspectionPhone},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="createdBy != null">#{createdBy},</if>
            <if test="updatedBy != null">#{updatedBy},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="siteId != null">#{siteId},</if>
        </trim>
    </insert>

    <update id="updateGSiteReservoirInfo" parameterType="GSiteReservoirInfo">
        update g_site_reservoir_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="projectName != null">project_name = #{projectName},</if>
            <if test="geoCoordinates != null">geo_coordinates = #{geoCoordinates},</if>
            <if test="projectLocation != null">project_location = #{projectLocation},</if>
            <if test="drainageBasin != null">drainage_basin = #{drainageBasin},</if>
            <if test="drainageSystem != null">drainage_system = #{drainageSystem},</if>
            <if test="river != null">river = #{river},</if>
            <if test="townVillage != null">town_village = #{townVillage},</if>
            <if test="reservoirType != null">reservoir_type = #{reservoirType},</if>
            <if test="reservoirFunction != null">reservoir_function = #{reservoirFunction},</if>
            <if test="constructionStatus != null">construction_status = #{constructionStatus},</if>
            <if test="reservoirLevel != null">reservoir_level = #{reservoirLevel},</if>
            <if test="mainDamLevel != null">main_dam_level = #{mainDamLevel},</if>
            <if test="mainDamHeight != null">main_dam_height = #{mainDamHeight},</if>
            <if test="mainDamLength != null">main_dam_length = #{mainDamLength},</if>
            <if test="damCrestElevation != null">dam_crest_elevation = #{damCrestElevation},</if>
            <if test="normalStorageLevel != null">normal_storage_level = #{normalStorageLevel},</if>
            <if test="deadWaterLevel != null">dead_water_level = #{deadWaterLevel},</if>
            <if test="totalCapacity != null">total_capacity = #{totalCapacity},</if>
            <if test="beneficialCapacity != null">beneficial_capacity = #{beneficialCapacity},</if>
            <if test="deadStorage != null">dead_storage = #{deadStorage},</if>
            <if test="normalStorageArea != null">normal_storage_area = #{normalStorageArea},</if>
            <if test="annualSupplyCapacity != null">annual_supply_capacity = #{annualSupplyCapacity},</if>
            <if test="administrativeResponsible != null">administrative_responsible = #{administrativeResponsible},</if>
            <if test="administrativeUnitName != null">administrative_unit_name = #{administrativeUnitName},</if>
            <if test="administrativePosition != null">administrative_position = #{administrativePosition},</if>
            <if test="administrativePhone != null">administrative_phone = #{administrativePhone},</if>
            <if test="technicalResponsible != null">technical_responsible = #{technicalResponsible},</if>
            <if test="technicalUnitName != null">technical_unit_name = #{technicalUnitName},</if>
            <if test="technicalPosition != null">technical_position = #{technicalPosition},</if>
            <if test="technicalPhone != null">technical_phone = #{technicalPhone},</if>
            <if test="inspectionResponsible != null">inspection_responsible = #{inspectionResponsible},</if>
            <if test="inspectionUnitName != null">inspection_unit_name = #{inspectionUnitName},</if>
            <if test="inspectionPosition != null">inspection_position = #{inspectionPosition},</if>
            <if test="inspectionPhone != null">inspection_phone = #{inspectionPhone},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="createdBy != null">created_by = #{createdBy},</if>
            <if test="updatedBy != null">updated_by = #{updatedBy},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="siteId != null">site_id = #{siteId},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteGSiteReservoirInfoById" parameterType="Long">
        delete from g_site_reservoir_info where id = #{id}
    </delete>

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