<?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.zehong.system.mapper.TSupBalStopSupMapper">
    
    <resultMap type="TSupBalStopSup" id="TSupBalStopSupResult">
        <result property="fGasStopId"    column="f_gas_stop_id"    />
        <result property="fCompanyInfoId"    column="f_company_info_id"    />
        <result property="fStartDate"    column="f_start_date"    />
        <result property="fEndDate"    column="f_end_date"    />
        <result property="fStopType"    column="f_stop_type"    />
        <result property="fInfluenceCus"    column="f_influence_cus"    />
        <result property="fStopReason"    column="f_stop_reason"    />
        <result property="fStopRange"    column="f_stop_range"    />
        <result property="fStopProgress"    column="f_stop_progress"    />
        <result property="fRecoveryGasTime"    column="f_recovery_gas_time"    />
        <result property="fRepStatus"    column="f_rep_status"    />
        <result property="entRepTime"    column="f_ent_rep_time"    />
        <result property="fGasStopArea"    column="f_gas_stop_area"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="isDel"    column="is_del"    />
        <result property="remarks"    column="remarks"    />
        <result property="fGovUploadStatus"    column="f_gov_upload_status"    />
        <result property="fGovUploadTime"    column="f_gov_upload_time"    />
    </resultMap>

    <sql id="selectTSupBalStopSupVo">
        SELECT
            st.f_gas_stop_id,
            st.f_company_info_id,
            st.f_start_date,
            st.f_end_date,
            st.f_stop_type,
            st.f_influence_cus,
            st.f_stop_reason,
            st.f_stop_range,
            st.f_stop_progress,
            st.f_recovery_gas_time,
            st.f_rep_status,
            st.f_ent_rep_time,
            st.f_gas_stop_area,
            st.create_by,
            st.create_time,
            st.update_by,
            st.update_time,
            st.is_del,
            st.remarks,
            st.f_gov_upload_status,
            st.f_gov_upload_time,
            en.enterprise_name AS enterpriseName
        FROM
            t_sup_bal_stop_sup st
        LEFT JOIN t_enterprise_info en ON en.enterprise_id = st.f_company_info_id
    </sql>

    <select id="selectTSupBalStopSupList" parameterType="TSupBalStopSup" resultMap="TSupBalStopSupResult">
        <include refid="selectTSupBalStopSupVo"/>
        <where>  
            <if test="fCompanyInfoId != null  and fCompanyInfoId != ''"> and st.f_company_info_id = #{fCompanyInfoId}</if>
            <if test="fStopType != null  and fStopType != ''"> and st.f_stop_type = #{fStopType}</if>
            <if test="fStopProgress != null  and fStopProgress != ''"> and st.f_stop_progress = #{fStopProgress}</if>
            <if test="fRepStatus != null  and fRepStatus != ''"> and st.f_rep_status = #{fRepStatus}</if>
            <if test="enterpriseName != null  and enterpriseName != ''"> and en.enterprise_name like concat('%', #{enterpriseName}, '%')</if>
            <if test="fGovUploadStatus != null  and fGovUploadStatus != ''"> and st.f_gov_upload_status = #{fGovUploadStatus}</if>
            <if test="fGovUploadTime != null "> and st.f_gov_upload_time = #{fGovUploadTime}</if>
        </where>
        order by st.create_time desc
    </select>
    
    <select id="selectTSupBalStopSupById" parameterType="Long" resultMap="TSupBalStopSupResult">
        <include refid="selectTSupBalStopSupVo"/>
        where f_gas_stop_id = #{fGasStopId}
    </select>
        
    <insert id="insertTSupBalStopSup" parameterType="TSupBalStopSup" useGeneratedKeys="true" keyProperty="fGasStopId">
        insert into t_sup_bal_stop_sup
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="fCompanyInfoId != null">f_company_info_id,</if>
            <if test="fStartDate != null">f_start_date,</if>
            <if test="fEndDate != null">f_end_date,</if>
            <if test="fStopType != null and fStopType != ''">f_stop_type,</if>
            <if test="fInfluenceCus != null">f_influence_cus,</if>
            <if test="fStopReason != null">f_stop_reason,</if>
            <if test="fStopRange != null and fStopRange != ''">f_stop_range,</if>
            <if test="fStopProgress != null and fStopProgress != ''">f_stop_progress,</if>
            <if test="fRecoveryGasTime != null">f_recovery_gas_time,</if>
            <if test="fRepStatus != null and fRepStatus != ''">f_rep_status,</if>
            <if test="entRepTime != null">f_ent_rep_time,</if>
            <if test="fGasStopArea != null">f_gas_stop_area,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="isDel != null">is_del,</if>
            <if test="remarks != null">remarks,</if>
            <if test="fGovUploadStatus != null">f_gov_upload_status,</if>
            <if test="fGovUploadTime != null">f_gov_upload_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="fCompanyInfoId != null">#{fCompanyInfoId},</if>
            <if test="fStartDate != null">#{fStartDate},</if>
            <if test="fEndDate != null">#{fEndDate},</if>
            <if test="fStopType != null and fStopType != ''">#{fStopType},</if>
            <if test="fInfluenceCus != null">#{fInfluenceCus},</if>
            <if test="fStopReason != null">#{fStopReason},</if>
            <if test="fStopRange != null and fStopRange != ''">#{fStopRange},</if>
            <if test="fStopProgress != null and fStopProgress != ''">#{fStopProgress},</if>
            <if test="fRecoveryGasTime != null">#{fRecoveryGasTime},</if>
            <if test="fRepStatus != null and fRepStatus != ''">#{fRepStatus},</if>
            <if test="entRepTime != null">#{entRepTime},</if>
            <if test="fGasStopArea != null">#{fGasStopArea},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="isDel != null">#{isDel},</if>
            <if test="remarks != null">#{remarks},</if>
            <if test="fGovUploadStatus != null">#{fGovUploadStatus},</if>
            <if test="fGovUploadTime != null">#{fGovUploadTime},</if>
         </trim>
    </insert>

    <update id="updateTSupBalStopSup" parameterType="TSupBalStopSup">
        update t_sup_bal_stop_sup
        <trim prefix="SET" suffixOverrides=",">
            <if test="fCompanyInfoId != null">f_company_info_id = #{fCompanyInfoId},</if>
            <if test="fStartDate != null">f_start_date = #{fStartDate},</if>
            <if test="fEndDate != null">f_end_date = #{fEndDate},</if>
            <if test="fStopType != null and fStopType != ''">f_stop_type = #{fStopType},</if>
            <if test="fInfluenceCus != null">f_influence_cus = #{fInfluenceCus},</if>
            <if test="fStopReason != null">f_stop_reason = #{fStopReason},</if>
            <if test="fStopRange != null and fStopRange != ''">f_stop_range = #{fStopRange},</if>
            <if test="fStopProgress != null and fStopProgress != ''">f_stop_progress = #{fStopProgress},</if>
            <if test="fRecoveryGasTime != null">f_recovery_gas_time = #{fRecoveryGasTime},</if>
            <if test="fRepStatus != null and fRepStatus != ''">f_rep_status = #{fRepStatus},</if>
            <if test="entRepTime != null">f_ent_rep_time = #{entRepTime},</if>
            <if test="fGasStopArea != null">f_gas_stop_area = #{fGasStopArea},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="isDel != null">is_del = #{isDel},</if>
            <if test="remarks != null">remarks = #{remarks},</if>
            <if test="fGovUploadStatus != null">f_gov_upload_status = #{fGovUploadStatus},</if>
            <if test="fGovUploadTime != null">f_gov_upload_time = #{fGovUploadTime},</if>
        </trim>
        where f_gas_stop_id = #{fGasStopId}
    </update>

    <delete id="deleteTSupBalStopSupById" parameterType="Long">
        delete from t_sup_bal_stop_sup where f_gas_stop_id = #{fGasStopId}
    </delete>

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