<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="工序理化自动判定">
	<query id="BcPhyJudgeTask.getZcCheck" desc="获取委托表">
		<![CDATA[
SELECT *
  FROM (SELECT A.CHECK_NO
          FROM QCM_ZC_CHECKCONSIGN A,
               (SELECT NVL(C3.JUDGE_STOVE_NO, C4.JUDGE_STOVE_NO) JUDGE_STOVE_NO,
                       NVL(C3.BATCH_NO, C4.BATCH_NO) BATCH_NO,
                       NVL(C3.SAMPLE_ID, C4.SAMPLE_ID) SAMPLE_ID,
                       C3.SAMPLE_ID CHEM_ID,
                       C4.SAMPLE_ID PHY_ID
                  FROM (SELECT C2.JUDGE_STOVE_NO, C2.BATCH_NO, C2.SAMPLE_ID
                          FROM QCM_JHY_ELEMENTS C2
                         WHERE C2.LG_JUDGE_FLAG = '00'
                           AND C2.ASSAYTYPE = 'B'
                         GROUP BY C2.JUDGE_STOVE_NO, C2.BATCH_NO, C2.SAMPLE_ID) C3
                  FULL JOIN (SELECT D2.JUDGE_STOVE_NO,
                                   D2.BATCH_NO,
                                   D2.SAMPLE_ID
                              FROM QCM_JHY_PHYRESULT D2
                             WHERE D2.JUDGE_FLAG = '00'
                             GROUP BY D2.JUDGE_STOVE_NO,
                                      D2.BATCH_NO,
                                      D2.SAMPLE_ID) C4
                    ON C3.JUDGE_STOVE_NO = C4.JUDGE_STOVE_NO
                   AND C3.BATCH_NO = C4.BATCH_NO
                   AND C3.SAMPLE_ID = C4.SAMPLE_ID) C,
               PLN_SALEORD H,
               CRAFT_ORD_DESIGN E
         WHERE A.IS_FLAG = '0'
           AND A.PROCESS_CODE = {0}
           AND A.JUDGE_STOVE_NO = C.JUDGE_STOVE_NO
           AND A.BATCH_NO = C.BATCH_NO
           AND A.CHECK_NO = C.SAMPLE_ID
           AND H.ORD_LN_DLY_PK = A.ORD_LN_DLY_PK
           AND E.ORD_LN_PK = H.ORD_LN_PK
           AND E.CRAFT_SEQ = A.CRAFT_SEQ
           AND (EXISTS
                (SELECT 1
                   FROM QCM_ZC_CHECKCONSIGN_DETAIL B
                  WHERE B.CHECK_NO = A.CHECK_NO
                    AND B.BATCH_NO = A.BATCH_NO
                    AND B.PHY_CODE_MAX IN ('HX', 'ONH')
                    AND B.VALIDFLAG = '1') AND EXISTS
                (SELECT 1
                   FROM QCM_ZC_CHECKCONSIGN_DETAIL B
                  WHERE B.CHECK_NO = A.CHECK_NO
                    AND B.BATCH_NO = A.BATCH_NO
                    AND B.PHY_CODE_MAX NOT IN ('HX', 'ONH')
                    AND B.VALIDFLAG = '1')
-- 								AND NOT EXISTS
--                 (SELECT 1
--                    FROM CRAFT_ORD_DESIGN_STD_CIC F
--                   WHERE F.DESGIN_KEY = E.DESGIN_KEY
--                     AND F.MSC_PLINE = A.INDEX_SEQ
--                     AND F.PROCESS_CODE = A.PROCESS_CODE
--                     AND F.CIC = A.CIC
--                     AND F.STDMEMO IS NOT NULL)
-- 								AND NOT EXISTS
--                 (SELECT 1
--                    FROM CRAFT_ORD_DESIGN_STD_PIC   G,
--                         QCM_ZC_CHECKCONSIGN_DETAIL B
--                   WHERE G.DESGIN_KEY = E.DESGIN_KEY
--                     AND G.MSC_PLINE = A.INDEX_SEQ
--                     AND G.PROCESS_CODE = A.PROCESS_CODE
--                     AND G.PIC = A.PIC
--                     AND G.STDMEMO IS NOT NULL
--                     AND B.CHECK_NO = A.CHECK_NO
--                     AND B.BATCH_NO = A.BATCH_NO
--                     AND B.PHY_CODE_MAX NOT IN ('HX', 'ONH')
--                     AND B.PHY_CODE_MAX = G.PHY_CODE_MIN
--                     AND B.VALIDFLAG = '1')

								OR EXISTS
                (SELECT 1
                   FROM QCM_ZC_CHECKCONSIGN_DETAIL B
                  WHERE B.CHECK_NO = A.CHECK_NO
                    AND B.BATCH_NO = A.BATCH_NO
                    AND B.PHY_CODE_MAX IN ('HX', 'ONH')
                    AND B.VALIDFLAG = '1') AND NOT EXISTS
                (SELECT 1
                   FROM QCM_ZC_CHECKCONSIGN_DETAIL B
                  WHERE B.CHECK_NO = A.CHECK_NO
                    AND B.BATCH_NO = A.BATCH_NO
                    AND B.PHY_CODE_MAX NOT IN ('HX', 'ONH')
                    AND B.VALIDFLAG = '1')
-- 										AND NOT EXISTS
--                 (SELECT 1
--                    FROM CRAFT_ORD_DESIGN_STD_CIC F
--                   WHERE F.DESGIN_KEY = E.DESGIN_KEY
--                     AND F.MSC_PLINE = A.INDEX_SEQ
--                     AND F.PROCESS_CODE = A.PROCESS_CODE
--                     AND F.CIC = A.CIC
--                     AND F.STDMEMO IS NOT NULL)
										OR NOT EXISTS
                (SELECT 1
                   FROM QCM_ZC_CHECKCONSIGN_DETAIL B
                  WHERE B.CHECK_NO = A.CHECK_NO
                    AND B.BATCH_NO = A.BATCH_NO
                    AND B.PHY_CODE_MAX IN ('HX', 'ONH')
                    AND B.VALIDFLAG = '1') AND EXISTS
                (SELECT 1
                   FROM QCM_ZC_CHECKCONSIGN_DETAIL B
                  WHERE B.CHECK_NO = A.CHECK_NO
                    AND B.BATCH_NO = A.BATCH_NO
                    AND B.PHY_CODE_MAX NOT IN ('HX', 'ONH')
                    AND B.VALIDFLAG = '1')
-- 										AND NOT EXISTS
--                 (SELECT 1
--                    FROM CRAFT_ORD_DESIGN_STD_PIC   G,
--                         QCM_ZC_CHECKCONSIGN_DETAIL B
--                   WHERE G.DESGIN_KEY = E.DESGIN_KEY
--                     AND G.MSC_PLINE = A.INDEX_SEQ
--                     AND G.PROCESS_CODE = A.PROCESS_CODE
--                     AND G.PIC = A.PIC
--                     AND G.STDMEMO IS NOT NULL
--                     AND B.CHECK_NO = A.CHECK_NO
--                     AND B.BATCH_NO = A.BATCH_NO
--                     AND B.PHY_CODE_MAX NOT IN ('HX', 'ONH')
--                     AND G.PHY_CODE_MIN = B.PHY_CODE_MAX
--                     AND B.VALIDFLAG = '1')
										)
         GROUP BY A.CHECK_NO)
 WHERE ROWNUM <= 50
		]]>
	</query>
	
	<query id="BcPhyJudgeTask.getMaxPhyJudgeId" desc="查询最大的理化判定记录号（自动判定位数为0）">
		<![CDATA[
SELECT NVL(SUBSTR(MAX(T.PHY_JUDGE_ID), 1, 13), TO_CHAR(SYSDATE, 'YYYYMMDD') || '00000') + 1  || '0' MAX_VALUE
  FROM QCM_BC_PHYJUDGE T
 WHERE T.PHY_JUDGE_ID LIKE TO_CHAR(SYSDATE, 'YYYYMMDD') || '%'
		]]>
	</query>
	
	<query id="BcPhyJudgeTask.QueryGroupSampleNoByBatchNo" desc="查询">
        <![CDATA[
SELECT T.SAMPLE_ID, T.JUDGE_STOVE_NO, T.BATCH_NO, T.SAMPLE_NO
  FROM QCM_JHY_PHYRESULT T, COM_BASE_PLINE A
 WHERE A.PLINE_CODE = T.PLINE_CODE
   AND A.PROCESS_CODE = {3}
   AND T.VALIDFLAG = '1'
   AND T.SAMPLE_ID = {0}
   AND T.JUDGE_STOVE_NO = {1}
   AND T.BATCH_NO = {2}
 GROUP BY T.SAMPLE_ID, T.JUDGE_STOVE_NO, T.BATCH_NO, T.SAMPLE_NO
        ]]>
    </query>
    
    <query id="BcPhyJudgeTask.InsertPhyJudge" desc="新增">
        <![CDATA[
INSERT INTO QCM_BC_PHYJUDGE
  (PHY_JUDGE_ID,
   STOVE_NO,
   JUDGE_STOVE_NO,
   OBJECTNO,
   PLINE_CODE,
   PROCESS_CDOE,
   PROCESS_DESC,
   JUDGERESULT_PHY,
   JUDGESTEELCODE,
   JUDGEGRADECODE,
   MEMO,
   PHY_RESULT_ID,
   CREATE_NAME,
   CREATE_TIME,
   JUGDE_APPLY_CODE,
   BATCH_NO,
   HEAT_PLAN_NO,
   DESIGN_KEY,
   MSC_PLINE,
   PIC,
   SAMPLE_NO,
   JUDGE_SEQ,
   PRO_PLAN_ID,
   SAMPLE_TYPE,
   MERGE_PHY_RESULT,
   JF_PHY_RESULT,
   ORD_LN_DLY_PK,
   CRAFT_SEQ,
   SAMPLE_ID,
   LOT_NO,
   CRAFT_SOURCE)
VALUES
  ('#PHY_JUDGE_ID#',
   '#STOVE_NO#',
   '#JUDGE_STOVE_NO#',
   '#OBJECTNO#',
   '#PLINE_CODE#',
   '#PROCESS_CDOE#',
   (SELECT A.PROCESS_DESC
      FROM COM_BASE_PROCESS A
     WHERE A.PROCESS_CODE = '#PROCESS_CDOE#'),
   '#JUDGERESULT_PHY#',
   '#JUDGESTEELCODE#',
   '#JUDGEGRADECODE#',
   '#MEMO#',
   '#PHY_RESULT_ID#',
   '#CREATE_NAME#',
   SYSDATE,
   '#JUGDE_APPLY_CODE#',
   '#BATCH_NO#',
   '#HEAT_PLAN_NO#',
   '#DESIGN_KEY#',
   '#MSC_PLINE#',
   '#PIC#',
   '#SAMPLE_NO#',
   '#JUDGE_SEQ#',
   '#PRO_PLAN_ID#',
   '#SAMPLE_TYPE#',
   '#MERGE_PHY_RESULT#',
   '#JF_PHY_RESULT#',
   '#ORD_LN_DLY_PK#',
   '#CRAFT_SEQ#',
   '#SAMPLE_ID#',
   '#LOT_NO#',
   '#CRAFT_SOURCE#')
        ]]>
    </query>
    
    <query id="BcPhyJudgeTask.udpateZgJudgeApplyCxFlag" desc="查询计划轧管表">
		<![CDATA[
UPDATE QCM_ZG_JUGDE_APPLY T
   SET T.PHY_RESULT_CODE = {3}
 WHERE T.JUDGE_STOVE_NO = {0}
 AND T.BATCH_NO = {1}
 AND T.PROCESS_CODE = {2}
 AND T.IS_FLAG = '0'
 AND T.IS_ALL_SCRAP = '0'
		]]>
	</query>
	
	<query id="BcPhyJudgeTask.updateQcmJhyPhy" desc="获取检化验理化信息">
		<![CDATA[
UPDATE QCM_JHY_PHYRESULT T
   SET T.JUDGE_FLAG = {3}
 WHERE T.JUDGE_STOVE_NO = {0}
   AND T.BATCH_NO = {1}
   AND EXISTS (SELECT 1
          FROM COM_BASE_PLINE A
         WHERE A.PLINE_CODE = T.PLINE_CODE
           AND A.PROCESS_CODE = {2})
		]]>
	</query>
	
	<query id="BcPhyJudgeTask.QueryByBatchNoSampleNo" desc="查询">
        <![CDATA[
SELECT T.SAMPLE_ID,
       T.SAMPLE_NO,
       T.INDEX_SEQ,
       T.LOT_NO,
       T.STOVE_NO,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.SAMPLE_TYPE,
       DECODE(T.SAMPLE_TYPE, '0', '初样', '1', '复样') SAMPLE_TYPE_DESC,
       T.CONSIGNER,
       T.PLINE_CODE,
       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.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,
       T.FOR_CHECK_NO,
       T.RATE,
       T.ORIGINAL_AREA,
       T.IS_GOOD,
       T.IS_DEFECT,
       T.CHECK_TEMP,
       T.HARDNESS_TYPE,
       T.PHY_CODE_DIR,
       T.PHY_NAME_DIR,
       T.SAMPLE_STYLE,
       T.SAMPLE_SIZE,
       T.REMARK
  FROM QCM_JHY_PHYRESULT T, COM_BASE_PLINE A, QCM_ZC_CHECKCONSIGN_DETAIL B
 WHERE A.PLINE_CODE = T.PLINE_CODE
   AND A.PROCESS_CODE = {0}
   AND T.SAMPLE_ID = {1}
   AND T.JUDGE_STOVE_NO = {2}
   AND T.BATCH_NO = {3}
   AND T.SAMPLE_NO = {4}
   AND B.CHECK_NO = T.SAMPLE_ID
   AND B.BATCH_NO = T.BATCH_NO
   AND B.SAMPLE_NO = T.SAMPLE_NO
   AND B.PHY_CODE_MAX = T.PHY_CODE_MIN
   AND B.VALIDFLAG = '1'
        ]]>
    </query>
    
    <query id="BcPhyJudgeTask.queryCraftPhy" desc="查询工艺评审理化记录">
		<![CDATA[
SELECT *
  FROM CRAFT_ORD_DESIGN_STD_PIC T
 WHERE T.DESGIN_KEY = {0}
   AND T.MSC_PLINE = {1}
   AND T.PIC = {2}
   AND T.PROCESS_CODE = {3}
		]]>
	</query>
	
	<query id="BcPhyJudgeTask.queryCraftJfPhy" desc="查询工艺评审交付理化记录">
		<![CDATA[
SELECT *
  FROM CRAFT_ORD_DESIGN_STD_PIC T
 WHERE T.DESGIN_KEY = {0}
   AND T.SPECL_FL = '0'
   AND NOT EXISTS (SELECT 1
          FROM CRAFT_ORD_DESIGN_STD_PIC A
         WHERE A.DESGIN_KEY = T.DESGIN_KEY
           AND A.SPECL_FL = '1'
           AND A.PHY_CODE = T.PHY_CODE
           AND A.ITEM_CODE_F = T.ITEM_CODE_F
           AND A.ITEM_CODE_W = T.ITEM_CODE_W
           AND A.ITEM_CODE_S = T.ITEM_CODE_S)
UNION ALL
SELECT *
  FROM CRAFT_ORD_DESIGN_STD_PIC T
 WHERE T.DESGIN_KEY = {0}
   AND T.SPECL_FL = '1'
		]]>
	</query>
	
	<query id="BcPhyJudgeTask.InsertPhyResult" 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="BcPhyJudgeTask.updatePhyJudgeValid" desc="修改理化判定记录的有效标志">
        <![CDATA[
UPDATE QCM_BC_PHYJUDGE T
   SET T.VALIDFLAG = {5}
 WHERE T.JUDGE_STOVE_NO = {0}
   AND T.BATCH_NO = {1}
   AND T.SAMPLE_NO = {2}
   AND T.SAMPLE_ID = {3}
   AND T.PROCESS_CDOE = {4}
        ]]>
    </query>
    
    <query id="BcPhyJudgeTask.setSampleType" desc="修改试样类型和合并成分结果">
		<![CDATA[
UPDATE QCM_BC_PHYJUDGE T
   SET T.SAMPLE_TYPE      = DECODE((SELECT COUNT(1)
                                     FROM QCM_BC_PHYJUDGE A
                                    WHERE A.PHY_JUDGE_ID = T.PHY_JUDGE_ID
                                      AND A.SAMPLE_NO LIKE '%F%'),
                                   0,
                                   '1',
                                   '2'),
       T.MERGE_PHY_RESULT = {1}
 WHERE T.PHY_JUDGE_ID = {0}
		]]>
	</query>
	
	<query id="BcPhyJudgeTask.queryCraftPhyByDlyLnPk" desc="通过交货行PK获取工艺评审理化">
		<![CDATA[
SELECT T.DESGIN_KEY,
       T.PIC,
       T.USE_CODE,
       T.USE_DESC,
       DECODE(T.SPECL_FL, '0', '1', T.SPECL_FL) SPECL_FL,
       T.INDEX_SEQ,
       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.GROUP_SEQ,
       T.ISCHECK,
       T.ISQUOTE,
       T.RESULT_COUNT,
       T.ISJUDGE,
       T.PHY_TYPE,
       T.PHY_FORMULA,
       T.STDMIN_SIGN,
       T.STDMIN,
       T.STDMAX_SIGN,
       T.STDMAX,
       CASE
         WHEN T.PHY_NAME LIKE '冲击功%' OR T.PHY_NAME LIKE '冲击值%' THEN
           'D'
         ELSE
           T.JUDGE_BASIS
       END JUDGE_BASIS,
       T.SPEC_JG,
       T.SPEC_JG_DESC,
       T.ADDCONDITION,
       T.ADDSTDCON_CODE,
       T.ADDSTD_MIN_SIGN,
       T.ADDSTD_MIN,
       T.ADDSTD_MAX_SIGN,
       T.ADDSTD_MAX,
       T.ADDPERCENT,
       T.STDMIN_SIGN2,
       T.STDMIN2,
       T.STDMAX_SIGN2,
       T.STDMAX2,
       T.STD_CHOOSE,
       T.MSC_PLINE,
       T.PROCESS_CODE
  FROM CRAFT_ORD_DESIGN_STD_PIC T, PLN_SALEORD B, CRAFT_ORD_DESIGN C
 WHERE B.ORD_LN_DLY_PK = {0}
   AND B.ORD_LN_PK = C.ORD_LN_PK
   AND C.CRAFT_SEQ = {1}
   AND T.DESGIN_KEY = C.DESGIN_KEY
   AND ({6} = '1' AND T.CRAFT_SOURCE = '2' OR {6} <> '1' AND T.MSC_PLINE = {2}
   AND T.PROCESS_CODE = {3}
   AND T.PIC = {4})
   AND ({5} IS NULL OR T.PHY_CODE_MIN = {5})
		]]>
	</query>
	
	<query id="BcPhyJudgeTask.getCraftJfPhyByDlyLnPk" desc="获取工艺评审成分">
		<![CDATA[
SELECT T.DESGIN_KEY,
       T.PIC,
       T.USE_CODE,
       T.USE_DESC,
       '1' SPECL_FL,
       T.INDEX_SEQ,
       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 ITEM_CODE_F,
       D2.ITEM_NAME ITEM_NAME_F,
       T.ITEM_CODE_W,
       T.ITEM_NAME_W,
       T.ITEM_CODE_s ITEM_CODE_S,
       D3.ITEM_NAME ITEM_NAME_S,
       T.GROUP_SEQ,
       T.ISCHECK,
       T.ISQUOTE,
       T.RESULT_COUNT,
       T.ISJUDGE,
       T.PHY_TYPE,
       T.PHY_FORMULA,
       T.STDMIN_SIGN,
       T.STDMIN,
       T.STDMAX_SIGN,
       T.STDMAX,
       CASE
         WHEN T.PHY_NAME LIKE '冲击功%' OR T.PHY_NAME LIKE '冲击值%' THEN
          'D'
         ELSE
          T.JUDGE_BASIS
       END JUDGE_BASIS,
       T.SPEC_JG,
       T.SPEC_JG_DESC,
       T.ADDCONDITION,
       T.ADDSTDCON_CODE,
       T.ADDSTD_MIN_SIGN,
       T.ADDSTD_MIN,
       T.ADDSTD_MAX_SIGN,
       T.ADDSTD_MAX,
       T.ADDPERCENT,
       T.STDMIN_SIGN2,
       T.STDMIN2,
       T.STDMAX_SIGN2,
       T.STDMAX2,
       T.STD_CHOOSE,
       T.MSC_PLINE,
       T.PROCESS_CODE
  FROM CRAFT_ORD_DESIGN_STD_PIC T
  LEFT JOIN COM_BASE_PHY_ITEM D2
    ON D2.ITEM_CODE = T.ITEM_CODE_F
  LEFT JOIN COM_BASE_PHY_ITEM D3
    ON D3.ITEM_CODE = T.ITEM_CODE_s, CRAFT_ORD_DESIGN C
 WHERE C.ORD_LN_PK = {0}
   AND C.CRAFT_SEQ = {1}
   AND C.DESGIN_KEY = T.DESGIN_KEY
   AND T.SPECL_FL = '0'
   AND NOT EXISTS
 (SELECT 1
          FROM CRAFT_ORD_DESIGN_STD_PIC A
         WHERE A.DESGIN_KEY = T.DESGIN_KEY
           AND A.SPECL_FL = '1'
           AND T.PHY_CODE_MAX = A.PHY_CODE_MAX
           AND T.PHY_CODE_MIN = A.PHY_CODE_MIN
           AND T.PHY_CODE = A.PHY_CODE
           AND NVL(T.ITEM_CODE_F, '1') = NVL(A.ITEM_CODE_F, '1')
           AND NVL(T.ITEM_CODE_W, '1') = NVL(A.ITEM_CODE_W, '1')
           AND NVL(T.ITEM_CODE_S, '1') = NVL(A.ITEM_CODE_S, '1'))
   AND ({2} IS NULL OR T.PHY_CODE_MIN = {2})
UNION ALL
SELECT T.DESGIN_KEY,
       T.PIC,
       T.USE_CODE,
       T.USE_DESC,
       T.SPECL_FL,
       T.INDEX_SEQ,
       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 ITEM_CODE_F,
       D2.ITEM_NAME ITEM_NAME_F,
       T.ITEM_CODE_W,
       T.ITEM_NAME_W,
       T.ITEM_CODE_s ITEM_CODE_S,
       D3.ITEM_NAME ITEM_NAME_S,
       T.GROUP_SEQ,
       T.ISCHECK,
       T.ISQUOTE,
       T.RESULT_COUNT,
       T.ISJUDGE,
       T.PHY_TYPE,
       T.PHY_FORMULA,
       T.STDMIN_SIGN,
       T.STDMIN,
       T.STDMAX_SIGN,
       T.STDMAX,
       CASE
         WHEN T.PHY_NAME LIKE '冲击功%' OR T.PHY_NAME LIKE '冲击值%' THEN
          'D'
         ELSE
          T.JUDGE_BASIS
       END JUDGE_BASIS,
       T.SPEC_JG,
       T.SPEC_JG_DESC,
       T.ADDCONDITION,
       T.ADDSTDCON_CODE,
       T.ADDSTD_MIN_SIGN,
       T.ADDSTD_MIN,
       T.ADDSTD_MAX_SIGN,
       T.ADDSTD_MAX,
       T.ADDPERCENT,
       T.STDMIN_SIGN2,
       T.STDMIN2,
       T.STDMAX_SIGN2,
       T.STDMAX2,
       T.STD_CHOOSE,
       T.MSC_PLINE,
       T.PROCESS_CODE
  FROM CRAFT_ORD_DESIGN_STD_PIC T
  LEFT JOIN COM_BASE_PHY_ITEM D2
    ON D2.ITEM_CODE = T.ITEM_CODE_F
  LEFT JOIN COM_BASE_PHY_ITEM D3
    ON D3.ITEM_CODE = T.ITEM_CODE_s, CRAFT_ORD_DESIGN C
 WHERE C.ORD_LN_PK = {0}
   AND C.CRAFT_SEQ = {1}
   AND T.DESGIN_KEY = C.DESGIN_KEY
   AND T.SPECL_FL = '1'
   AND ({2} IS NULL OR T.PHY_CODE_MIN = {2})
		]]>
	</query>
	
	<query id="BcPhyJudgeTask.getOrdLnPkForPln" desc="获取合同行PK值">
		<![CDATA[
	SELECT T.ORD_LN_PK FROM PLN_SALEORD T WHERE T.ORD_LN_DLY_PK = {0}
		]]>
	</query>
	
	<query id="BcPhyJudgeTask.getOrdLnPkByDlyPk" desc="获取合同行PK值">
		<![CDATA[
	SELECT T.ORD_LN_PK FROM SLM_ORDER_LINE_DELIVERY T WHERE T.ORD_LN_DLY_PK = {0}
		]]>
	</query>
	
	<query id="BcPhyJudgeTask.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="BcPhyJudgeTask.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="BcPhyJudgeTask.updateZcCheckResult" desc="修改委托表判定结果">
        <![CDATA[
UPDATE QCM_ZC_CHECKCONSIGN T
   SET T.PHY_RESULT_CODE   = {4},
       T.CHEM_RESULT_CODE  = {5},
       T.JUDGE_RESULT_CODE = {6},
       T.JUDGE_MAKER       = {7},
       T.JUDGE_TIME        = SYSDATE,
       T.JUDGE_MEMO        = {8},
       T.CHEM_JUDGE_ID     = {9},
       T.PHY_JUDGE_ID      = {10},
       T.VALIDFLAG         = {11},
       T.RESAMPLE = {12},
       T.IS_NO_SSC = {13}
 WHERE T.CHECK_NO = {0}
   AND T.JUDGE_STOVE_NO = {1}
   AND T.BATCH_NO = {2}
   AND T.PROCESS_CODE = {3}
        ]]>
    </query>
    
    <query id="BcPhyJudgeTask.updateJudgeFlagByBatchNo" desc="通过批号修改判定状态">
        <![CDATA[
UPDATE QCM_JHY_PHYRESULT T
   SET T.JUDGE_FLAG = {1}
 WHERE T.SAMPLE_ID = {0}
        ]]>
    </query>
	
	 <query id="BcPhyJudgeTask.setSampleType" desc="修改试样类型和合并成分结果">
		<![CDATA[
UPDATE QCM_BC_PHYJUDGE T
   SET T.SAMPLE_TYPE      = DECODE((SELECT COUNT(1)
                                     FROM QCM_BC_PHYJUDGE A
                                    WHERE A.PHY_JUDGE_ID = T.PHY_JUDGE_ID
                                      AND A.SAMPLE_NO LIKE '%F%'),
                                   0,
                                   '1',
                                   '2'),
       T.MERGE_PHY_RESULT = {1}
 WHERE T.PHY_JUDGE_ID = {0}
		]]>
	</query>
	
	<query id="BcPhyJudgeTask.updatePhyResultJudge" 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="BcPhyJudgeTask.getChemResultBySampleNo" desc="通过试样号获取成分">
		<![CDATA[
SELECT B.NK_QUALIFIED, B.JF_QUALIFIED
  FROM QCM_BC_CHEMJUDGE A, QCM_BC_CHEM_RESULT 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.CHEM_JUDGE_ID = A.CHEM_JUDGE_ID
   AND B.JUDGE_SEQ = A.JUDGE_SEQ
		]]>
	</query>
	
	<query id="BcPhyJudgeTask.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="BcPhyJudgeTask.setConsignDetailJudgeResult" 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="BcPhyJudgeTask.QueryPhyConsignDetaiByBatchNo" desc="查询">
        <![CDATA[
SELECT D.CHECK_NO SAMPLE_ID,
       E.SAMPLE_NO,
       C.PHY_CODE_MIN,
       C.PHY_NAME_MIN,
       CASE
         WHEN MIN(C.RATE) = '408603' AND MIN(C.ATTACH_PERCENT) IS NOT NULL THEN
          MIN(C.ATTACH_COUNT)
         ELSE
          SUM(C.DESC_COUNT * C.SAMPLE_COUNT)
       END DESC_COUNT,
       D.LOT_NO,
       MIN(D.LOT_NO_GROUP) LOT_NO_GROUP,
       D.JUDGE_STOVE_NO,
       D.BATCH_NO,
       MIN(C.PROCESS_CODE) PROCESS_CODE,
       MIN(C2.PROCESS_DESC) PROCESS_DESC,
       C.PIC,
       MIN(E.NK_RESULT) NK_RESULT,
       MIN(E.JF_RESULT) JF_RESULT,
       (SELECT LISTAGG(F.STDMEMO) WITHIN GROUP(ORDER BY F.PHY_NAME)
          FROM CRAFT_ORD_DESIGN_STD_PIC F
         WHERE F.DESGIN_KEY = B.DESGIN_KEY
           AND F.MSC_PLINE = {2}
           AND F.PROCESS_CODE = {3}
           AND F.PIC = C.PIC
           AND F.PHY_CODE_MIN = C.PHY_CODE_MIN) STDMEMO,
       MIN(E.MAT_NO) MAT_NO,
       MIN(E.HEAD_MAT_NO) HEAD_MAT_NO,
       MIN(E.BAR_CODE) BAR_CODE,
       MIN(C.DESC_RATE) DESC_RATE,
       MIN(C.RATE) RATE,
       MIN(E.RESULT_SOURCE) RESULT_SOURCE,
       MIN(D.APPLY_RESAMPLE) APPLY_RESAMPLE,
       MIN(D.CYCLES_FLAG) CYCLES_FLAG,
       'False' CHK,
       MIN(E.OLD_JUDGE_STOVE_NO) OLD_JUDGE_STOVE_NO,
       MIN(E.OLD_BATCH_NO) OLD_BATCH_NO,
       DECODE(MIN(E.IS_MAIN), '0', '否', '是') IS_MAIN,
       DECODE(MIN(C.CRAFT_SOURCE), '2', '1', '0') CRAFT_SOURCE,
       DECODE(MIN(C.CRAFT_SOURCE), '2', '首日检', '生产样') CRAFT_SOURCE_DESC
  FROM PLN_SALEORD A, CRAFT_ORD_DESIGN B, CRAFT_ORD_DESIGN_STD_PIC_SMP C
  LEFT JOIN QCM_ZC_CHECKCONSIGN_DETAIL E
    ON EXISTS (SELECT 1
          FROM QCM_ZC_CHECKCONSIGN E2, PLN_SALEORD E3, PLN_SALEORD E4
          WHERE ({9} = '1' OR C.RATE IN ('408601', '408608')
               AND ( C.LOOP_VALUE = '0' or E2.LOT_NO = {7})
               AND ( C.LOOP_VALUE = '0' or ({8} IS NULL OR E2.LOT_NO_GROUP = {8}) )
               AND E2.CHECK_NO NOT LIKE '%P%'
               OR C.RATE = '408603' AND E2.JUDGE_STOVE_NO = {5}
               OR E2.JUDGE_STOVE_NO = {5} AND E2.BATCH_NO = {6})
           AND E2.PROCESS_CODE = {3}
           AND E3.ORD_LN_DLY_PK = E2.ORD_LN_DLY_PK
           AND E3.ORD_LN_PK = E4.ORD_LN_PK
           AND E4.ORD_LN_DLY_PK = {0}
           AND ({15} IS NULL OR {15} = '0' AND EXISTS
                (SELECT 1
                   FROM QCM_GP_JUDGE_APPLY E5
                  WHERE E5.STOVE_NO = E2.STOVE_NO
                    AND E5.IS_FLAG = '0'
                    AND E5.PLINE_CODE NOT IN ('C063', 'C064')) OR
                {15} = '1' AND EXISTS
                (SELECT 1
                   FROM QCM_GP_JUDGE_APPLY E5
                  WHERE E5.STOVE_NO = E2.STOVE_NO
                    AND E5.IS_FLAG = '0'
                    AND E5.PLINE_CODE IN ('C063', 'C064')))
           AND E2.CRAFT_SOURCE = {9}
           AND E2.IS_FLAG = '0'
           AND E2.CYCLES_FLAG = {13}
           AND E2.PLINE_CODE = {14}
           AND E.CHECK_NO = E2.CHECK_NO
           AND E.BATCH_NO = E2.BATCH_NO)
   AND E.PHY_CODE_MAX = C.PHY_CODE_MIN
   AND E.VALIDFLAG = '1'
   AND ({12} IS NULL OR E.IS_MAIN = {12})
  LEFT JOIN QCM_ZC_CHECKCONSIGN D
    ON D.CHECK_NO = E.CHECK_NO
   AND D.BATCH_NO = E.BATCH_NO
  LEFT JOIN COM_BASE_PROCESS C2
    ON C2.PROCESS_CODE = C.PROCESS_CODE
 WHERE A.ORD_LN_DLY_PK = {0}
   AND B.ORD_LN_PK = A.ORD_LN_PK
   AND B.CRAFT_SEQ = {1}
   AND C.DESGIN_KEY = B.DESGIN_KEY
   AND ({9} = '1' AND C.CRAFT_SOURCE = '2' AND C.PROCESS_CODE = {3} OR {9} = '0' AND
       C.MSC_PLINE = {2} AND C.PROCESS_CODE = {3} AND C.PIC = {4})
   AND ({10} = '0' OR C.PHY_CODE_MIN IN {11})
 GROUP BY D.LOT_NO,
          D.CHECK_NO,
          D.JUDGE_STOVE_NO,
          D.BATCH_NO,
          E.SAMPLE_NO,
          C.PHY_CODE_MIN,
          C.PHY_NAME_MIN,
          B.DESGIN_KEY,
          C.PIC
 ORDER BY D.JUDGE_STOVE_NO, D.BATCH_NO, C.PHY_NAME_MIN, E.SAMPLE_NO
        ]]>
    </query>
    
    <query id="BcPhyJudgeTask.getChemConsignDetaiByBatchNo" desc="通过炉批查询成分信息">
		<![CDATA[
SELECT C.CHECK_NO SAMPLE_ID,
       D.SAMPLE_NO,
       'HX' PHY_CODE_MIN,
       '化学' PHY_NAME_MIN,
       DECODE(B3.PRODUCT_CNT_N, NULL, B3.PRODUCT_CNT, B3.PRODUCT_CNT_N) DESC_COUNT,
       C.LOT_NO,
       C.JUDGE_STOVE_NO,
       C.BATCH_NO,
       C.PROCESS_CODE,
       B2.PROCESS_DESC,
       {5} PIC,
       CASE
         WHEN D.NK_RESULT IS NULL OR
              D2.CHECK_NO IS NOT NULL AND D2.NK_RESULT IS NULL THEN
          NULL
         WHEN D.NK_RESULT = '0' OR
              D2.CHECK_NO IS NOT NULL AND D2.NK_RESULT = '0' THEN
          '0'
         ELSE
          '1'
       END NK_RESULT,
       CASE
         WHEN D.JF_RESULT IS NULL OR
              D2.CHECK_NO IS NOT NULL AND D2.JF_RESULT IS NULL THEN
          NULL
         WHEN D.JF_RESULT = '0' OR
              D2.CHECK_NO IS NOT NULL AND D2.JF_RESULT = '0' THEN
          '0'
         ELSE
          '1'
       END JF_RESULT,
       D.MAT_NO,
       D.HEAD_MAT_NO,
       D.BAR_CODE,
       '炉' DESC_RATE,
       D.RESULT_SOURCE,
       C.APPLY_RESAMPLE,
       C.CYCLES_FLAG,
       'False' CHK,
       D.OLD_JUDGE_STOVE_NO,
       D.OLD_BATCH_NO,
       DECODE(D.IS_MAIN, '0', '否', '是') IS_MAIN,
       C.CRAFT_SOURCE,
       DECODE(C.CRAFT_SOURCE, '1', '首日检', '生产样') CRAFT_SOURCE_DESC
  FROM PLN_SALEORD A, CRAFT_ORD_DESIGN B
  LEFT JOIN QCM_ZC_CHECKCONSIGN_DETAIL D
    ON EXISTS (SELECT 1
          FROM QCM_ZC_CHECKCONSIGN D3, PLN_SALEORD D4, PLN_SALEORD D5
         WHERE ({6} = '1' OR D3.JUDGE_STOVE_NO = {2}
           AND ({7} = '408603' OR D3.BATCH_NO = {3}))
           AND D3.PROCESS_CODE = {4}
           AND D3.CRAFT_SOURCE = {6}
           AND D3.ORD_LN_DLY_PK = D4.ORD_LN_DLY_PK
           AND D4.ORD_LN_PK = D5.ORD_LN_PK
           AND D5.ORD_LN_DLY_PK = {0}
           AND ({9} IS NULL OR {9} = '0' AND EXISTS
                (SELECT 1
                   FROM QCM_GP_JUDGE_APPLY D6
                  WHERE D6.STOVE_NO = D3.STOVE_NO
                    AND D6.IS_FLAG = '0'
                    AND D6.PLINE_CODE NOT IN ('C063', 'C064')) OR
                {9} = '1' AND EXISTS
                (SELECT 1
                   FROM QCM_GP_JUDGE_APPLY D6
                  WHERE D6.STOVE_NO = D3.STOVE_NO
                    AND D6.IS_FLAG = '0'
                    AND D6.PLINE_CODE IN ('C063', 'C064')))
           AND D3.IS_FLAG = '0'
           AND D3.CYCLES_FLAG = '0'
           AND D3.PLINE_CODE = {8}
           and D.CHECK_NO = D3.CHECK_NO
           AND D.BATCH_NO = D3.BATCH_NO)
   AND D.PHY_CODE_MAX = 'HX'
   AND D.VALIDFLAG = '1'
  LEFT JOIN QCM_ZC_CHECKCONSIGN_DETAIL D2
    ON D.CHECK_NO IS NOT NULL
   AND D2.CHECK_NO = D.CHECK_NO
   AND D2.BATCH_NO = D.BATCH_NO
   AND D2.SAMPLE_NO = D.SAMPLE_NO
   AND D2.PHY_CODE_MAX = 'ONH'
   AND D2.VALIDFLAG = '1'
  LEFT JOIN QCM_ZC_CHECKCONSIGN C
    ON D.CHECK_NO IS NOT NULL
   AND C.CHECK_NO = D.CHECK_NO
   AND C.BATCH_NO = D.BATCH_NO
  LEFT JOIN COM_BASE_PROCESS B2
    ON B2.PROCESS_CODE = {4}
  LEFT JOIN CRAFT_ORD_DESIGN_STD B3
    ON B3.DESGIN_KEY = B.DESGIN_KEY
 WHERE A.ORD_LN_DLY_PK = {0}
   AND B.ORD_LN_PK = A.ORD_LN_PK
   AND B.CRAFT_SEQ = {1}
		]]>
	</query>
	
	<query id="BcPhyJudgeTask.getBcBatchResultByBatchNo" desc="通过批号查询">
		<![CDATA[
SELECT *
  FROM QCM_BC_BATCH_RESULT T
 WHERE T.JUDGE_STOVE_NO = {0}
   AND T.BATCH_NO = {1}
   AND T.PROCESS_CODE = {2}
   AND T.CRAFT_SOURCE = {3}
		]]>
	</query>
	
	<query id="BcPhyJudgeTask.insertBcBatchResult" desc="新增炉批结果表">
		<![CDATA[
INSERT INTO QCM_BC_BATCH_RESULT
  (JUDGE_STOVE_NO,
   BATCH_NO,
   PROCESS_CODE,
   CRAFT_SOURCE,
   CHEM_RESULT_CODE,
   PHY_RESULT_CODE,
   JUDGE_RESULT_CODE,
   IS_NO_SSC,
   CHECK_NO_S,
   IS_NO_HIC,
   JUDGE_TIME,
   JUDGE_MAKER,
   ORD_LN_DLY_PK)
VALUES
  ('#JUDGE_STOVE_NO#',
   '#BATCH_NO#',
   '#PROCESS_CODE#',
   '#CRAFT_SOURCE#',
   '#CHEM_RESULT_CODE#',
   '#PHY_RESULT_CODE#',
   '#JUDGE_RESULT_CODE#',
   '#IS_NO_SSC#',
   '#CHECK_NO_S#',
   '#IS_NO_HIC#',
   SYSDATE,
   '#JUDGE_MAKER#',
   '#ORD_LN_DLY_PK#')
		]]>
	</query>
	
	<query id="BcPhyJudgeTask.updateBcBatchResult" desc="修改炉批结果表">
		<![CDATA[
UPDATE QCM_BC_BATCH_RESULT
   SET CHEM_RESULT_CODE  = '#CHEM_RESULT_CODE#',
       PHY_RESULT_CODE   = '#PHY_RESULT_CODE#',
       JUDGE_RESULT_CODE = '#JUDGE_RESULT_CODE#',
       IS_NO_SSC         = '#IS_NO_SSC#',
       CHECK_NO_S        = '#CHECK_NO_S#',
       IS_NO_HIC = '#IS_NO_HIC#',
       JUDGE_TIME = SYSDATE,
       JUDGE_MAKER = '#JUDGE_MAKER#'
 WHERE JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
   AND BATCH_NO = '#BATCH_NO#'
   AND PROCESS_CODE = '#PROCESS_CODE#'
   AND CRAFT_SOURCE = '#CRAFT_SOURCE#'
   AND ORD_LN_DLY_PK = '#ORD_LN_DLY_PK#'
		]]>
	</query>
	
	<query id="BcPhyJudgeTask.queryConsignAllByCheckNo" desc="查询委托表">
        <![CDATA[
SELECT T.*
  FROM QCM_ZC_CHECKCONSIGN T
 WHERE T.CHECK_NO = {0}
   AND T.IS_FLAG = '0'
        ]]>
    </query>
    
    <query id="BcPhyJudgeTask.QueryGroupSampleNoByCheckNo" desc="查询">
        <![CDATA[
SELECT A.CHECK_NO, A.JUDGE_STOVE_NO, A.BATCH_NO, B.SAMPLE_NO
  FROM QCM_ZC_CHECKCONSIGN A, QCM_ZC_CHECKCONSIGN_DETAIL B
 WHERE A.CHECK_NO = {0}
   AND A.JUDGE_STOVE_NO = {1}
   AND A.BATCH_NO = {2}
   AND A.PROCESS_CODE = {3}
   AND A.IS_FLAG = '0'
   AND B.CHECK_NO = A.CHECK_NO
   AND B.BATCH_NO = A.BATCH_NO
   AND B.VALIDFLAG = '1'
   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="BcPhyJudgeTask.queryJhyElementAllByCheckNo" desc="通过检验编号查询所有检验记录">
		<![CDATA[
SELECT A.ASSAYNO,
       A.STOVE_NO,
       A.JUDGE_STOVE_NO,
       A.BATCH_NO,
       A.ASSAYTYPE,
       A.FLAG,
       A.C,
       A.SI,
       A.MN,
       A.P,
       A.S,
       A.NI,
       A.CR,
       A.MO,
       A.CU,
       A.AL,
       A.CA,
       A.V,
       A.NB,
       A.TI,
       A.B,
       A.PB,
       A.SN,
       A.ASN,
       A.SB,
       A.BI,
       A.O,
       A.N,
       A.H,
       A.ZR,
       A.W,
       A.ZN,
       A.ALS,
       A.ALT,
       A.SE,
       A.CO,
       A.SAMPLE_ID,
       A.XH,
       A.MACHINE,
       A.CREATE_NAME,
       A.CREATE_TIME,
       A.UPDATE_NAME,
       A.UPDATE_TIME,
       A.DELETE_NAME,
       A.DELETE_TIME,
       A.VALIDFLAG,
       A.MEMO,
       A.SAMPLE_NO,
       A.PLINE_CODE
  FROM QCM_JHY_ELEMENTS A, COM_BASE_PLINE C
 WHERE A.PLINE_CODE = C.PLINE_CODE
   AND C.PROCESS_CODE = {3}
   AND A.VALIDFLAG = '1'
   AND A.ASSAYTYPE = 'B'
   AND A.SAMPLE_ID = {0}
   AND A.JUDGE_STOVE_NO = {1}
   AND A.BATCH_NO = {2}
		]]>
	</query>
	
	<query id="BcPhyJudgeTask.QueryJudgeApplyByBatchNo" desc="通过批号查询">
        <![CDATA[
SELECT *
  FROM QCM_ZG_JUGDE_APPLY T
 WHERE T.JUDGE_STOVE_NO = {0}
   AND T.BATCH_NO = {1}
   AND PROCESS_CODE = {2}
   AND T.IS_FLAG = '0'
   AND T.IS_ALL_SCRAP = '0'
        ]]>
    </query>
    
    <query id="BcPhyJudgeTask.updateConsignResult" desc="修改委托表判定结果">
        <![CDATA[
UPDATE QCM_ZC_CHECKCONSIGN T
   SET T.PHY_RESULT_CODE   = {4},
       T.CHEM_RESULT_CODE  = {5},
       T.JUDGE_RESULT_CODE = {6},
       T.JUDGE_MAKER       = {7},
       T.JUDGE_TIME        = SYSDATE,
       T.JUDGE_MEMO        = {8},
       T.CHEM_JUDGE_ID     = NVL({9}, T.CHEM_JUDGE_ID),
       T.PHY_JUDGE_ID      = NVL({10}, PHY_JUDGE_ID),
       T.VALIDFLAG         = {11},
       T.RESAMPLE = {12},
       T.IS_NO_SSC = {13},
       T.IS_NO_HIC = {14}
 WHERE T.CHECK_NO = {0}
   AND T.JUDGE_STOVE_NO = {1}
   AND T.BATCH_NO = {2}
   AND T.PROCESS_CODE = {3}
        ]]>
    </query>
    
    <query id="BcPhyJudgeTask.updateConsignFirstDate" desc="修改委托表判定结果">
        <![CDATA[
			UPDATE QCM_ZC_CHECKCONSIGN T
			   SET T.FIRST_JUDGE_DATE        = SYSDATE
			 WHERE T.CHECK_NO = {0}
			   AND T.JUDGE_STOVE_NO = {1}
			   AND T.BATCH_NO = {2}
			   AND T.PROCESS_CODE = {3}
			   AND T.FIRST_JUDGE_DATE IS NULL
        ]]>
    </query>
    
   <query id="BcPhyJudgeTask.updatePipeFlag" desc="修改委托表判定结果">
        <![CDATA[
		UPDATE PIPE_CHECKCONSIGN_BASEINFO T
		   SET T.OK_FLAG = {0}
		 WHERE T.CHECK_NO = {1}
        ]]>
    </query>
    
    <query id="BcPhyJudgeTask.isLxPhy" desc="修改委托表判定结果">
        <![CDATA[
		SELECT COUNT(1) from COM_BASE_PHY_C t WHERE T.PHY_CODE=? AND T.PHY_DEPTNAME LIKE '%力学%'
        ]]>
    </query>
	
	<query id="BcPhyJudgeTask.getConsignDetail" desc="通过检验编号查询试样组结果">
        <![CDATA[
SELECT T.*,
       (SELECT LISTAGG(D2.STDMEMO) WITHIN GROUP(ORDER BY D2.PHY_NAME)
          FROM CRAFT_ORD_DESIGN_STD_PIC D2
         WHERE D2.DESGIN_KEY = A5.DESGIN_KEY
           AND D2.MSC_PLINE = T.MSC_PLINE
           AND D2.PROCESS_CODE = T.PROCESS_CODE
           AND D2.PIC = T.PIC
           AND D2.PHY_CODE_MIN = T.PHY_CODE_MIN) STDMEMO,
       'False' CHK
  FROM (SELECT A.CHECK_NO,
               A.CHECK_NO SAMPLE_ID,
               B.JUDGE_STOVE_NO,
               A.BATCH_NO,
               A.SAMPLE_NO,
               A.PHY_NAME_MAX PHY_NAME_MIN,
               A.PHY_CODE_MAX PHY_CODE_MIN,
               A.PHY_CODE_MAX,
               DECODE(A.PHY_CODE_MAX, 'HX', '炉', A.DESC_RATE) DESC_RATE,
               A.RESULT_SOURCE,
               A.MAT_NO,
               A.HEAD_MAT_NO,
               A.BAR_CODE,
               B.APPLY_RESAMPLE,
               B.CYCLES_FLAG,
               B.LOT_NO,
               B2.PROCESS_DESC,
               B.PROCESS_CODE,
               DECODE(A.PHY_CODE_MAX, 'HX', B.CIC, B.PIC) PIC,
               B.ORD_LN_DLY_PK,
               B.CRAFT_SEQ,
               B.INDEX_SEQ MSC_PLINE,
               B.CIC,
               CASE
                 WHEN A.NK_RESULT IS NULL OR A2.CHECK_NO IS NOT NULL AND A2.NK_RESULT IS NULL THEN
                  NULL
                 WHEN A.NK_RESULT = '0' OR A2.CHECK_NO IS NOT NULL AND A2.NK_RESULT = '0' THEN
                  '0'
                 ELSE
                  '1'
               END NK_RESULT,
               CASE
                 WHEN A.JF_RESULT IS NULL OR A2.CHECK_NO IS NOT NULL AND A2.JF_RESULT IS NULL THEN
                  NULL
                 WHEN A.JF_RESULT = '0' OR A2.CHECK_NO IS NOT NULL AND A2.JF_RESULT = '0' THEN
                  '0'
                 ELSE
                  '1'
               END JF_RESULT
          FROM QCM_ZC_CHECKCONSIGN_DETAIL A
          LEFT JOIN QCM_ZC_CHECKCONSIGN_DETAIL A2
            ON A2.CHECK_NO = A.CHECK_NO
           AND A2.BATCH_NO = A.BATCH_NO
           AND A2.SAMPLE_NO = A.SAMPLE_NO
           AND A2.PHY_CODE_MAX = 'ONH'
           AND A2.VALIDFLAG = '1'
           AND A.PHY_CODE_MAX = 'HX', QCM_ZC_CHECKCONSIGN B
          LEFT JOIN COM_BASE_PROCESS B2
            ON B2.PROCESS_CODE = B.PROCESS_CODE
         WHERE A.CHECK_NO = {0}
           AND A.CHECK_NO = B.CHECK_NO
           AND A.BATCH_NO = B.BATCH_NO
           AND A.PHY_CODE_MAX <> 'ONH'
           AND A.VALIDFLAG = '1') T
  LEFT JOIN QCM_BC_PHYJUDGE A2
    ON A2.SAMPLE_ID = T.CHECK_NO
   AND A2.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
   AND A2.BATCH_NO = T.BATCH_NO
   AND A2.SAMPLE_NO = T.SAMPLE_NO
   AND A2.VALIDFLAG = '1'
  LEFT JOIN PLN_SALEORD A4
    ON A4.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
  LEFT JOIN CRAFT_ORD_DESIGN A5
    ON A5.ORD_LN_PK = A4.ORD_LN_PK
   AND A5.CRAFT_SEQ = T.CRAFT_SEQ
 ORDER BY T.BATCH_NO, T.PHY_NAME_MIN, T.SAMPLE_NO
        ]]>
    </query>
    
    <query id="BcPhyJudgeTask.getCraftPhyCnt" desc="查询工艺理化数">
        <![CDATA[
SELECT COUNT(1) COUNT
  FROM CRAFT_ORD_DESIGN_STD_PIC T, PLN_SALEORD B, CRAFT_ORD_DESIGN C
 WHERE B.ORD_LN_DLY_PK = {0}
   AND B.ORD_LN_PK = C.ORD_LN_PK
   AND C.CRAFT_SEQ = {1}
   AND T.DESGIN_KEY = C.DESGIN_KEY
   AND ({3} = '1' AND T.CRAFT_SOURCE = '2' OR
       {3} <> '1' AND T.CRAFT_SOURCE = '0' AND T.PROCESS_CODE = {2}
       AND T.MSC_PLINE = {4})
        ]]>
    </query>
    
    <query id="BcPhyJudgeTask.getCraftChemCnt" desc="查询工艺成分数">
        <![CDATA[
SELECT SUM(CNT) COUNT
  FROM (SELECT COUNT(1) CNT
          FROM CRAFT_ORD_DESIGN_STD_CIC T,
               PLN_SALEORD B,
               CRAFT_ORD_DESIGN C,
               (SELECT MAX(D.PROCESS_CODE) PROCESS_CODE
                  FROM PLN_SALEORD                 B2,
                       CRAFT_ORD_DESIGN            C2,
                       CRAFT_ORD_DESIGN_MSC_PL_STI D
                 WHERE B2.ORD_LN_DLY_PK = {0}
                   AND C2.ORD_LN_PK = B2.ORD_LN_PK
                   AND C2.CRAFT_SEQ = {1}
                   AND D.DESGIN_KEY = C2.DESGIN_KEY
                   AND D.STATION_TYPE = '403202'
                   AND D.MSC_PLINE = {3}) D2
         WHERE B.ORD_LN_DLY_PK = {0}
           AND B.ORD_LN_PK = C.ORD_LN_PK
           AND C.CRAFT_SEQ = {1}
           AND T.DESGIN_KEY = C.DESGIN_KEY
           AND ({2} IS NULL OR {2} = '1')
           AND T.CRAFT_SOURCE = '2'
           AND D2.PROCESS_CODE = {4}
        UNION ALL
        SELECT COUNT(1)
          FROM CRAFT_ORD_DESIGN_MSC_PL_STI T,
               PLN_SALEORD                 B,
               CRAFT_ORD_DESIGN            C
         WHERE B.ORD_LN_DLY_PK = {0}
           AND B.ORD_LN_PK = C.ORD_LN_PK
           AND C.CRAFT_SEQ = {1}
           AND T.DESGIN_KEY = C.DESGIN_KEY
           AND ({2} IS NULL OR {2} <> '1')
           AND T.MSC_PLINE = {3}
           AND T.PROCESS_CODE = {4}
           AND T.STATION_TYPE = '403201')
        ]]>
    </query>
    
    <query id="BcPhyJudgeTask.getProductCnt" desc="获取成品成分套数">
		<![CDATA[
SELECT NVL(DECODE(T.PRODUCT_CNT_N, NULL, T.PRODUCT_CNT, T.PRODUCT_CNT_N), 1) PRODUCT_CNT_N,
       NVL(DECODE(T.RATE_N, NULL, T.RATE, T.RATE_N), '408603') RATE_N
  FROM CRAFT_ORD_DESIGN_STD T, PLN_SALEORD B, CRAFT_ORD_DESIGN C
 WHERE B.ORD_LN_DLY_PK = {0}
   AND B.ORD_LN_PK = C.ORD_LN_PK
   AND C.CRAFT_SEQ = {1}
   AND T.DESGIN_KEY = C.DESGIN_KEY
   AND {2} = '0'
UNION ALL
SELECT T.PRODUCT_CNT_FD, T.RATE_FD
  FROM CRAFT_ORD_FD_CIC_COUNT T, PLN_SALEORD B
 WHERE B.ORD_LN_DLY_PK = {0}
   AND B.ORD_LN_PK = T.ORD_LN_PK
   AND {2} = '1'
		]]>
	</query>
    
    <query id="BcPhyJudgeTask.getConsignDetailByBatchNo" desc="通过批号获取委托二层表">
		<![CDATA[
SELECT T.*
  FROM QCM_ZC_CHECKCONSIGN_DETAIL T
 WHERE T.CHECK_NO = {0}
   AND T.BATCH_NO = {1}
		]]>
	</query>
	
	<query id="BcPhyJudgeTask.getConsignByLotNo" desc="通过生产批号查询">
        <![CDATA[
SELECT *
  FROM QCM_ZC_CHECKCONSIGN T2
 WHERE T2.CHECK_NO IN
       (SELECT MIN(T.CHECK_NO)
          FROM QCM_ZC_CHECKCONSIGN T
         WHERE T.LOT_NO = {0}
           AND ({1} IS NULL OR T.LOT_NO_GROUP = {1})
           AND T.CRAFT_SOURCE = {2}
           AND T.PROCESS_CODE = {3}
         GROUP BY T.JUDGE_STOVE_NO, T.BATCH_NO, T.ORD_LN_DLY_PK)
        ]]>
    </query>

	<query id="JdgCraftOrdDesignStdPicSmp.getRate" desc="获取取样频率">
		<![CDATA[
SELECT C.PHY_CODE_MIN,
       MIN(C.DESC_RATE) DESC_RATE,
       MIN(C.RATE) RATE,
       MIN(C.ATTACH_PERCENT) ATTACH_PERCENT,
       MIN(C.ATTACH_COUNT) ATTACH_COUNT,
       MIN(C.PIC) PIC,
       NVL(MIN(C.DESC_COUNT), 0) DESC_COUNT,
       NVL(MIN(C.SAMPLE_COUNT), 0) SAMPLE_COUNT,
       MIN(C.PHY_NAME_MIN) PHY_NAME_MIN,
       MIN(C.PHY_CODE_MIN) PHY_CODE_MAX,
       MIN(C.PHY_NAME_MIN) PHY_NAME_MAX,
       MIN(C.LOOP_VALUE) LOOP_VALUE
  FROM CRAFT_ORD_DESIGN B, CRAFT_ORD_DESIGN_STD_PIC_SMP C
  LEFT JOIN COM_BASE_PHY_C D
    ON D.PHY_CODE = C.PHY_CODE_MIN
 WHERE B.CRAFT_SEQ = {1}
   AND B.ORD_LN_PK = {0}
   AND C.DESGIN_KEY = B.DESGIN_KEY
   AND C.MSC_PLINE = {2}
   AND C.PROCESS_CODE = {3}
   AND C.PIC = {4}
 GROUP BY C.PHY_CODE_MIN
		]]>
	</query>

    <query id="BcPhyJudgeTask.getConsignByJudgeStoveNo" desc="通过判定炉号号查询">
        <![CDATA[
SELECT *
  FROM QCM_ZC_CHECKCONSIGN T2
 WHERE T2.CHECK_NO IN
       (SELECT MIN(T.CHECK_NO) CHECK_NO
          FROM QCM_ZC_CHECKCONSIGN T
         WHERE T.JUDGE_STOVE_NO = {0}
           AND T.CRAFT_SOURCE = {1}
           AND T.PROCESS_CODE = {2}
         GROUP BY T.BATCH_NO, T.ORD_LN_DLY_PK)
        ]]>
    </query>
    
    <query id="BcPhyJudgeTask.getConsignByOrdLnDlyPkPline" desc="通过合同号、产线查询">
        <![CDATA[
SELECT *
  FROM QCM_ZC_CHECKCONSIGN T2
 WHERE T2.CHECK_NO IN
       (SELECT MIN(T.CHECK_NO)
          FROM QCM_ZC_CHECKCONSIGN T, PLN_SALEORD A, PLN_SALEORD A2
         WHERE T.PLINE_CODE = {1}
           AND T.CRAFT_SOURCE = {2}
           AND T.PROCESS_CODE = {3}
           AND A.ORD_LN_DLY_PK = {0}
           AND A2.ORD_LN_PK = A.ORD_LN_PK
           AND T.ORD_LN_DLY_PK = A2.ORD_LN_DLY_PK
         GROUP BY T.LOT_NO, T.JUDGE_STOVE_NO, T.BATCH_NO, T.ORD_LN_DLY_PK)
        ]]>
    </query>
    
    <query id="BcPhyJudgeTask.getGpApplyPlineByStoveNo" desc="通过熔炼炉号查询产线">
        <![CDATA[
SELECT T.PLINE_CODE
  FROM QCM_GP_JUDGE_APPLY T
 WHERE T.STOVE_NO = {0}
   AND T.IS_FLAG = '0'
   AND ROWNUM <= 1
        ]]>
    </query>
</queryMap>