<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="基础信息">
    <query id="JdgQcmZcCheckConsignDetail.GetPhyMinByBatchNo" desc="查询">
        <![CDATA[
SELECT DISTINCT A.CHECK_NO SAMPLE_ID,
                A.CHECK_NO,
                B.SAMPLE_NO,
                A.STOVE_NO,
                A.JUDGE_STOVE_NO,
                A.BATCH_NO,
                A.LOT_NO,
                A.LOT_NO_GROUP,
                B.NK_RESULT,
                B.JF_RESULT,
                B.MAT_NO,
                B.HEAD_MAT_NO,
                B.BAR_CODE,
                B.RESULT_SOURCE,
                A.APPLY_RESAMPLE,
                A.CYCLES_FLAG,
                B.OLD_JUDGE_STOVE_NO,
                B.OLD_BATCH_NO,
                B.IS_MAIN,
                A.CRAFT_SOURCE,
                DECODE(B.PHY_CODE_MAX, 'ONH', 'HX', B.PHY_CODE_MAX) PHY_CODE_MAX,
                DECODE(B.PHY_NAME_MAX, 'ONH', '化学', B.PHY_NAME_MAX) PHY_NAME_MAX,
                DECODE(B.PHY_CODE_MAX, 'ONH', 'HX', B.PHY_CODE_MAX) PHY_CODE_MIN,
                DECODE(B.PHY_NAME_MAX, 'ONH', '化学', B.PHY_NAME_MAX) PHY_NAME_MIN,
                A.APPLY_RESAMPLE,
                A.CYCLES_FLAG
  FROM QCM_ZC_CHECKCONSIGN A
  LEFT JOIN SLM_ORDER_LINE_DELIVERY C
    ON C.ORD_LN_DLY_PK = A.ORD_LN_DLY_PK,
  QCM_ZC_CHECKCONSIGN_DETAIL B
 WHERE A.JUDGE_STOVE_NO = {0}
   AND A.BATCH_NO = {1}
   AND A.PROCESS_CODE = {2}
   AND A.CRAFT_SOURCE = {3}
   AND A.CYCLES_FLAG = {4}
   AND A.IS_FLAG = '0'
   AND ({7} IS NULL AND A.CHECK_NO NOT LIKE '%L%' OR {7} IS NOT NULL)
   AND B.CHECK_NO = A.CHECK_NO
   AND B.BATCH_NO = A.BATCH_NO
   AND B.VALIDFLAG = '1'
   AND ({5} = 'HX' AND B.PHY_CODE_MAX = 'ONH' OR B.PHY_CODE_MAX = {5})
   AND ({6} IS NULL OR B.IS_MAIN = {6})
   AND ({7} IS NULL OR C.ORD_LN_PK = {7})
        ]]>
    </query>

    <query id="JdgQcmZcCheckConsignDetail.GetBLPhyMinByBatchNo" desc="查询">
        <![CDATA[
SELECT   DISTINCT
         A.CHECK_NO SAMPLE_ID,
         A.CHECK_NO,
         B.SAMPLE_NO,
         A.STOVE_NO,
         A.JUDGE_STOVE_NO,
         A.BATCH_NO,
         A.LOT_NO,
         A.LOT_NO_GROUP,
         B.NK_RESULT,
         B.JF_RESULT,
         B.MAT_NO,
         B.HEAD_MAT_NO,
         B.BAR_CODE,
         B.RESULT_SOURCE,
         A.APPLY_RESAMPLE,
         A.CYCLES_FLAG,
         B.OLD_JUDGE_STOVE_NO,
         B.OLD_BATCH_NO,
         B.IS_MAIN,
         A.CRAFT_SOURCE,
         DECODE(B.PHY_CODE_MAX, 'ONH', 'HX', B.PHY_CODE_MAX) PHY_CODE_MAX,
         DECODE(B.PHY_NAME_MAX, 'ONH', '化学', B.PHY_NAME_MAX) PHY_NAME_MAX,
         DECODE(B.PHY_CODE_MAX, 'ONH', 'HX', B.PHY_CODE_MAX) PHY_CODE_MIN,
         DECODE(B.PHY_NAME_MAX, 'ONH', '化学', B.PHY_NAME_MAX) PHY_NAME_MIN,
         A.APPLY_RESAMPLE,
         A.CYCLES_FLAG
    FROM QCM_ZC_CHECKCONSIGN        A,
         QCM_ZC_CHECKCONSIGN_DETAIL B,
         PLN_SALEORD C
   WHERE A.JUDGE_STOVE_NO = {0}
     AND A.BATCH_NO = {1}
     AND A.PROCESS_CODE = {2}
     AND A.CRAFT_SOURCE = {3}
     AND A.CYCLES_FLAG = {4}
     AND A.IS_FLAG = '0'
     AND ({7} IS NULL AND A.CHECK_NO NOT LIKE '%L%' OR {7} IS NOT NULL)
     AND B.CHECK_NO = A.CHECK_NO
     AND B.BATCH_NO = A.BATCH_NO
     AND B.VALIDFLAG = '1'
     AND ({5} = 'HX' AND B.PHY_CODE_MAX = 'ONH' OR B.PHY_CODE_MAX = {5})
     AND ({6} IS NULL OR B.IS_MAIN = {6})
     AND C.ORD_LN_DLY_PK = A.ORD_LN_DLY_PK
     AND ({7} IS NULL OR C.ORD_LN_PK = {7})
        ]]>
    </query>

    <query id="JdgQcmZcCheckConsignDetail.GetPhyMinByJudgeStoveNo" desc="查询">
        <![CDATA[
SELECT DISTINCT A.CHECK_NO SAMPLE_ID,
                A.CHECK_NO,
                B.SAMPLE_NO,
                A.STOVE_NO,
                A.JUDGE_STOVE_NO,
                A.BATCH_NO,
                A.LOT_NO,
                A.LOT_NO_GROUP,
                B.NK_RESULT,
                B.JF_RESULT,
                B.MAT_NO,
                B.HEAD_MAT_NO,
                B.BAR_CODE,
                B.RESULT_SOURCE,
                A.APPLY_RESAMPLE,
                A.CYCLES_FLAG,
                B.OLD_JUDGE_STOVE_NO,
                B.OLD_BATCH_NO,
                B.IS_MAIN,
                A.CRAFT_SOURCE,
                DECODE(B.PHY_CODE_MAX, 'ONH', 'HX', B.PHY_CODE_MAX) PHY_CODE_MAX,
                DECODE(B.PHY_NAME_MAX, 'ONH', '化学', B.PHY_NAME_MAX) PHY_NAME_MAX,
                DECODE(B.PHY_CODE_MAX, 'ONH', 'HX', B.PHY_CODE_MAX) PHY_CODE_MIN,
                DECODE(B.PHY_NAME_MAX, 'ONH', '化学', B.PHY_NAME_MAX) PHY_NAME_MIN,
                A.APPLY_RESAMPLE,
                A.CYCLES_FLAG
  FROM QCM_ZC_CHECKCONSIGN A
  LEFT JOIN SLM_ORDER_LINE_DELIVERY C
    ON C.ORD_LN_DLY_PK = A.ORD_LN_DLY_PK,
   QCM_ZC_CHECKCONSIGN_DETAIL B
 WHERE A.JUDGE_STOVE_NO = {0}
   AND A.PROCESS_CODE = {1}
   AND A.CRAFT_SOURCE = {2}
   AND A.CYCLES_FLAG = {3}
   AND A.IS_FLAG = '0'
   AND ({7} IS NULL AND A.CHECK_NO NOT LIKE '%L%' OR {7} IS NOT NULL)
   AND B.CHECK_NO = A.CHECK_NO
   AND B.BATCH_NO = A.BATCH_NO
   AND B.VALIDFLAG = '1'
   AND ({4} = 'HX' AND B.PHY_CODE_MAX = 'ONH' OR B.PHY_CODE_MAX = {4})
   AND ({5} IS NULL OR B.IS_MAIN = {5})
   AND ({6} IS NULL OR A.PLINE_CODE = {6})
   AND ({7} IS NULL OR C.ORD_LN_PK = {7})
        ]]>
    </query>

    <query id="JdgQcmZcCheckConsignDetail.GetBLPhyMinByJudgeStoveNo" desc="查询">
        <![CDATA[
SELECT   DISTINCT
         A.CHECK_NO SAMPLE_ID,
         A.CHECK_NO,
         B.SAMPLE_NO,
         A.STOVE_NO,
         A.JUDGE_STOVE_NO,
         A.BATCH_NO,
         A.LOT_NO,
         A.LOT_NO_GROUP,
         B.NK_RESULT,
         B.JF_RESULT,
         B.MAT_NO,
         B.HEAD_MAT_NO,
         B.BAR_CODE,
         B.RESULT_SOURCE,
         A.APPLY_RESAMPLE,
         A.CYCLES_FLAG,
         B.OLD_JUDGE_STOVE_NO,
         B.OLD_BATCH_NO,
         B.IS_MAIN,
         A.CRAFT_SOURCE,
         DECODE(B.PHY_CODE_MAX, 'ONH', 'HX', B.PHY_CODE_MAX) PHY_CODE_MAX,
         DECODE(B.PHY_NAME_MAX, 'ONH', '化学', B.PHY_NAME_MAX) PHY_NAME_MAX,
         DECODE(B.PHY_CODE_MAX, 'ONH', 'HX', B.PHY_CODE_MAX) PHY_CODE_MIN,
         DECODE(B.PHY_NAME_MAX, 'ONH', '化学', B.PHY_NAME_MAX) PHY_NAME_MIN,
         A.APPLY_RESAMPLE,
         A.CYCLES_FLAG
    FROM QCM_ZC_CHECKCONSIGN        A,
         QCM_ZC_CHECKCONSIGN_DETAIL B,
         PLN_SALEORD C
   WHERE A.JUDGE_STOVE_NO = {0}
     AND A.PROCESS_CODE = {1}
     AND A.CRAFT_SOURCE = {2}
     AND A.CYCLES_FLAG = {3}
     AND A.IS_FLAG = '0'
     AND ({7} IS NULL AND A.CHECK_NO NOT LIKE '%L%' OR {7} IS NOT NULL)
     AND B.CHECK_NO = A.CHECK_NO
     AND B.BATCH_NO = A.BATCH_NO
     AND B.VALIDFLAG = '1'
     AND ({4} = 'HX' AND B.PHY_CODE_MAX = 'ONH' OR B.PHY_CODE_MAX = {4})
     AND ({5} IS NULL OR B.IS_MAIN = {5})
     AND ({6} IS NULL OR A.PLINE_CODE = {6})
     AND C.ORD_LN_DLY_PK = A.ORD_LN_DLY_PK
     AND ({7} IS NULL OR C.ORD_LN_PK = {7})
        ]]>
    </query>

    <query id="JdgQcmZcCheckConsignDetail.GetPhyMinByLotNo" desc="查询">
        <![CDATA[
SELECT DISTINCT A.CHECK_NO SAMPLE_ID,
                A.CHECK_NO,
                B.SAMPLE_NO,
                A.STOVE_NO,
                A.JUDGE_STOVE_NO,
                A.BATCH_NO,
                A.LOT_NO,
                A.LOT_NO_GROUP,
                B.NK_RESULT,
                B.JF_RESULT,
                B.MAT_NO,
                B.HEAD_MAT_NO,
                B.BAR_CODE,
                B.RESULT_SOURCE,
                A.APPLY_RESAMPLE,
                A.CYCLES_FLAG,
                B.OLD_JUDGE_STOVE_NO,
                B.OLD_BATCH_NO,
                B.IS_MAIN,
                A.CRAFT_SOURCE,
                DECODE(B.PHY_CODE_MAX, 'ONH', 'HX', B.PHY_CODE_MAX) PHY_CODE_MAX,
                DECODE(B.PHY_NAME_MAX, 'ONH', '化学', B.PHY_NAME_MAX) PHY_NAME_MAX,
                DECODE(B.PHY_CODE_MAX, 'ONH', 'HX', B.PHY_CODE_MAX) PHY_CODE_MIN,
                DECODE(B.PHY_NAME_MAX, 'ONH', '化学', B.PHY_NAME_MAX) PHY_NAME_MIN,
                A.APPLY_RESAMPLE,
                A.CYCLES_FLAG
  FROM QCM_ZC_CHECKCONSIGN A
  LEFT JOIN SLM_ORDER_LINE_DELIVERY C
    ON C.ORD_LN_DLY_PK = A.ORD_LN_DLY_PK,
   QCM_ZC_CHECKCONSIGN_DETAIL B
 WHERE
    ({0} IS NULL OR A.LOT_NO = {0})
   AND ({1} IS NULL OR A.LOT_NO_GROUP = {1})
   AND A.CHECK_NO NOT LIKE '%P%'
   AND A.PROCESS_CODE = {2}
   AND A.CRAFT_SOURCE = {3}
   AND A.CYCLES_FLAG = {4}
   AND A.IS_FLAG = '0'
   AND ({8} IS NULL AND A.CHECK_NO NOT LIKE '%L%' OR {8} IS NOT NULL)
   AND B.CHECK_NO = A.CHECK_NO
   AND B.BATCH_NO = A.BATCH_NO
   AND B.VALIDFLAG = '1'
   AND ({5} = 'HX' AND B.PHY_CODE_MAX = 'ONH' OR B.PHY_CODE_MAX = {5})
   AND ({6} IS NULL OR B.IS_MAIN = {6})
   AND ({7} IS NULL OR A.PLINE_CODE = {7})
   AND ({8} IS NULL OR C.ORD_LN_PK = {8})
        ]]>
    </query>

    <query id="JdgQcmZcCheckConsignDetail.GetBLPhyMinByLotNo" desc="查询">
        <![CDATA[
SELECT DISTINCT A.CHECK_NO SAMPLE_ID,
                A.CHECK_NO,
                B.SAMPLE_NO,
                A.STOVE_NO,
                A.JUDGE_STOVE_NO,
                A.BATCH_NO,
                A.LOT_NO,
                A.LOT_NO_GROUP,
                B.NK_RESULT,
                B.JF_RESULT,
                B.MAT_NO,
                B.HEAD_MAT_NO,
                B.BAR_CODE,
                B.RESULT_SOURCE,
                A.APPLY_RESAMPLE,
                A.CYCLES_FLAG,
                B.OLD_JUDGE_STOVE_NO,
                B.OLD_BATCH_NO,
                B.IS_MAIN,
                A.CRAFT_SOURCE,
                DECODE(B.PHY_CODE_MAX, 'ONH', 'HX', B.PHY_CODE_MAX) PHY_CODE_MAX,
                DECODE(B.PHY_NAME_MAX, 'ONH', '化学', B.PHY_NAME_MAX) PHY_NAME_MAX,
                DECODE(B.PHY_CODE_MAX, 'ONH', 'HX', B.PHY_CODE_MAX) PHY_CODE_MIN,
                DECODE(B.PHY_NAME_MAX, 'ONH', '化学', B.PHY_NAME_MAX) PHY_NAME_MIN,
                A.APPLY_RESAMPLE,
                A.CYCLES_FLAG
  FROM QCM_ZC_CHECKCONSIGN A, QCM_ZC_CHECKCONSIGN_DETAIL B, PLN_SALEORD C
 WHERE ({0} IS NULL OR A.LOT_NO = {0})
   AND ({1} IS NULL OR A.LOT_NO_GROUP = {1})
   AND A.CHECK_NO NOT LIKE '%P%'
   AND A.PROCESS_CODE = {2}
   AND A.CRAFT_SOURCE = {3}
   AND A.CYCLES_FLAG = {4}
   AND A.IS_FLAG = '0'
   AND ({8} IS NULL AND A.CHECK_NO NOT LIKE '%L%' OR {8} IS NOT NULL)
   AND B.CHECK_NO = A.CHECK_NO
   AND B.BATCH_NO = A.BATCH_NO
   AND B.VALIDFLAG = '1'
   AND ({5} = 'HX' AND B.PHY_CODE_MAX = 'ONH' OR B.PHY_CODE_MAX = {5})
   AND ({6} IS NULL OR B.IS_MAIN = {6})
   AND ({7} IS NULL OR A.PLINE_CODE = {7})
   AND C.ORD_LN_DLY_PK = A.ORD_LN_DLY_PK
   AND ({8} IS NULL OR C.ORD_LN_PK = {8})
        ]]>
    </query>

    <query id="JdgQcmZcCheckConsignDetail.GetPhyMinByOrdLnPk" desc="查询">
        <![CDATA[
SELECT DISTINCT
       A.CHECK_NO SAMPLE_ID,
       A.CHECK_NO,
       B.SAMPLE_NO,
       A.STOVE_NO,
       A.JUDGE_STOVE_NO,
       A.BATCH_NO,
       MIN(A.LOT_NO) LOT_NO,
       MIN(A.LOT_NO_GROUP) LOT_NO_GROUP,
       MIN(B.NK_RESULT) NK_RESULT,
       MIN(B.JF_RESULT) JF_RESULT,
       MIN(B.MAT_NO) MAT_NO,
       MIN(B.HEAD_MAT_NO) HEAD_MAT_NO,
       MIN(B.BAR_CODE) BAR_CODE,
       MIN(B.RESULT_SOURCE) RESULT_SOURCE,
       MIN(A.APPLY_RESAMPLE) APPLY_RESAMPLE,
       MIN(A.CYCLES_FLAG) CYCLES_FLAG,
       MIN(B.OLD_JUDGE_STOVE_NO) OLD_JUDGE_STOVE_NO,
       MIN(B.OLD_BATCH_NO) OLD_BATCH_NO,
       MIN(B.IS_MAIN) IS_MAIN,
       MIN(A.CRAFT_SOURCE) CRAFT_SOURCE,
       DECODE(MIN(B.PHY_CODE_MAX), 'ONH', 'HX', MIN(B.PHY_CODE_MAX)) PHY_CODE_MAX,
       DECODE(MIN(B.PHY_NAME_MAX), 'ONH', '化学', MIN(B.PHY_NAME_MAX)) PHY_NAME_MAX,
       DECODE(MIN(B.PHY_CODE_MAX), 'ONH', 'HX', MIN(B.PHY_CODE_MAX)) PHY_CODE_MIN,
       DECODE(MIN(B.PHY_NAME_MAX), 'ONH', '化学', MIN(B.PHY_NAME_MAX)) PHY_NAME_MIN,
       MIN(A.APPLY_RESAMPLE) APPLY_RESAMPLE,
       MIN(A.CYCLES_FLAG) CYCLES_FLAG
  FROM QCM_ZC_CHECKCONSIGN        A,
       QCM_ZC_CHECKCONSIGN_DETAIL B,
       SLM_ORDER_LINE_DELIVERY    C
   WHERE A.PROCESS_CODE = {0}
   AND A.CRAFT_SOURCE = {1}
   AND A.CYCLES_FLAG = {2}
   AND A.PLINE_CODE = {3}
   AND A.IS_FLAG = '0'
   AND C.ORD_LN_DLY_PK = A.ORD_LN_DLY_PK
   AND C.ORD_LN_PK = {4}
   AND B.CHECK_NO = A.CHECK_NO
   AND B.BATCH_NO = A.BATCH_NO
   AND B.VALIDFLAG = '1'
   AND ({5} = 'HX' AND B.PHY_CODE_MAX = 'ONH' OR
       B.PHY_CODE_MAX = {5})
   AND ({6} IS NULL OR B.IS_MAIN = {6})

 GROUP BY A.CHECK_NO, A.JUDGE_STOVE_NO, A.BATCH_NO, B.SAMPLE_NO, A.STOVE_NO
        ]]>
    </query>

    <query id="JdgQcmZcCheckConsignDetail.GetBLPhyMinByOrdLnPk" desc="查询">
        <![CDATA[
SELECT DISTINCT
       A.CHECK_NO SAMPLE_ID,
       A.CHECK_NO,
       B.SAMPLE_NO,
       A.STOVE_NO,
       A.JUDGE_STOVE_NO,
       A.BATCH_NO,
       MIN(A.LOT_NO) LOT_NO,
       MIN(A.LOT_NO_GROUP) LOT_NO_GROUP,
       MIN(B.NK_RESULT) NK_RESULT,
       MIN(B.JF_RESULT) JF_RESULT,
       MIN(B.MAT_NO) MAT_NO,
       MIN(B.HEAD_MAT_NO) HEAD_MAT_NO,
       MIN(B.BAR_CODE) BAR_CODE,
       MIN(B.RESULT_SOURCE) RESULT_SOURCE,
       MIN(A.APPLY_RESAMPLE) APPLY_RESAMPLE,
       MIN(A.CYCLES_FLAG) CYCLES_FLAG,
       MIN(B.OLD_JUDGE_STOVE_NO) OLD_JUDGE_STOVE_NO,
       MIN(B.OLD_BATCH_NO) OLD_BATCH_NO,
       MIN(B.IS_MAIN) IS_MAIN,
       MIN(A.CRAFT_SOURCE) CRAFT_SOURCE,
       DECODE(MIN(B.PHY_CODE_MAX), 'ONH', 'HX', MIN(B.PHY_CODE_MAX)) PHY_CODE_MAX,
       DECODE(MIN(B.PHY_NAME_MAX), 'ONH', '化学', MIN(B.PHY_NAME_MAX)) PHY_NAME_MAX,
       DECODE(MIN(B.PHY_CODE_MAX), 'ONH', 'HX', MIN(B.PHY_CODE_MAX)) PHY_CODE_MIN,
       DECODE(MIN(B.PHY_NAME_MAX), 'ONH', '化学', MIN(B.PHY_NAME_MAX)) PHY_NAME_MIN,
       MIN(A.APPLY_RESAMPLE) APPLY_RESAMPLE,
       MIN(A.CYCLES_FLAG) CYCLES_FLAG
  FROM QCM_ZC_CHECKCONSIGN        A,
       QCM_ZC_CHECKCONSIGN_DETAIL B,
       PLN_SALEORD    C,
       QCM_GP_JUDGE_APPLY         D
 WHERE A.PROCESS_CODE = {0}
   AND A.CRAFT_SOURCE = {1}
   AND A.CYCLES_FLAG = {2}
   AND A.PLINE_CODE = {3}
   AND A.IS_FLAG = '0'
   AND C.ORD_LN_DLY_PK = A.ORD_LN_DLY_PK
   AND C.ORD_LN_PK = {4}
   AND B.CHECK_NO = A.CHECK_NO
   AND B.BATCH_NO = A.BATCH_NO
   AND B.VALIDFLAG = '1'
   AND ({5} = 'HX' AND B.PHY_CODE_MAX = 'ONH' OR
       B.PHY_CODE_MAX = {5})
   AND ({6} IS NULL OR B.IS_MAIN = {6})
   AND D.STOVE_NO = A.STOVE_NO
   AND D.IS_FLAG = '0'
   AND ({7} = '0' AND D.PLINE_CODE NOT IN ('C063', 'C064') OR
       {7} = '1' AND D.PLINE_CODE IN ('C063', 'C064'))
 GROUP BY A.CHECK_NO, A.JUDGE_STOVE_NO, A.BATCH_NO, B.SAMPLE_NO, A.STOVE_NO
        ]]>
    </query>

    <query id="JdgQcmZcCheckConsignDetail.GetPhyMinByCheckNo" desc="查询">
        <![CDATA[
SELECT DISTINCT
       A.CHECK_NO           SAMPLE_ID,
       A.CHECK_NO,
       B.SAMPLE_NO,
       A.STOVE_NO,
       A.JUDGE_STOVE_NO,
       A.BATCH_NO,
       A.LOT_NO,
       A.LOT_NO_GROUP,
       B.NK_RESULT,
       B.JF_RESULT,
       B.MAT_NO,
       B.HEAD_MAT_NO,
       B.BAR_CODE,
       B.RESULT_SOURCE,
       A.APPLY_RESAMPLE,
       A.CYCLES_FLAG,
       B.OLD_JUDGE_STOVE_NO,
       B.OLD_BATCH_NO,
       B.IS_MAIN,
       A.CRAFT_SOURCE,
       DECODE(B.PHY_CODE_MAX, 'ONH', 'HX', B.PHY_CODE_MAX) PHY_CODE_MAX,
       DECODE(B.PHY_NAME_MAX, 'ONH', '化学', B.PHY_NAME_MAX) PHY_NAME_MAX,
       DECODE(B.PHY_CODE_MAX, 'ONH', 'HX', B.PHY_CODE_MAX) PHY_CODE_MIN,
       DECODE(B.PHY_NAME_MAX, 'ONH', '化学', B.PHY_NAME_MAX) PHY_NAME_MIN,
       A.APPLY_RESAMPLE,
       A.CYCLES_FLAG,
       B.RATE,
       B.DESC_RATE,
       DECODE(B.PHY_CODE_MAX, 'HX', A.CIC, 'ONH', A.CIC, A.PIC) PIC
  FROM QCM_ZC_CHECKCONSIGN A, QCM_ZC_CHECKCONSIGN_DETAIL B
 WHERE A.CHECK_NO = {0}
   AND A.IS_FLAG = '0'
   AND B.CHECK_NO = A.CHECK_NO
   AND B.BATCH_NO = A.BATCH_NO
   AND B.VALIDFLAG = '1'
        ]]>
    </query>

	<query id="JdgQcmZcCheckConsignDetail.setJudgeResult" desc="设置判定结果">
		<![CDATA[
UPDATE QCM_ZC_CHECKCONSIGN_DETAIL T
      SET T.NK_RESULT = {4}, T.JF_RESULT = {5}, T.RESULT_SOURCE = {6}
    WHERE T.CHECK_NO = {0}
      AND T.BATCH_NO = {1}
      AND T.SAMPLE_NO = {2}
      AND T.PHY_CODE_MAX = {3}
		]]>
	</query>
	
	<query id="JdgQcmZcCheckConsignDetail.setChemJudgeResultByCheckNo" desc="设置判定结果">
		<![CDATA[
UPDATE QCM_ZC_CHECKCONSIGN_DETAIL T
      SET T.NK_RESULT = {1}, T.JF_RESULT = {2}, T.RESULT_SOURCE = {3}
    WHERE T.CHECK_NO = {0} AND T.PHY_CODE_MAX IN ('HX', 'ONH')
		]]>
	</query>
	
	<query id="JdgQcmZcCheckConsignDetail.setPhyJudgeResultByCheckNo" desc="设置判定结果">
		<![CDATA[
UPDATE QCM_ZC_CHECKCONSIGN_DETAIL T
      SET T.NK_RESULT = {2}, T.JF_RESULT = {3}, T.RESULT_SOURCE = {4}
WHERE T.CHECK_NO = {0}
AND T.BATCH_NO = {1}
AND T.PHY_CODE_MAX NOT IN ('HX', 'ONH', 'C0030', 'C0031', 'C0032', 'C0033', 'C0133','C0147','C0150', 'C0007','C0061','C0065', 'C0146','C0148')
		]]>
	</query>
	
	<query id="JdgQcmZcCheckConsignDetail.setPhySscJudgeResultByCheckNo" desc="设置判定结果">
		<![CDATA[
UPDATE QCM_ZC_CHECKCONSIGN_DETAIL T
      SET T.NK_RESULT = {2}, T.JF_RESULT = {3}, T.RESULT_SOURCE = {4}
WHERE T.CHECK_NO = {0}
AND T.BATCH_NO = {1}
 AND T.PHY_CODE_MAX IN ('C0030', 'C0031', 'C0032', 'C0033', 'C0133','C0147','C0150')
		]]>
	</query>
	
	<query id="JdgQcmZcCheckConsignDetail.setPhyHicJudgeResultByCheckNo" desc="设置判定结果">
		<![CDATA[
UPDATE QCM_ZC_CHECKCONSIGN_DETAIL T
      SET T.NK_RESULT = {2}, T.JF_RESULT = {3}, T.RESULT_SOURCE = {4}
WHERE T.CHECK_NO = {0}
AND T.BATCH_NO = {1}
 AND T.PHY_CODE_MAX IN ('C0007')
		]]>
	</query>
	
	<query id="JdgQcmZcCheckConsignDetail.getConsignDetailByCheckNo" desc="获取委托二层表">
		<![CDATA[
SELECT T.*,
         T.PHY_CODE_MAX   PHY_CODE_MIN,
         T.PHY_NAME_MAX   PHY_NAME_MIN,
         A.JUDGE_STOVE_NO,
         'False' CHK,
         'False' BACK_RCL
    FROM QCM_ZC_CHECKCONSIGN_DETAIL T, QCM_ZC_CHECKCONSIGN A
   WHERE T.CHECK_NO = {0}
     AND A.CHECK_NO = T.CHECK_NO
     AND A.BATCH_NO = T.BATCH_NO
     AND T.VALIDFLAG = '1'
ORDER BY T.BATCH_NO, T.PHY_NAME_MAX, T.SAMPLE_NO
		]]>
	</query>
	<query id = "JdgQcmZcCheckConsignDetail.getPipeDetialByCheckNo" desc = "查询126委托二层表">
	SELECT 
       T.CHECK_NO,
       T.BATCH_NO,
       T.SAMPLE_NO,
       T.SAMPLE_NO_MIN,
       T.SAMPLE_BARCODE,
       T.SAMPLE_LEN,
       T.CHECK_STD,
       T.PHY_CODE_MAX,
       T.PHY_NAME_MAX,
       T.SAMPLE_COUNT,
       T.DEPT_ID,
       T.LENGTH,
       T.WIDTH,
       T.EIC,
       T.PHY_DIR,
       T.SIZE_DESC,
       T.JG_SEND_NAME,
       TO_CHAR(T.JG_SEND_TIME, 'YYYY-MM-DD HH24:MI:SS') JG_SEND_TIME,
       T.LAB_RECEIVE_NAME,
       TO_CHAR(T.LAB_RECEIVE_TIME, 'YYYY-MM-DD HH24:MI:SS') LAB_RECEIVE_TIME,
       T.CHECK_TEMP,
       T.DEVICE_NO,
       T.DEVICE_NAME,
       T.CHECK_SHIFT,
       T.CHECK_CLASS,
       T.CHECK_NAME,
       TO_CHAR(T.CHECK_TIME, 'YYYY-MM-DD HH24:MI:SS') CHECK_TIME,
       T.AUDIT_NAME,
       TO_CHAR(T.AUDIT_TIME, 'YYYY-MM-DD HH24:MI:SS') AUDIT_TIME,
       T.ISRCL,
       T.RCL_MOVE_REMARK,
       T.IS_NOTICE_PRODUCER,
       T.NOTICE_PRODUCER_REMARK,
       T.IS_RESAMPLE_REST,
       T.RESAMPLE_REST_REMARK,
       T.SPEC_FLAG,
       T.SPEC_MOVE_REMARK,
       T.FLAG,
       T.SAMPLE_REMARK,
       T.REMARK,
       T.FORMUAL_NO,
       T.FORMUAL_NAME,
       T.MAT_NO,
       T.SAMPLE_TYPE,
       T.FOR_CHECK_NO,
       T.VALIDFLAG,
       T.CHECK_HUMIDITY,
       T.STD_STEEL_NO,
       T.STD_STEEL_TYPE,
       T.STD_STEEL_VALUE,
       T.ACTUAL_VALUE,
       T.HARDNESS_TYPE,
       T.RATE,
       T.DESC_RATE,
       T.SSC_CONDITION,
       T.JG_SEND_SHIFT,
       T.JG_SEND_GROUP,
       T.JG_PRINT_COUNT,
       T.RCL_AUDIT_NAME,
       TO_CHAR(T.RCL_AUDIT_TIME, 'YYYY-MM-DD HH24:MI:SS') RCL_AUDIT_TIME,
       T.ORIGINAL_AREA,
       T.LAB_PRINT_COUNT,
       T.RCL_FLAG,
       T.FILE_PATH1,
       T.FILE_PATH2,
       T.HEAD_MAT_NO,
       T.BAR_CODE,
       T.SAMPLE_STYLE,
       T.MERG_NAME,
       TO_CHAR(T.MERG_TIME, 'YYYY-MM-DD HH24:MI:SS') MERG_TIME,
       T.BACK_MEMO,
       T.UPDATE_NAME,
       TO_CHAR(T.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       T.CONTENT,
       T.TS_SAMPLE_REMARK,
       T.TS_REMARK
       FROM PIPE_CHECKCONSIGN_DETAIL T WHERE T.CHECK_NO = {0}
	</query>
	<query id="JdgQcmZcCheckConsignDetail.getPhyMinQuote" desc="获取试样组报出情况">
		<![CDATA[
SELECT A.PHY_CODE_MAX,
       A.SAMPLE_NO,
       (SELECT COUNT(1)
          FROM QCM_JHY_PHYRESULT A2
         WHERE A2.SAMPLE_ID = A.CHECK_NO
           AND A2.BATCH_NO = A.BATCH_NO
           AND A2.PHY_CODE_MIN = A.PHY_CODE_MAX
           AND A2.SAMPLE_NO = A.SAMPLE_NO) CNT
  FROM QCM_ZC_CHECKCONSIGN_DETAIL A
 WHERE A.CHECK_NO = {0}
   AND A.PHY_CODE_MAX NOT IN ('HX', 'ONH')
   AND A.VALIDFLAG = '1'
UNION ALL
SELECT NULL,
       A.SAMPLE_NO,
       (SELECT COUNT(1)
          FROM QCM_JHY_ELEMENTS A2
         WHERE A2.SAMPLE_ID = A.CHECK_NO
           AND A2.BATCH_NO = A.BATCH_NO
           AND A2.SAMPLE_NO = A.SAMPLE_NO) CNT
  FROM QCM_ZC_CHECKCONSIGN_DETAIL A
 WHERE A.CHECK_NO = {0}
   AND A.PHY_CODE_MAX IN ('HX', 'ONH')
   AND A.VALIDFLAG = '1'
		]]>
	</query>
	
	<query id="JdgQcmZcCheckConsignDetail.getHardnessPhy" desc="获取洛氏硬度试样组">
		<![CDATA[
SELECT A.CHECK_NO,
          A.JUDGE_STOVE_NO,
          A.BATCH_NO,
          T.PHY_CODE_MAX PHY_CODE_MIN,
          T.PHY_NAME_MAX PHY_NAME_MIN,
          DECODE(T.NK_RESULT, '0', '不合格', '1', '合格', T.NK_RESULT) NK_RESULT,
          DECODE(T.JF_RESULT, '0', '不合格', '1', '合格', T.JF_RESULT) JF_RESULT,
          'False' CHK,
          'False' IS_ORIGINAL
     FROM QCM_ZC_CHECKCONSIGN_DETAIL T,
          QCM_ZC_CHECKCONSIGN        A,
          COM_BASE_PHY_C             C
    WHERE T.CHECK_NO = {0}
      AND T.VALIDFLAG = '1'
      AND A.CHECK_NO = T.CHECK_NO
      AND A.BATCH_NO = T.BATCH_NO
      AND C.PHY_TYPE_M = 'R0004'
      AND C.PHY_CODE = T.PHY_CODE_MAX
		]]>
	</query>
	
	<query id="JdgQcmZcCheckConsignDetail.deleteByBatchNoOrdLnPkCheckNo" desc="通过炉批+合同行PK删除">
		<![CDATA[
  DELETE FROM QCM_ZC_CHECKCONSIGN_DETAIL A
   WHERE EXISTS (SELECT 1
            FROM QCM_ZC_CHECKCONSIGN T
           WHERE T.JUDGE_STOVE_NO = {0}
             AND T.BATCH_NO = {1}
             AND T.PROCESS_CODE = {2}
             AND T.CRAFT_SOURCE = {3}
             AND T.ORD_LN_DLY_PK = {4}
             AND T.CHECK_NO LIKE '%' || {5} || '%'
             AND T.CHECK_NO = A.CHECK_NO
             AND T.BATCH_NO = A.BATCH_NO)
		]]>
	</query>
	
	<query id="JdgQcmZcCheckConsignDetail.deleteByBatchNoOrdLnPkCheckNo1" desc="通过炉批+合同行PK删除">
		<![CDATA[
  DELETE FROM QCM_ZC_CHECKCONSIGN_DETAIL A
   WHERE A.CHECK_NO = {0}
		]]>
	</query>
	<query id="JdgQcmZcCheckConsignDetail.getOriginalByBatchNoPhyMin" desc="通过炉批查询">
		<![CDATA[
SELECT T.*
  FROM QCM_ZC_CHECKCONSIGN_DETAIL T, QCM_ZC_CHECKCONSIGN A
 WHERE A.CHECK_NO = T.CHECK_NO
   AND A.BATCH_NO = T.BATCH_NO
   AND A.PROCESS_CODE = {2}
   AND A.CRAFT_SOURCE = {3}
   AND A.ORD_LN_DLY_PK = {4}
   AND A.IS_FLAG = '0'
   AND A.JUDGE_STOVE_NO = {0}
   AND A.BATCH_NO = {1}
   AND T.PHY_CODE_MAX = {5}
   AND T.VALIDFLAG = '1'
   AND (A.CHECK_NO NOT LIKE '%P%' AND A.CHECK_NO NOT LIKE '%L%')
		]]>
	</query>
	
	<query id="JdgQcmZcCheckConsignDetail.getOriginalByJudgeStoveNoPhyMin" desc="通过炉号查询">
		<![CDATA[
SELECT T.*
  FROM QCM_ZC_CHECKCONSIGN_DETAIL T, QCM_ZC_CHECKCONSIGN A
 WHERE A.CHECK_NO = T.CHECK_NO
   AND A.BATCH_NO = T.BATCH_NO
   AND A.PROCESS_CODE = {1}
   AND A.CRAFT_SOURCE = {2}
   AND A.ORD_LN_DLY_PK = {3}
   AND A.IS_FLAG = '0'
   AND A.JUDGE_STOVE_NO = {0}
   AND T.PHY_CODE_MAX = {4}
   AND T.VALIDFLAG = '1'
   AND (A.CHECK_NO NOT LIKE '%P%' AND A.CHECK_NO NOT LIKE '%L%')
		]]>
	</query>
	
	<query id="JdgQcmZcCheckConsignDetail.getOriginalByLotNoPhyMin" desc="通过生产批查询">
		<![CDATA[
SELECT T.* FROM QCM_ZC_CHECKCONSIGN_DETAIL T, QCM_ZC_CHECKCONSIGN A
 WHERE A.CHECK_NO = T.CHECK_NO
   AND A.BATCH_NO = T.BATCH_NO
   AND A.PROCESS_CODE = {2}
   AND A.CRAFT_SOURCE = {3}
   AND A.ORD_LN_DLY_PK = {4}
   AND A.IS_FLAG = '0'
   AND A.LOT_NO = {0}
   AND ({1} IS NULL OR A.LOT_NO_GROUP = {1})
   AND T.PHY_CODE_MAX = {5}
   AND T.VALIDFLAG = '1'
   AND (A.CHECK_NO NOT LIKE '%P%' AND A.CHECK_NO NOT LIKE '%L%')
		]]>
	</query>
	
	<query id="JdgQcmZcCheckConsignDetail.insert" desc="新增">
		<![CDATA[
INSERT INTO QCM_ZC_CHECKCONSIGN_DETAIL(
        CHECK_NO,
        BATCH_NO,
        SAMPLE_NO,
        PHY_CODE_MAX,
        PHY_NAME_MAX,
        RATE,
        DESC_RATE,
        EIC,
        SAMPLE_NO_MIN,
        SAMPLE_COUNT,
        SAMPLE_LEN,
        MAT_NO,
        HEAD_MAT_NO,
        BAR_CODE,
        OLD_JUDGE_STOVE_NO,
        OLD_BATCH_NO,
        IS_MAIN)
 VALUES( 
        '#CHECK_NO#',
        '#BATCH_NO#',
        '#SAMPLE_NO#',
        '#PHY_CODE_MAX#',
        '#PHY_NAME_MAX#',
        '#RATE#',
        '#DESC_RATE#',
        '#EIC#',
        '#SAMPLE_NO_MIN#',
        '#SAMPLE_COUNT#',
        '#SAMPLE_LEN#',
        '#MAT_NO#',
        '#HEAD_MAT_NO#',
        '#BAR_CODE#',
        '#OLD_JUDGE_STOVE_NO#',
        '#OLD_BATCH_NO#',
        '#IS_MAIN#')
		]]>
	</query>
	<query id = "JdgQcmZcCheckConsignDetail.insertPipeDetial" desc = "新增126委托二层表">
	 INSERT INTO PIPE_CHECKCONSIGN_DETAIL(
        CHECK_NO,
        BATCH_NO,
        SAMPLE_NO,
        SAMPLE_NO_MIN,
        SAMPLE_BARCODE,
        SAMPLE_LEN,
        CHECK_STD,
        PHY_CODE_MAX,
        PHY_NAME_MAX,
        SAMPLE_COUNT,
        DEPT_ID,
        LENGTH,
        WIDTH,
        EIC,
        PHY_DIR,
        SIZE_DESC,
        JG_SEND_NAME,
        JG_SEND_TIME,
        LAB_RECEIVE_NAME,
        LAB_RECEIVE_TIME,
        CHECK_TEMP,
        DEVICE_NO,
        DEVICE_NAME,
        CHECK_SHIFT,
        CHECK_CLASS,
        CHECK_NAME,
        CHECK_TIME,
        AUDIT_NAME,
        AUDIT_TIME,
        ISRCL,
        RCL_MOVE_REMARK,
        IS_NOTICE_PRODUCER,
        NOTICE_PRODUCER_REMARK,
        IS_RESAMPLE_REST,
        RESAMPLE_REST_REMARK,
        SPEC_FLAG,
        SPEC_MOVE_REMARK,
        FLAG,
        SAMPLE_REMARK,
        REMARK,
        FORMUAL_NO,
        FORMUAL_NAME,
        MAT_NO,
        SAMPLE_TYPE,
        FOR_CHECK_NO,
        VALIDFLAG,
        CHECK_HUMIDITY,
        STD_STEEL_NO,
        STD_STEEL_TYPE,
        STD_STEEL_VALUE,
        ACTUAL_VALUE,
        HARDNESS_TYPE,
        RATE,
        DESC_RATE,
        SSC_CONDITION,
        JG_SEND_SHIFT,
        JG_SEND_GROUP,
        JG_PRINT_COUNT,
        RCL_AUDIT_NAME,
        RCL_AUDIT_TIME,
        ORIGINAL_AREA,
        LAB_PRINT_COUNT,
        RCL_FLAG,
        FILE_PATH1,
        FILE_PATH2,
        HEAD_MAT_NO,
        BAR_CODE,
        SAMPLE_STYLE,
        MERG_NAME,
        MERG_TIME,
        BACK_MEMO,
        UPDATE_NAME,
        UPDATE_TIME,
        CONTENT,
        TS_SAMPLE_REMARK,
        TS_REMARK)
 VALUES( 
        '#CHECK_NO#',
        '#BATCH_NO#',
        '#SAMPLE_NO#',
        '#SAMPLE_NO_MIN#',
        '#SAMPLE_BARCODE#',
        '#SAMPLE_LEN#',
        '#CHECK_STD#',
        '#PHY_CODE_MAX#',
        '#PHY_NAME_MAX#',
        '#SAMPLE_COUNT#',
        '#DEPT_ID#',
        '#LENGTH#',
        '#WIDTH#',
        '#EIC#',
        '#PHY_DIR#',
        '#SIZE_DESC#',
        '#JG_SEND_NAME#',
        TO_DATE('#JG_SEND_TIME#','YYYY-MM-DD HH24:MI:SS'),
        
        '#LAB_RECEIVE_NAME#',
        TO_DATE('#LAB_RECEIVE_TIME#','YYYY-MM-DD HH24:MI:SS'),
        '#CHECK_TEMP#',
        '#DEVICE_NO#',
        '#DEVICE_NAME#',
        '#CHECK_SHIFT#',
        '#CHECK_CLASS#',
        '#CHECK_NAME#',
        TO_DATE('#CHECK_TIME#','YYYY-MM-DD HH24:MI:SS'),
        
        '#AUDIT_NAME#',
        TO_DATE('#AUDIT_TIME#','YYYY-MM-DD HH24:MI:SS'),
        
        '#ISRCL#',
        '#RCL_MOVE_REMARK#',
        '#IS_NOTICE_PRODUCER#',
        '#NOTICE_PRODUCER_REMARK#',
        '#IS_RESAMPLE_REST#',
        '#RESAMPLE_REST_REMARK#',
        '#SPEC_FLAG#',
        '#SPEC_MOVE_REMARK#',
        '#FLAG#',
        '#SAMPLE_REMARK#',
        '#REMARK#',
        '#FORMUAL_NO#',
        '#FORMUAL_NAME#',
        '#MAT_NO#',
        '#SAMPLE_TYPE#',
        '#FOR_CHECK_NO#',
        '#VALIDFLAG#',
        '#CHECK_HUMIDITY#',
        '#STD_STEEL_NO#',
        '#STD_STEEL_TYPE#',
        '#STD_STEEL_VALUE#',
        '#ACTUAL_VALUE#',
        '#HARDNESS_TYPE#',
        '#RATE#',
        '#DESC_RATE#',
        '#SSC_CONDITION#',
        '#JG_SEND_SHIFT#',
        '#JG_SEND_GROUP#',
        '#JG_PRINT_COUNT#',
        '#RCL_AUDIT_NAME#',
        TO_DATE('#RCL_AUDIT_TIME#','YYYY-MM-DD HH24:MI:SS'),
        
        '#ORIGINAL_AREA#',
        '#LAB_PRINT_COUNT#',
        '#RCL_FLAG#',
        '#FILE_PATH1#',
        '#FILE_PATH2#',
        '#HEAD_MAT_NO#',
        '#BAR_CODE#',
        '#SAMPLE_STYLE#',
        '#MERG_NAME#',
        TO_DATE('#MERG_TIME#','YYYY-MM-DD HH24:MI:SS'),
        
        '#BACK_MEMO#',
        '#UPDATE_NAME#',
        TO_DATE('#UPDATE_TIME#','YYYY-MM-DD HH24:MI:SS'),
        
        
        '#CONTENT#',
        '#TS_SAMPLE_REMARK#',
        '#TS_REMARK#')
	</query>
	<query id="JdgQcmZcCheckConsignDetail.getByBatchNo" desc="通过批号获取">
		<![CDATA[
SELECT T.*
  FROM QCM_ZC_CHECKCONSIGN_DETAIL T
 WHERE T.CHECK_NO = {0}
   AND T.BATCH_NO = {1}
		]]>
	</query>
	
	<query id="JdgQcmZcCheckConsignDetail.getNoBatchNo" desc="通过批号获取">
		<![CDATA[
SELECT T.*
  FROM QCM_ZC_CHECKCONSIGN_DETAIL T
 WHERE T.CHECK_NO = {0}
		]]>
	</query>
	
	<query id="JdgQcmZcCheckConsignDetail.getByBatchNoGroupBySampleNo" desc="通过批号获取">
		<![CDATA[
SELECT A.CHECK_NO,
       A.JUDGE_STOVE_NO,
       A.BATCH_NO,
       B.SAMPLE_NO,
       MIN(B.OLD_JUDGE_STOVE_NO) OLD_JUDGE_STOVE_NO,
       MIN(B.OLD_BATCH_NO) OLD_BATCH_NO,
       MIN(B.IS_MAIN) IS_MAIN
  FROM QCM_ZC_CHECKCONSIGN A, QCM_ZC_CHECKCONSIGN_DETAIL B
 WHERE A.CHECK_NO = B.CHECK_NO
   AND A.BATCH_NO = B.BATCH_NO
   AND A.CHECK_NO = {0}
   AND A.JUDGE_STOVE_NO = {1}
   AND A.BATCH_NO = {2}
   AND A.PROCESS_CODE = {3}
   AND B.PHY_CODE_MAX NOT IN ('HX', 'ONH')
 GROUP BY A.CHECK_NO, A.JUDGE_STOVE_NO, A.BATCH_NO, B.SAMPLE_NO
		]]>
	</query>
	
	<query id="JdgQcmZcCheckConsignDetail.getOriginalRateByBatchNo" desc="通过炉批获取取样频率">
		<![CDATA[
SELECT B.PHY_CODE_MAX, B.PHY_CODE_MAX PHY_CODE_MIN, MIN(B.RATE) RATE
  FROM QCM_ZC_CHECKCONSIGN A, QCM_ZC_CHECKCONSIGN_DETAIL B
 WHERE A.JUDGE_STOVE_NO = {0}
   AND A.PROCESS_CODE = {2}
   AND A.CRAFT_SOURCE = {3}
   AND A.IS_FLAG = '0'
   AND (A.CHECK_NO NOT LIKE '%P%' AND A.CHECK_NO NOT LIKE '%L%')
   AND B.CHECK_NO = A.CHECK_NO
   AND B.BATCH_NO = A.BATCH_NO
   AND B.VALIDFLAG = '1'
   AND (B.RATE = '408603' OR B.BATCH_NO = {1})
 GROUP BY B.PHY_CODE_MAX
		]]>
	</query>
	
	<query id="JdgQcmZcCheckConsignDetail.getAllByCheckNo" desc="通过检验编号获取所有试样组">
		<![CDATA[
SELECT A.JUDGE_STOVE_NO,
       A.BATCH_NO,
       B.PHY_CODE_MAX   PHY_CODE_MIN,
       B.PHY_NAME_MAX   PHY_NAME_MIN,
       'False' CHK,
       'False' IS_ORIGINAL,
       DECODE(MIN(B.NK_RESULT), '0', '不合格', '1', '合格') NK_RESULT
  FROM QCM_ZC_CHECKCONSIGN A, QCM_ZC_CHECKCONSIGN_DETAIL B
 WHERE A.CHECK_NO = B.CHECK_NO
   AND A.BATCH_NO = B.BATCH_NO
   AND A.IS_FLAG = '0'
   AND A.CHECK_NO = {0}
GROUP BY A.JUDGE_STOVE_NO, A.BATCH_NO, B.PHY_CODE_MAX, B.PHY_NAME_MAX
ORDER BY A.JUDGE_STOVE_NO, A.BATCH_NO, MIN(B.NK_RESULT), B.PHY_NAME_MAX
		]]>
	</query>
	
	<query id="JdgQcmZcCheckConsignDetail.getAllByJudgeStoveNo" desc="通过判定炉获取所有试样组">
		<![CDATA[
SELECT A.JUDGE_STOVE_NO,
		A.BATCH_NO,
       A.LOT_NO,
       A.LOT_NO_GROUP,
       B.PHY_CODE_MAX   PHY_CODE_MIN,
       B.PHY_NAME_MAX   PHY_NAME_MIN,
       B2.BASENAME      RATE_DESC,
       'False' CHK,
       'False' IS_ORIGINAL,
       DECODE(B.NK_RESULT, '0', '不合格', '1', '合格') NK_RESULT
  FROM QCM_ZC_CHECKCONSIGN A, QCM_ZC_CHECKCONSIGN_DETAIL B
  LEFT JOIN COM_BASE_INFO B2
    ON B2.BASECODE = B.RATE
 WHERE A.CHECK_NO = B.CHECK_NO
   AND A.BATCH_NO = B.BATCH_NO
   AND A.IS_FLAG = '0'
   AND A.JUDGE_STOVE_NO = {0}
   AND A.ORD_LN_DLY_PK = {1}
   AND B.RATE = '408603'
		]]>
	</query>
	
	<query id="JdgQcmZcCheckConsignDetail.getAllByLotNo" desc="通过生产批获取所有试样组">
		<![CDATA[
SELECT A.JUDGE_STOVE_NO,
		A.BATCH_NO,
       A.LOT_NO,
       A.LOT_NO_GROUP,
       B.PHY_CODE_MAX   PHY_CODE_MIN,
       B.PHY_NAME_MAX   PHY_NAME_MIN,
       B2.BASENAME      RATE_DESC,
       'False' CHK,
       'False' IS_ORIGINAL,
       DECODE(B.NK_RESULT, '0', '不合格', '1', '合格') NK_RESULT
  FROM QCM_ZC_CHECKCONSIGN A, QCM_ZC_CHECKCONSIGN_DETAIL B
  LEFT JOIN COM_BASE_INFO B2
    ON B2.BASECODE = B.RATE
 WHERE A.CHECK_NO = B.CHECK_NO
   AND A.BATCH_NO = B.BATCH_NO
   AND A.IS_FLAG = '0'
   AND A.LOT_NO = {0}
   AND ({1} IS NULL AND A.LOT_NO_GROUP IS NULL OR A.LOT_NO_GROUP = {1})
   AND A.ORD_LN_DLY_PK = {2}
   AND B.RATE = '408601'
		]]>
	</query>
	
	<query id="JdgQcmZcCheckConsignDetail.getByPk" desc="通过生产批获取所有试样组">
		<![CDATA[
select T.*
  from QCM_ZC_CHECKCONSIGN_DETAIL t
 WHERE T.CHECK_NO = {0}
   AND T.BATCH_NO = {1}
   AND T.SAMPLE_NO = {2}
   AND T.PHY_CODE_MAX = {3}
		]]>
	</query>
	
	<query id="JdgQcmZcCheckConsignDetail.deleteNoJhyData" desc="删除没有检验结果的二层表记录">
		<![CDATA[
DELETE FROM QCM_ZC_CHECKCONSIGN_DETAIL A
 WHERE EXISTS (SELECT 1
          FROM QCM_ZC_CHECKCONSIGN B
         WHERE B.CHECK_NO = {0}
           AND A.CHECK_NO = B.CHECK_NO
           AND A.BATCH_NO = B.BATCH_NO)
   AND NOT EXISTS (SELECT 1
          FROM QCM_JHY_PHYRESULT C
         WHERE C.SAMPLE_ID = A.CHECK_NO
           AND C.BATCH_NO = A.BATCH_NO
           AND C.PHY_CODE_MIN = A.PHY_CODE_MAX
           AND C.SAMPLE_NO = A.SAMPLE_NO)
   AND NOT EXISTS (SELECT 1
          FROM QCM_JHY_ELEMENTS C
         WHERE C.SAMPLE_ID = A.CHECK_NO
           AND C.BATCH_NO = A.BATCH_NO
           AND A.PHY_CODE_MAX IN ('HX', 'ONH')
           AND C.SAMPLE_NO = A.SAMPLE_NO)
		]]>
	</query>
</queryMap>