<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="QCM_BC_PHYRESULT （生成工具：代码生成工具4.0   访问地址：http://172.16.2.128/tool/）">
    <query id="QcmBcPhyresultDAL.Query" desc="查询">
        <![CDATA[
SELECT T.PHY_RESULT_ID,
       T.PHY_RESULT_SEQ,
       T.LOT_NO,
       T.STOVE_NO,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.OBJECTNO,
       T.PHY_CODE_MAX,
       T.PHY_NAME_MAX,
       T.PHY_CODE_MIN,
       T.PHY_NAME_MIN,
       T.PHY_CODE,
       T.PHY_NAME,
       T.ITEM_CODE_F,
       T.ITEM_NAME_F,
       T.ITEM_CODE_W,
       T.ITEM_NAME_W,
       T.ITEM_CODE_S,
       T.ITEM_NAME_S,
       T.VALUE1,
       T.VALUE2,
       T.VALUE3,
       T.VALUE4,
       T.VALUE5,
       T.VALUE6,
       T.VALUE7,
       T.VALUE8,
       T.VALUE9,
       T.VALUE10,
       T.VALUE11,
       T.VALUE12,
       T.VALUE13,
       T.VALUE14,
       T.VALUE15,
       T.AVERAGE,
       T.ALLRESULT,
       T.SAMPLE_ID,
       T.XH,
       T.INDEX_SEQ,
       T.VALIDFLAG,
       DECODE(T.VALIDFLAG, '1', '有效', '0', '无效') VALIDFLAG_DESC,
       T.CREATE_NAME,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T.UPDATE_NAME,
       TO_CHAR(T.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       T.DELETE_NAME,
       TO_CHAR(T.DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME
  FROM QCM_BC_PHYRESULT T, QCM_ZG_PHYJUDGE A
 WHERE A.PHY_RESULT_ID = T.PHY_RESULT_ID
   AND A.PROCESS_CDOE = {0}
        ]]>
    </query>
    <query id="QcmBcPhyresultDAL.QueryByPk" desc="通过主键查询">
        <![CDATA[
 SELECT 
       T.PHY_RESULT_ID,
       T.PHY_RESULT_SEQ,
       T.LOT_NO,
       T.STOVE_NO,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.OBJECTNO,
       T.PHY_CODE_MAX,
       T.PHY_NAME_MAX,
       T.PHY_CODE_MIN,
       T.PHY_NAME_MIN,
       T.PHY_CODE,
       T.PHY_NAME,
       T.ITEM_CODE_F,
       T.ITEM_NAME_F,
       T.ITEM_CODE_W,
       T.ITEM_NAME_W,
       T.ITEM_CODE_S,
       T.ITEM_NAME_S,
       T.VALUE1,
       T.VALUE2,
       T.VALUE3,
       T.VALUE4,
       T.VALUE5,
       T.VALUE6,
       T.VALUE7,
       T.VALUE8,
       T.VALUE9,
       T.VALUE10,
       T.VALUE11,
       T.VALUE12,
       T.VALUE13,
       T.VALUE14,
       T.VALUE15,
       T.AVERAGE,
       T.ALLRESULT,
       T.SAMPLE_ID,
       T.XH,
       T.INDEX_SEQ,
       T.VALIDFLAG,
       T.CREATE_NAME,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T.UPDATE_NAME,
       TO_CHAR(T.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       T.DELETE_NAME,
       TO_CHAR(T.DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME
 FROM QCM_BC_PHYRESULT T
 WHERE
       T.PHY_RESULT_ID = '#PHY_RESULT_ID#'
       AND T.PHY_RESULT_SEQ = '#PHY_RESULT_SEQ#'
        ]]>
    </query>
    <query id="QcmBcPhyresultDAL.Insert" desc="新增">
        <![CDATA[
INSERT INTO QCM_BC_PHYRESULT(
        PHY_RESULT_ID,
        PHY_RESULT_SEQ,
        PHY_CODE_MAX,
        PHY_NAME_MAX,
        PHY_CODE_MIN,
        PHY_NAME_MIN,
        PHY_CODE,
        PHY_NAME,
        ITEM_CODE_F,
        ITEM_NAME_F,
        ITEM_CODE_W,
        ITEM_NAME_W,
        ITEM_CODE_S,
        ITEM_NAME_S,
        VALUE1,
        VALUE2,
        VALUE3,
        VALUE4,
        VALUE5,
        VALUE6,
        VALUE7,
        VALUE8,
        VALUE9,
        VALUE10,
        VALUE11,
        VALUE12,
        VALUE13,
        VALUE14,
        VALUE15,
        AVERAGE,
        ALLRESULT,
        XH,
        CREATE_NAME,
        CREATE_TIME,
        NK_QUALIFIED,
        NK_MIN,
        FILE_PATH,
        NK_MAX,
        JF_MIN,
        JF_MAX,
        JF_QUALIFIED,
        NK_ADD_MIN,
        NK_ADD_MAX,
        NK_ADD_QUALIFIED,
        JF_ADD_MIN,
        JF_ADD_MAX,
        JF_ADD_QUALIFIED,
        NK_JUDGE_BASIS,
        NK_ADD_CONDITION,
        NK_ADD_JUDGE_BASIS,
        JF_JUDGE_BASIS,
        JF_ADD_CONDITION,
        JF_ADD_JUDGE_BASIS,
        UNQUALIFIED_TYPE,
        NK_TOL_QUALIFIED,
        JF_TOL_QUALIFIED,
        IS_GOOD,
        IS_DEFECT,
        CHECK_TEMP,
        HARDNESS_TYPE,
        PHY_CODE_DIR,
        PHY_NAME_DIR,
        SAMPLE_STYLE,
        SAMPLE_SIZE)
 VALUES( 
        '#PHY_RESULT_ID#',
        '#PHY_RESULT_SEQ#',
        '#PHY_CODE_MAX#',
        '#PHY_NAME_MAX#',
        '#PHY_CODE_MIN#',
        '#PHY_NAME_MIN#',
        '#PHY_CODE#',
        '#PHY_NAME#',
        '#ITEM_CODE_F#',
        '#ITEM_NAME_F#',
        '#ITEM_CODE_W#',
        '#ITEM_NAME_W#',
        '#ITEM_CODE_S#',
        '#ITEM_NAME_S#',
        '#VALUE1#',
        '#VALUE2#',
        '#VALUE3#',
        '#VALUE4#',
        '#VALUE5#',
        '#VALUE6#',
        '#VALUE7#',
        '#VALUE8#',
        '#VALUE9#',
        '#VALUE10#',
        '#VALUE11#',
        '#VALUE12#',
        '#VALUE13#',
        '#VALUE14#',
        '#VALUE15#',
        '#AVERAGE#',
        '#ALLRESULT#',
        '#XH#',
        '#CREATE_NAME#',
        SYSDATE,
        '#NK_QUALIFIED#',
        '#NK_MIN#',
        '#FILE_PATH#',
        '#NK_MAX#',
        '#JF_MIN#',
        '#JF_MAX#',
        '#JF_QUALIFIED#',
        '#NK_ADD_MIN#',
        '#NK_ADD_MAX#',
        '#NK_ADD_QUALIFIED#',
        '#JF_ADD_MIN#',
        '#JF_ADD_MAX#',
        '#JF_ADD_QUALIFIED#',
        '#NK_JUDGE_BASIS#',
        '#NK_ADD_CONDITION#',
        '#NK_ADD_JUDGE_BASIS#',
        '#JF_JUDGE_BASIS#',
        '#JF_ADD_CONDITION#',
        '#JF_ADD_JUDGE_BASIS#',
        '#UNQUALIFIED_TYPE#',
        '#NK_TOL_QUALIFIED#',
        '#JF_TOL_QUALIFIED#',
        '#IS_GOOD#',
        '#IS_DEFECT#',
        '#CHECK_TEMP#',
        '#HARDNESS_TYPE#',
        '#PHY_CODE_DIR#',
        '#PHY_NAME_DIR#',
        '#SAMPLE_STYLE#',
        '#SAMPLE_SIZE#')
        ]]>
    </query>
    
    <query id="QcmBcPhyresultDAL.getFilePathByPhy" desc="通过理化大项获取文件路径">
        <![CDATA[
SELECT *
  FROM (SELECT T.CAILI_PATH FILE_PATH, '002001007009' UNIT_CODE
          FROM QCM_JHY_PIPE_CHECKCONSIGN T
         WHERE T.CHECK_NO = {0}
        UNION ALL
        SELECT T.FUSHI_PATH, '002001007013' UNIT_CODE
          FROM QCM_JHY_PIPE_CHECKCONSIGN T
         WHERE T.CHECK_NO = {0}
        UNION ALL
        SELECT T.JINWU_PATH, '002001007015' UNIT_CODE
          FROM QCM_JHY_PIPE_CHECKCONSIGN T
         WHERE T.CHECK_NO = {0}
        UNION ALL
        SELECT T.GONGCHENG_PATH, '002001007014' UNIT_CODE
          FROM QCM_JHY_PIPE_CHECKCONSIGN T
         WHERE T.CHECK_NO = {0}
        UNION ALL
        SELECT T.DIBEI_PATH, '002001007020' UNIT_CODE
          FROM QCM_JHY_PIPE_CHECKCONSIGN T
         WHERE T.CHECK_NO = {0}
        UNION ALL
        SELECT T.HUAXUE_PATH, '002001007010' UNIT_CODE
          FROM QCM_JHY_PIPE_CHECKCONSIGN T
         WHERE T.CHECK_NO = {0})
 WHERE UNIT_CODE = {1}
        ]]>
    </query>
    
    <query id="QcmBcPhyresultDAL.getJudgeInfo" desc="获取判定记录">
		<![CDATA[
SELECT A.LOT_NO,
       A.JUDGE_STOVE_NO,
       A.BATCH_NO,
       A.SAMPLE_ID,
       A.SAMPLE_NO,
       A.PLINE_CODE,
       B.PHY_CODE_MAX,
       B.PHY_NAME_MAX,
       B.PHY_CODE_MIN,
       B.PHY_NAME_MIN,
       B.PHY_CODE,
       B.PHY_NAME,
       B.JF_TOL_QUALIFIED,
       B.NK_TOL_QUALIFIED,
       B.ITEM_CODE_F,
       B.ITEM_NAME_F,
       B.ITEM_CODE_W,
       B.ITEM_NAME_W,
       B.ITEM_CODE_S,
       B.ITEM_NAME_S
  FROM QCM_BC_PHYJUDGE A, QCM_BC_PHYRESULT B
 WHERE A.SAMPLE_ID = {0}
   AND A.JUDGE_STOVE_NO = {1}
   AND A.BATCH_NO = {2}
   AND A.PROCESS_CDOE = {3}
   AND A.VALIDFLAG = '1'
   AND B.PHY_RESULT_ID = A.PHY_JUDGE_ID
   AND B.PHY_RESULT_SEQ = A.JUDGE_SEQ
   AND B.PHY_CODE_MAX NOT IN ('R0008', 'R0007')
 GROUP BY A.LOT_NO,
          A.JUDGE_STOVE_NO,
          A.BATCH_NO,
          A.SAMPLE_ID,
          A.SAMPLE_NO,
          A.PLINE_CODE,
          B.PHY_CODE_MAX,
          B.PHY_NAME_MAX,
          B.PHY_CODE_MIN,
          B.PHY_NAME_MIN,
          B.PHY_CODE,
          B.PHY_NAME,
          B.JF_TOL_QUALIFIED,
          B.NK_TOL_QUALIFIED,
          B.ITEM_CODE_F,
	      B.ITEM_NAME_F,
	      B.ITEM_CODE_W,
	      B.ITEM_NAME_W,
	      B.ITEM_CODE_S,
	      B.ITEM_NAME_S
		]]>
	</query>
	
	<query id="QcmBcPhyresultDAL.getResampleData" desc="获取复取样数据">
		<![CDATA[
SELECT F.PHY_JUDGE_ID,
       G.PHY_CODE_MAX,
       G.PHY_NAME_MAX,
       G.PHY_CODE_MIN,
       G.PHY_NAME_MIN,
       MIN(F.JUDGE_STOVE_NO) JUDGE_STOVE_NO,
       MIN(F.BATCH_NO) BATCH_NO,
       CASE
         WHEN EXISTS (SELECT 1
                 FROM QCM_BC_PHYRESULT H
                WHERE H.PHY_RESULT_ID = F.PHY_JUDGE_ID
                  AND H.PHY_CODE_MIN = H.PHY_CODE_MIN
                  AND H.NK_TOL_QUALIFIED IN ('0', '2')) THEN
          '不合格'
         ELSE
          '合格'
       END NK_RESULT,
       'False' CHK,
       'False' IS_ORIGINAL
  FROM QCM_BC_PHYJUDGE F, QCM_BC_PHYRESULT G, QCM_ZC_CHECKCONSIGN T
 WHERE F.PHY_JUDGE_ID = G.PHY_RESULT_ID
   AND F.JUDGE_SEQ = G.PHY_RESULT_SEQ
   AND F.VALIDFLAG = '1'
   AND F.SAMPLE_ID = {0}
   AND G.NK_TOL_QUALIFIED = '0'
   AND T.CHECK_NO = F.SAMPLE_ID
   AND T.JUDGE_STOVE_NO = F.JUDGE_STOVE_NO
   AND T.BATCH_NO = F.BATCH_NO
 GROUP BY F.PHY_JUDGE_ID,
          G.PHY_CODE_MAX,
          G.PHY_NAME_MAX,
          G.PHY_CODE_MIN,
          G.PHY_NAME_MIN

UNION ALL

SELECT A.CHEM_JUDGE_ID,
       'HX' PHY_CODE_MAX,
       '化学' PHY_NAME_MAX,
       B.CHEM_NAME PHY_CODE_MIN,
       B.CHEM_NAME PHY_NAME_MIN,
       MIN(A.JUDGE_STOVE_NO) JUDGE_STOVE_NO,
       MIN(A.BATCH_NO) BATCH_NO,
       CASE
         WHEN EXISTS (SELECT 1
                 FROM QCM_BC_CHEM_RESULT C
                WHERE C.CHEM_JUDGE_ID = A.CHEM_JUDGE_ID
                  AND C.NK_QUALIFIED IN ('0', '2')) THEN
          '不合格'
         ELSE
          '合格'
       END NK_RESULT,
       'False' CHK,
       'False' IS_ORIGINAL
  FROM QCM_BC_CHEMJUDGE A, QCM_BC_CHEM_RESULT B, QCM_ZC_CHECKCONSIGN T
 WHERE A.CHEM_JUDGE_ID = B.CHEM_JUDGE_ID
   AND A.JUDGE_SEQ = B.JUDGE_SEQ
   AND A.VALIDFLAG = '1'
   AND A.SAMPLE_ID = {0}
   AND B.NK_QUALIFIED IN ('0', '2')
   AND T.CHECK_NO = A.SAMPLE_ID
   AND T.JUDGE_STOVE_NO = A.JUDGE_STOVE_NO
   AND T.BATCH_NO = A.BATCH_NO
 GROUP BY A.CHEM_JUDGE_ID, B.CHEM_NAME
		]]>
	</query>
	
	<query id="QcmBcPhyresultDAL.getChemResampleData" desc="获取成分复取样数据">
		<![CDATA[
SELECT A.CHEM_JUDGE_ID,
       'HX' PHY_CODE_MAX,
       '化学' PHY_NAME_MAX,
       B.CHEM_NAME PHY_CODE_MIN,
       B.CHEM_NAME PHY_NAME_MIN,
       MIN(A.JUDGE_STOVE_NO) JUDGE_STOVE_NO,
       MIN(A.BATCH_NO) BATCH_NO,
       CASE
         WHEN EXISTS (SELECT 1
                 FROM QCM_BC_CHEM_RESULT C
                WHERE C.CHEM_JUDGE_ID = A.CHEM_JUDGE_ID
                  AND C.NK_QUALIFIED IN ('0', '2')) THEN
          '不合格'
         ELSE
          '合格'
       END NK_RESULT,
       'False' CHK,
       'False' IS_ORIGINAL
  FROM QCM_BC_CHEMJUDGE A, QCM_BC_CHEM_RESULT B, QCM_ZC_CHECKCONSIGN T
 WHERE A.CHEM_JUDGE_ID = B.CHEM_JUDGE_ID
   AND A.JUDGE_SEQ = B.JUDGE_SEQ
   AND A.VALIDFLAG = '1'
   AND A.SAMPLE_ID = {0}
   AND B.NK_QUALIFIED IN ('0', '2')
   AND T.CHECK_NO = A.SAMPLE_ID
   AND T.JUDGE_STOVE_NO = A.JUDGE_STOVE_NO
   AND T.BATCH_NO = A.BATCH_NO
 GROUP BY A.CHEM_JUDGE_ID, B.CHEM_NAME
		]]>
	</query>
	
	<query id="JdgQcmBcPhyResult.getGroupPhyCnt" desc="获取理化分组数目">
		<![CDATA[
SELECT PHY_CODE_MIN, COUNT(1) COUNT
  FROM (SELECT T.PHY_CODE_MIN
          FROM QCM_BC_PHYRESULT T, QCM_BC_PHYJUDGE A
         WHERE T.PHY_RESULT_ID = {0}
           AND A.PHY_JUDGE_ID = T.PHY_RESULT_ID
           AND A.JUDGE_SEQ = T.PHY_RESULT_SEQ
         GROUP BY T.PHY_CODE_MIN, A.SAMPLE_NO)
 GROUP BY PHY_CODE_MIN
		]]>
	</query>
	
	<query id="JdgQcmBcPhyResult.getGroupPhyNoCnt" desc="获取不合格理化分组数目">
		<![CDATA[
SELECT PHY_CODE_MIN, COUNT(1) COUNT
  FROM (SELECT T.PHY_CODE_MIN
          FROM QCM_BC_PHYRESULT T, QCM_BC_PHYJUDGE A
         WHERE T.PHY_RESULT_ID = {0}
           AND T.NK_TOL_QUALIFIED = '0'
           AND A.PHY_JUDGE_ID = T.PHY_RESULT_ID
           AND A.JUDGE_SEQ = T.PHY_RESULT_SEQ
         GROUP BY T.PHY_CODE_MIN, A.SAMPLE_NO)
 GROUP BY PHY_CODE_MIN
		]]>
	</query>
	
	<query id="JdgQcmBcPhyResult.updatePhyJudge" desc="修改理化判定结果">
        <![CDATA[
UPDATE QCM_BC_PHYRESULT T
   SET T.NK_TOL_QUALIFIED = DECODE(T.NK_TOL_QUALIFIED, '3', {6}, T.NK_TOL_QUALIFIED),
       T.JF_TOL_QUALIFIED = DECODE(T.JF_TOL_QUALIFIED, '3', {6}, T.JF_TOL_QUALIFIED),
       T.NK_QUALIFIED = DECODE(T.NK_QUALIFIED, '3', {6}, T.NK_QUALIFIED),
       T.JF_QUALIFIED = DECODE(T.JF_QUALIFIED, '3', {6}, T.JF_QUALIFIED)
 WHERE EXISTS (SELECT 1
          FROM QCM_BC_PHYJUDGE A
         WHERE A.JUDGE_STOVE_NO = {0}
           AND A.BATCH_NO = {1}
           AND A.SAMPLE_ID = {2}
           AND A.SAMPLE_NO = {3}
           AND A.PROCESS_CDOE = {4}
           AND A.VALIDFLAG = '1'
           AND T.PHY_RESULT_ID = A.PHY_JUDGE_ID
           AND T.PHY_RESULT_SEQ = A.JUDGE_SEQ)
       AND T.PHY_CODE_MIN = {5}
        ]]>
    </query>
    
    <query id="JdgQcmBcPhyResult.getPhyResultBySampleNoPhyMin" desc="获取理化结果">
        <![CDATA[
SELECT B.NK_TOL_QUALIFIED, B.JF_TOL_QUALIFIED
  FROM QCM_BC_PHYJUDGE A, QCM_BC_PHYRESULT B
 WHERE A.SAMPLE_ID = {0}
   AND A.JUDGE_STOVE_NO = {1}
   AND A.BATCH_NO = {2}
   AND A.SAMPLE_NO = {3}
   AND A.CRAFT_SOURCE = {4}
   AND A.VALIDFLAG = '1'
   AND B.PHY_RESULT_ID = A.PHY_JUDGE_ID
   AND B.PHY_RESULT_SEQ = A.JUDGE_SEQ
   AND B.PHY_CODE_MIN = {5}
        ]]>
    </query>
    
    <query id="JdgQcmBcPhyResult.getByBatchNo" desc="通过炉批查询">
        <![CDATA[
SELECT A.SAMPLE_ID, A.JUDGE_STOVE_NO, A.BATCH_NO, A.SAMPLE_NO, A.SAMPLE_ID, A.PROCESS_CDOE PROCESS_CODE, B.*
  FROM QCM_BC_PHYJUDGE            A,
       QCM_BC_PHYRESULT           B,
       QCM_ZC_CHECKCONSIGN_DETAIL C,
       QCM_ZC_CHECKCONSIGN        D
 WHERE A.PHY_JUDGE_ID = B.PHY_RESULT_ID
   AND A.JUDGE_SEQ = B.PHY_RESULT_SEQ
   AND A.VALIDFLAG = '1'
   AND A.CRAFT_SOURCE = '0'
   AND A.JUDGE_STOVE_NO = {0}
   AND A.BATCH_NO = {1}
   AND A.PROCESS_CDOE = {2}
   AND A.ORD_LN_DLY_PK = {3}
   AND B.PHY_CODE_MIN = {4}
   AND C.CHECK_NO = A.SAMPLE_ID
   AND C.BATCH_NO = A.BATCH_NO
   AND C.SAMPLE_NO = A.SAMPLE_NO
   AND C.PHY_CODE_MAX = B.PHY_CODE_MIN
   AND C.IS_MAIN = '1'
   AND D.CHECK_NO = A.SAMPLE_ID
   AND D.JUDGE_STOVE_NO = A.JUDGE_STOVE_NO
   AND D.BATCH_NO = A.BATCH_NO
   AND D.CYCLES_FLAG = {5}
        ]]>
    </query>
    
    <query id="JdgQcmBcPhyResult.getByJudgeStoveNo" desc="通过炉查询">
        <![CDATA[
SELECT A.JUDGE_STOVE_NO, A.BATCH_NO, A.SAMPLE_NO, A.SAMPLE_ID, A.PROCESS_CDOE PROCESS_CODE, B.*
  FROM QCM_BC_PHYJUDGE            A,
       QCM_BC_PHYRESULT           B,
       QCM_ZC_CHECKCONSIGN_DETAIL C,
       QCM_ZC_CHECKCONSIGN        D
 WHERE A.PHY_JUDGE_ID = B.PHY_RESULT_ID
   AND A.JUDGE_SEQ = B.PHY_RESULT_SEQ
   AND A.VALIDFLAG = '1'
   AND A.CRAFT_SOURCE = '0'
   AND A.JUDGE_STOVE_NO = {0}
   AND A.PROCESS_CDOE = {1}
   AND A.ORD_LN_DLY_PK = {2}
   AND B.PHY_CODE_MIN = {3}
   AND C.CHECK_NO = A.SAMPLE_ID
   AND C.BATCH_NO = A.BATCH_NO
   AND C.SAMPLE_NO = A.SAMPLE_NO
   AND C.PHY_CODE_MAX = B.PHY_CODE_MIN
   AND C.IS_MAIN = '1'
   AND D.CHECK_NO = A.SAMPLE_ID
   AND D.JUDGE_STOVE_NO = A.JUDGE_STOVE_NO
   AND D.BATCH_NO = A.BATCH_NO
   AND D.CYCLES_FLAG = {4}
        ]]>
    </query>
    
    <query id="JdgQcmBcPhyResult.getByLotNo" desc="通过生产批查询">
        <![CDATA[
SELECT A.JUDGE_STOVE_NO, A.BATCH_NO, A.SAMPLE_NO, A.SAMPLE_ID, A.PROCESS_CDOE PROCESS_CODE, B.*
  FROM QCM_BC_PHYJUDGE            A,
       QCM_BC_PHYRESULT           B,
       QCM_ZC_CHECKCONSIGN_DETAIL C,
       QCM_ZC_CHECKCONSIGN        D
 WHERE A.PHY_JUDGE_ID = B.PHY_RESULT_ID
   AND A.JUDGE_SEQ = B.PHY_RESULT_SEQ
   AND A.VALIDFLAG = '1'
   AND A.CRAFT_SOURCE = '0'
   AND A.PROCESS_CDOE = {2}
   AND A.ORD_LN_DLY_PK = {3}
   AND B.PHY_CODE_MIN = {4}
   AND C.CHECK_NO = A.SAMPLE_ID
   AND C.BATCH_NO = A.BATCH_NO
   AND C.SAMPLE_NO = A.SAMPLE_NO
   AND C.PHY_CODE_MAX = B.PHY_CODE_MIN
   AND C.IS_MAIN = '1'
   AND D.CHECK_NO = A.SAMPLE_ID
   AND D.JUDGE_STOVE_NO = A.JUDGE_STOVE_NO
   AND D.BATCH_NO = A.BATCH_NO
   AND D.LOT_NO = {0}
   AND ({1} IS NULL OR D.LOT_NO_GROUP = {1})
   AND D.CYCLES_FLAG = {5}
        ]]>
    </query>
</queryMap>