<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="成分实绩信息表">
	<query id="QcmJhyElementsDAL.queryByStoveNo" desc="查询炉成分实绩表">
		<![CDATA[
SELECT T.ASSAYNO,
       T.STOVE_NO,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       DECODE(T.ASSAYTYPE, 'A', '熔炼成分', 'B', '成品成分', '未识别') ASSAYTYPE,
       DECODE(T.FLAG, '1', '已判', '0', '未判', '未识别') FLAG,
       T.C,
       T.SI,
       T.MN,
       T.P,
       T.S,
       T.NI,
       T.CR,
       T.CU,
       T.ASN,
       T.TI,
       T.V,
       T.MO,
       T.B,
       T.W,
       T.AL,
       T.ZN,
       T.PB,
       T.SN,
       T.CA,
       T.LA,
       T.SB,
       T.CE,
       T.SE,
       T.MG,
       T.NB,
       T.CD,
       T.BI,
       T.N,
       T.H,
       T.O,
       T.FE,
       T.ALT,
       T.ALS,
       T.ALINS,
       T.BS,
       T.BN,
       T.MGO,
       T.SIO2,
       T.AL2O3,
       T.TFEO,
       T.FE2O3,
       T.H2O,
       T.CAF2,
       T.P2O5,
       T.TFE,
       T.CR2O3,
       T.TIO2,
       T.MNO,
       T.V2O5,
       T.FEO,
       T.CAO,
       T.ZR,
       T.CO,
       T.TA,
       T.SAMPLE_ID,
       T.XH,
       T.MACHINE,
       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.VALIDFLAG,
       T.MEMO,
       T.SAMPLE_NO,
       (
        SELECT
            RATIO_VALUE
        FROM
            COM_BASE_CHEM_RATIO T
        WHERE
            T.VALIDFLAG IN ( '1' )
            AND CHEM_NAME = 'C'
            AND (
                (
                    ( MIN_SIGN = '=' AND T.C = MIN_VALUE )
                    OR ( MIN_SIGN = '>' AND T.C > MIN_VALUE )
                    OR ( MIN_SIGN = '>=' AND T.C >= MIN_VALUE )
                )
                OR ( ( MAX_SIGN = '<=' AND T.C = MAX_VALUE ) OR ( MAX_SIGN = '<' AND T.C < MAX_VALUE ) )
            )
        ) "f"
  FROM QCM_JHY_ELEMENTS T, COM_BASE_PLINE A
 WHERE A.PLINE_CODE = T.PLINE_CODE
   AND A.PROCESS_CODE = {0}
   AND T.SAMPLE_NO LIKE '60%'
   AND T.VALIDFLAG = '1'
   AND T.ASSAYTYPE = 'A'
   AND T.STOVE_NO = {1}
 ORDER BY T.CREATE_TIME DESC, T.SAMPLE_NO
		]]>
	</query>
	<query id="QcmJhyElementsDAL.queryBySampleNo" desc="查询炉成分实绩表">
		<![CDATA[
SELECT T.ASSAYNO,
       T.STOVE_NO,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       DECODE(T.ASSAYTYPE, 'A', '熔炼成分', 'B', '成品成分', '未识别') ASSAYTYPE,
       DECODE(T.FLAG, '1', '已判', '0', '未判', '未识别') FLAG,
       T.C,
       T.SI,
       T.MN,
       T.P,
       T.S,
       T.NI,
       T.CR,
       T.CU,
       T.ASN,
       T.TI,
       T.V,
       T.MO,
       T.B,
       T.W,
       T.AL,
       T.ZN,
       T.PB,
       T.SN,
       T.CA,
       T.LA,
       T.SB,
       T.CE,
       T.SE,
       T.MG,
       T.NB,
       T.CD,
       T.BI,
       T.N,
       T.H,
       T.O,
       T.FE,
       T.ALT,
       T.ALS,
       T.ALINS,
       T.BS,
       T.BN,
       T.MGO,
       T.SIO2,
       T.AL2O3,
       T.TFEO,
       T.FE2O3,
       T.H2O,
       T.CAF2,
       T.P2O5,
       T.TFE,
       T.CR2O3,
       T.TIO2,
       T.MNO,
       T.V2O5,
       T.FEO,
       T.CAO,
       T.ZR,
       T.CO,
       T.TA,
       T.SAMPLE_ID,
       T.XH,
       T.MACHINE,
       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.VALIDFLAG,
       T.MEMO,
       T.SAMPLE_NO,
       CASE
         WHEN EXISTS (SELECT 1
                 FROM QCM_BC_CHEMJUDGE T2, QCM_BC_CHEM_RESULT T3
                WHERE T2.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
                  AND T2.SAMPLE_NO = T.SAMPLE_NO
                  AND T2.PROCESS_CDOE = {0}
                  AND T2.VALIDFLAG = '1'
                  AND T3.CHEM_JUDGE_ID = T2.CHEM_JUDGE_ID
                  AND T3.JUDGE_SEQ = T2.JUDGE_SEQ
                  AND T3.NK_QUALIFIED IN ('0', '2')) THEN
          '不合格'
         ELSE
          '合格'
       END NK_RESULT,
       (
        SELECT
            RATIO_VALUE
        FROM
            COM_BASE_CHEM_RATIO T
        WHERE
            T.VALIDFLAG IN ( '1' )
            AND CHEM_NAME = 'C'
            AND (
                (
                    ( MIN_SIGN = '=' AND T.C = MIN_VALUE )
                    OR ( MIN_SIGN = '>' AND T.C > MIN_VALUE )
                    OR ( MIN_SIGN = '>=' AND T.C >= MIN_VALUE )
                )
                OR ( ( MAX_SIGN = '<=' AND T.C = MAX_VALUE ) OR ( MAX_SIGN = '<' AND T.C < MAX_VALUE ) )
            )
        ) "f"
  FROM QCM_JHY_ELEMENTS T, COM_BASE_PLINE A
 WHERE A.PLINE_CODE = T.PLINE_CODE
   AND A.PROCESS_CODE = {0}
   AND T.VALIDFLAG = '1'
   AND T.ASSAYTYPE = 'B'
   AND T.JUDGE_STOVE_NO = {1}
   AND T.BATCH_NO = {2}
   AND T.SAMPLE_ID = {3}
   AND T.SAMPLE_NO = {4}
 ORDER BY T.CREATE_TIME DESC, T.SAMPLE_NO
		]]>
	</query>
	<query id="QcmJhyElementsDAL.steelMakingColligateQuery" desc="查询炉成分实绩表">
		<![CDATA[
SELECT T.ASSAYNO,
       T.STOVE_NO,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       DECODE(T.ASSAYTYPE, 'A', '熔炼成分', 'B', '成品成分', '未识别') ASSAYTYPE,
       DECODE(T.FLAG, '1', '已判', '0', '未判', '未识别') FLAG,
       T.C,
       T.SI,
       T.MN,
       T.P,
       T.S,
       T.NI,
       T.CR,
       T.CU,
       T.ASN,
       T.TI,
       T.V,
       T.MO,
       T.B,
       T.W,
       T.AL,
       T.ZN,
       T.PB,
       T.SN,
       T.CA,
       T.LA,
       T.SB,
       T.CE,
       T.SE,
       T.MG,
       T.NB,
       T.CD,
       T.BI,
       T.N,
       T.H,
       T.O,
       T.FE,
       T.ALT,
       T.ALS,
       T.ALINS,
       T.BS,
       T.BN,
       T.MGO,
       T.SIO2,
       T.AL2O3,
       T.TFEO,
       T.FE2O3,
       T.H2O,
       T.CAF2,
       T.P2O5,
       T.TFE,
       T.CR2O3,
       T.TIO2,
       T.MNO,
       T.V2O5,
       T.FEO,
       T.CAO,
       T.ZR,
       T.CO,
       T.TA,
       T.SAMPLE_ID,
       T.XH,
       T.MACHINE,
       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.VALIDFLAG,
       T.MEMO,
       T.SAMPLE_NO,
       (
        SELECT
            RATIO_VALUE
        FROM
            COM_BASE_CHEM_RATIO T
        WHERE
            T.VALIDFLAG IN ( '1' )
            AND CHEM_NAME = 'C'
            AND (
                (
                    ( MIN_SIGN = '=' AND T.C = MIN_VALUE )
                    OR ( MIN_SIGN = '>' AND T.C > MIN_VALUE )
                    OR ( MIN_SIGN = '>=' AND T.C >= MIN_VALUE )
                )
                OR ( ( MAX_SIGN = '<=' AND T.C = MAX_VALUE ) OR ( MAX_SIGN = '<' AND T.C < MAX_VALUE ) )
            )
        ) "f"
  FROM QCM_JHY_ELEMENTS T, COM_BASE_PLINE A
 WHERE A.PLINE_CODE = T.PLINE_CODE
   AND A.PROCESS_CODE = 'A'
   AND T.SAMPLE_NO LIKE '60%'
   AND T.VALIDFLAG = '1'
   AND T.ASSAYTYPE = 'A'
   AND T.STOVE_NO = {0}
		]]>
	</query>
	<query id="QcmJhyElementsDAL.queryQcmJhyElementsQuery" desc="检化验数据查询">
		<![CDATA[
SELECT MIN(TT.ASSAYNO) ASSAYNO,
       TT.STOVE_NO STOVE_NO,
       MIN(TT.C) C,
       MIN(TT.SI) SI,
       MIN(TT.MN) MN,
       MIN(TT.P) P,
       MIN(TT.S) S,
       MIN(TT.NI) NI,
       MIN(TT.CR) CR,
       MIN(TT.CU) CU,
       MIN(TT.ASN) ASN,
       MIN(TT.TI) TI,
       MIN(TT.V) V,
       MIN(TT.MO) MO,
       MIN(TT.B) B,
       MIN(TT.W) W,
       MIN(TT.AL) AL,
       MIN(TT.ZN) ZN,
       MIN(TT.PB) PB,
       MIN(TT.SN) SN,
       MIN(TT.CA) CA,
       MIN(TT.LA) LA,
       MIN(TT.SB) SB,
       MIN(TT.CE) CE,
       MIN(TT.SE) SE,
       MIN(TT.MG) MG,
       MIN(TT.NB) NB,
       MIN(TT.CD) CD,
       MIN(TT.BI) BI,
       MIN(TT.N) N,
       MIN(TT.H) H,
       MIN(TT.O) O,
       MIN(TT.FE) FE,
       MIN(TT.ALT) ALT,
       MIN(TT.ALS) ALS,
       MIN(TT.ALINS) ALINS,
       MIN(TT.BS) BS,
       MIN(TT.BN) BN,
       MIN(TT.MGO) MGO,
       MIN(TT.SIO2) SIO2,
       MIN(TT.AL2O3) AL2O3,
       MIN(TT.TFEO) TFEO,
       MIN(TT.FE2O3) FE2O3,
       MIN(TT.H2O) H2O,
       MIN(TT.CAF2) CAF2,
       MIN(TT.P2O5) P2O5,
       MIN(TT.TFE) TFE,
       MIN(TT.CR2O3) CR2O3,
       MIN(TT.TIO2) TIO2,
       MIN(TT.MNO) MNO,
       MIN(TT.V2O5) V2O5,
       MIN(TT.FEO) FEO,
       MIN(TT.CAO) CAO,
       MIN(TT.SAMPLE_ID) SAMPLE_ID,
       MIN(TT.XH) XH,
       MIN(TT.MACHINE) MACHINE,
       MIN(TT.CREATE_TIME) CREATE_TIME,
       TT.SAMPLE_NO,
       MIN(TT.ZR) ZR,
       MIN(TT.CO) CO,
       MIN(TT.TA) TA,
          MIN(TT.CEpcm) CEpcm,
         MIN(TT. CEⅡw)  CEⅡw,
       MIN(TT.GRADENAME) GRADENAME,
       MIN(TT.PLINE_NAME) PLINE_NAME,
       LISTAGG(TT.JUDGE_STOVE_NO, ',') WITHIN GROUP(ORDER BY TT.CUT_NUM) JUDGE_STOVE_NO,
       LISTAGG(TT.ORDER_NO, ',') WITHIN GROUP(ORDER BY TT.CUT_NUM) ORDER_NO
   FROM (
SELECT MIN(T.ASSAYNO) ASSAYNO,
       T.STOVE_NO STOVE_NO,
       MIN(T.C) C,
       MIN(T.SI) SI,
       MIN(T.MN) MN,
       MIN(T.P) P,
       MIN(T.S) S,
       MIN(T.NI) NI,
       MIN(T.CR) CR,
       MIN(T.CU) CU,
       MIN(T.ASN) ASN,
       MIN(T.TI) TI,
       MIN(T.V) V,
       MIN(T.MO) MO,
       MIN(T.B) B,
       MIN(T.W) W,
       MIN(T.AL) AL,
       MIN(T.ZN) ZN,
       MIN(T.PB) PB,
       MIN(T.SN) SN,
       MIN(T.CA) CA,
       MIN(T.LA) LA,
       MIN(T.SB) SB,
       MIN(T.CE) CE,
       MIN(T.SE) SE,
       MIN(T.MG) MG,
       MIN(T.NB) NB,
       MIN(T.CD) CD,
       MIN(T.BI) BI,
       MIN(T.N) N,
       MIN(T.H) H,
       MIN(T.O) O,
       MIN(T.FE) FE,
       MIN(T.ALT) ALT,
       MIN(T.ALS) ALS,
       MIN(T.ALINS) ALINS,
       MIN(T.BS) BS,
       MIN(T.BN) BN,
       MIN(T.MGO) MGO,
       MIN(T.SIO2) SIO2,
       MIN(T.AL2O3) AL2O3,
       MIN(T.TFEO) TFEO,
       MIN(T.FE2O3) FE2O3,
       MIN(T.H2O) H2O,
       MIN(T.CAF2) CAF2,
       MIN(T.P2O5) P2O5,
       MIN(T.TFE) TFE,
       MIN(T.CR2O3) CR2O3,
       MIN(T.TIO2) TIO2,
       MIN(T.MNO) MNO,
       MIN(T.V2O5) V2O5,
       MIN(T.FEO) FEO,
       MIN(T.CAO) CAO,
       MIN(T.SAMPLE_ID) SAMPLE_ID,
       MIN(T.XH) XH,
       MIN(T.MACHINE) MACHINE,
       TO_CHAR(MIN(T.CREATE_TIME), 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T.SAMPLE_NO,
       MIN(T.ZR) ZR,
       MIN(T.CO) CO,
       MIN(T.TA) TA,
       NVL(MIN(T2.GRADENAME), MIN(T4.GRADENAME)) GRADENAME,
       NVL(MIN(T2.PLINE_NAME), MIN(T4.PLINE_NAME)) PLINE_NAME,
       NVL(T5.JUDGE_STOVE_NO, T4.JUDGE_STOVE_NO) JUDGE_STOVE_NO,
       NVL(MIN(T5.CUT_NUM), 1) CUT_NUM,
       T5.ORDER_NO ORDER_NO,
       min(round(abs(t.c)+ abs(t.mn/6)+  (abs(t.cr)+abs(t.mo)+abs(t.v))/5+ (abs(t.cu)+abs(t.ni))/15,2)) CEⅡw,
    min(round( abs(t.c)+abs( t.si/30)+ abs(t.mn/20)+ abs(t.cu/20)+abs( t.ni/60)+abs( t.cr/20)+abs( t.mo/15)+abs(t.v/10)+abs( t.b*5),2)) CEpcm
  FROM QCM_JHY_ELEMENTS T
  LEFT JOIN PLN_STEELFORFURNACE T2
    ON T2.STOVE_NO = T.STOVE_NO
  LEFT JOIN COM_BASE_PLINE T3
    ON T3.PLINE_CODE = T.PLINE_CODE
  LEFT JOIN QCM_GP_JUDGE_APPLY T4
    ON T4.STOVE_NO = T.STOVE_NO
   AND T4.IS_FLAG = '0'
  LEFT JOIN PLN_STEELFOR_ORD T5
   ON T5.STOVE_NO = T.STOVE_NO
   AND T5.Ccm_Pln_Type = '00'
 WHERE 
 ({0} IS NULL OR T.STOVE_NO LIKE '%' || {0} || '%')
   AND ({1} IS NULL OR
       T.CREATE_TIME >= TO_DATE({1}, 'YYYY-MM-DD HH24:MI:SS'))
   AND ({2} IS NULL OR
       T.CREATE_TIME <= TO_DATE({2}, 'YYYY-MM-DD HH24:MI:SS'))
   AND ({3} = '0' OR T2.PLINE_CODE IN {4} OR T4.PLINE_CODE IN {4})
   AND ({5} IS NULL OR NVL(T5.JUDGE_STOVE_NO, T4.JUDGE_STOVE_NO) LIKE '%' || {5} || '%')
   AND T.ASSAYTYPE = 'A'
   AND ({6} IS NULL OR T.SAMPLE_NO LIKE '60%')
 GROUP BY T.SAMPLE_NO, T.STOVE_NO, NVL(T5.JUDGE_STOVE_NO, T4.JUDGE_STOVE_NO),T5.ORDER_NO) TT
 GROUP BY TT.SAMPLE_NO, TT.STOVE_NO
 ORDER BY TT.STOVE_NO, TT.SAMPLE_NO
		]]>
	</query>
	
	<query id="QcmJhyElementsDAL.queryRolledTubeDesignKey" desc="查询轧管工艺设计结果成分">
		<![CDATA[
SELECT A.DESGIN_KEY, C.CIC, C.PIC, A.ORD_LN_PK, C.INDEX_SEQ MSC_PLINE
  FROM CRAFT_ORD_DESIGN A, PLN_ZY_ZG_M C, PLN_SALEORD D
 WHERE C.PRO_PLAN_ID = {0}
   AND C.GX_PLAN_NO = {1}
   AND D.ORD_LN_DLY_PK = C.ORD_LN_DLY_PK
   AND D.ORD_LN_PK = A.ORD_LN_PK
   AND A.CRAFT_SEQ = C.CRAFT_SEQ
		]]>
	</query>
	<query id="QcmJhyElementsDAL.queryExpansionDesignKey" desc="查询镦拔扩工艺设计结果成分">
		<![CDATA[
 SELECT A.DESGIN_KEY, B.CIC, B.PIC, A.ORD_LN_PK
   FROM CRAFT_ORD_DESIGN A,
        PLN_ORDER_DBK_S  B,
        PLN_ZY_DBK_M     C,
        PLN_SALEORD      D
  WHERE C.HEAT_PLAN_NO = {0}
    AND B.PRO_PLAN_ID = C.PRO_PLAN_ID
    AND B.GX_PLAN_NO = C.GX_PLAN_NO
    AND D.ORD_LN_DLY_PK = B.ORD_LN_DLY_PK
    AND D.ORD_LN_PK = A.ORD_LN_PK
    AND A.CRAFT_SEQ = B.CRAFT_SEQ
		]]>
	</query>
	
	<query id="QcmJhyElementsDAL.querySteelForOrdDesignKey" desc="查询工艺设计结果成分">
		<![CDATA[
SELECT DESGIN_KEY, MAX(CIC) CIC, MAX(PIC) PIC, MAX(ORD_LN_PK) ORD_LN_PK
  FROM (SELECT T.CIC, T.PIC, C.DESGIN_KEY, C.ORD_LN_PK
          FROM PLN_STEELFOR_ORD T,
               PLN_ORDER_ZG_S   D,
               PLN_SALEORD      P,
               CRAFT_ORD_DESIGN C
         WHERE T.STOVE_NO = {0}
           AND D.GPREQ_ID = T.PRO_PLAN_ID
           AND D.GPREQ_ID IN
               (SELECT MAX(D.GPREQ_ID) OVER(PARTITION BY D.GPREQ_ID ORDER BY D.CREATE_TIME DESC)
                  FROM PLN_ORDER_ZG_S D
                 WHERE D.GPREQ_ID = T.PRO_PLAN_ID)
           AND D.ORD_LN_DLY_PK = P.ORD_LN_DLY_PK
           AND P.ORD_LN_PK = C.ORD_LN_PK
           AND D.CRAFT_SEQ = C.CRAFT_SEQ
           AND D.ORDER_SOURCE <> '备料需求'
        UNION ALL (SELECT T.CIC, T.PIC, C.DESGIN_KEY, C.ORD_LN_PK
                    FROM PLN_STEELFOR_ORD  T,
                         PLN_ORDER_ZG_S    D,
                         PLN_PORDER_BL_REQ BL,
                         CRAFT_ORD_DESIGN  C
                   WHERE T.STOVE_NO = {0}
                     AND D.GPREQ_ID = T.PRO_PLAN_ID
                     AND D.GPREQ_ID IN
                         (SELECT MAX(D.GPREQ_ID) OVER(PARTITION BY D.GPREQ_ID ORDER BY D.CREATE_TIME DESC)
                            FROM PLN_ORDER_ZG_S D
                           WHERE D.GPREQ_ID = T.PRO_PLAN_ID)
                     AND D.ORDER_SOURCE = '备料需求'
                     AND D.ORD_LN_DLY_PK = BL.REQ_BL_ID
                     AND (BL.CODE_DJ_BL || BL.CODE_JG_BL = C.ORD_LN_PK)
                     AND D.CRAFT_SEQ = C.CRAFT_SEQ))
 GROUP BY DESGIN_KEY
		]]>
	</query>
	
	<query id="QcmJhyElementsDAL.queryCraftResultCic" desc="查询工艺设计结果成分">
		<![CDATA[
SELECT T.*, A.CHEM_SEQ
          FROM CRAFT_ORD_DESIGN_STD_CIC T
          LEFT JOIN COM_BASE_CHEM A
            ON A.CHEM_CODE = T.CHEM_CODE
           AND A.VALIDFLAG = '1'
         WHERE T.DESGIN_KEY = {0}
           AND DECODE(SPECL_FL, '2', MSC_PLINE, 1) =
               DECODE(SPECL_FL, '2', {1}, 1)
           AND DECODE(SPECL_FL, '2', PROCESS_CODE, 1) =
               DECODE(SPECL_FL, '2', {2}, 1)
           AND DECODE(SPECL_FL, '2', CIC, 1) = DECODE(SPECL_FL, '2', {3}, 1)
           AND SPECl_FL IN {4}
         ORDER BY A.CHEM_SEQ
		]]>
	</query>
	
	<query id="QcmJhyElementsDAL.queryCraftResultCicJf" desc="查询工艺设计结果成分">
		<![CDATA[
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.SIZE_CODE2,
       T.SIZE_NAME2,
       T.SIZE_MIN_SIGN2,
       T.SIZE_MIN2,
       T.SIZE_MAX_SIGN2,
       T.SIZE_MAX2,
       T.SIZE_CODE,
       T.SIZE_NAME,
       T.SIZE_MIN_SIGN,
       T.SIZE_MIN,
       T.SIZE_MAX_SIGN,
       T.SIZE_MAX,
       T.SPEC_JG,
       T.SPEC_JG_DESC,
       T.VALIDFLAG,
       T.CREATE_NAME,
       T.CREATE_TIME,
       T.UPDATE_NAME,
       T.UPDATE_TIME,
       T.DELETE_NAME,
       T.DELETE_TIME,
       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,
       A.ORD_LN_PK
  FROM CRAFT_ORD_DESIGN_STD_CIC T, CRAFT_ORD_DESIGN A
 WHERE T.DESGIN_KEY = A.DESGIN_KEY
   AND EXISTS
 (SELECT 1
          FROM PLN_ORDER_ZG B
         WHERE B.PRO_PLAN_ID = '#PRO_PLAN_ID#'
           AND SUBSTR(B.ORD_LN_DLY_PK, 0, LENGTH(B.ORD_LN_DLY_PK) - 3) =
               A.ORD_LN_PK
           AND B.CRAFT_SEQ = A.CRAFT_SEQ)
		]]>
	</query>
	
	<query id="QcmJhyElementsDAL.queryByPk" desc="通过主键查询成分实绩信息">
		<![CDATA[
SELECT T.ASSAYNO,
       T.STOVE_NO,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       DECODE(T.ASSAYTYPE, 'A', '熔炼成分', 'B', '成品成分', '未识别') ASSAYTYPE,
       DECODE(T.FLAG, '1', '已判', '0', '未判', '未识别') FLAG,
       T.C,
       T.SI,
       T.MN,
       T.P,
       T.S,
       T.NI,
       T.CR,
       T.CU,
       T.ASN,
       T.TI,
       T.V,
       T.MO,
       T.B,
       T.W,
       T.AL,
       T.ZN,
       T.PB,
       T.SN,
       T.CA,
       T.LA,
       T.SB,
       T.CE,
       T.SE,
       T.MG,
       T.NB,
       T.CD,
       T.BI,
       T.N,
       T.H,
       T.O,
       T.FE,
       T.ALT,
       T.ALS,
       T.ALINS,
       T.BS,
       T.BN,
       T.MGO,
       T.SIO2,
       T.AL2O3,
       T.TFEO,
       T.FE2O3,
       T.H2O,
       T.CAF2,
       T.P2O5,
       T.TFE,
       T.CR2O3,
       T.TIO2,
       T.MNO,
       T.V2O5,
       T.FEO,
       T.CAO,
       T.ZR,
       T.CO,
       T.TA,
       T.SAMPLE_ID,
       T.XH,
       T.MACHINE,
       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.VALIDFLAG,
       T.MEMO
  FROM QCM_JHY_ELEMENTS T
 WHERE T.ASSAYNO = {0}
		]]>
	</query>
	
	<query id="QcmJhyElementsDAL.updateJudgeFlag" 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="QcmJhyElementsDAL.updateJudgeFlagByBatchNo" desc="修改判定标志">
		<![CDATA[
UPDATE QCM_JHY_ELEMENTS T
   SET T.JUDGE_FLAG = {4},
       T.LG_JUDGE_FLAG = {4}
 WHERE T.SAMPLE_ID = {0}
   AND T.JUDGE_STOVE_NO = {1}
   AND T.BATCH_NO = {2}
   AND T.ASSAYTYPE = 'B'
   AND EXISTS (SELECT 1
          FROM COM_BASE_PLINE A
         WHERE A.PLINE_CODE = T.PLINE_CODE
           AND A.PROCESS_CODE = {3})
		]]>
	</query>
	
	<query id="QcmJhyElementsDAL.QueryCraftChemCnt" desc="查询工艺成分套数">
		<![CDATA[
SELECT NVL(T.SMELTING_CNT_N, '1') SMELTING_CNT_N, NVL(T.PRODUCT_CNT_N, '1') PRODUCT_CNT_N
  FROM CRAFT_ORD_DESIGN_STD T
 WHERE T.DESGIN_KEY = {0}
		]]>
	</query>
	
	<query id="QcmJhyElementsDAL.deleteJhyElements" desc="删除检化验成分实绩">
		<![CDATA[
DELETE FROM QCM_JHY_ELEMENTS T
 WHERE T.STOVE_NO = {0}
   AND T.ASSAYTYPE = 'A'
   AND T.SAMPLE_NO LIKE '60%'
		]]>
	</query>

    <query id="QcmJhyElementsDAL.queryJhyElements" desc="删除检化验成分实绩">
        <![CDATA[
   SELECT * FROM QCM_JHY_ELEMENTS T
 WHERE T.STOVE_NO = {0}
   AND T.ASSAYTYPE = 'A'
   AND T.SAMPLE_NO LIKE '60%'
		]]>
    </query>
	
	<query id="QcmJhyElementsDAL.deleteJhyElementsByCheckNo" desc="删除检化验成分实绩">
		<![CDATA[
DELETE FROM QCM_JHY_ELEMENTS T
 WHERE T.SAMPLE_ID = {0}
   AND T.ASSAYTYPE = 'B'
		]]>
	</query>
	
	<query id="QcmJhyElementsDAL.queryAllByStoveNo" 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.FE,
       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="QcmJhyElementsDAL.queryLoadNoByStoveNo" desc="通过炉号查询所有检验记录">
		<![CDATA[
			SELECT  A.FEED_HEAT_NO FROM PLN_ZY_RCL_M A WHERE A.JUDGE_STOVE_NO={0}

		]]>
	</query>
	
	<query id="QcmJhyElementsDAL.queryAllByJudgeStoveNo" 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.FE,
       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, COM_BASE_PLINE C, QCM_ZC_CHECKCONSIGN B
 WHERE A.PLINE_CODE = C.PLINE_CODE
   AND C.PROCESS_CODE = {0}
   AND A.VALIDFLAG = '1'
   AND A.ASSAYTYPE = 'B'
   AND A.JUDGE_STOVE_NO = {1}
   AND B.CHECK_NO = A.SAMPLE_ID
   AND B.JUDGE_STOVE_NO = A.JUDGE_STOVE_NO
   AND B.BATCH_NO = A.BATCH_NO
   AND B.CRAFT_SOURCE IN {2}
   AND A.VALIDFLAG = '1'
   AND (A.SAMPLE_TYPE = '2' OR NOT EXISTS
        (SELECT 1
           FROM QCM_JHY_ELEMENTS A2
          WHERE A2.JUDGE_STOVE_NO = A.JUDGE_STOVE_NO
            AND A2.PLINE_CODE = A.PLINE_CODE
            AND A2.ASSAYTYPE = 'B'
            AND A2.SAMPLE_TYPE = '2') AND A.SAMPLE_TYPE = '0')
		]]>
	</query>
	
	<query id="QcmJhyElementsDAL.queryAllByCheckNo" 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.FE,
       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, 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="QcmJhyElementsDAL.queryAllNoBatchNo" 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.FE,
       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, 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}
		]]>
	</query>
	
	<query id = "QcmJhyElementsDAL.queryPipeChemCheckNo" desc = "查询检化验成分信息">
 SELECT 
       T.CHECK_NO,
       T.SAMPLE_NO,
       T.CHEM_CODE,
       T.CHEM_NAME,
       T.CHEM_TYPE,
       T.ISCHECK,
       T.ISJUDGE,
       T.ISQUOTE,
       T.COMPLEX_TYPE,
       T.CHEM_FORMULA,
       T.STDMIN_SIGN,
       T.STDMIN,
       T.STDMAX_SIGN,
       T.STDMAX,
       T.STDTARGET,
       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.SELECT_STEEL_NO,
       T.STD_STEEL_STD_VALUE,
       T.STD_STEEL_PROCESS_VALUE,
       T.ROUND_VALUE,
       T.PROCESS_VALUE,
       T.AUDIT_VALUE,
       T.QUOTE_VALUE,
       T.REMARK,
       T.CHECK_CLASS,
       T.CHECK_TEMP,
       T.DEVICE_NO,
       T.DEVICE_NAME,
       T.AUDIT_NAME,
       TO_CHAR(T.AUDIT_TIME, 'YYYY-MM-DD HH24:MI:SS') AUDIT_TIME,
       T.IS_CJ,
       T.BATCH_NO
