<?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="org.jeecg.modules.projectManagement.mapper.FdProjectQuotationMapper">


    <select id="findByPage" resultType="org.jeecg.modules.projectManagement.entity.FdProjectQuotation">
        SELECT
        *,
        u.realname as createByName,
        gm.name as generalManagerName,
        cs.name as clinicalSectionName,
        cp.name as centralPriceName,
        ds.name as dataStatisticsName,
        pc.name as pkComputingName,
        b.name as bioanalysisName,
        bd.name as projectManagerName
        FROM
        fd_project_quotation fpq
        LEFT JOIN sys_user u on fpq.create_by=u.username
        left join fd_personnel gm on gm.id = fpq.general_manager
        left join fd_personnel cs on cs.id = fpq.clinical_section_id
        left join fd_personnel cp on cp.id=fpq.central_price_id
        left join fd_personnel ds on ds.id=fpq.data_statistics_id
        left join fd_personnel pc on pc.id=fpq.pk_computing_id
        left join fd_personnel b on b.id=fpq.bioanalysis_id
        left join fd_personnel bd on bd.id=fpq.project_manager
        ${ew.customSqlSegment}
    </select>
    <!--<select id="findByPage" resultType="org.jeecg.modules.projectManagement.entity.FdProjectQuotation">-->
        <!--SELECT-->
            <!--fpq.id,-->
            <!--fpq.`code`,-->
            <!--fpq.`name`,-->
            <!--fpq.pk_customer_id,-->
            <!--fpq.customer_name,-->
            <!--fpqcd.compound,-->
            <!--fpq.quotation_date,-->
            <!--fpq.STATUS,-->
            <!--fpq.create_time,-->
            <!--fpqcs.contact_psn AS contactPsn,-->
            <!--fpqcs.contact_tel AS contactTel,-->
            <!--fpqcs.email AS contactEmail,-->
            <!--fpqcs.is_default AS isDefault,-->
            <!--fpqcs.memo AS Notes,-->
            <!--u.realname as createByName-->
        <!--FROM-->
            <!--fd_project_quotation fpq-->
            <!--LEFT JOIN fd_project_quotation_compound fpqcd ON fpq.id = fpqcd.quotation_id-->
            <!--LEFT JOIN fd_project_quotation_contacts fpqcs ON fpq.id = fpqcs.quotation_id-->
            <!--LEFT JOIN sys_user u on fpq.create_by=u.username-->
            <!--${ew.customSqlSegment}-->
    <!--</select>-->

    <update id="updateStatusBatch" parameterType="java.util.List">
        update fd_project_quotation set status = '2' where id in
        <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
            #{item}
        </foreach>
    </update>

    <update id="updateReviewBatch" parameterType="java.util.List">
        update fd_project_quotation set status = '1' where id in
        <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
            #{item}
        </foreach>
    </update>

    <update id="updateAuditBatch" parameterType="java.util.List">
        update fd_project_quotation set status = '0' where id in
        <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
            #{item}
        </foreach>
    </update>

    <select id="getQuotationById" resultType="org.jeecg.modules.projectManagement.entity.FdProjectQuotation">
        SELECT
            *,
        pm.name as projectManagerName,
        bm.name as businessManagerName,
        d.name as directorName,
        gm.name as generalManagerName,
        cs.name as clinicalSectionName,
        cp.name as centralPriceName,
        ds.name as dataStatisticsName,
        pc.name as pkComputingName,
        b.name as bioanalysisName,
        pqc.contact_psn AS contactPsn,
        pqc.contact_tel AS contactTel,
        pqc.email AS contactEmail,
        c.short_name as shortName
        FROM
            fd_project_quotation pq
            left join fd_personnel pm on pm.id = pq.project_manager
            left join fd_personnel bm on bm.id = pq.business_manager
            left join fd_personnel d on d.id = pq.director
            left join fd_personnel gm on gm.id = pq.general_manager
            left join fd_personnel cs on cs.id = pq.clinical_section_id
            left join fd_personnel cp on cp.id=pq.central_price_id
            left join fd_personnel ds on ds.id=pq.data_statistics_id
            left join fd_personnel pc on pc.id=pq.pk_computing_id
            left join fd_personnel b on b.id=pq.bioanalysis_id
	        LEFT JOIN fd_project_quotation_contacts pqc ON pqc.quotation_id = pq.id
	        LEFT JOIN fd_customer c on pq.pk_customer_id =c.id
        where pq.del_flag='0' and pq.id=#{0}
            and pqc.is_default='1'
            and pqc.del_flag='0'
            and c.del_flag='0'
    </select>

    <!-- 项目经理-->
    <select id="getProjectManagerList" resultType="org.jeecg.modules.basedata.entity.FdPersonnel">
        SELECT
            p.id,
            p.CODE,
            p.NAME,
            s.username
        FROM
            fd_personnel p
            LEFT JOIN sys_user s ON p.id = s.personnel_id
            left join sys_user_role sur on sur.user_id=s.id
            left join sys_role sr on sr.id=sur.role_id
        WHERE
            s.personnel_id != ''
            AND p.del_flag = '0'
            and sr.id='98a506f628ddcfdd3dfe6100f6a11a4d'
    </select>

    <!--( SELECT count( * ) FROM fd_project_quotation AS fdq WHERE fdq.del_flag='0' and fp.create_by = fdq.create_by and fdq.create_time between #{quotationDate} and #{endDate} ) AS translate-->
    <!--之前为制单人统计数据
    fp.create_by,
    count(fp.create_by) as translate
    -->
    <!--<select id="totalProportion" resultType="org.jeecg.modules.projectManagement.entity.FdProjectQuotation">-->
        <!--SELECT-->
            <!--fper.name as projectManagerName,-->
            <!--count(fp.project_manager) as translate-->
        <!--FROM-->
            <!--fd_project_quotation as fp-->
            <!--LEFT JOIN fd_personnel fper on fper.id=fp.project_manager-->
            <!--where-->
             <!--fp.del_flag='0' AND-->
             <!--fper.name is not null and-->
             <!--fp.create_time between #{quotationDate} and #{endDate}-->
             <!--<if test="fdProjectQuotation.biologicalAnalysisLaboratoryIds!=null and fdProjectQuotation.biologicalAnalysisLaboratoryIds.size > 0">-->
                 <!--AND fp.biological_analysis_laboratory in-->
                 <!--<foreach collection="fdProjectQuotation.biologicalAnalysisLaboratoryIds" index="index" item="item" separator="," open="(" close=")">-->
                     <!--#{item}-->
                 <!--</foreach>-->
             <!--</if>-->
            <!--<if test="fdProjectQuotation.hospitalList!=null and fdProjectQuotation.hospitalList!=''">-->
                <!--and fp.hospital_list LIKE "%"#{fdProjectQuotation.hospitalList}"%"-->
            <!--</if>-->
            <!--<if test="fdProjectQuotation.projectManager!=null and fdProjectQuotation.projectManager!=''">-->
                <!--and fp.project_manager=#{fdProjectQuotation.projectManager}-->
            <!--</if>-->
            <!--<if test="fdProjectQuotation.quotationType!=null and fdProjectQuotation.quotationType!=''">-->
                <!--and fp.quotation_type=#{fdProjectQuotation.quotationType}-->
            <!--</if>-->
            <!--<if test="fdProjectQuotation.createBy!=null and fdProjectQuotation.createBy!=''">-->
                <!--and fp.create_by=#{fdProjectQuotation.createBy}-->
            <!--</if>-->
            <!--<if test="fdProjectQuotation.contractType!=null and fdProjectQuotation.contractType!=''">-->
                <!--and fp.contractType LIKE "%"#{fdProjectQuotation.contractType}"%"-->
            <!--</if>-->
            <!--group by fp.project_manager,fper.name-->
    <!--</select>-->



    <select id="totalProportion" resultType="org.jeecg.modules.projectManagement.entity.FdProjectQuotation">
        SELECT
        fper.name as projectManagerName,
        count(fp.code) as translate
        FROM
        fd_project_quotation as fp
        LEFT JOIN fd_personnel fper on fper.id=fp.project_manager
        where
        fp.del_flag='0'

        <if test="quotationDate!=null">
            <![CDATA[   and DATE_FORMAT(fp.create_time, '%Y-%m-%d')>=  DATE_FORMAT(#{quotationDate}, '%Y-%m-%d')]]>
        </if>
        <if test="endDate!=null">
            <![CDATA[  and DATE_FORMAT(fp.create_time, '%Y-%m-%d') <= DATE_FORMAT(#{endDate}, '%Y-%m-%d') ]]>
        </if>

        <if test="fdProjectQuotation.biologicalAnalysisLaboratoryIds!=null and fdProjectQuotation.biologicalAnalysisLaboratoryIds.size > 0">
            AND fp.biological_analysis_laboratory in
            <foreach collection="fdProjectQuotation.biologicalAnalysisLaboratoryIds" index="index" item="item" separator="," open="(" close=")">
                #{item}
            </foreach>
        </if>
        <if test="fdProjectQuotation.hospitalListIds!=null and fdProjectQuotation.hospitalListIds.size > 0">
            AND (
            <foreach collection="fdProjectQuotation.hospitalListIds" index="index" item="hospital">
                <if test="index>0">
                    or
                </if>
                fp.hospital_list LIKE "%"#{hospital}"%"
            </foreach>
            )
        </if>
        <if test="fdProjectQuotation.projectManagerIds!=null and fdProjectQuotation.projectManagerIds.size > 0">
            and fp.project_manager in
            <foreach collection="fdProjectQuotation.projectManagerIds" index="index" item="item" separator="," open="(" close=")">
                #{item}
            </foreach>
        </if>
        <if test="fdProjectQuotation.quotationTypeIds!=null and fdProjectQuotation.quotationTypeIds.size > 0">
            and fp.quotation_type in
            <foreach collection="fdProjectQuotation.quotationTypeIds" index="index" item="item" separator="," open="(" close=")">
                #{item}
            </foreach>
        </if>
        <if test="fdProjectQuotation.createByIds!=null and fdProjectQuotation.createByIds.size > 0">
            and fp.create_by IN
            <foreach collection="fdProjectQuotation.createByIds" index="index" item="item" separator="," open="(" close=")">
                #{item}
            </foreach>
        </if>
        <if test="fdProjectQuotation.contractTypeIds!=null and fdProjectQuotation.contractTypeIds.size > 0">
            AND (
            <foreach collection="fdProjectQuotation.contractTypeIds" index="index" item="contractType">
                <if test="index>0">
                    or
                </if>
                fp.contract_type LIKE "%"#{contractType}"%"
            </foreach>
            )
        </if>
        <if test="fdProjectQuotation.statusIds!=null and fdProjectQuotation.statusIds.size > 0">
            and fp.status IN
            <foreach collection="fdProjectQuotation.statusIds" index="index" item="item" separator="," open="(" close=")">
                #{item}
            </foreach>
        </if>
        group by fp.project_manager,fper.name
    </select>

    <select id="signed" resultType="org.jeecg.modules.projectManagement.entity.FdProjectQuotation">
        SELECT
            fper.name as projectManagerName,
            count(fp.code) as translate,
            ( SELECT count( * ) FROM fd_project_quotation AS fdqs WHERE fdqs.del_flag='0' and fp.project_manager = fdqs.project_manager AND fdqs.STATUS = '8' and fdqs.create_time between #{quotationDate} and #{endDate}
                <if test="fdProjectQuotation.biologicalAnalysisLaboratoryIds!=null and fdProjectQuotation.biologicalAnalysisLaboratoryIds.size > 0">
                    AND fdqs.biological_analysis_laboratory in
                    <foreach collection="fdProjectQuotation.biologicalAnalysisLaboratoryIds" index="index" item="item" separator="," open="(" close=")">
                        #{item}
                    </foreach>
                </if>
                <if test="fdProjectQuotation.hospitalListIds!=null and fdProjectQuotation.hospitalListIds.size > 0">
                    AND (
                    <foreach collection="fdProjectQuotation.hospitalListIds" index="index" item="hospital">
                        <if test="index>0">
                            or
                        </if>
                        fdqs.hospital_list LIKE "%"#{hospital}"%"
                    </foreach>
                    )
                </if>
                <if test="fdProjectQuotation.projectManagerIds!=null and fdProjectQuotation.projectManagerIds.size > 0">
                    and fdqs.project_manager in
                    <foreach collection="fdProjectQuotation.projectManagerIds" index="index" item="item" separator="," open="(" close=")">
                        #{item}
                    </foreach>
                </if>
                <if test="fdProjectQuotation.quotationTypeIds!=null and fdProjectQuotation.quotationTypeIds.size > 0">
                    and fdqs.quotation_type in
                    <foreach collection="fdProjectQuotation.quotationTypeIds" index="index" item="item" separator="," open="(" close=")">
                        #{item}
                    </foreach>
                </if>
                <if test="fdProjectQuotation.createByIds!=null and fdProjectQuotation.createByIds.size > 0">
                    and fdqs.create_by IN
                    <foreach collection="fdProjectQuotation.createByIds" index="index" item="item" separator="," open="(" close=")">
                        #{item}
                    </foreach>
                </if>
                <if test="fdProjectQuotation.contractTypeIds!=null and fdProjectQuotation.contractTypeIds.size > 0">
                    AND (
                    <foreach collection="fdProjectQuotation.contractTypeIds" index="index" item="contractType">
                        <if test="index>0">
                            or
                        </if>
                        fdqs.contract_type LIKE "%"#{contractType}"%"
                    </foreach>
                    )
                </if>
            ) AS signing
        FROM
            fd_project_quotation AS fp
            LEFT JOIN fd_personnel fper on fper.id=fp.project_manager
            WHERE fp.del_flag='0' and
            fp.create_time between #{quotationDate} and #{endDate}
            <if test="fdProjectQuotation.biologicalAnalysisLaboratoryIds!=null and fdProjectQuotation.biologicalAnalysisLaboratoryIds.size > 0">
                AND fp.biological_analysis_laboratory in
                <foreach collection="fdProjectQuotation.biologicalAnalysisLaboratoryIds" index="index" item="item" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </if>
            <if test="fdProjectQuotation.hospitalListIds!=null and fdProjectQuotation.hospitalListIds.size > 0">
                AND (
                <foreach collection="fdProjectQuotation.hospitalListIds" index="index" item="hospital">
                    <if test="index>0">
                        or
                    </if>
                    fp.hospital_list LIKE "%"#{hospital}"%"
                </foreach>
                )
            </if>
            <if test="fdProjectQuotation.projectManagerIds!=null and fdProjectQuotation.projectManagerIds.size > 0">
                and fp.project_manager in
                <foreach collection="fdProjectQuotation.projectManagerIds" index="index" item="item" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </if>
            <if test="fdProjectQuotation.quotationTypeIds!=null and fdProjectQuotation.quotationTypeIds.size > 0">
                and fp.quotation_type in
                <foreach collection="fdProjectQuotation.quotationTypeIds" index="index" item="item" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </if>
            <if test="fdProjectQuotation.createByIds!=null and fdProjectQuotation.createByIds.size > 0">
                and fp.create_by IN
                <foreach collection="fdProjectQuotation.createByIds" index="index" item="item" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </if>
            <if test="fdProjectQuotation.contractTypeIds!=null and fdProjectQuotation.contractTypeIds.size > 0">
                AND (
                <foreach collection="fdProjectQuotation.contractTypeIds" index="index" item="contractType">
                    <if test="index>0">
                        or
                    </if>
                    fp.contract_type LIKE "%"#{contractType}"%"
                </foreach>
                )
            </if>
            group by fp.project_manager,fper.name
    </select>

    <select id="monthlyGrouping" resultType="org.jeecg.modules.projectManagement.entity.FdProjectQuotation">
        SELECT
            fper.name as projectManagerName,
            count(fp.code) as translate,
            ( SELECT count( * ) FROM fd_project_quotation AS fdqs WHERE fdqs.del_flag='0' and fp.project_manager = fdqs.project_manager AND fdqs.STATUS = '8'and year(fdqs.create_time)=YEAR(#{fdProjectQuotation.createTime}) and month(fdqs.create_time) between ${smallMonth} and ${largeMonth}
            <if test="fdProjectQuotation.biologicalAnalysisLaboratoryIds!=null and fdProjectQuotation.biologicalAnalysisLaboratoryIds.size > 0">
                AND fdqs.biological_analysis_laboratory in
                <foreach collection="fdProjectQuotation.biologicalAnalysisLaboratoryIds" index="index" item="item" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </if>
            <if test="fdProjectQuotation.hospitalListIds!=null and fdProjectQuotation.hospitalListIds.size > 0">
                AND (
                <foreach collection="fdProjectQuotation.hospitalListIds" index="index" item="hospital">
                    <if test="index>0">
                        or
                    </if>
                    fdqs.hospital_list LIKE "%"#{hospital}"%"
                </foreach>
                )
            </if>
            <if test="fdProjectQuotation.projectManagerIds!=null and fdProjectQuotation.projectManagerIds.size > 0">
                and fdqs.project_manager in
                <foreach collection="fdProjectQuotation.projectManagerIds" index="index" item="item" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </if>
            <if test="fdProjectQuotation.quotationTypeIds!=null and fdProjectQuotation.quotationTypeIds.size > 0">
                and fdqs.quotation_type in
                <foreach collection="fdProjectQuotation.quotationTypeIds" index="index" item="item" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </if>
            <if test="fdProjectQuotation.createByIds!=null and fdProjectQuotation.createByIds.size > 0">
                and fdqs.create_by IN
                <foreach collection="fdProjectQuotation.createByIds" index="index" item="item" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </if>
            <if test="fdProjectQuotation.contractTypeIds!=null and fdProjectQuotation.contractTypeIds.size > 0">
                AND (
                <foreach collection="fdProjectQuotation.contractTypeIds" index="index" item="contractType">
                    <if test="index>0">
                        or
                    </if>
                    fdqs.contract_type LIKE "%"#{contractType}"%"
                </foreach>
                )
            </if>
            ) AS signing
        FROM
            fd_project_quotation AS fp
            LEFT JOIN fd_personnel fper on fper.id=fp.project_manager
            where fp.del_flag='0'
            and year(fp.create_time)=YEAR(#{fdProjectQuotation.createTime})
            and month(fp.create_time) between ${smallMonth} and ${largeMonth}
            <if test="fdProjectQuotation.biologicalAnalysisLaboratoryIds!=null and fdProjectQuotation.biologicalAnalysisLaboratoryIds.size > 0">
                AND fp.biological_analysis_laboratory in
                <foreach collection="fdProjectQuotation.biologicalAnalysisLaboratoryIds" index="index" item="item" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </if>
            <if test="fdProjectQuotation.hospitalListIds!=null and fdProjectQuotation.hospitalListIds.size > 0">
                AND (
                <foreach collection="fdProjectQuotation.hospitalListIds" index="index" item="hospital">
                    <if test="index>0">
                        or
                    </if>
                    fp.hospital_list LIKE "%"#{hospital}"%"
                </foreach>
                )
            </if>
            <if test="fdProjectQuotation.projectManagerIds!=null and fdProjectQuotation.projectManagerIds.size > 0">
                and fp.project_manager in
                <foreach collection="fdProjectQuotation.projectManagerIds" index="index" item="item" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </if>
            <if test="fdProjectQuotation.quotationTypeIds!=null and fdProjectQuotation.quotationTypeIds.size > 0">
                and fp.quotation_type in
                <foreach collection="fdProjectQuotation.quotationTypeIds" index="index" item="item" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </if>
            <if test="fdProjectQuotation.createByIds!=null and fdProjectQuotation.createByIds.size > 0">
                and fp.create_by IN
                <foreach collection="fdProjectQuotation.createByIds" index="index" item="item" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </if>
            <if test="fdProjectQuotation.contractTypeIds!=null and fdProjectQuotation.contractTypeIds.size > 0">
                AND (
                <foreach collection="fdProjectQuotation.contractTypeIds" index="index" item="contractType">
                    <if test="index>0">
                        or
                    </if>
                    fp.contract_type LIKE "%"#{contractType}"%"
                </foreach>
                )
            </if>
            group by fp.project_manager,fper.name
    </select>



    <!--<select id="getQuotationById" resultType="org.jeecg.modules.projectManagement.entity.FdProjectQuotation">-->
        <!--SELECT-->
            <!--*,-->
            <!--pm.name as projectManagerName,-->
            <!--bm.name as businessManagerName,-->
            <!--d.name as directorName,-->
            <!--gm.name as generalManagerName-->
        <!--FROM-->
            <!--fd_project_quotation pq-->
            <!--left join fd_project_quotation_compound pqc on pqc.quotation_id=pq.id-->
            <!--left join fd_personnel pm on pm.id=pq.project_manager-->
            <!--left join fd_personnel bm on pm.id=pq.business_manager-->
            <!--left join fd_personnel d on pm.id=pq.director-->
            <!--left join fd_personnel gm on pm.id=pq.general_manager-->
        <!--WHERE-->
            <!--pq.del_flag='0'-->
            <!--and pqc.sort='1'-->
            <!--where pq.id=#{0}-->
    <!--</select>-->

    <update id="parentIdBatch" parameterType="java.util.List">
        <foreach collection="templateItemList" item="templateItem" index="index" open="" close="" separator=";">
            update fd_project_quotation_template_item
            <set>
                parent_id =#{templateItem.parentId}
            </set>
            <where>
                id=#{templateItem.id}
            </where>
        </foreach>
    </update>

    <update id="updataStatusShared" parameterType="java.util.List">
        update fd_project_quotation set status = #{status} where id in
        <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
            #{item}
        </foreach>
    </update>

    <update id="updatePersonnelStatus" parameterType="java.util.List">
        UPDATE fd_project_quotation
            <trim prefix="set" suffixOverrides=",">
                <if test="quotation.clinicalSectionId!=null and quotation.clinicalSectionId!=''">
                    clinical_section_memo = '',
                    is_clinical_section_examine = '0',
                </if>
                <if test="quotation.centralPriceId!=null and quotation.centralPriceId!=''">
                    central_price_memo = '',
                    is_central_price_examine = '0',
                </if>
                <if test="quotation.dataStatisticsId!=null and quotation.dataStatisticsId!=''">
                    data_statistics_memo = '',
                    is_data_statistics_examine = '0',
                </if>
                <if test="quotation.pkComputingId!=null and quotation.pkComputingId!=''">
                    pk_computing_memo = '',
                    is_pk_computing_examine = '0',
                </if>
                <if test="quotation.bioanalysisId!=null and quotation.bioanalysisId!=''">
                    bioanalysis_memo = '',
                    is_bioanalysis_examine = '0',
                </if>
                <if test="quotation.generalManager!=null and quotation.generalManager!=''">
                    general_manager_memo = '',
                    is_general_examine = '0',
                </if>
            </trim>
        WHERE
            id in
        <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
            #{item}
        </foreach>
    </update>

    <update id="updateExamineStatusByQuotationId">
        UPDATE fd_project_quotation
          <set>
              def1=NULL,
              <if test="projectQuotation.clinicalSectionMemo!=null and projectQuotation.clinicalSectionMemo!=''">
                  clinical_section_memo = #{projectQuotation.clinicalSectionMemo},
              </if>
              <if test="projectQuotation.isClinicalSectionExamine!=null and projectQuotation.isClinicalSectionExamine!=''">
                  is_clinical_section_examine =  #{projectQuotation.isClinicalSectionExamine},
              </if>
              <if test="projectQuotation.centralPriceMemo!=null and projectQuotation.centralPriceMemo!=''">
                  central_price_memo =  #{projectQuotation.centralPriceMemo},
              </if>
              <if test="projectQuotation.isCentralPriceExamine!=null and projectQuotation.isCentralPriceExamine!=''">
                  is_central_price_examine =  #{projectQuotation.isCentralPriceExamine},
              </if>
              <if test="projectQuotation.dataStatisticsMemo!=null and projectQuotation.dataStatisticsMemo!=''">
                  data_statistics_memo =  #{projectQuotation.dataStatisticsMemo},
              </if>
              <if test="projectQuotation.isDataStatisticsExamine!=null and projectQuotation.isDataStatisticsExamine!=''">
                  is_data_statistics_examine =  #{projectQuotation.isDataStatisticsExamine},
              </if>
              <if test="projectQuotation.pkComputingMemo!=null and projectQuotation.pkComputingMemo!=''">
                  pk_computing_memo =  #{projectQuotation.pkComputingMemo},
              </if>
              <if test="projectQuotation.isPkComputingExamine!=null and projectQuotation.isPkComputingExamine!=''">
                  is_pk_computing_examine =  #{projectQuotation.isPkComputingExamine},
              </if>
              <if test="projectQuotation.bioanalysisMemo!=null and projectQuotation.bioanalysisMemo!=''">
                  bioanalysis_memo =  #{projectQuotation.bioanalysisMemo},
              </if>
              <if test="projectQuotation.isBioanalysisExamine!=null and projectQuotation.isBioanalysisExamine!=''">
                  is_bioanalysis_examine =  #{projectQuotation.isBioanalysisExamine},
              </if>
              <if test="projectQuotation.generalManagerMemo!=null and projectQuotation.generalManagerMemo!=''">
                  general_manager_memo =  #{projectQuotation.generalManagerMemo},
              </if>
              <if test="projectQuotation.isGeneralExamine!=null and projectQuotation.isGeneralExamine!=''">
                  is_general_examine =  #{projectQuotation.isGeneralExamine},
              </if>
              <if test="projectQuotation.finalAuditorId!=null and projectQuotation.finalAuditorId!=''">
                  final_auditor_id =  #{projectQuotation.finalAuditorId},
              </if>
              <if test="projectQuotation.finalAuditorName!=null and projectQuotation.finalAuditorName!=''">
                  final_auditor_name =  #{projectQuotation.finalAuditorName}
              </if>
          </set>
        WHERE
            id =  #{projectQuotation.id}
    </update>

    <select id="getQuotationIdsByfileIds" resultType="java.lang.String" parameterType="java.util.List">
        SELECT
            fpq.id
        FROM
            fd_project_file fpf
            LEFT JOIN fd_contract fc ON fc.id = fpf.contract_id
            LEFT JOIN fd_project_quotation fpq ON fpq.id = fc.quotation_id
        WHERE
            fpf.del_flag = '0'
            AND fpf.id IN
        <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
            #{item}
        </foreach>
    </select>

    <select id="getReportPage" resultType="org.jeecg.modules.projectManagement.entity.FdProjectQuotation">
        SELECT
            fpq.*,
            fp.NAME AS projectManagerName,
            su.realname AS createByName
        FROM
            fd_project_quotation fpq
            LEFT JOIN fd_personnel fp ON fpq.project_manager = fp.id
            LEFT JOIN sys_user su ON fpq.create_by = su.username
            ${ew.customSqlSegment}
    </select>

    <update id="updateSponsorName">
        UPDATE fd_project_quotation
        SET sponsor_name = #{fdProjectQuotation.sponsorName}
        WHERE
            id = ( SELECT quotation_id FROM fd_contract WHERE id = #{fdProjectQuotation.contractId} )

    </update>

</mapper>