<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="QCM_LG_CHEMJUDGE （生成工具：代码生成工具4.0   访问地址：http://172.16.2.128/tool/）">
    <query id="QcmLgChemjudgeDAL.Query" desc="查询">
        <![CDATA[
SELECT T.CHEM_JUDGE_ID,
       T.STOVE_NO,
       T.JUDGE_STOVE_NO,
       T.MAT_NO,
       T.PLINE_CODE,
       B.PLINE_NAME,
       T.PROCESS_CDOE,
       T.PROCESS_DESC,
       T.PLAN_ORDERNO,
       T.JUDGE_ORDERNO,
       A.BASENAME JUDGERESULT_CHEM,
       DECODE(T.ORDERISUNCHAIN, '1', '是', '0', '否') ORDERISUNCHAIN,
       T.ASSAYNO,
       DECODE(T.VALIDFLAG, '1', '有效', '0', '无效') VALIDFLAG,
       T.MEMO,
       T.CREATE_NAME,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T.JUGDE_APPLY_CODE
  FROM QCM_LG_CHEMJUDGE T
  LEFT JOIN COM_BASE_INFO A
    ON A.BASECODE = T.JUDGERESULT_CHEM
  LEFT JOIN COM_BASE_PLINE B
  ON T.PLINE_CODE = B.PLINE_CODE
 WHERE T.STOVE_NO = {0}
 AND T.PROCESS_CDOE = {1}
 AND T.VALIDFLAG = '1'
 ORDER BY T.CHEM_JUDGE_ID DESC
        ]]>
    </query>
    <query id="QcmLgChemjudgeDAL.QuerySteelMaking" desc="查询">
        <![CDATA[
SELECT T.CHEM_JUDGE_ID,
       T.STOVE_NO,
       T.JUDGE_STOVE_NO,
       T.MAT_NO,
       T.PLINE_CODE,
       B.PLINE_NAME,
       T.PROCESS_CDOE,
       T.PROCESS_DESC,
       T.PLAN_ORDERNO,
       T.JUDGE_ORDERNO,
       T.JUDGERESULT_CHEM JUDGE_CHEM_CODE,
       A.BASENAME JUDGERESULT_CHEM,
       DECODE(T.ORDERISUNCHAIN, '1', '是', '0', '否') ORDERISUNCHAIN,
       T.ASSAYNO,
       DECODE(T.VALIDFLAG, '1', '有效', '0', '无效') VALIDFLAG,
       T.MEMO,
       T.CREATE_NAME,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T.JUGDE_APPLY_CODE
  FROM QCM_LG_CHEMJUDGE T
  LEFT JOIN COM_BASE_INFO A
    ON A.BASECODE = T.JUDGERESULT_CHEM
  LEFT JOIN COM_BASE_PLINE B
    ON T.PLINE_CODE = B.PLINE_CODE
 WHERE T.PROCESS_CDOE = {0}
   AND ({1} IS NULL OR T.STOVE_NO LIKE '%' || {1} || '%')
   AND ({2} IS NULL OR T.JUDGE_STOVE_NO LIKE '%' || {2} || '%')
   AND ({3} IS NULL OR {3} = '0' AND T.JUDGERESULT_CHEM IS NULL OR
       {3} = '1' AND T.JUDGERESULT_CHEM IS NOT NULL OR
       {3} NOT IN ('0', '1') AND T.JUDGERESULT_CHEM = {3})
   AND ({4} IS NULL OR
       T.CREATE_TIME >= TO_DATE({4}, 'YYYY-MM-DD HH24:MI:SS'))
   AND ({5} IS NULL OR
       T.CREATE_TIME <= TO_DATE({5}, 'YYYY-MM-DD HH24:MI:SS'))
   AND ({6} = '0' OR T.PLINE_CODE IN {7})
   AND T.VALIDFLAG = '1'
 ORDER BY T.JUDGE_STOVE_NO, T.CHEM_JUDGE_ID DESC
        ]]>
    </query>
    <query id="QcmLgChemjudgeDAL.QueryByPk" desc="通过主键查询">
        <![CDATA[
 SELECT 
       T.CHEM_JUDGE_ID,
       T.STOVE_NO,
       T.JUDGE_STOVE_NO,
       T.MAT_NO,
       T.PLINE_CODE,
       T.PROCESS_CDOE,
       T.PROCESS_DESC,
       T.PLAN_ORDERNO,
       T.JUDGE_ORDERNO,
       T.JUDGERESULT_CHEM,
       T.ORDERISUNCHAIN,
       T.ASSAYNO,
       T.VALIDFLAG,
       T.MEMO,
       T.CREATE_NAME,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T.JUGDE_APPLY_CODE
 FROM QCM_LG_CHEMJUDGE T
 WHERE
       T.CHEM_JUDGE_ID = {0}
        ]]>
    </query>
    
    <query id="QcmLgChemjudgeDAL.Insert" 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="QcmLgChemjudgeDAL.Update" desc="修改">
        <![CDATA[
 UPDATE QCM_LG_CHEMJUDGE T
   SET 
        T.CHEM_JUDGE_ID = '#CHEM_JUDGE_ID#',
        T.STOVE_NO = '#STOVE_NO#',
        T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#',
        T.MAT_NO = '#MAT_NO#',
        T.PLINE_CODE = '#PLINE_CODE#',
        T.PROCESS_CDOE = '#PROCESS_CDOE#',
        T.PROCESS_DESC = '#PROCESS_DESC#',
        T.PLAN_ORDERNO = '#PLAN_ORDERNO#',
        T.JUDGE_ORDERNO = '#JUDGE_ORDERNO#',
        T.JUDGERESULT_CHEM = '#JUDGERESULT_CHEM#',
        T.ORDERISUNCHAIN = '#ORDERISUNCHAIN#',
        T.ASSAYNO = '#ASSAYNO#',
        T.VALIDFLAG = '#VALIDFLAG#',
        T.MEMO = '#MEMO#',
        T.CREATE_NAME = '#CREATE_NAME#',
        T.CREATE_TIME = SYSDATE,
        T.JUGDE_APPLY_CODE = '#JUGDE_APPLY_CODE#'
 WHERE
       T.CHEM_JUDGE_ID = '#CHEM_JUDGE_ID#'
        ]]>
    </query>
    <query id="QcmLgChemjudgeDAL.GetMaxPk" desc="获取最大主键">
        <![CDATA[
SELECT NVL(MAX(CHEM_JUDGE_ID), 0) + 1 MAX_VALUE FROM QCM_LG_CHEMJUDGE T
        ]]>
    </query>
    <query id="QcmLgChemjudgeDAL.Delete" desc="作废">
        <![CDATA[
UPDATE QCM_LG_CHEMJUDGE T
   SET
       T.VALIDFLAG = '0',
       T.DELETE_NAME = '#DELETE_NAME#',
       T.DELETE_TIME = SYSDATE
WHERE
       T.CHEM_JUDGE_ID = '#CHEM_JUDGE_ID#'
        ]]>
    </query>
    <query id="QcmLgChemjudgeDAL.Resume" desc="恢复">
        <![CDATA[
UPDATE QCM_LG_CHEMJUDGE T
   SET
       T.VALIDFLAG = '1',
       T.DELETE_NAME = NULL,
       T.DELETE_TIME = NULL,
       T.UPDATE_NAME = '#UPDATE_NAME#',
       T.UPDATE_TIME = SYSDATE
WHERE
       T.CHEM_JUDGE_ID = '#CHEM_JUDGE_ID#'
        ]]>
    </query>
    
    <query id="QcmLgChemJudgeDAL.getMaxChemJudgeId" desc="查询最大的成分判定记录号">
		<![CDATA[
SELECT NVL(MAX(T.CHEM_JUDGE_ID), TO_CHAR(SYSDATE, 'YYYYMMDD') || '00000') + 1 MAX_VALUE
  FROM QCM_LG_CHEMJUDGE T
 WHERE T.CHEM_JUDGE_ID LIKE TO_CHAR(SYSDATE, 'YYYYMMDD') || '%'
		]]>
	</query>
	
	<query id="QcmLgChemJudgeDAL.setChemJudgeId" desc="修改成分判定ID">
		<![CDATA[
UPDATE PLN_STEELFOR_ORD T
   SET T.CHEM_JUDGE_ID = {0}
 WHERE T.FURNACENO = {1}
		]]>
	</query>
	<query id="QcmLgChemJudgeDAL.setPhyJudgeId" desc="修改理化判定ID">
		<![CDATA[
UPDATE PLN_STEELFOR_ORD T
   SET T.PHY_JUDGE_ID = {0}
 WHERE T.FURNACENO = {1}
		]]>
	</query>
	<query id="QcmLgChemJudgeDAL.setColligateJudgeId" desc="修改理化判定ID">
		<![CDATA[
UPDATE PLN_STEELFOR_ORD T
   SET T.COLLIGATE_JUDGE_ID = {0}
 WHERE T.FURNACENO = {1}
		]]>
	</query>
	<query id="QcmLgChemJudgeDAL.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="QcmLgChemJudgeDAL.getCraftJfChem" 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 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 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 T.SPECL_FL = '1'
 ORDER BY CHEM_SEQ
		]]>
	</query>
	<query id="QcmLgChemJudgeDAL.updateValidflag" desc="修改有效标志">
		<![CDATA[
UPDATE QCM_LG_CHEMJUDGE T
   SET T.VALIDFLAG = {2}
 WHERE T.STOVE_NO = {0}
   AND T.PROCESS_CDOE = {1}
		]]>
	</query>
	<query id="QcmLgChemJudgeDAL.updateMemo" desc="修改备注">
		<![CDATA[
UPDATE QCM_LG_CHEMJUDGE T
   SET T.MEMO = {2}
 WHERE T.JUDGE_STOVE_NO = {0}
   AND T.PROCESS_CDOE = {1}
   AND T.VALIDFLAG = '1'
		]]>
	</query>
	
	<query id="QcmLgChemJudgeDAL.queryCntByJudgeStoveNo" desc="查询是否存在成分判定记录">
		<![CDATA[
SELECT COUNT(1) FROM QCM_LG_CHEMJUDGE T
 WHERE T.JUDGE_STOVE_NO = {0}
   AND T.PROCESS_CDOE = {1}
   AND T.VALIDFLAG = '1'
		]]>
	</query>
	
	<query id="QcmLgChemJudgeDAL.queryCntByStoveNo" desc="查询是否存在成分判定记录">
		<![CDATA[
SELECT COUNT(1) FROM QCM_LG_CHEMJUDGE T
 WHERE T.STOVE_NO = {0}
   AND T.PROCESS_CDOE = {1}
   AND T.VALIDFLAG = '1'
		]]>
	</query>
	
	<query id="QcmLgChemJudgeDAL.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="QcmLgChemJudgeDAL.getLgChemJudgeByNoChemId" desc="新增成分判定记录">
		<![CDATA[
SELECT A.* FROM QCM_LG_CHEMJUDGE A
WHERE A.CREATE_TIME >= TO_DATE('20180101', 'YYYYMMDD')
		]]>
	</query>
	
	<query id="QcmLgChemJudgeDAL.getJhyElementByAssayNo" desc="新增成分判定记录">
		<![CDATA[
SELECT * FROM QCM_JHY_ELEMENTS T WHERE T.ASSAYNO = {0}
		]]>
	</query>
	
	<query id="QcmLgChemJudgeDAL.deleteChemResult" desc="新增成分判定记录">
		<![CDATA[
DELETE FROM QCM_LG_CHEM_RESULT T
 WHERE T.CHEM_JUDGE_ID = {0}
   AND T.JUDGE_SEQ = {1}
		]]>
	</query>
	
	<query id="QcmLgChemJudgeDAL.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>
</queryMap>