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

    <resultMap type="GSitePumpInfo" id="GSitePumpInfoResult">
        <result property="id"    column="id"    />
        <result property="projectName"    column="project_name"    />
        <result property="projectCode"    column="project_code"    />
        <result property="geographicalCoordLongitude"    column="geographical_coord_longitude"    />
        <result property="geographicalCoordLatitude"    column="geographical_coord_latitude"    />
        <result property="location"    column="location"    />
        <result property="waterResourceArea"    column="water_resource_area"    />
        <result property="riverName"    column="river_name"    />
        <result property="irrigationArea"    column="irrigation_area"    />
        <result property="pumpStationType"    column="pump_station_type"    />
        <result property="constructionStatus"    column="construction_status"    />
        <result property="isHubProject"    column="is_hub_project"    />
        <result property="isGateStation"    column="is_gate_station"    />
        <result property="isSpringProject"    column="is_spring_project"    />
        <result property="projectGrade"    column="project_grade"    />
        <result property="buildingGrade"    column="building_grade"    />
        <result property="pumpCount"    column="pump_count"    />
        <result property="designLift"    column="design_lift"    />
        <result property="installedPower"    column="installed_power"    />
        <result property="installedFlow"    column="installed_flow"    />
        <result property="task"    column="task"    />
        <result property="managementUnit"    column="management_unit"    />
        <result property="ownership"    column="ownership"    />
        <result property="responsiblePerson"    column="responsible_person"    />
        <result property="position"    column="position"    />
        <result property="phone"    column="phone"    />
        <result property="isDemarcated"    column="is_demarcated"    />
        <result property="isConfirmed"    column="is_confirmed"    />
        <result property="floodPrevention"    column="flood_prevention"    />
        <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="selectGSitePumpInfoVo">
        select id, project_name, project_code, geographical_coord_longitude, geographical_coord_latitude, location, water_resource_area, river_name, irrigation_area, pump_station_type, construction_status, is_hub_project, is_gate_station, is_spring_project, project_grade, building_grade, pump_count, design_lift, installed_power, installed_flow, task, management_unit, ownership, responsible_person, position, phone, is_demarcated, is_confirmed, flood_prevention, del_flag, create_time, create_by, update_time, update_by, site_id from g_site_pump_info
    </sql>

    <select id="selectGSitePumpInfoList" parameterType="GSitePumpInfo" resultMap="GSitePumpInfoResult">
        <include refid="selectGSitePumpInfoVo"/>
        <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="geographicalCoordLongitude != null "> and geographical_coord_longitude = #{geographicalCoordLongitude}</if>
            <if test="geographicalCoordLatitude != null "> and geographical_coord_latitude = #{geographicalCoordLatitude}</if>
            <if test="location != null  and location != ''"> and location = #{location}</if>
            <if test="waterResourceArea != null  and waterResourceArea != ''"> and water_resource_area = #{waterResourceArea}</if>
            <if test="riverName != null  and riverName != ''"> and river_name like concat('%', #{riverName}, '%')</if>
            <if test="irrigationArea != null  and irrigationArea != ''"> and irrigation_area = #{irrigationArea}</if>
            <if test="pumpStationType != null  and pumpStationType != ''"> and pump_station_type = #{pumpStationType}</if>
            <if test="constructionStatus != null  and constructionStatus != ''"> and construction_status = #{constructionStatus}</if>
            <if test="isHubProject != null "> and is_hub_project = #{isHubProject}</if>
            <if test="isGateStation != null "> and is_gate_station = #{isGateStation}</if>
            <if test="isSpringProject != null "> and is_spring_project = #{isSpringProject}</if>
            <if test="projectGrade != null "> and project_grade = #{projectGrade}</if>
            <if test="buildingGrade != null "> and building_grade = #{buildingGrade}</if>
            <if test="pumpCount != null "> and pump_count = #{pumpCount}</if>
            <if test="designLift != null "> and design_lift = #{designLift}</if>
            <if test="installedPower != null "> and installed_power = #{installedPower}</if>
            <if test="installedFlow != null "> and installed_flow = #{installedFlow}</if>
            <if test="task != null  and task != ''"> and task = #{task}</if>
            <if test="managementUnit != null  and managementUnit != ''"> and management_unit = #{managementUnit}</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="phone != null  and phone != ''"> and phone = #{phone}</if>
            <if test="isDemarcated != null "> and is_demarcated = #{isDemarcated}</if>
            <if test="isConfirmed != null "> and is_confirmed = #{isConfirmed}</if>
            <if test="floodPrevention != null  and floodPrevention != ''"> and flood_prevention = #{floodPrevention}</if>
            <if test="siteId != null "> and site_id = #{siteId}</if>
        </where>
    </select>

    <select id="selectGSitePumpInfoBySiteId" parameterType="Long" resultMap="GSitePumpInfoResult">
        <include refid="selectGSitePumpInfoVo"/>
        where site_id = #{site_id}
    </select>

    <insert id="insertGSitePumpInfo" parameterType="GSitePumpInfo" useGeneratedKeys="true" keyProperty="id">
        insert into g_site_pump_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="projectName != null and projectName != ''">project_name,</if>
            <if test="projectCode != null">project_code,</if>
            <if test="geographicalCoordLongitude != null">geographical_coord_longitude,</if>
            <if test="geographicalCoordLatitude != null">geographical_coord_latitude,</if>
            <if test="location != null and location != ''">location,</if>
            <if test="waterResourceArea != null and waterResourceArea != ''">water_resource_area,</if>
            <if test="riverName != null and riverName != ''">river_name,</if>
            <if test="irrigationArea != null and irrigationArea != ''">irrigation_area,</if>
            <if test="pumpStationType != null and pumpStationType != ''">pump_station_type,</if>
            <if test="constructionStatus != null and constructionStatus != ''">construction_status,</if>
            <if test="isHubProject != null">is_hub_project,</if>
            <if test="isGateStation != null">is_gate_station,</if>
            <if test="isSpringProject != null">is_spring_project,</if>
            <if test="projectGrade != null">project_grade,</if>
            <if test="buildingGrade != null">building_grade,</if>
            <if test="pumpCount != null">pump_count,</if>
            <if test="designLift != null">design_lift,</if>
            <if test="installedPower != null">installed_power,</if>
            <if test="installedFlow != null">installed_flow,</if>
            <if test="task != null and task != ''">task,</if>
            <if test="managementUnit != null and managementUnit != ''">management_unit,</if>
            <if test="ownership != null">ownership,</if>
            <if test="responsiblePerson != null">responsible_person,</if>
            <if test="position != null">position,</if>
            <if test="phone != null">phone,</if>
            <if test="isDemarcated != null">is_demarcated,</if>
            <if test="isConfirmed != null">is_confirmed,</if>
            <if test="floodPrevention != null">flood_prevention,</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 and projectName != ''">#{projectName},</if>
            <if test="projectCode != null">#{projectCode},</if>
            <if test="geographicalCoordLongitude != null">#{geographicalCoordLongitude},</if>
            <if test="geographicalCoordLatitude != null">#{geographicalCoordLatitude},</if>
            <if test="location != null and location != ''">#{location},</if>
            <if test="waterResourceArea != null and waterResourceArea != ''">#{waterResourceArea},</if>
            <if test="riverName != null and riverName != ''">#{riverName},</if>
            <if test="irrigationArea != null and irrigationArea != ''">#{irrigationArea},</if>
            <if test="pumpStationType != null and pumpStationType != ''">#{pumpStationType},</if>
            <if test="constructionStatus != null and constructionStatus != ''">#{constructionStatus},</if>
            <if test="isHubProject != null">#{isHubProject},</if>
            <if test="isGateStation != null">#{isGateStation},</if>
            <if test="isSpringProject != null">#{isSpringProject},</if>
            <if test="projectGrade != null">#{projectGrade},</if>
            <if test="buildingGrade != null">#{buildingGrade},</if>
            <if test="pumpCount != null">#{pumpCount},</if>
            <if test="designLift != null">#{designLift},</if>
            <if test="installedPower != null">#{installedPower},</if>
            <if test="installedFlow != null">#{installedFlow},</if>
            <if test="task != null and task != ''">#{task},</if>
            <if test="managementUnit != null and managementUnit != ''">#{managementUnit},</if>
            <if test="ownership != null">#{ownership},</if>
            <if test="responsiblePerson != null">#{responsiblePerson},</if>
            <if test="position != null">#{position},</if>
            <if test="phone != null">#{phone},</if>
            <if test="isDemarcated != null">#{isDemarcated},</if>
            <if test="isConfirmed != null">#{isConfirmed},</if>
            <if test="floodPrevention != null">#{floodPrevention},</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="updateGSitePumpInfo" parameterType="GSitePumpInfo">
        update g_site_pump_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="geographicalCoordLongitude != null">geographical_coord_longitude = #{geographicalCoordLongitude},</if>
            <if test="geographicalCoordLatitude != null">geographical_coord_latitude = #{geographicalCoordLatitude},</if>
            <if test="location != null and location != ''">location = #{location},</if>
            <if test="waterResourceArea != null and waterResourceArea != ''">water_resource_area = #{waterResourceArea},</if>
            <if test="riverName != null and riverName != ''">river_name = #{riverName},</if>
            <if test="irrigationArea != null and irrigationArea != ''">irrigation_area = #{irrigationArea},</if>
            <if test="pumpStationType != null and pumpStationType != ''">pump_station_type = #{pumpStationType},</if>
            <if test="constructionStatus != null and constructionStatus != ''">construction_status = #{constructionStatus},</if>
            <if test="isHubProject != null">is_hub_project = #{isHubProject},</if>
            <if test="isGateStation != null">is_gate_station = #{isGateStation},</if>
            <if test="isSpringProject != null">is_spring_project = #{isSpringProject},</if>
            <if test="projectGrade != null">project_grade = #{projectGrade},</if>
            <if test="buildingGrade != null">building_grade = #{buildingGrade},</if>
            <if test="pumpCount != null">pump_count = #{pumpCount},</if>
            <if test="designLift != null">design_lift = #{designLift},</if>
            <if test="installedPower != null">installed_power = #{installedPower},</if>
            <if test="installedFlow != null">installed_flow = #{installedFlow},</if>
            <if test="task != null and task != ''">task = #{task},</if>
            <if test="managementUnit != null and managementUnit != ''">management_unit = #{managementUnit},</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="phone != null">phone = #{phone},</if>
            <if test="isDemarcated != null">is_demarcated = #{isDemarcated},</if>
            <if test="isConfirmed != null">is_confirmed = #{isConfirmed},</if>
            <if test="floodPrevention != null">flood_prevention = #{floodPrevention},</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="deleteGSitePumpInfoById" parameterType="Long">
        delete from g_site_pump_info where id = #{id}
    </delete>

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