<?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.rechargecard.mapper.NgInformationWaterIntakeMapper">

    <resultMap type="NgInformationWaterIntake" id="NgInformationWaterIntakeResult">
        <result property="intakeId"    column="intake_id"    />
        <result property="wellId"    column="well_id"    />
        <result property="deviceCode"    column="device_code"    />
        <result property="location"    column="location"    />
        <result property="constructionDate"    column="construction_date"    />
        <result property="maintenanceStatus"    column="maintenance_status"    />
        <result property="lastMaintenanceDate"    column="last_maintenance_date"    />
        <result property="waterQuality"    column="water_quality"    />
        <result property="waterExtractionVolume"    column="water_extraction_volume"    />
        <result property="type"    column="type"    />
        <result property="responsiblePerson"    column="responsible_person"    />
        <result property="contactInformation"    column="contact_information"    />
        <result property="parameter"    column="parameter"    />
        <result property="remark"    column="remark"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateBy"    column="update_by"    />
    </resultMap>

    <sql id="selectNgInformationWaterIntakeVo">
        select intake_id, well_id, device_code, location, construction_date, maintenance_status, last_maintenance_date, water_quality, water_extraction_volume, type, responsible_person, contact_information, parameter, remark, create_time, update_time, create_by, update_by from ng_information_water_intake
    </sql>

    <select id="selectNgInformationWaterIntakeList" parameterType="NgInformationWaterIntake" resultMap="NgInformationWaterIntakeResult">
        <include refid="selectNgInformationWaterIntakeVo"/>
        <where>
            <if test="wellId != null  and wellId != ''"> and well_id = #{wellId}</if>
            <if test="deviceCode != null  and deviceCode != ''"> and device_code = #{deviceCode}</if>
            <if test="location != null  and location != ''"> and location = #{location}</if>
            <if test="constructionDate != null "> and construction_date = #{constructionDate}</if>
            <if test="maintenanceStatus != null "> and maintenance_status = #{maintenanceStatus}</if>
            <if test="lastMaintenanceDate != null "> and last_maintenance_date = #{lastMaintenanceDate}</if>
            <if test="waterQuality != null  and waterQuality != ''"> and water_quality = #{waterQuality}</if>
            <if test="waterExtractionVolume != null "> and water_extraction_volume = #{waterExtractionVolume}</if>
            <if test="type != null "> and type = #{type}</if>
            <if test="responsiblePerson != null  and responsiblePerson != ''"> and responsible_person = #{responsiblePerson}</if>
            <if test="contactInformation != null  and contactInformation != ''"> and contact_information = #{contactInformation}</if>
            <if test="parameter != null  and parameter != ''"> and parameter = #{parameter}</if>
        </where>
    </select>

    <select id="selectNgInformationWaterIntakeByIntakeId" parameterType="Long" resultMap="NgInformationWaterIntakeResult">
        <include refid="selectNgInformationWaterIntakeVo"/>
        where intake_id = #{intakeId}
    </select>

    <insert id="insertNgInformationWaterIntake" parameterType="NgInformationWaterIntake" useGeneratedKeys="true" keyProperty="intakeId">
        insert into ng_information_water_intake
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="wellId != null">well_id,</if>
            <if test="deviceCode != null">device_code,</if>
            <if test="location != null">location,</if>
            <if test="constructionDate != null">construction_date,</if>
            <if test="maintenanceStatus != null">maintenance_status,</if>
            <if test="lastMaintenanceDate != null">last_maintenance_date,</if>
            <if test="waterQuality != null">water_quality,</if>
            <if test="waterExtractionVolume != null">water_extraction_volume,</if>
            <if test="type != null">type,</if>
            <if test="responsiblePerson != null">responsible_person,</if>
            <if test="contactInformation != null">contact_information,</if>
            <if test="parameter != null">parameter,</if>
            <if test="remark != null">remark,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateBy != null">update_by,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="wellId != null">#{wellId},</if>
            <if test="deviceCode != null">#{deviceCode},</if>
            <if test="location != null">#{location},</if>
            <if test="constructionDate != null">#{constructionDate},</if>
            <if test="maintenanceStatus != null">#{maintenanceStatus},</if>
            <if test="lastMaintenanceDate != null">#{lastMaintenanceDate},</if>
            <if test="waterQuality != null">#{waterQuality},</if>
            <if test="waterExtractionVolume != null">#{waterExtractionVolume},</if>
            <if test="type != null">#{type},</if>
            <if test="responsiblePerson != null">#{responsiblePerson},</if>
            <if test="contactInformation != null">#{contactInformation},</if>
            <if test="parameter != null">#{parameter},</if>
            <if test="remark != null">#{remark},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateBy != null">#{updateBy},</if>
        </trim>
    </insert>

    <update id="updateNgInformationWaterIntake" parameterType="NgInformationWaterIntake">
        update ng_information_water_intake
        <trim prefix="SET" suffixOverrides=",">
            <if test="wellId != null">well_id = #{wellId},</if>
            <if test="deviceCode != null">device_code = #{deviceCode},</if>
            <if test="location != null">location = #{location},</if>
            <if test="constructionDate != null">construction_date = #{constructionDate},</if>
            <if test="maintenanceStatus != null">maintenance_status = #{maintenanceStatus},</if>
            <if test="lastMaintenanceDate != null">last_maintenance_date = #{lastMaintenanceDate},</if>
            <if test="waterQuality != null">water_quality = #{waterQuality},</if>
            <if test="waterExtractionVolume != null">water_extraction_volume = #{waterExtractionVolume},</if>
            <if test="type != null">type = #{type},</if>
            <if test="responsiblePerson != null">responsible_person = #{responsiblePerson},</if>
            <if test="contactInformation != null">contact_information = #{contactInformation},</if>
            <if test="parameter != null">parameter = #{parameter},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
        </trim>
        where intake_id = #{intakeId}
    </update>

    <delete id="deleteNgInformationWaterIntakeByIntakeId" parameterType="Long">
        delete from ng_information_water_intake where intake_id = #{intakeId}
    </delete>

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