<?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.TConGasProIncMapper">
    
    <resultMap type="TConGasProInc" id="TConGasProIncResult">
        <result property="fConGasProIncId"    column="f_con_gas_pro_inc_id"    />
        <result property="fIntersectConstructionId"    column="f_intersect_construction_id"    />
        <result property="fTitle"    column="f_title"    />
        <result property="fDescription"    column="f_description"    />
        <result property="fOccurrenctTime"    column="f_occurrenct_time"    />
        <result property="fAttachment"    column="f_attachment"    />
        <result property="fCompanyInfoId"    column="f_company_info_id"    />
        <result property="fRemark"    column="f_remark"    />
        <result property="fUpdateTime"    column="f_update_time"    />

        <result property="fCompanyInfoId"    column="f_company_info_id"    />
        <result property="entUploadTime"    column="f_ent_upload_time"    />
        <result property="entUploadState"    column="f_ent_upload_state"    />
        <result property="govUploadTime"    column="f_gov_upload_time"    />
        <result property="govUploadState"    column="f_gov_upload_state"    />
    </resultMap>

    <sql id="selectTConGasProIncVo">
        SELECT
            inc.f_con_gas_pro_inc_id,
            inc.f_intersect_construction_id,
            inc.f_title,
            inc.f_description,
            inc.f_occurrenct_time,
            inc.f_attachment,
            inc.f_remark,
            inc.f_update_time,
            inc.f_ent_upload_time,
            inc.f_ent_upload_state,
            inc.f_gov_upload_time,
            inc.f_gov_upload_state,
            info.f_project_code AS projectCode,
            enterprise.enterprise_name as f_company_info_id
        FROM
            t_con_gas_pro_inc inc
        LEFT JOIN t_con_gas_pro_infor info ON info.f_con_gas_pro_infor_id = inc.f_intersect_construction_id
        LEFT JOIN t_enterprise_info enterprise ON info.f_company_info_id = enterprise.enterprise_id
    </sql>

    <select id="selectTConGasProIncList" parameterType="TConGasProInc" resultMap="TConGasProIncResult">
        <include refid="selectTConGasProIncVo"/>
        <where>  
            <if test="fIntersectConstructionId != null  and fIntersectConstructionId != ''"> and info.f_project_code like concat('%', #{fIntersectConstructionId}, '%')</if>
            <if test="fTitle != null  and fTitle != ''"> and inc.f_title like concat('%', #{fTitle}, '%')</if>
            <if test="fDescription != null  and fDescription != ''"> and inc.f_description = #{fDescription}</if>
            <if test="fOccurrenctTime != null  and fOccurrenctTime != ''"> and inc.f_occurrenct_time = #{fOccurrenctTime}</if>
            <if test="fAttachment != null  and fAttachment != ''"> and inc.f_attachment = #{fAttachment}</if>
            <if test="fRemark != null  and fRemark != ''"> and inc.f_remark = #{fRemark}</if>
            <if test="fUpdateTime != null  and fUpdateTime != ''"> and inc.f_update_time = #{fUpdateTime}</if>
            <if test="fCompanyInfoId != null  and fCompanyInfoId != ''"> and inc.f_company_info_id = #{fCompanyInfoId}</if>
            <if test="entUploadState != null  and entUploadState != ''"> and inc.f_ent_upload_state = #{entUploadState}</if>
            <if test="govUploadState != null  and govUploadState != ''"> and inc.f_gov_upload_state = #{govUploadState}</if>
        </where>
        order by f_update_time desc
    </select>

    <select id="exportTConGasProInforList" parameterType="TConGasProInc" resultMap="TConGasProIncResult">
        <include refid="selectTConGasProIncVo"/>
        <where>
            <if test="fIntersectConstructionId != null  and fIntersectConstructionId != ''"> and info.f_project_code like concat('%', #{fIntersectConstructionId}, '%')</if>
            <if test="fTitle != null  and fTitle != ''"> and inc.f_title like concat('%', #{fTitle}, '%')</if>
            <if test="fDescription != null  and fDescription != ''"> and inc.f_description = #{fDescription}</if>
            <if test="fOccurrenctTime != null  and fOccurrenctTime != ''"> and inc.f_occurrenct_time = #{fOccurrenctTime}</if>
            <if test="fAttachment != null  and fAttachment != ''"> and inc.f_attachment = #{fAttachment}</if>
            <if test="fRemark != null  and fRemark != ''"> and inc.f_remark = #{fRemark}</if>
            <if test="fUpdateTime != null  and fUpdateTime != ''"> and inc.f_update_time = #{fUpdateTime}</if>
            <if test="fCompanyInfoId != null  and fCompanyInfoId != ''"> and inc.f_company_info_id = #{fCompanyInfoId}</if>
            <if test="entUploadState != null  and entUploadState != ''"> and inc.f_ent_upload_state = #{entUploadState}</if>
            <if test="govUploadState != null  and govUploadState != ''"> and inc.f_gov_upload_state = #{govUploadState}</if>
        </where>
        order by f_update_time desc
    </select>


    <select id="selectTConGasProIncById" parameterType="Long" resultMap="TConGasProIncResult">
        <include refid="selectTConGasProIncVo"/>
        where inc.f_con_gas_pro_inc_id = #{fConGasProIncId}
    </select>
        
    <insert id="insertTConGasProInc" parameterType="TConGasProInc" useGeneratedKeys="true" keyProperty="fConGasProIncId">
        insert into t_con_gas_pro_inc
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="fIntersectConstructionId != null and fIntersectConstructionId != ''">f_intersect_construction_id,</if>
            <if test="fTitle != null and fTitle != ''">f_title,</if>
            <if test="fDescription != null and fDescription != ''">f_description,</if>
            <if test="fOccurrenctTime != null and fOccurrenctTime != ''">f_occurrenct_time,</if>
            <if test="fAttachment != null and fAttachment != ''">f_attachment,</if>
            <if test="fRemark != null and fRemark != ''">f_remark,</if>
            <if test="fUpdateTime != null and fUpdateTime != ''">f_update_time,</if>

            <if test="fCompanyInfoId != null and fCompanyInfoId != ''">f_company_info_id,</if>
            <if test="entUploadTime != null and entUploadTime != ''">f_ent_upload_time,</if>
            <if test="entUploadState != null and entUploadState != ''">f_ent_upload_state,</if>
            <if test="govUploadTime != null and govUploadTime != ''">f_gov_upload_time,</if>
            <if test="govUploadState != null and govUploadState != ''">f_gov_upload_state,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="fIntersectConstructionId != null and fIntersectConstructionId != ''">#{fIntersectConstructionId},</if>
            <if test="fTitle != null and fTitle != ''">#{fTitle},</if>
            <if test="fDescription != null and fDescription != ''">#{fDescription},</if>
            <if test="fOccurrenctTime != null and fOccurrenctTime != ''">#{fOccurrenctTime},</if>
            <if test="fAttachment != null and fAttachment != ''">#{fAttachment},</if>
            <if test="fRemark != null and fRemark != ''">#{fRemark},</if>
            <if test="fUpdateTime != null and fUpdateTime != ''">#{fUpdateTime},</if>

            <if test="fCompanyInfoId != null and fCompanyInfoId != ''">#{fCompanyInfoId},</if>
            <if test="entUploadTime != null and entUploadTime != ''">#{entUploadTime},</if>
            <if test="entUploadState != null and entUploadState != ''">#{entUploadState},</if>
            <if test="govUploadTime != null and govUploadTime != ''">#{govUploadTime},</if>
            <if test="govUploadState != null and govUploadState != ''">#{govUploadState},</if>
         </trim>
    </insert>

    <update id="updateTConGasProInc" parameterType="TConGasProInc">
        update t_con_gas_pro_inc
        <trim prefix="SET" suffixOverrides=",">
            <if test="fIntersectConstructionId != null and fIntersectConstructionId != ''">f_intersect_construction_id = #{fIntersectConstructionId},</if>
            <if test="fTitle != null and fTitle != ''">f_title = #{fTitle},</if>
            <if test="fDescription != null and fDescription != ''">f_description = #{fDescription},</if>
            <if test="fOccurrenctTime != null and fOccurrenctTime != ''">f_occurrenct_time = #{fOccurrenctTime},</if>
            <if test="fAttachment != null and fAttachment != ''">f_attachment = #{fAttachment},</if>
            <if test="fRemark != null and fRemark != ''">f_remark = #{fRemark},</if>
            <if test="fUpdateTime != null and fUpdateTime != ''">f_update_time = #{fUpdateTime},</if>

            <if test="entUploadTime != null">f_ent_upload_time = #{entUploadTime},</if>
            <if test="entUploadState != null and entUploadState != ''">f_ent_upload_state = #{entUploadState},</if>
            <if test="govUploadTime != null">f_gov_upload_time = #{govUploadTime},</if>
            <if test="govUploadState != null and govUploadState != ''">f_gov_upload_state = #{govUploadState},</if>
        </trim>
        where f_con_gas_pro_inc_id = #{fConGasProIncId}
    </update>

    <delete id="deleteTConGasProIncById" parameterType="Long">
        delete from t_con_gas_pro_inc where f_con_gas_pro_inc_id = #{fConGasProIncId}
    </delete>

    <update id="updateEntUploadStateById">
        update t_con_gas_pro_inc set f_ent_upload_state = #{state}, f_ent_upload_time = #{entUploadTime} where  f_con_gas_pro_inc_id = #{fConGasProIncId}
    </update>

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