FROM PIPE_CHECKCONSIGN_CHEMDETAIL T WHERE T.CHECK_NO = {0}
	</query>
	<query id = "QcmJhyElementsDAL.insertPipeElements" desc = "新增检化验成分">
	 INSERT INTO PIPE_CHECKCONSIGN_CHEMDETAIL(
        CHECK_NO,
        SAMPLE_NO,
        CHEM_CODE,
        CHEM_NAME,
        CHEM_TYPE,
        ISCHECK,
        ISJUDGE,
        ISQUOTE,
        COMPLEX_TYPE,
        CHEM_FORMULA,
        STDMIN_SIGN,
        STDMIN,
        STDMAX_SIGN,
        STDMAX,
        STDTARGET,
        STDMEMO,
        ELE_CODE,
        ELE_NAME,
        ELE_MIN_SIGN,
        ELE_MIN,
        ELE_MAX_SIGN,
        ELE_MAX,
        REP_CODE,
        REP_NAME,
        REP_MIN_SIGN,
        REP_MIN,
        REP_MAX_SIGN,
        REP_MAX,
        REP_VAL,
        SELECT_STEEL_NO,
        STD_STEEL_STD_VALUE,
        STD_STEEL_PROCESS_VALUE,
        ROUND_VALUE,
        PROCESS_VALUE,
        AUDIT_VALUE,
        QUOTE_VALUE,
        REMARK,
        CHECK_CLASS,
        CHECK_TEMP,
        DEVICE_NO,
        DEVICE_NAME,
        AUDIT_NAME,
        AUDIT_TIME,
        IS_CJ,
        BATCH_NO)
 VALUES( 
        '#CHECK_NO#',
        '#SAMPLE_NO#',
        '#CHEM_CODE#',
        '#CHEM_NAME#',
        '#CHEM_TYPE#',
        '#ISCHECK#',
        '#ISJUDGE#',
        '#ISQUOTE#',
        '#COMPLEX_TYPE#',
        '#CHEM_FORMULA#',
        '#STDMIN_SIGN#',
        '#STDMIN#',
        '#STDMAX_SIGN#',
        '#STDMAX#',
        '#STDTARGET#',
        '#STDMEMO#',
        '#ELE_CODE#',
        '#ELE_NAME#',
        '#ELE_MIN_SIGN#',
        '#ELE_MIN#',
        '#ELE_MAX_SIGN#',
        '#ELE_MAX#',
        '#REP_CODE#',
        '#REP_NAME#',
        '#REP_MIN_SIGN#',
        '#REP_MIN#',
        '#REP_MAX_SIGN#',
        '#REP_MAX#',
        '#REP_VAL#',
        '#SELECT_STEEL_NO#',
        '#STD_STEEL_STD_VALUE#',
        '#STD_STEEL_PROCESS_VALUE#',
        '#ROUND_VALUE#',
        '#PROCESS_VALUE#',
        '#AUDIT_VALUE#',
        '#QUOTE_VALUE#',
        '#REMARK#',
        '#CHECK_CLASS#',
        '#CHECK_TEMP#',
        '#DEVICE_NO#',
        '#DEVICE_NAME#',
        '#AUDIT_NAME#',
        TO_DATE('#AUDIT_TIME#','YYYY-MM-DD HH24:MI:SS'),
        '#IS_CJ#',
        '#BATCH_NO#')
	</query>
	<query id="QcmJhyElementsDAL.deleteJhyElementsByAssayNo" desc="删除检化验成分实绩">
		<![CDATA[
DELETE FROM QCM_JHY_ELEMENTS T WHERE T.ASSAYNO = {0}
		]]>
	</query>
	
	<query id="QcmJhyElementsDAL.getCountByBatchNo" desc="查询成分数">
		<![CDATA[
SELECT COUNT(1) COUNT
  FROM QCM_JHY_ELEMENTS T, COM_BASE_PLINE A
 WHERE T.PLINE_CODE = A.PLINE_CODE
   AND T.JUDGE_STOVE_NO = {0}
   AND A.PROCESS_CODE = {1}
		]]>
	</query>
	
	<query id="QcmJhyElementsDAL.getPhyMinByBatchNo" desc="通过炉批查询成分信息">
		<![CDATA[
SELECT C.CHECK_NO SAMPLE_ID,
       C.CHECK_NO,
       D.SAMPLE_NO,
       'HX' PHY_CODE_MIN,
       '化学' PHY_NAME_MIN,
       CASE
         WHEN {6} = '0' THEN
          DECODE(B3.PRODUCT_CNT_N, NULL, B3.PRODUCT_CNT, B3.PRODUCT_CNT_N)
         WHEN {6} = '1' THEN
          B4.PRODUCT_CNT_FD
       END DESC_COUNT,
       C.LOT_NO,
       C.JUDGE_STOVE_NO,
       C.BATCH_NO,
       C.PROCESS_CODE,
       B2.PROCESS_DESC,
       DECODE({6}, '1', 'CIC', {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,
       '408603' RATE,
       '炉' 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({6}, '1', '首日检', '生产样') CRAFT_SOURCE_DESC
  FROM CRAFT_ORD_DESIGN B
  LEFT JOIN QCM_ZC_CHECKCONSIGN_DETAIL D
    ON EXISTS (SELECT 1
          FROM QCM_ZC_CHECKCONSIGN D3, PLN_SALEORD D4
         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 = {9}
           AND ({10} IS NULL OR {10} = '0' AND EXISTS
                (SELECT 1
                   FROM QCM_GP_JUDGE_APPLY D5
                  WHERE D5.STOVE_NO = D3.STOVE_NO
                    AND D5.IS_FLAG = '0'
                    AND D5.PLINE_CODE NOT IN ('C063', 'C064')) OR
                {10} = '1' AND EXISTS
                (SELECT 1
                   FROM QCM_GP_JUDGE_APPLY D5
                  WHERE D5.STOVE_NO = D3.STOVE_NO
                    AND D5.IS_FLAG = '0'
                    AND D5.PLINE_CODE IN ('C063', 'C064')))
           AND D3.PLINE_CODE = {8}
           AND D3.IS_FLAG = '0'
           AND D3.CYCLES_FLAG = '0'
           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
  LEFT JOIN CRAFT_ORD_FD_CIC_COUNT B4
    ON B4.ORD_LN_PK = B.ORD_LN_PK
 WHERE B.ORD_LN_PK = {0}
   AND B.CRAFT_SEQ = {1}
		]]>
	</query>
	
	<query id="QcmJhyElementsDAL.getLgPhyMinByStoveNo" desc="通过炉批查询成分信息">
		<![CDATA[
SELECT DISTINCT
       '化学' PHY_NAME_MIN,
       'HX' PHY_CODE_MIN,
       NULL SAMPLE_ID,
       DECODE(B2.PRODUCT_CNT_N, NULL, B2.PRODUCT_CNT, B2.PRODUCT_CNT_N) DESC_COUNT,
       E.SAMPLE_NO,
       {2} STOVE_NO,
       {3} JUDGE_STOVE_NO,
       NULL BATCH_NO,
       'A' PROCESS_CODE,
       '炼钢' PROCESS_DESC,
       {4} PIC,
       DECODE(F.JUDGE_RESULT_CODE, '40740701', '1', NULL) NK_RESULT,
       DECODE(F.JUDGE_RESULT_CODE, '40740701', '1', NULL) JF_RESULT,
       '408603' RATE,
       '炉' DESC_RATE,
       CASE
         WHEN E2.CHEM_JUDGE_ID IS NULL THEN
          NULL
         ELSE
          '0'
       END RESULT_SOURCE,
       '0' CRAFT_SOURCE,
       '生产样' CRAFT_SOURCE_DESC,
       '0' IS_MAIN,
       'False' CHK
  FROM CRAFT_ORD_DESIGN B
  LEFT JOIN QCM_LG_CHEMJUDGE E2
    ON E2.JUDGE_STOVE_NO = {3}
   AND E2.VALIDFLAG = '1'
   AND E2.PROCESS_CDOE = 'B'
  LEFT JOIN QCM_JHY_ELEMENTS E
    ON E.STOVE_NO = {2}
   AND E.ASSAYTYPE = 'A'
   AND E.SAMPLE_NO LIKE '60%'
   AND (E2.SAMPLE_NO IS NULL OR E.SAMPLE_NO = E2.SAMPLE_NO)
  LEFT JOIN CRAFT_ORD_DESIGN_STD B2
    ON B2.DESGIN_KEY = B.DESGIN_KEY
  LEFT JOIN QCM_GP_JUDGE_APPLY F
    ON F.JUDGE_STOVE_NO = E2.JUDGE_STOVE_NO
   AND F.IS_FLAG = '0'
   AND F.IS_ALL_SCRAP = '0'
 WHERE B.ORD_LN_PK = {0}
   AND B.CRAFT_SEQ = {1}
		]]>
	</query>
	
	<query id="QcmJhyElementsDAL.copyByBatchNo" desc="通过炉批复制">
		<![CDATA[
INSERT INTO QCM_JHY_ELEMENTS
  (ASSAYNO,
   STOVE_NO,
   JUDGE_STOVE_NO,
   BATCH_NO,
   ASSAYTYPE,
   FLAG,
   C,
   SI,
   MN,
   P,
   S,
   NI,
   CR,
   CU,
   ASN,
   TI,
   V,
   MO,
   B,
   W,
   AL,
   ZN,
   PB,
   SN,
   CA,
   LA,
   SB,
   CE,
   SE,
   MG,
   NB,
   CD,
   BI,
   N,
   H,
   O,
   FE,
   ALT,
   ALS,
   ALINS,
   BS,
   BN,
   MGO,
   SIO2,
   AL2O3,
   TFEO,
   FE2O3,
   H2O,
   CAF2,
   P2O5,
   TFE,
   CR2O3,
   TIO2,
   MNO,
   V2O5,
   FEO,
   CAO,
   SAMPLE_ID,
   XH,
   MACHINE,
   CREATE_NAME,
   CREATE_TIME,
   UPDATE_NAME,
   UPDATE_TIME,
   DELETE_NAME,
   DELETE_TIME,
   VALIDFLAG,
   MEMO,
   SAMPLE_NO,
   PLINE_CODE,
   JUDGE_FLAG,
   ZR,
   LG_JUDGE_FLAG,
   CO,
   TA,
   SAMPLE_TYPE,
   MAT_NO,
   HEAD_MAT_NO,
   BAR_CODE)
  (SELECT T.ASSAYNO,
          T.STOVE_NO,
          T.JUDGE_STOVE_NO,
          T.BATCH_NO,
          T.ASSAYTYPE,
          T.FLAG,
          T.C,
          T.SI,
          T.MN,
          T.P,
          T.S,
          T.NI,
          T.CR,
          T.CU,
          T.ASN,
          T.TI,
          T.V,
          T.MO,
          T.B,
          T.W,
          T.AL,
          T.ZN,
          T.PB,
          T.SN,
          T.CA,
          T.LA,
          T.SB,
          T.CE,
          T.SE,
          T.MG,
          T.NB,
          T.CD,
          T.BI,
          T.N,
          T.H,
          T.O,
          T.FE,
          T.ALT,
          T.ALS,
          T.ALINS,
          T.BS,
          T.BN,
          T.MGO,
          T.SIO2,
          T.AL2O3,
          T.TFEO,
          T.FE2O3,
          T.H2O,
          T.CAF2,
          T.P2O5,
          T.TFE,
          T.CR2O3,
          T.TIO2,
          T.MNO,
          T.V2O5,
          T.FEO,
          T.CAO,
          T.SAMPLE_ID,
          T.XH,
          T.MACHINE,
          T.CREATE_NAME,
          T.CREATE_TIME,
          T.UPDATE_NAME,
          T.UPDATE_TIME,
          T.DELETE_NAME,
          T.DELETE_TIME,
          T.VALIDFLAG,
          T.MEMO,
          T.SAMPLE_NO,
          T.PLINE_CODE,
          T.JUDGE_FLAG,
          T.ZR,
          T.LG_JUDGE_FLAG,
          T.CO,
          T.TA,
          T.SAMPLE_TYPE,
          T.MAT_NO,
          T.HEAD_MAT_NO,
          T.BAR_CODE
     FROM QCM_JHY_ELEMENTS T, QCM_ZC_CHECKCONSIGN A
    WHERE A.JUDGE_STOVE_NO = {0}
      AND A.BATCH_NO = {1}
      AND A.PROCESS_CODE = {2}
      AND A.CRAFT_SOURCE = {3}
      AND A.CHECK_NO = T.SAMPLE_ID
      AND A.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
      AND A.BATCH_NO = T.BATCH_NO
      AND A.ORD_LN_DLY_PK = {4})
		]]>
	</query>
	
	<query id="QcmJhyElementsDAL.getPhyByJudgeStoveNo" desc="通过判定炉好查询成分实绩">
		<![CDATA[
SELECT T.ASSAYNO,
       T.STOVE_NO,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.ASSAYTYPE,
       T.FLAG,
       T.C,
       T.SI,
       T.MN,
       T.P,
       T.S,
       T.NI,
       T.CR,
       T.CU,
       T.ASN,
       T.TI,
       T.V,
       T.MO,
       T.B,
       T.W,
       T.AL,
       T.ZN,
       T.PB,
       T.SN,
       T.CA,
       T.LA,
       T.SB,
       T.CE,
       T.SE,
       T.MG,
       T.NB,
       T.CD,
       T.BI,
       T.N,
       T.H,
       T.O,
       T.FE,
       T.ALT,
       T.ALS,
       T.ALINS,
       T.BS,
       T.BN,
       T.MGO,
       T.SIO2,
       T.AL2O3,
       T.TFEO,
       T.FE2O3,
       T.H2O,
       T.CAF2,
       T.P2O5,
       T.TFE,
       T.CR2O3,
       T.TIO2,
       T.MNO,
       T.V2O5,
       T.FEO,
       T.CAO,
       T.SAMPLE_ID,
       T.XH,
       T.MACHINE,
       T.CREATE_NAME,
       T.CREATE_TIME,
       T.UPDATE_NAME,
       T.UPDATE_TIME,
       T.DELETE_NAME,
       T.DELETE_TIME,
       T.VALIDFLAG,
       T.MEMO,
       T.SAMPLE_NO,
       T.PLINE_CODE,
       T.JUDGE_FLAG,
       T.ZR,
       T.LG_JUDGE_FLAG,
       T.CO,
       T.TA,
       T.SAMPLE_TYPE,
       T.MAT_NO,
       T.HEAD_MAT_NO,
       T.BAR_CODE
  FROM QCM_JHY_ELEMENTS     T,
       QCM_ZC_CHECKCONSIGN  A,
       PLN_SALEORD B,
       CRAFT_ORD_DESIGN     C,
       CRAFT_ORD_DESIGN_STD D
 WHERE A.JUDGE_STOVE_NO = {0}
   AND A.PROCESS_CODE = {1}
   AND A.CRAFT_SOURCE = {2}
   AND A.ORD_LN_DLY_PK = {3}
   AND A.CHECK_NO = T.SAMPLE_ID
   AND A.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
   AND A.BATCH_NO = T.BATCH_NO
   AND B.ORD_LN_DLY_PK = A.ORD_LN_DLY_PK
   AND C.ORD_LN_PK = B.ORD_LN_PK
   AND C.CRAFT_SEQ = A.CRAFT_SEQ
   AND D.DESGIN_KEY = C.DESGIN_KEY
		]]>
	</query>
	
	<query id="QcmJhyElementsDAL.getPhyByBatchNo" desc="通过判定炉好查询成分实绩">
		<![CDATA[
SELECT T.ASSAYNO,
       T.STOVE_NO,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.ASSAYTYPE,
       T.FLAG,
       T.C,
       T.SI,
       T.MN,
       T.P,
       T.S,
       T.NI,
       T.CR,
       T.CU,
       T.ASN,
       T.TI,
       T.V,
       T.MO,
       T.B,
       T.W,
       T.AL,
       T.ZN,
       T.PB,
       T.SN,
       T.CA,
       T.LA,
       T.SB,
       T.CE,
       T.SE,
       T.MG,
       T.NB,
       T.CD,
       T.BI,
       T.N,
       T.H,
       T.O,
       T.FE,
       T.ALT,
       T.ALS,
       T.ALINS,
       T.BS,
       T.BN,
       T.MGO,
       T.SIO2,
       T.AL2O3,
       T.TFEO,
       T.FE2O3,
       T.H2O,
       T.CAF2,
       T.P2O5,
       T.TFE,
       T.CR2O3,
       T.TIO2,
       T.MNO,
       T.V2O5,
       T.FEO,
       T.CAO,
       T.SAMPLE_ID,
       T.XH,
       T.MACHINE,
       T.CREATE_NAME,
       T.CREATE_TIME,
       T.UPDATE_NAME,
       T.UPDATE_TIME,
       T.DELETE_NAME,
       T.DELETE_TIME,
       T.VALIDFLAG,
       T.MEMO,
       T.SAMPLE_NO,
       T.PLINE_CODE,
       T.JUDGE_FLAG,
       T.ZR,
       T.LG_JUDGE_FLAG,
       T.CO,
       T.TA,
       T.SAMPLE_TYPE,
       T.MAT_NO,
       T.HEAD_MAT_NO,
       T.BAR_CODE
  FROM QCM_JHY_ELEMENTS     T,
       QCM_ZC_CHECKCONSIGN  A,
       PLN_SALEORD B,
       CRAFT_ORD_DESIGN     C,
       CRAFT_ORD_DESIGN_STD D
 WHERE A.JUDGE_STOVE_NO = {0}
   AND A.PROCESS_CODE = {2}
   AND A.CRAFT_SOURCE = {3}
   AND A.ORD_LN_DLY_PK = {4}
   AND A.CHECK_NO = T.SAMPLE_ID
   AND A.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
   AND A.BATCH_NO = T.BATCH_NO
   AND B.ORD_LN_DLY_PK = A.ORD_LN_DLY_PK
   AND C.ORD_LN_PK = B.ORD_LN_PK
   AND C.CRAFT_SEQ = A.CRAFT_SEQ
   AND D.DESGIN_KEY = C.DESGIN_KEY
   AND A.BATCH_NO = {1}
		]]>
	</query>
	
	<query id="QcmJhyElementsDAL.deleteByBathNoOrdLnDlyPkCheckNo" desc="通过炉批+交货行PK删除">
        <![CDATA[
DELETE FROM QCM_JHY_ELEMENTS 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.SAMPLE_ID
             AND T.JUDGE_STOVE_NO = A.JUDGE_STOVE_NO
             AND T.BATCH_NO = A.BATCH_NO)
        ]]>
    </query>
    <query id="QcmJhyElementsDAL.deleteByBathNoOrdLnDlyPkCheckNo1" desc="通过炉批+交货行PK删除">
        <![CDATA[
DELETE FROM QCM_JHY_ELEMENTS A
   WHERE A.SAMPLE_ID = {0}
        ]]>
    </query>
    <query id="QcmJhyElementsDAL.insertQcmJhyElements" desc="新增质量成分化验实绩表">
		<![CDATA[
INSERT INTO QCM_JHY_ELEMENTS
  (ASSAYNO,
   STOVE_NO,
   JUDGE_STOVE_NO,
   BATCH_NO,
   ASSAYTYPE,
   FLAG,
   C,
   SI,
   MN,
   P,
   S,
   NI,
   CR,
   CU,
   ASN,
   TI,
   V,
   MO,
   B,
   W,
   AL,
   ZN,
   PB,
   SN,
   CA,
   LA,
   SB,
   CE,
   SE,
   MG,
   NB,
   CD,
   BI,
   N,
   H,
   O,
   FE,
   ALT,
   ALS,
   ALINS,
   BS,
   BN,
   MGO,
   SIO2,
   AL2O3,
   TFEO,
   FE2O3,
   H2O,
   CAF2,
   P2O5,
   TFE,
   CR2O3,
   TIO2,
   MNO,
   V2O5,
   FEO,
   CAO,
   ZR,
   CO,
   TA,
   SAMPLE_ID,
   XH,
   MACHINE,
   CREATE_NAME,
   CREATE_TIME,
   MEMO,
   SAMPLE_NO,
   PLINE_CODE,
   SAMPLE_TYPE,
   MAT_NO,
   HEAD_MAT_NO,
   BAR_CODE,
   JUDGE_FLAG,
   LG_JUDGE_FLAG)
VALUES
  ('#ASSAYNO#',
   '#STOVE_NO#',
   '#JUDGE_STOVE_NO#',
   '#BATCH_NO#',
   '#ASSAYTYPE#',
   '#FLAG#',
   '#C#',
   '#SI#',
   '#MN#',
   '#P#',
   '#S#',
   '#NI#',
   '#CR#',
   '#CU#',
   '#ASN#',
   '#TI#',
   '#V#',
   '#MO#',
   '#B#',
   '#W#',
   '#AL#',
   '#ZN#',
   '#PB#',
   '#SN#',
   '#CA#',
   '#LA#',
   '#SB#',
   '#CE#',
   '#SE#',
   '#MG#',
   '#NB#',
   '#CD#',
   '#BI#',
   '#N#',
   '#H#',
   '#O#',
   '#FE#',
   '#ALT#',
   '#ALS#',
   '#ALINS#',
   '#BS#',
   '#BN#',
   '#MGO#',
   '#SIO2#',
   '#AL2O3#',
   '#TFEO#',
   '#FE2O3#',
   '#H2O#',
   '#CAF2#',
   '#P2O5#',
   '#TFE#',
   '#CR2O3#',
   '#TIO2#',
   '#MNO#',
   '#V2O5#',
   '#FEO#',
   '#CAO#',
   '#ZR#',
   '#CO#',
   '#TA#',
   '#SAMPLE_ID#',
   '#XH#',
   '#MACHINE#',
   '#CREATE_NAME#',
   SYSDATE,
   '#MEMO#',
   '#SAMPLE_NO#',
   '#PLINE_CODE#',
   '#SAMPLE_TYPE#',
   '#MAT_NO#',
   '#HEAD_MAT_NO#',
   '#BAR_CODE#',
   '#JUDGE_FLAG#',
   '#LG_JUDGE_FLAG#')
		]]>
	</query>
	
	<query id="QcmJhyElementsDAL.importMeltingQuery" desc="熔炼成分导入查询">
		<![CDATA[
SELECT T.*
  FROM QCM_JHY_ELEMENTS T
  LEFT JOIN QCM_LG_JUDGE A
    ON A.STOVE_NO = T.STOVE_NO
   AND A.PROCESS_CDOE = 'B'
   AND A.VALIDFLAG = '1'
 WHERE T.VALIDFLAG = '1'
   AND T.ASSAYTYPE = 'A'
   AND T.SAMPLE_NO LIKE '60%'
   AND ({0} IS NULL OR T.STOVE_NO LIKE '%' || {0} || '%')
   AND ({1} IS NULL OR A.JUDGE_STOVE_NO = {1})
   AND ({2} IS NULL OR
       T.CREATE_TIME >= TO_DATE({2}, 'YYYY-MM-DD HH24:MI:SS'))
   AND ({3} IS NULL OR
       T.CREATE_TIME <= TO_DATE({3}, 'YYYY-MM-DD HH24:MI:SS'))
		]]>
	</query>
</queryMap>