<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="同步检化验成品成分到质量成分">
	<query id="SteelMakingAdvanceJudgeTask.getJhyElementStoveNo" desc="检化验成分数据">
		<![CDATA[
SELECT DISTINCT STOVE_NO
  FROM (SELECT A.STOVE_NO
          FROM QCM_JHY_ELEMENTS A, STL_INCISION B
         WHERE A.SAMPLE_NO IN
               ('601', '602', '601F1', '601F2', '602F1', '602F2')
           AND A.VALIDFLAG = '1'
           AND A.ASSAYTYPE = 'A'
           AND A.LG_JUDGE_FLAG = '00'
           AND B.STOVE_NO = A.STOVE_NO
           AND B.PRO_PLAN_ID IS NOT NULL
        UNION
        SELECT A.STOVE_NO
          FROM QCM_JHY_ELEMENTS A, QCM_GP_JUDGE_APPLY c
         WHERE A.SAMPLE_NO IN
               ('601', '602', '601F1', '601F2', '602F1', '602F2')
           AND A.VALIDFLAG = '1'
           AND A.ASSAYTYPE = 'A'
           AND A.LG_JUDGE_FLAG = '00'
           and C.STOVE_NO = A.STOVE_NO
           AND C.IS_FLAG = '0'
           AND (C.PLINE_CODE IN ('C063', 'C064') OR C.LK_FLAG = '1' OR
               C.GPTYPE = '2' OR
               C.OLD_GRADECODE IS NOT NULL AND C.OLD_CIC IS NOT NULL)
           AND (C.PRO_PLAN_ID_NEXT IS NOT NULL OR C.PRO_PLAN_ID IS NOT NULL))
 WHERE ROWNUM <= 50
		]]>
	</query>
	
	<query id="SteelMakingAdvanceJudgeTask.getJhyElements" 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.TA,
       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
 WHERE A.SAMPLE_NO LIKE '60%'
   AND A.VALIDFLAG = '1'
   AND A.ASSAYTYPE = 'A'
   AND A.STOVE_NO = {0}
   AND (A.SAMPLE_NO LIKE {1} || 'F%' OR A.SAMPLE_NO = {1} AND NOT EXISTS
        (SELECT 1
           FROM QCM_JHY_ELEMENTS B
          WHERE B.STOVE_NO = A.STOVE_NO
            AND B.VALIDFLAG = '1'
            AND B.ASSAYTYPE = 'A'
            AND B.SAMPLE_NO LIKE {1} || 'F%'))
		]]>
	</query>
	
	<query id="SteelMakingAdvanceJudgeTask.getStlJudgeStoveNo" desc="获取切割表中的判定炉号">
		<![CDATA[
SELECT *
  FROM (SELECT A.STOVE_NO, A.JUDGE_STOVE_NO
          FROM STL_INCISION A, QCM_JHY_ELEMENTS B
         WHERE (EXISTS (SELECT 1
                          FROM STL_INCISION C
                         WHERE A.JUDGE_STOVE_NO = C.JUDGE_STOVE_NO
                           AND C.JUDGE_FLAG = '00'
                           AND C.PRO_PLAN_ID IS NOT NULL) OR EXISTS
                (SELECT 1
                   FROM STL_INCISION C
                  WHERE C.JUDGE_STOVE_NO = A.JUDGE_STOVE_NO
                    AND C.PRO_PLAN_ID IS NOT NULL) AND EXISTS
                (SELECT 1
                   FROM STL_INCISION C
                  WHERE C.JUDGE_STOVE_NO = A.JUDGE_STOVE_NO
                    AND C.PRO_PLAN_ID IS NULL
                    AND C.JUDGE_FLAG = '00'))
           AND A.STOVE_NO = B.STOVE_NO
           AND B.SAMPLE_NO LIKE '60%'
           AND B.VALIDFLAG = '1'
           AND B.ASSAYTYPE = 'A'
           AND A.JUDGE_FLAG = '00'
         GROUP BY A.STOVE_NO, A.JUDGE_STOVE_NO)
 WHERE ROWNUM <= 25
		]]>
	</query>
	
	<query id="SteelMakingAdvanceJudgeTask.getApplyJudgeStoveNo" desc="获取申请判定表中的判定炉号">
		<![CDATA[
SELECT *
  FROM (SELECT A.STOVE_NO, A.JUDGE_STOVE_NO
          FROM QCM_GP_JUDGE_APPLY A, QCM_JHY_ELEMENTS B
         WHERE EXISTS
         (SELECT 1
                  FROM QCM_GP_JUDGE_APPLY C
                 WHERE C.JUDGE_STOVE_NO = A.JUDGE_STOVE_NO
                   AND C.IS_FLAG = '0'
                   AND C.CX_FLAG_CHEM = '00'
                   AND (C.PLINE_CODE IN ('C063', 'C064') OR C.LK_FLAG = '1' OR
                       C.GPTYPE = '2' OR
                       C.OLD_GRADECODE IS NOT NULL AND C.OLD_CIC IS NOT NULL)
                   AND (	(C.PRO_PLAN_ID_NEXT IS NULL AND
                                (EXISTS (SELECT 1 FROM PLN_ORDER_ZG_S D WHERE D.GPREQ_ID = C.PRO_PLAN_ID) OR EXISTS
                                 (SELECT 1 FROM PLN_REQINF_GP E WHERE E.GPREQ_ID = C.PRO_PLAN_ID))) OR
                            (C.PRO_PLAN_ID_NEXT LIKE 'ZG%' AND EXISTS
                                (SELECT 1 FROM PLN_ORDER_ZG_S D WHERE D.PRO_PLAN_ID = C.PRO_PLAN_ID_NEXT)) OR
                            EXISTS (SELECT 1 FROM PLN_ORDER_ZG_S D WHERE D.GPREQ_ID = C.PRO_PLAN_ID_NEXT) OR
                            EXISTS (SELECT 1 FROM PLN_REQINF_GP E WHERE E.GPREQ_ID = C.PRO_PLAN_ID_NEXT) OR
                            (C.PRO_PLAN_ID LIKE '%PO%' AND c.chem_result_code is null and EXISTS
                                (SELECT 1 FROM COM_MSC_STD_CHEM SC WHERE SC.CIC = C.CIC))
                            )    )
           AND A.STOVE_NO = B.STOVE_NO
           AND A.IS_FLAG = '0'
           AND B.SAMPLE_NO LIKE '60%'
           AND B.VALIDFLAG = '1'
           AND B.ASSAYTYPE = 'A'
           AND A.CX_FLAG_CHEM = '00'
         GROUP BY A.STOVE_NO, A.JUDGE_STOVE_NO
         union 
         --补充特殊数据
          SELECT A.STOVE_NO, A.JUDGE_STOVE_NO
          FROM QCM_GP_JUDGE_APPLY A, QCM_JHY_ELEMENTS B
         WHERE EXISTS
         (SELECT c.*
                  FROM QCM_GP_JUDGE_APPLY C
                 WHERE C.JUDGE_STOVE_NO = a.judge_stove_no
                   AND C.IS_FLAG = '0'
                   AND C.CX_FLAG_CHEM = '20'
                   and c.validflag = '00'
                   AND (C.PLINE_CODE IN ('C063', 'C064') OR C.LK_FLAG = '1' OR
                       C.GPTYPE = '2' OR
                       C.OLD_GRADECODE IS NOT NULL AND C.OLD_CIC IS NOT NULL)
                   AND (  (C.PRO_PLAN_ID_NEXT IS NULL AND
                                (EXISTS (SELECT 1 FROM PLN_ORDER_ZG_S D WHERE D.GPREQ_ID = C.PRO_PLAN_ID) OR EXISTS
                                 (SELECT 1 FROM PLN_REQINF_GP E WHERE E.GPREQ_ID = C.PRO_PLAN_ID))) OR
                            (C.PRO_PLAN_ID_NEXT LIKE 'ZG%' AND EXISTS
                                (SELECT 1 FROM PLN_ORDER_ZG_S D WHERE D.PRO_PLAN_ID = C.PRO_PLAN_ID_NEXT)) OR
                            EXISTS (SELECT 1 FROM PLN_ORDER_ZG_S D WHERE D.GPREQ_ID = C.PRO_PLAN_ID_NEXT) OR
                            EXISTS (SELECT 1 FROM PLN_REQINF_GP E WHERE E.GPREQ_ID = C.PRO_PLAN_ID_NEXT) OR
                            (C.PRO_PLAN_ID LIKE '%PO%' AND c.chem_result_code is null and EXISTS
                                (SELECT 1 FROM COM_MSC_STD_CHEM SC WHERE SC.CIC = C.CIC))
                            ))
           AND A.STOVE_NO = B.STOVE_NO
           AND A.IS_FLAG = '0'
           AND B.SAMPLE_NO LIKE '60%'
           AND B.VALIDFLAG = '1'
           AND B.ASSAYTYPE = 'A'
           AND A.CX_FLAG_CHEM = '20'
           and a.validflag = '00'
         GROUP BY A.STOVE_NO, A.JUDGE_STOVE_NO
         )
         
 WHERE ROWNUM <= 25
		]]>
	</query>
	
	<query id="SteelMakingAdvanceJudgeTask.queryCraftCicByGpreqId" desc="查询工艺DesignKey">
		<![CDATA[
SELECT MIN(DESGIN_KEY) DESGIN_KEY, MIN(MSC_PLINE) MSC_PLINE, CIC
  FROM (SELECT FIRST_VALUE(C.DESGIN_KEY) OVER(PARTITION BY A.CIC_GP ORDER BY A.PRO_PLAN_ID) DESGIN_KEY,
               FIRST_VALUE(A.INDEX_SEQ) OVER(PARTITION BY A.CIC_GP ORDER BY A.PRO_PLAN_ID) MSC_PLINE,
               A.CIC_GP CIC
          FROM PLN_ORDER_ZG_S A, PLN_SALEORD B, CRAFT_ORD_DESIGN C
         WHERE B.ORD_LN_DLY_PK = A.ORD_LN_DLY_PK
           AND B.ORD_LN_PK = C.ORD_LN_PK
           AND A.CRAFT_SEQ = C.CRAFT_SEQ
           AND A.GPREQ_ID IN {0})
 GROUP BY CIC
		]]>
	</query>
	
	<query id="SteelMakingAdvanceJudgeTask.queryCraftCicByZgProPlanId" desc="查询工艺DesignKey">
		<![CDATA[
 SELECT MIN(DESGIN_KEY) DESGIN_KEY, MIN(MSC_PLINE) MSC_PLINE, CIC
   FROM (SELECT FIRST_VALUE(C.DESGIN_KEY) OVER(PARTITION BY A.CIC_GP ORDER BY A.PRO_PLAN_ID) DESGIN_KEY,
                FIRST_VALUE(A.INDEX_SEQ) OVER(PARTITION BY A.CIC_GP ORDER BY A.PRO_PLAN_ID) MSC_PLINE,
                D.cic
           FROM PLN_ORDER_ZG_S           A,
                PLN_SALEORD              B,
                CRAFT_ORD_DESIGN         C,
                CRAFT_ORD_DESIGN_STD_CIC D
          WHERE B.ORD_LN_DLY_PK = A.ORD_LN_DLY_PK
            AND B.ORD_LN_PK = C.ORD_LN_PK
            AND A.CRAFT_SEQ = C.CRAFT_SEQ
            AND A.PRO_PLAN_ID || A.GX_PLAN_NO IN {0}
            AND D.DESGIN_KEY = C.DESGIN_KEY
            AND D.PROCESS_CODE = 'A'
            AND ({1} = '0' OR D.CIC IN {2}))
  GROUP BY CIC
		]]>
	</query>
	
	<query id="SteelMakingAdvanceJudgeTask.queryStlInCision" desc="查询连铸切割信息表">
		<![CDATA[
SELECT T.PLINE_CODE
  FROM STL_INCISION T
 WHERE T.PRO_PLAN_ID = {0}
   AND T.GX_PLAN_NO = {1}
   AND T.STOVE_NO = {2}
   AND T.JUDGE_STOVE_NO = {3}
   AND ROWNUM <= 1
		]]>
	</query>
	
	<query id="SteelMakingAdvanceJudgeTask.queryCraftChem" desc="查询工艺评审成分记录">
		<![CDATA[
SELECT *
  FROM CRAFT_ORD_DESIGN_STD_CIC T
 WHERE T.DESGIN_KEY = {0}
   AND T.MSC_PLINE = {1}
   AND T.CIC = {2}
   AND T.PROCESS_CODE = {3}
		]]>
	</query>
	
		<query id="SteelMakingAdvanceJudgeTask.getCraftNkChem" desc="获取工艺评审成分">
		<![CDATA[
SELECT T.*, A.CHEM_SEQ FROM
	(SELECT T.*
	  FROM CRAFT_ORD_DESIGN_MSC MSC,
	  CRAFT_ORD_DESIGN_STD_CIC T
	 WHERE T.DESGIN_KEY = {0}
	   AND T.DESGIN_KEY=MSC.DESGIN_KEY
	   AND MSC_PLINE = {1}
	   AND PROCESS_CODE = {2}
	   AND CIC = {3}
	   AND T.CHEM_CODE NOT IN ('C012',
                                   'C013',
                                   'C014',
                                   'C032',
                                   'C043',
                                   'C051',
                                   'C064',
                                   'C065')
	UNION ALL
	SELECT T.*
	  FROM CRAFT_ORD_DESIGN_MSC MSC,
	  CRAFT_ORD_DESIGN_STD_CIC T
	 WHERE T.DESGIN_KEY = {0}
	   AND T.DESGIN_KEY=MSC.DESGIN_KEY
	   AND MSC_PLINE = {1}
	   AND PROCESS_CODE = {2}
	   AND CIC = {3}
	   AND MSC.JUDGEFLAG IN ('1','3')
	   AND T.CHEM_CODE IN ('C012',
                                   'C013',
                                   'C014',
                                   'C032',
                                   'C043',
                                   'C051',
                                   'C064',
                                   'C065'))T
  LEFT JOIN COM_BASE_CHEM A
    ON A.CHEM_CODE = T.CHEM_CODE
   AND A.VALIDFLAG = '1'
 ORDER BY A.CHEM_SEQ
		]]>
	</query>
	
		<query id="SteelMakingAdvanceJudgeTask.getCraftNewJfChem" desc="获取工艺评审成分">
		<![CDATA[
SELECT T.*, A.CHEM_SEQ
  FROM (SELECT T.DESGIN_KEY,
               T.CIC,
               T.USE_CODE,
               T.USE_DESC,
               T.SPECL_FL,
               T.INDEX_SEQ,
               T.CHEM_CODE,
               T.CHEM_NAME,
               T.CHEM_TYPE,
               T.CHEM_FORMULA,
               T.ISCHECK,
               T.ISJUDGE,
               T.ISQUOTE,
               T.COMPLEX_TYPE,
               T.STDMIN_SIGN,
               T.STDMIN,
               T.STDMAX_SIGN,
               T.STDMAX,
               T.STDTARGET,
               T.MODEL_CODE,
               T.MODEL_DESC,
               T.STDMEMO,
               T.ELE_CODE,
               T.ELE_NAME,
               T.ELE_MIN_SIGN,
               T.ELE_MIN,
               T.ELE_MAX_SIGN,
               T.ELE_MAX,
               T.REP_CODE,
               T.REP_NAME,
               T.REP_MIN_SIGN,
               T.REP_MIN,
               T.REP_MAX_SIGN,
               T.REP_MAX,
               T.REP_VAL,
               T.MSC_PLINE,
               T.PROCESS_CODE,
               T.CRAFT_SOURCE,
               T.CIC_MEMO,
               T.GROUP_SEQ 
               FROM CRAFT_ORD_DESIGN_STD_CIC T
 WHERE T.DESGIN_KEY = {0}
   AND T.SPECL_FL = '0'
   AND NOT EXISTS (SELECT 1
          FROM CRAFT_ORD_DESIGN_STD_CIC A
         WHERE A.DESGIN_KEY = T.DESGIN_KEY
           AND A.SPECL_FL = '1'
           AND T.CHEM_CODE = A.CHEM_CODE)
   AND T.CHEM_CODE NOT IN ('C012',
                                   'C013',
                                   'C014',
                                   'C032',
                                   'C043',
                                   'C051',
                                   'C064',
                                   'C065')
UNION ALL
SELECT T.DESGIN_KEY,
               T.CIC,
               T.USE_CODE,
               T.USE_DESC,
               T.SPECL_FL,
               T.INDEX_SEQ,
               T.CHEM_CODE,
               T.CHEM_NAME,
               T.CHEM_TYPE,
               T.CHEM_FORMULA,
               T.ISCHECK,
               T.ISJUDGE,
               T.ISQUOTE,
               T.COMPLEX_TYPE,
               T.STDMIN_SIGN,
               T.STDMIN,
               T.STDMAX_SIGN,
               T.STDMAX,
               T.STDTARGET,
               T.MODEL_CODE,
               T.MODEL_DESC,
               T.STDMEMO,
               T.ELE_CODE,
               T.ELE_NAME,
               T.ELE_MIN_SIGN,
               T.ELE_MIN,
               T.ELE_MAX_SIGN,
               T.ELE_MAX,
               T.REP_CODE,
               T.REP_NAME,
               T.REP_MIN_SIGN,
               T.REP_MIN,
               T.REP_MAX_SIGN,
               T.REP_MAX,
               T.REP_VAL,
               T.MSC_PLINE,
               T.PROCESS_CODE,
               T.CRAFT_SOURCE,
               T.CIC_MEMO,
               T.GROUP_SEQ
  FROM CRAFT_ORD_DESIGN_STD_CIC T
 WHERE T.DESGIN_KEY = {0}
   AND T.SPECL_FL = '1'
   AND T.CHEM_CODE NOT IN ('C012',
                                   'C013',
                                   'C014',
                                   'C032',
                                   'C043',
                                   'C051',
                                   'C064',
                                   'C065')
UNION ALL
SELECT T.DESGIN_KEY,
               T.CIC,
               T.USE_CODE,
               T.USE_DESC,
               '0' SPECL_FL,
               T.INDEX_SEQ,
               T.CHEM_CODE,
               T.CHEM_NAME,
               T.CHEM_TYPE,
               T.CHEM_FORMULA,
               T.ISCHECK,
               T.ISJUDGE,
               T.ISQUOTE,
               T.COMPLEX_TYPE,
               T.STDMIN_SIGN,
               T.STDMIN,
               T.STDMAX_SIGN,
               T.STDMAX,
               T.STDTARGET,
               T.MODEL_CODE,
               T.MODEL_DESC,
               T.STDMEMO,
               T.ELE_CODE,
               T.ELE_NAME,
               T.ELE_MIN_SIGN,
               T.ELE_MIN,
               T.ELE_MAX_SIGN,
               T.ELE_MAX,
               T.REP_CODE,
               T.REP_NAME,
               T.REP_MIN_SIGN,
               T.REP_MIN,
               T.REP_MAX_SIGN,
               T.REP_MAX,
               T.REP_VAL,
               T.MSC_PLINE,
               T.PROCESS_CODE,
               T.CRAFT_SOURCE,
               T.CIC_MEMO,
               T.GROUP_SEQ
  FROM CRAFT_ORD_DESIGN_STD_CIC T,
  CRAFT_ORD_DESIGN_MSC MSC
 WHERE T.DESGIN_KEY = {0}
   AND T.CIC = {1}
   AND T.DESGIN_KEY=MSC.DESGIN_KEY
   AND T.SPECL_FL = '2'
   AND T.PROCESS_CODE='A'
   AND MSC.JUDGEFLAG IN ('1','3')
   AND T.CHEM_CODE IN ('C012',
                                   'C013',
                                   'C014',
                                   'C032',
                                   'C043',
                                   'C051',
                                   'C064',
                                   'C065')
                                   
                                   )T
   LEFT JOIN COM_BASE_CHEM A
    ON A.CHEM_CODE = T.CHEM_CODE
 ORDER BY CHEM_SEQ
 
		]]>
	</query>
	
	<query id="SteelMakingAdvanceJudgeTask.getCraftJfChem" desc="获取工艺评审交付成分">
		<![CDATA[
SELECT *
          FROM CRAFT_ORD_DESIGN_STD_CIC T
         WHERE T.DESGIN_KEY = {0}
           AND T.SPECL_FL = '0'
           AND NOT EXISTS (SELECT 1
                  FROM CRAFT_ORD_DESIGN_STD_CIC A
                 WHERE A.DESGIN_KEY = T.DESGIN_KEY
                   AND A.SPECL_FL = '1'
                   AND T.CHEM_CODE = A.CHEM_CODE)
        UNION ALL
        SELECT *
          FROM CRAFT_ORD_DESIGN_STD_CIC T
         WHERE T.DESGIN_KEY = {0}
           AND T.SPECL_FL = '1'
		]]>
	</query>
	
	<query id="SteelMakingAdvanceJudgeTask.queryApplyChemByJudgeStoveNo" desc="查询工艺DesignKey">
		<![CDATA[
SELECT D.*, E.CHEM_SEQ, '2' SPECL_FL
  FROM (SELECT B.CIC
          FROM QCM_GP_JUDGE_APPLY A, PLN_REQINF_GP B
         WHERE A.JUDGE_STOVE_NO = {0}
           AND A.IS_FLAG = '0'
           AND (A.PLINE_CODE IN ('C063', 'C064') OR A.LK_FLAG = '1' OR A.GPTYPE = '2'
           OR A.OLD_GRADECODE IS NOT NULL AND A.OLD_CIC IS NOT NULL)
           AND A.PRO_PLAN_ID = B.GPREQ_ID
         GROUP BY B.CIC) C,
       COM_MSC_STD_CHEM D,
       COM_BASE_CHEM E
 WHERE C.CIC = D.CIC
   AND D.VALIDFLAG = '1'
   AND E.CHEM_CODE = D.CHEM_CODE
		]]>
	</query>
			<query id="SteelMakingAdvanceJudgeTask.queryBaseChemByJudgeStoveNo" desc="查询外购坯成分">
		<![CDATA[
SELECT D.*, E.CHEM_SEQ, '2' SPECL_FL
  FROM (SELECT A.CIC
          FROM QCM_GP_JUDGE_APPLY A
         WHERE A.JUDGE_STOVE_NO = {0}
           AND A.IS_FLAG = '0'
         GROUP BY A.CIC) C,
       COM_MSC_STD_CHEM D,
       COM_BASE_CHEM E
 WHERE C.CIC = D.CIC
   AND D.VALIDFLAG = '1'
   AND E.CHEM_CODE = D.CHEM_CODE
		]]>
	</query>
	

	
	<query id="SteelMakingAdvanceJudgeTask.getMaxChemJudgeId" desc="查询最大的成分判定记录号">
		<![CDATA[
SELECT NVL(MAX(T.CHEM_JUDGE_ID), TO_CHAR(SYSDATE, 'YYYYMMDD') || '00000') CHEM_JUDGE_ID
  FROM QCM_LG_CHEMJUDGE T
 WHERE T.CHEM_JUDGE_ID LIKE TO_CHAR(SYSDATE, 'YYYYMMDD') || '%'
		]]>
	</query>
	
	<query id="SteelMakingAdvanceJudgeTask.InsertLgChemJudge" desc="新增">
        <![CDATA[
 INSERT INTO QCM_LG_CHEMJUDGE
  (CHEM_JUDGE_ID,
   STOVE_NO,
   JUDGE_STOVE_NO,
   MAT_NO,
   PLINE_CODE,
   PROCESS_CDOE,
   PROCESS_DESC,
   PLAN_ORDERNO,
   JUDGE_ORDERNO,
   JUDGERESULT_CHEM,
   ORDERISUNCHAIN,
   ASSAYNO,
   MEMO,
   CREATE_NAME,
   CREATE_TIME,
   JUGDE_APPLY_CODE,
   DESIGN_KEY,
   MSC_PLINE,
   CIC,
   SAMPLE_NO,
   JUDGE_SEQ,
   PRO_PLAN_ID,
   OLD_GRADECODE,
   OLD_GRADENAME,
   OLD_CIC)
VALUES
  ('#CHEM_JUDGE_ID#',
   '#STOVE_NO#',
   '#JUDGE_STOVE_NO#',
   '#MAT_NO#',
   '#PLINE_CODE#',
   '#PROCESS_CDOE#',
   '#PROCESS_DESC#',
   '#PLAN_ORDERNO#',
   '#JUDGE_ORDERNO#',
   '#JUDGERESULT_CHEM#',
   '#ORDERISUNCHAIN#',
   '#ASSAYNO#',
   '#MEMO#',
   '#CREATE_NAME#',
   SYSDATE,
   '#JUGDE_APPLY_CODE#',
   '#DESIGN_KEY#',
   '#MSC_PLINE#',
   '#CIC#',
   '#SAMPLE_NO#',
   '#JUDGE_SEQ#',
   '#PRO_PLAN_ID#',
   '#OLD_GRADECODE#',
   '#OLD_GRADENAME#',
   '#OLD_CIC#')
        ]]>
    </query>
    
    <query id="SteelMakingAdvanceJudgeTask.updateStlInCision" desc="更新连铸切割信息表">
		<![CDATA[
UPDATE STL_INCISION T
      SET T.CHEM_JUDGE_ID    = {1},
          T.JUDGE_FLAG       = {2},
          T.JUDGERESULT_CHEM = {3}
    WHERE T.JUDGE_STOVE_NO = {0}
		]]>
	</query>
	
	<query id="SteelMakingAdvanceJudgeTask.getStlJudgeStoveNoByStoveNo" desc="获取切割信息">
		<![CDATA[
SELECT T.JUDGE_STOVE_NO FROM STL_INCISION T WHERE T.STOVE_NO = {0}
GROUP BY T.JUDGE_STOVE_NO
		]]>
	</query>
	
	<query id="SteelMakingAdvanceJudgeTask.getStlPlnIdByJudgeStoveNo" desc="获取切割信息">
		<![CDATA[
SELECT NVL(T.PRO_PLAN_ID,
           (SELECT A.PRO_PLAN_ID
              FROM STL_INCISION A
             WHERE A.STOVE_NO = T.STOVE_NO
               AND A.PRO_PLAN_ID IS NOT NULL
               AND ROWNUM <= 1)) PRO_PLAN_ID,
       NVL(T.GX_PLAN_NO,
           (SELECT A.GX_PLAN_NO
              FROM STL_INCISION A
             WHERE A.STOVE_NO = T.STOVE_NO
               AND A.PRO_PLAN_ID IS NOT NULL
               AND ROWNUM <= 1)) GX_PLAN_NO,
       MAX(T.PLINE_CODE) PLINE_CODE
  FROM STL_INCISION T
 WHERE T.JUDGE_STOVE_NO = {0}
 GROUP BY T.STOVE_NO, T.PRO_PLAN_ID, T.GX_PLAN_NO
		]]>
	</query>
	
	<query id="SteelMakingAdvanceJudgeTask.getApplyJudgeStoveNoByStoveNo" desc="获取申请判定信息">
		<![CDATA[
SELECT T.JUDGE_STOVE_NO
  FROM QCM_GP_JUDGE_APPLY T
 WHERE T.STOVE_NO = {0}
   AND T.IS_FLAG = '0'
   AND (T.PLINE_CODE IN ('C063', 'C064') OR T.LK_FLAG = '1' OR T.GPTYPE = '2'
       OR T.OLD_GRADECODE IS NOT NULL AND T.OLD_CIC IS NOT NULL)
   AND (T.PRO_PLAN_ID_NEXT IS NOT NULL OR T.PRO_PLAN_ID IS NOT NULL)
GROUP BY T.JUDGE_STOVE_NO
		]]>
	</query>
	
	<query id="SteelMakingAdvanceJudgeTask.getApplyPlnIdByJudgeStoveNo" desc="获取切割信息">
		<![CDATA[
SELECT T.PRO_PLAN_ID, T.GX_PLAN_NO, T.PRO_PLAN_ID_NEXT, T.GX_PLAN_NO_NEXT,
 MAX(T.PLINE_CODE) PLINE_CODE
  FROM QCM_GP_JUDGE_APPLY T
 WHERE T.JUDGE_STOVE_NO = {0}
 AND T.IS_FLAG = '0'
 GROUP BY T.PRO_PLAN_ID, T.GX_PLAN_NO, T.PRO_PLAN_ID_NEXT, T.GX_PLAN_NO_NEXT
		]]>
	</query>
	
	<query id="SteelMakingAdvanceJudgeTask.getApplyPlnIdByStoveNoApplyNo" desc="获取切割信息">
		<![CDATA[
SELECT T.PRO_PLAN_ID, T.GX_PLAN_NO, T.PRO_PLAN_ID_NEXT, T.GX_PLAN_NO_NEXT,
 MAX(T.PLINE_CODE) PLINE_CODE, MAX(T.STOVE_NO) STOVE_NO
  FROM QCM_GP_JUDGE_APPLY T
 WHERE  T.JUDGE_STOVE_NO != {2}
 AND T.STOVE_NO={3}
 GROUP BY T.PRO_PLAN_ID, T.GX_PLAN_NO, T.PRO_PLAN_ID_NEXT, T.GX_PLAN_NO_NEXT
		]]>
	</query>
	
	<query id="SteelMakingAdvanceJudgeTask.updateQcmJhyElement" desc="获取检化验信息">
		<![CDATA[
UPDATE QCM_JHY_ELEMENTS T SET T.LG_JUDGE_FLAG = {0} WHERE T.STOVE_NO = {1}
AND T.ASSAYTYPE = 'A' AND T.SAMPLE_NO LIKE '60%'
		]]>
	</query>
	
	<query id="SteelMakingAdvanceJudgeTask.updateLgChemJudgeValid" desc="修改炼钢判定记录状态">
		<![CDATA[
UPDATE QCM_LG_CHEMJUDGE T
   SET T.VALIDFLAG = {1}
 WHERE T.JUDGE_STOVE_NO = {0}
   AND T.PROCESS_CDOE = 'B'
		]]>
	</query>
	
	<query id="SteelMakingAdvanceJudgeTask.updateLgChemJudgeExceptionValid" desc="修改炼钢判定记录状态">
		<![CDATA[
UPDATE QCM_LG_CHEMJUDGE_EXCEPTION T
   SET T.VALIDFLAG = {1}
 WHERE EXISTS (SELECT 1
          FROM QCM_LG_CHEMJUDGE A
         WHERE A.JUDGE_STOVE_NO = {0}
           AND A.PROCESS_CDOE = 'B'
           AND A.CHEM_JUDGE_ID = T.CHEM_JUDGE_ID)
		]]>
	</query>
	
	<query id="SteelMakingAdvanceJudgeTask.queryByGpreqId" desc="查询计划轧管表">
		<![CDATA[
SELECT (T.PRO_PLAN_ID || T.GX_PLAN_NO) PRO_PLAN_ID
  FROM PLN_ORDER_ZG_S T
 WHERE T.GPREQ_ID = {0}
		]]>
	</query>
	
	<query id="SteelMakingAdvanceJudgeTask.udpateGpJudgeApplyCxFlag" desc="修改判定表">
		<![CDATA[
UPDATE QCM_GP_JUDGE_APPLY T
   SET T.CX_FLAG_CHEM = {1}, T.CHEM_RESULT_CODE = {2}
 WHERE T.JUDGE_STOVE_NO = {0}
 AND T.IS_FLAG = '0'    AND (
       (t.cx_flag_chem = '00')
        OR
       (t.cx_flag_chem = '20' AND T.CHEM_RESULT_CODE IS NULL)
       )
		]]>
	</query>
	
	<query id="SteelMakingAdvanceJudgeTask.insertLgChemResult" desc="新增成分判定记录">
		<![CDATA[
INSERT INTO QCM_LG_CHEM_RESULT(
        CHEM_JUDGE_ID,
        JUDGE_SEQ,
        CHEM_SEQ,
        CHEM_NAME,
        CHEM_VALUE,
        NK_MIN,
        NK_MAX,
        QUALIFIED,
        UNQUALIFIED_TYPE,
        JF_MIN,
        JF_MAX,
        JF_QUALIFIED)
 VALUES(
        '#CHEM_JUDGE_ID#',
        '#JUDGE_SEQ#',
        '#CHEM_SEQ#',
        '#CHEM_NAME#',
        '#CHEM_VALUE#',
        '#NK_MIN#',
        '#NK_MAX#',
        '#QUALIFIED#',
        '#UNQUALIFIED_TYPE#',
        '#JF_MIN#',
        '#JF_MAX#',
        '#JF_QUALIFIED#')
		]]>
	</query>
	
	<query id="SteelMakingAdvanceJudgeTask.getGpApplyByJudgeStoveNo" desc="通过判定炉号查询申请判定表">
		<![CDATA[
SELECT * FROM QCM_GP_JUDGE_APPLY T WHERE T.JUDGE_STOVE_NO = {0}
AND T.IS_FLAG = '0'
		]]>
	</query>
	
	<query id="SteelMakingAdvanceJudgeTask.setSampleType" desc="修改试样类型和合并成分结果">
		<![CDATA[
UPDATE QCM_LG_CHEMJUDGE T
   SET T.SAMPLE_TYPE       = DECODE((SELECT COUNT(1)
                                      FROM QCM_LG_CHEMJUDGE A
                                     WHERE A.CHEM_JUDGE_ID = T.CHEM_JUDGE_ID
                                       AND A.SAMPLE_NO LIKE '%F%'),
                                    0,
                                    '1',
                                    '2'),
       T.MERGE_CHEM_RESULT = {1}
 WHERE T.CHEM_JUDGE_ID = {0}
		]]>
	</query>
	
	<query id="SteelMakingAdvanceJudgeTask.getCicByJudgeStoveNo" desc="通过判定炉号查询cic">
		<![CDATA[
select t.cic from pln_steelfor_ord t where t.judge_stove_no = {0}
		]]>
	</query>
</queryMap>