<?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.jeeplus.test.program.configuration.projectList.mapper.ProgramArchiveMapper">

    <resultMap id="BaseResultMap" type="com.jeeplus.test.program.configuration.projectList.service.dto.ProgramArchiveDto">
            <id property="id" column="id" jdbcType="VARCHAR"/>
            <result property="createBy.id" column="create_by" jdbcType="VARCHAR"/>
            <result property="createDate" column="create_date" jdbcType="TIMESTAMP"/>
            <result property="updateBy.id" column="update_by" jdbcType="VARCHAR"/>
            <result property="updateDate" column="update_date" jdbcType="TIMESTAMP"/>
            <result property="delFlag" column="del_flag" jdbcType="INTEGER"/>
            <result property="remarks" column="remarks" jdbcType="VARCHAR"/>
            <result property="programId" column="program_id" jdbcType="VARCHAR"/>
            <result property="year" column="year" jdbcType="VARCHAR"/>
            <result property="programType" column="program_type" jdbcType="VARCHAR"/>
            <result property="evaluationReportDate" column="evaluation_report_date" jdbcType="TIMESTAMP"/>
            <result property="protocolNum" column="protocol_num" jdbcType="VARCHAR"/>
            <result property="waystEvaluation" column="wayst_evaluation" jdbcType="VARCHAR"/>
            <result property="fixedAssetsEvaluation" column="fixed_assets_evaluation" jdbcType="VARCHAR"/>
            <result property="netAssetsEvaluation" column="net_assets_evaluation" jdbcType="VARCHAR"/>
            <result property="rentEvaluation" column="rent_evaluation" jdbcType="VARCHAR"/>
            <result property="forensics" column="forensics" jdbcType="VARCHAR"/>
            <result property="reportCharges" column="report_charges" jdbcType="VARCHAR"/>
            <result property="currentDisposePerson" column="current_dispose_person" jdbcType="VARCHAR"/>
            <result property="isInvoice" column="is_invoice" jdbcType="VARCHAR"/>
            <result property="invoiceDate" column="invoice_date" jdbcType="TIMESTAMP"/>
            <result property="actualCharges" column="actual_charges" jdbcType="VARCHAR"/>
            <result property="isContractArchive" column="is_contract_archive" jdbcType="VARCHAR"/>
            <result property="isPapersIntact" column="is_papers_intact" jdbcType="VARCHAR"/>
            <result property="isPapersArchive" column="is_papers_archive" jdbcType="VARCHAR"/>
            <result property="opsAmount" column="ops_amount" jdbcType="VARCHAR"/>
            <result property="isOpsReimbursement" column="is_ops_reimbursement" jdbcType="VARCHAR"/>
            <result property="reimbursementAmount" column="reimbursement_amount" jdbcType="VARCHAR"/>
            <result property="unreimbursedAmount" column="unreimbursed_amount" jdbcType="VARCHAR"/>
            <result property="reimbursementNum" column="reimbursement_num" jdbcType="VARCHAR"/>
            <result property="reimbursementDate" column="reimbursement_date" jdbcType="TIMESTAMP"/>
            <result property="auditDate" column="audit_date" jdbcType="TIMESTAMP"/>
            <result property="procInsId" column="proc_ins_id" jdbcType="VARCHAR"/>
            <result property="processDefinitionId" column="process_definition_id" jdbcType="VARCHAR"/>
            <result property="status" column="status" jdbcType="VARCHAR"/>
            <result property="reportNo" column="report_no" jdbcType="VARCHAR"/>
            <result property="auditUserId" column="audit_user_id" jdbcType="VARCHAR"/>
            <result property="signatureEvaluatorFirst" column="signature_evaluator_first" jdbcType="VARCHAR"/>
            <result property="signatureEvaluatorSecond" column="signature_evaluator_second" jdbcType="VARCHAR"/>
            <association property="programProjectListInfo" select="getProgram" javaType="com.jeeplus.test.program.configuration.projectList.domain.ProgramProjectListInfo" column="program_id"></association>
    </resultMap>

    <sql id="Base_Column_List">
        pa.id,
        pa.create_by,
        pa.create_date,
        pa.update_by,
        pa.update_date,
        pa.del_flag,
        pa.remarks,
        pa.program_id,
        pa.year,
        pa.program_type,
        pa.evaluation_report_date,
        pa.protocol_num,
        pa.wayst_evaluation,
        pa.fixed_assets_evaluation,
        pa.net_assets_evaluation,
        pa.rent_evaluation,
        pa.forensics,
        pa.report_charges,
        pa.rent_type,
        pa.current_dispose_person,
        pa.is_invoice,
        pa.invoice_date,
        pa.actual_charges,
        pa.is_contract_archive,
        pa.is_papers_intact,
        pa.is_papers_archive,
        pa.ops_amount,
        pa.is_ops_reimbursement,
        pa.reimbursement_amount,
        pa.unreimbursed_amount,
        pa.reimbursement_num,
        pa.reimbursement_date,
        pa.proc_ins_id,
        pa.process_definition_id,
        pa.status,
        pa.audit_date,
        pa.audit_date as "auditDateDate",
        pa.audit_user_id,
        pa.signature_evaluator_first,
        pa.signature_evaluator_second
    </sql>
    <sql id="Program_Column_List">
        ppli.id,
        ppli.create_by,
        ppli.create_date,
        ppli.update_by,
        ppli.update_date,
        ppli.del_flag,
        ppli.contract_id,
        ppli.contract_name,
        ppli.client,
        ppli.client_name,
        ppli.amount,
        ppli.contract_type,
        ppli.name,
        ppli.no,
        ppli.project_type,
        ppli.approval_no,
        ppli.company,
        ppli.project_mould,
        ppli.property_holder,
        ppli.property_holder_name,
        ppli.location,
        ppli.is_first,
        ppli.year_num,
        ppli.check_year,
        ppli.project_manager,
        ppli.project_manager_name,
        ppli.report_type,
        ppli.industry,
        ppli.enterprise_type,
        ppli.risk_level,
        ppli.project_source,
        ppli.estimate,
        ppli.plan_end_time,
        ppli.use_num,
        ppli.appointment,
        ppli.work_hours,
        ppli.remarks,
        ppli.assessment_enterprise,
        ppli.assessment_enterprise_name,
        ppli.link_num,
        ppli.relationship,
        ppli.assessment_way,
        ppli.assessment_objective,
        ppli.assessment_date,
        ppli.num,
        ppli.project_development,
        ppli.delegate_project_type,
        ppli.assessment_object,
        ppli.work_begin_date,
        ppli.work_end_date,
        ppli.reporting_date,
        ppli.is_have,
        ppli.is_influence,mode,
        ppli.status,
        ppli.proc_ins_id,
        ppli.process_definition_id
    </sql>
    <select id="getProgram" resultType="com.jeeplus.test.program.configuration.projectList.domain.ProgramProjectListInfo">
        select
        <include refid="Program_Column_List"></include>,
        wci.no AS contract_no
        from program_project_list_info ppli
        left join work_contract_info wci on wci.id = ppli.contract_id and wci.del_flag = '0'
        where ppli.del_flag = '0' and ppli.id = #{program_id}
    </select>
    <select id="findByIdArchive" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"></include>,
        prn.report_no as report_no
        from program_archive pa
        left join program_report_no prn on prn.program_id = pa.program_id and prn.del_flag = '0'
        where pa.del_flag = '0' and pa.id = #{id}
    </select>
    <select id="findByProgramIdArchive" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"></include>,
        prn.report_no as report_no
        from program_archive pa
        left join program_report_no prn on prn.program_id = pa.program_id and prn.del_flag = '0'
        where pa.del_flag = '0' and pa.program_id = #{id}
    </select>
</mapper>
