<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="">
	<query id="AuditMeltingDataDAL.query" desc="查询炉号数据">
		<![CDATA[
SELECT NVL(D.ASSAYNO, A.ASSAYNO) ASSAYNO,
       A.STOVE_NO,
       A.JUDGE_STOVE_NO,
       A.BATCH_NO,
       A.ASSAYTYPE,
       A.FLAG,
       NVL(D.C, A.C) C,
       NVL(D.SI, A.SI) SI,
       NVL(D.MN, A.MN) MN,
       NVL(D.P, A.P) P,
       NVL(D.S, A.S) S,
       NVL(D.NI, A.NI) NI,
       NVL(D.CR, A.CR) CR,
       NVL(D.MO, A.MO) MO,
       NVL(D.CU, A.CU) CU,
       NVL(D.AL, A.AL) AL,
       NVL(D.CA, A.CA) CA,
       NVL(D.V, A.V) V,
       NVL(D.NB, A.NB) NB,
       NVL(D.TI, A.TI) TI,
       NVL(D.B, A.B) B,
       NVL(D.PB, A.PB) PB,
       NVL(D.SN, A.SN) SN,
       NVL(D.ASN, A.ASN) ASN,
       NVL(D.SB, A.SB) SB,
       NVL(D.BI, A.BI) BI,
       NVL(D.O, A.O) O,
       NVL(D.N, A.N) N,
       NVL(D.H, A.H) H,
       NVL(D.ZR, A.ZR) ZR,
       NVL(D.W, A.W) W,
       NVL(D.ZN, A.ZN) ZN,
       NVL(D.ALS, A.ALS) ALS,
       NVL(D.ALT, A.ALT) ALT,
       NVL(D.SE, A.SE) SE,
       NVL(D.CO, A.CO) 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,
       DECODE(B.JUDGE_FLAG,
              '00',
              '初始',
              '05',
              '不用',
              '10',
              '不合',
              '20',
              '合格') JUDGE_FLAG,
       B.GRADENAME,
       B.DOWNMAN,
       TO_CHAR(B.DOWNTIME, 'YYYY-MM-DD HH24:MI:SS') DOWNTIME,
       B.EF_PLINE_NAME,
       B.CRAFT_NO,
       B.FURNACENO,
       B.EF_PLINE_NAME PLINE_NAME,
       B.PRO_MONTH
  FROM QCM_JHY_ELEMENTS A
  LEFT JOIN QCM_JHY_ELEMENTS D
    ON D.SAMPLE_NO LIKE '601_%'
   AND D.VALIDFLAG = '1'
   AND D.ASSAYTYPE = 'A'
   AND D.STOVE_NO = A.STOVE_NO, PLN_STEELFORFURNACE B, COM_BASE_PLINE C
 WHERE A.SAMPLE_NO = '601'
   AND A.VALIDFLAG = '1'
   AND A.ASSAYTYPE = 'A'
   AND B.STOVE_NO = A.STOVE_NO
   AND C.PLINE_CODE = B.EF_PLINE_CODE
   AND (D.STOVE_NO IS NULL OR
       D.SAMPLE_NO = (SELECT MAX(E.SAMPLE_NO)
                         FROM QCM_JHY_ELEMENTS E
                        WHERE E.STOVE_NO = D.STOVE_NO
                          AND E.VALIDFLAG = '1'
                          AND E.ASSAYTYPE = 'A'
                          AND E.SAMPLE_NO LIKE '601_%'))
   AND ({0} IS NULL OR B.DOWNTIME >= TO_DATE({0}, 'YYYY-MM-DD HH24:MI:SS'))
   AND ({1} IS NULL OR B.DOWNTIME <= TO_DATE({1}, 'YYYY-MM-DD HH24:MI:SS'))
   AND ({2} IS NULL OR B.JUDGE_FLAG = {2})
   AND ({3} IS NULL OR B.EF_PLINE_CODE = {3})
   AND ({3} IS NULL OR B.EF_PLINE_CODE = {3})
   AND ({4} IS NULL OR B.PRO_MONTH = {4})
   AND ({5} IS NULL OR A.STOVE_NO LIKE '%' || {5} || '%')
   AND (C.DEPARTMENT_CODE IN {6})
   ORDER BY A.STOVE_NO
		]]>
	</query>
	
	<query id="AuditMeltingDataDAL.getQcmJhyElements601" desc="获取成分实绩信息601样">
		<![CDATA[
SELECT *
   FROM QCM_JHY_ELEMENTS A
  WHERE A.STOVE_NO = {0}
    AND A.SAMPLE_NO = '601'
    AND A.ASSAYTYPE = 'A'
    AND A.VALIDFLAG = '1'
		]]>
	</query>
	
	<query id="AuditMeltingDataDAL.getQcmJhyElements601F" desc="获取成分实绩信息601复样">
		<![CDATA[
SELECT *
   FROM QCM_JHY_ELEMENTS A
  WHERE A.STOVE_NO = {0}
    AND A.SAMPLE_NO LIKE '601_%'
    AND A.ASSAYTYPE = 'A'
    AND A.VALIDFLAG = '1'
		]]>
	</query>
	
	<query id="AuditMeltingDataDAL.getBaseElements" desc="获取基础化学元素">
		<![CDATA[
SELECT T.CHEM_NAME FROM COM_BASE_CHEM T
		]]>
	</query>
	
	<query id="AuditMeltingDataDAL.getJhyElementsState" desc="获取检化验成分实绩">
		<![CDATA[
SELECT T.JUDGE_FLAG
     FROM QCM_JHY_ELEMENTS T
    WHERE T.STOVE_NO = {0}
      AND T.ASSAYTYPE = 'A'
      AND T.SAMPLE_NO = '601'
		]]>
	</query>
	
	<query id="AuditMeltingDataDAL.getPlnSteelforfurnaceState" desc="获取炼钢炉次计划表状态">
		<![CDATA[
SELECT T.JUDGE_FLAG FROM PLN_STEELFORFURNACE T WHERE T.FURNACENO = {0}
		]]>
	</query>
	
	<query id="AuditMeltingDataDAL.getPlnSteelforfurnace" desc="获取炼钢炉次计划表">
		<![CDATA[
SELECT A.FURNACENO, A.STOVE_NO, A.CRAFT_NO
          FROM PLN_STEELFORFURNACE A
         WHERE A.FURNACENO = {0}
		]]>
	</query>
	
	<query id="AuditMeltingDataDAL.getCraftLg2Cic" desc="获取炼钢二级工艺成分">
		<![CDATA[
SELECT B.*
  FROM CRAFT_LG2_M A, CRAFT_LG2_CIC B
 WHERE A.CRAFT_NO = {0}
   AND A.VALIDFLAG = '10'
   AND B.CIC_GID = A.CIC_GID
		]]>
	</query>
	
	<query id="AuditMeltingDataDAL.updatePlnSteelforfurnace" desc="更新炼钢炉次计划表">
		<![CDATA[
UPDATE PLN_STEELFORFURNACE T SET T.JUDGE_FLAG = {0} WHERE T.FURNACENO = {1}
		]]>
	</query>
	
	<query id="AuditMeltingDataDAL.updateJhyElements" desc="更新成分实绩表">
		<![CDATA[
UPDATE QCM_JHY_ELEMENTS T SET T.JUDGE_FLAG = {0} WHERE T.STOVE_NO = {1}
AND T.ASSAYTYPE = 'A' AND T.SAMPLE_NO LIKE '601%'
		]]>
	</query>
	
	<query id="AuditMeltingDataDAL.getBaseChem" desc="获取基础元素">
		<![CDATA[
SELECT T.CHEM_CODE, T.CHEM_NAME
  FROM COM_BASE_CHEM T
 WHERE T.VALIDFLAG = '1'
   AND T.CHEM_TYPE = 'A'
		]]>
	</query>
</queryMap>