<?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.TPipeOldPlanProcessMapper">
    
    <resultMap type="TPipeOldPlanProcess" id="TPipeOldPlanProcessResult">
        <result property="fOldPlanProcessId"    column="f_old_plan_process_id"    />
        <result property="fUuid"    column="f_uuid"    />
        <result property="fEntUuid"    column="f_ent_uuid"    />
        <result property="fRegion"    column="f_region"    />
        <result property="fProjectName"    column="f_project_name"    />
        <result property="fRelationObjectType"    column="f_relation_object_type"    />
        <result property="fYear"    column="f_year"    />
        <result property="fStartTime"    column="f_start_time"    />
        <result property="fEndTime"    column="f_end_time"    />
        <result property="fTotalInvestment"    column="f_total_investment"    />
        <result property="fCreateTime"    column="f_create_time"    />
        <result property="fUpdateTime"    column="f_update_time"    />
        <result property="fSubjectImplementation"    column="f_subject_implementation"    />
        <result property="fConcatPerson"    column="f_concat_person"    />
        <result property="fConcatTel"    column="f_concat_tel"    />
        <result property="fConstructionContent"    column="f_construction_content"    />
        <result property="fActualFinishTime"    column="f_actual_finish_time"    />
        <result property="fReconstructionProgress"    column="f_reconstruction_progress"    />
        <result property="fFundsDisbursementProgress"    column="f_funds_disbursement_progress"    />
        <result property="fUploadType"    column="f_upload_type"    />
        <result property="fUploadTime"    column="f_upload_time"    />
        <result property="fEnterpriseId"    column="f_enterprise_id"    />
        <result property="enterpriseName"    column="enterpriseName"    />

        <result property="govUploadState"    column="f_gov_upload_state"    />
        <result property="govUploadTime"    column="f_gov_upload_time"    />
    </resultMap>

    <sql id="selectTPipeOldPlanProcessVo">
        select process.f_old_plan_process_id,
               process.f_uuid,
               process.f_enterprise_id,
               enterprise.enterprise_name as enterpriseName,
               process.f_ent_uuid,
               process.f_region,
               process.f_project_name,
               process.f_relation_object_type,
               process.f_year,
               process.f_start_time,
               process.f_end_time,
               process.f_total_investment,
               process.f_create_time,
               process.f_update_time,
               process.f_subject_implementation,
               process.f_concat_person,
               process.f_concat_tel,
               process.f_construction_content,
               process.f_actual_finish_time,
               process.f_reconstruction_progress,
               process.f_funds_disbursement_progress,
               process.f_upload_type,
               process.f_upload_time,
               process.f_gov_upload_state,
               process.f_gov_upload_time
        from t_pipe_old_plan_process process left join t_enterprise_info enterprise on process.f_enterprise_id = enterprise.enterprise_id
    </sql>


    <resultMap type="TPipeOldPlanProcess" id="TPipeOldPlanProcessResultForExport">
        <result property="fOldPlanProcessId"    column="f_old_plan_process_id"    />
        <result property="fUuid"    column="f_uuid"    />
        <result property="fEntUuid"    column="f_ent_uuid"    />
        <result property="fEnterpriseId"    column="f_enterprise_id"    />
        <result property="enterpriseName"    column="enterpriseName"    />
        <result property="fRegion"    column="f_region"    />
        <result property="regionName"    column="regionName"    />
        <result property="fProjectName"    column="f_project_name"    />
        <result property="fRelationObjectType"    column="f_relation_object_type"    />
        <result property="fYear"    column="f_year"    />
        <result property="fStartTime"    column="f_start_time"    />
        <result property="fEndTime"    column="f_end_time"    />
        <result property="fTotalInvestment"    column="f_total_investment"    />
        <result property="fCreateTime"    column="f_create_time"    />
        <result property="fUpdateTime"    column="f_update_time"    />
        <result property="fSubjectImplementation"    column="f_subject_implementation"    />
        <result property="fConcatPerson"    column="f_concat_person"    />
        <result property="fConcatTel"    column="f_concat_tel"    />
        <result property="fConstructionContent"    column="f_construction_content"    />
        <result property="fActualFinishTime"    column="f_actual_finish_time"    />
        <result property="fReconstructionProgress"    column="f_reconstruction_progress"    />
        <result property="fFundsDisbursementProgress"    column="f_funds_disbursement_progress"    />
        <result property="fUploadType"    column="f_upload_type"    />
        <result property="fUploadTime"    column="f_upload_time"    />

        <result property="govUploadState"    column="f_gov_upload_state"    />
        <result property="govUploadTime"    column="f_gov_upload_time"    />
    </resultMap>

    <sql id="exportTPipeOldPlanProcessVo">
        select process.f_old_plan_process_id,
               process.f_uuid,
               process.f_enterprise_id,
               enterprise.enterprise_name as enterpriseName,
               process.f_ent_uuid,
               process.f_region,
               region.f_name as regionName,
               process.f_project_name,
               process.f_relation_object_type,
               process.f_year,
               process.f_start_time,
               process.f_end_time,
               process.f_total_investment,
               process.f_create_time,
               process.f_update_time,
               process.f_subject_implementation,
               process.f_concat_person,
               process.f_concat_tel,
               process.f_construction_content,
               process.f_actual_finish_time,
               process.f_reconstruction_progress,
               process.f_funds_disbursement_progress,
               process.f_upload_type,
               process.f_upload_time,
               process.f_gov_upload_state,
               process.f_gov_upload_time
        from t_pipe_old_plan_process process left join t_enterprise_info enterprise on process.f_enterprise_id = enterprise.enterprise_id
                                             left join t_county_level_region region on process.f_region = region.f_id
    </sql>

    <select id="selectTPipeOldPlanProcessList" parameterType="TPipeOldPlanProcess" resultMap="TPipeOldPlanProcessResult">
        <include refid="selectTPipeOldPlanProcessVo"/>
        <where>  
            <if test="fProjectName != null  and fProjectName != ''"> and f_project_name like concat('%', #{fProjectName}, '%')</if>
            <if test="fRelationObjectType != null  and fRelationObjectType != ''"> and f_relation_object_type = #{fRelationObjectType}</if>
            <if test="fConcatPerson != null  and fConcatPerson != ''"> and f_concat_person like concat('%', #{fConcatPerson}, '%')</if>
            <if test="fConcatTel != null  and fConcatTel != ''"> and f_concat_tel like concat('%', #{fConcatTel}, '%')</if>
            <if test="fFundsDisbursementProgress != null "> and f_funds_disbursement_progress = #{fFundsDisbursementProgress}</if>
            <if test="fUploadType != null  and fUploadType != ''"> and f_upload_type = #{fUploadType}</if>
            <if test="fEnterpriseId != null  and fEnterpriseId != ''"> and f_enterprise_id = #{fEnterpriseId}</if>
            <if test="govUploadState != null  and govUploadState != ''"> and f_gov_upload_state = #{govUploadState}</if>
        </where>
        order by f_create_time desc
    </select>

    <select id="exportPipeOldPlanProcessList" parameterType="TPipeOldPlanProcess" resultMap="TPipeOldPlanProcessResultForExport">
        <include refid="exportTPipeOldPlanProcessVo"/>
        <where>
            <if test="fProjectName != null  and fProjectName != ''"> and f_project_name like concat('%', #{fProjectName}, '%')</if>
            <if test="fRelationObjectType != null  and fRelationObjectType != ''"> and f_relation_object_type = #{fRelationObjectType}</if>
            <if test="fConcatPerson != null  and fConcatPerson != ''"> and f_concat_person like concat('%', #{fConcatPerson}, '%')</if>
            <if test="fConcatTel != null  and fConcatTel != ''"> and f_concat_tel like concat('%', #{fConcatTel}, '%')</if>
            <if test="fFundsDisbursementProgress != null "> and f_funds_disbursement_progress = #{fFundsDisbursementProgress}</if>
            <if test="fUploadType != null  and fUploadType != ''"> and f_upload_type = #{fUploadType}</if>
            <if test="fEnterpriseId != null  and fEnterpriseId != ''"> and f_enterprise_id = #{fEnterpriseId}</if>
            <if test="govUploadState != null  and govUploadState != ''"> and f_gov_upload_state = #{govUploadState}</if>
        </where>
        order by f_create_time desc
    </select>

    <select id="selectTPipeOldPlanProcessById" parameterType="Long" resultMap="TPipeOldPlanProcessResult">
        <include refid="selectTPipeOldPlanProcessVo"/>
        where f_old_plan_process_id = #{fOldPlanProcessId}
    </select>
        
    <insert id="insertTPipeOldPlanProcess" parameterType="TPipeOldPlanProcess" useGeneratedKeys="true" keyProperty="fOldPlanProcessId">
        insert into t_pipe_old_plan_process
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="fUuid != null and fUuid != ''">f_uuid,</if>
            <if test="fEntUuid != null">f_ent_uuid,</if>
            <if test="fRegion != null">f_region,</if>
            <if test="fProjectName != null">f_project_name,</if>
            <if test="fRelationObjectType != null">f_relation_object_type,</if>
            <if test="fYear != null">f_year,</if>
            <if test="fStartTime != null">f_start_time,</if>
            <if test="fEndTime != null">f_end_time,</if>
            <if test="fTotalInvestment != null">f_total_investment,</if>
            <if test="fCreateTime != null">f_create_time,</if>
            <if test="fUpdateTime != null">f_update_time,</if>
            <if test="fSubjectImplementation != null">f_subject_implementation,</if>
            <if test="fConcatPerson != null">f_concat_person,</if>
            <if test="fConcatTel != null">f_concat_tel,</if>
            <if test="fConstructionContent != null">f_construction_content,</if>
            <if test="fActualFinishTime != null">f_actual_finish_time,</if>
            <if test="fReconstructionProgress != null">f_reconstruction_progress,</if>
            <if test="fFundsDisbursementProgress != null">f_funds_disbursement_progress,</if>
            <if test="fUploadType != null">f_upload_type,</if>
            <if test="fUploadTime != null">f_upload_time,</if>
            <if test="fEnterpriseId != null">f_enterprise_id,</if>

            <if test="govUploadState != null">f_gov_upload_state,</if>
            <if test="govUploadTime != null">f_gov_upload_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="fUuid != null and fUuid != ''">#{fUuid},</if>
            <if test="fEntUuid != null">#{fEntUuid},</if>
            <if test="fRegion != null">#{fRegion},</if>
            <if test="fProjectName != null">#{fProjectName},</if>
            <if test="fRelationObjectType != null">#{fRelationObjectType},</if>
            <if test="fYear != null">#{fYear},</if>
            <if test="fStartTime != null">#{fStartTime},</if>
            <if test="fEndTime != null">#{fEndTime},</if>
            <if test="fTotalInvestment != null">#{fTotalInvestment},</if>
            <if test="fCreateTime != null">#{fCreateTime},</if>
            <if test="fUpdateTime != null">#{fUpdateTime},</if>
            <if test="fSubjectImplementation != null">#{fSubjectImplementation},</if>
            <if test="fConcatPerson != null">#{fConcatPerson},</if>
            <if test="fConcatTel != null">#{fConcatTel},</if>
            <if test="fConstructionContent != null">#{fConstructionContent},</if>
            <if test="fActualFinishTime != null">#{fActualFinishTime},</if>
            <if test="fReconstructionProgress != null">#{fReconstructionProgress},</if>
            <if test="fFundsDisbursementProgress != null">#{fFundsDisbursementProgress},</if>
            <if test="fUploadType != null">#{fUploadType},</if>
            <if test="fUploadTime != null">#{fUploadTime},</if>
            <if test="fEnterpriseId != null">#{fEnterpriseId},</if>

            <if test="govUploadState != null">#{govUploadState},</if>
            <if test="govUploadTime != null">#{govUploadTime},</if>
         </trim>
    </insert>

    <update id="updateTPipeOldPlanProcess" parameterType="TPipeOldPlanProcess">
        update t_pipe_old_plan_process
        <trim prefix="SET" suffixOverrides=",">
            <if test="fUuid != null and fUuid != ''">f_uuid = #{fUuid},</if>
            <if test="fEntUuid != null">f_ent_uuid = #{fEntUuid},</if>
            <if test="fRegion != null">f_region = #{fRegion},</if>
            <if test="fProjectName != null">f_project_name = #{fProjectName},</if>
            <if test="fRelationObjectType != null">f_relation_object_type = #{fRelationObjectType},</if>
            <if test="fYear != null">f_year = #{fYear},</if>
            <if test="fStartTime != null">f_start_time = #{fStartTime},</if>
            <if test="fEndTime != null">f_end_time = #{fEndTime},</if>
            <if test="fTotalInvestment != null">f_total_investment = #{fTotalInvestment},</if>
            <if test="fCreateTime != null">f_create_time = #{fCreateTime},</if>
            <if test="fUpdateTime != null">f_update_time = #{fUpdateTime},</if>
            <if test="fSubjectImplementation != null">f_subject_implementation = #{fSubjectImplementation},</if>
            <if test="fConcatPerson != null">f_concat_person = #{fConcatPerson},</if>
            <if test="fConcatTel != null">f_concat_tel = #{fConcatTel},</if>
            <if test="fConstructionContent != null">f_construction_content = #{fConstructionContent},</if>
            <if test="fActualFinishTime != null">f_actual_finish_time = #{fActualFinishTime},</if>
            <if test="fReconstructionProgress != null">f_reconstruction_progress = #{fReconstructionProgress},</if>
            <if test="fFundsDisbursementProgress != null">f_funds_disbursement_progress = #{fFundsDisbursementProgress},</if>
            <if test="fUploadType != null">f_upload_type = #{fUploadType},</if>
            <if test="fUploadTime != null">f_upload_time = #{fUploadTime},</if>
            <if test="fEnterpriseId != null">f_enterprise_id = #{fEnterpriseId},</if>

            <if test="govUploadState != null">f_gov_upload_state = #{govUploadState},</if>
            <if test="govUploadTime != null">f_gov_upload_time = #{govUploadTime},</if>
        </trim>
        where f_old_plan_process_id = #{fOldPlanProcessId}
    </update>

    <delete id="deleteTPipeOldPlanProcessById" parameterType="Long">
        delete from t_pipe_old_plan_process where f_old_plan_process_id = #{fOldPlanProcessId}
    </delete>

    <update id="entReportPipeOldPlanProcess">
        update t_pipe_old_plan_process set f_upload_type = #{state}, f_upload_time = #{entUploadTime} where  f_old_plan_process_id = #{fOldPlanProcessId}
    </update>
    <delete id="deleteTPipeOldPlanProcessByIds" parameterType="String">
        delete from t_pipe_old_plan_process where f_old_plan_process_id in 
        <foreach item="fOldPlanProcessId" collection="array" open="(" separator="," close=")">
            #{fOldPlanProcessId}
        </foreach>
    </delete>
</mapper>