<?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.qualityControl.mapper.FdQaBiometricSampleAnalysisMapper">

    <select id="queryQaBiometricByConId" resultType="org.jeecg.modules.qualityControl.entity.FdQaBiometricSampleAnalysis">
        SELECT
            pf.id AS pkProjectFile,
            pf.contract_id AS pkContract,
            pf.project_name AS projectName,
            pf.customer_id AS pkBidParty,
            pf.customer_name AS bidPartyName,
            pf.abbreviation AS bidPartyNameAbbreviation,
            pf.contract_party AS pkContractParty,
            c.`code` AS contractCode,
            c.sign_date AS contractSignDate,
            pf.contract_type AS analysisType,
            pf.bioanalytical_pm AS bioanalyticalPi,
            pf.assistant AS associateBioanalyticalPi,
            pf.matrix_type AS matrix
        FROM
            fd_project_file pf
            LEFT JOIN fd_contract c ON c.id = pf.contract_id
        WHERE
            c.del_flag = '0'
            and pf.contract_id=#{0}
    </select>

    <select id="findByPage" resultType="org.jeecg.modules.qualityControl.entity.FdQaBiometricSampleAnalysis">
        SELECT
        *,
        pf.personnel_with_authority_ids as personnelWithAuthorityIds,
        fqs.code as sampleCode,
        fp.name as responsibleQaName
        FROM fd_qa_biometric_sample_analysis qbsa
        LEFT JOIN fd_project_file pf on qbsa.pk_project_file=pf.id
        LEFT JOIN fd_qa_sample fqs on fqs.pk_qa_sample=qbsa.id
        left join fd_personnel fp on fp.id=qbsa.responsible_qa
        ${ew.customSqlSegment}
    </select>

    <select id="getBySampleCodeAndType" resultType="org.jeecg.modules.qualityControl.entity.FdQaBiometricSampleAnalysis">
       SELECT
        *,
        fqs.code as sampleCode
        FROM fd_qa_biometric_sample_analysis qbsa
        LEFT JOIN fd_qa_sample fqs on fqs.pk_qa_sample=qbsa.id
        WHERE
        qbsa.del_flag='0'
        and qbsa.pk_project_file=#{fdQaBiometricSampleAnalysis.pkProjectFile}
        AND qbsa.analysis_type=#{fdQaBiometricSampleAnalysis.analysisType}
        AND fqs.code=#{fdQaBiometricSampleAnalysis.sampleCode}
    </select>
</mapper>