<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="工艺评审成分标准">

	<query id="MscChemDao.getChemByCic" desc="通过成分索引号查询成分标准">  
             <![CDATA[ 
SELECT T.CIC,
       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.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.REP_CODE,
       T.REP_NAME,
       T.REP_MIN_SIGN,
       T.REP_MIN,
       T.REP_MAX_SIGN,
       T.REP_MAX,
       T.REP_VAL,
       A.MEMO CIC_MEMO,
       T.GROUP_SEQ
  FROM COM_MSC_STD_CHEM T, COM_MSC_STD_CIC A
 WHERE T.CIC = ?
   AND T.VALIDFLAG = '1'
   AND A.CIC = T.CIC
 ORDER BY T.CHEM_CODE, T.SIZE_CODE2, T.SIZE_CODE
               ]]>
	</query>
	
	<query id="MscChemDao.getCraftMsc0Chem" desc="获取MSC0的化学元素">  
             <![CDATA[ 
SELECT T.CHEM_CODE, T.CHEM_NAME
  FROM CRAFT_ORD_DESIGN_STD_CIC T
 WHERE T.DESGIN_KEY = ?
   AND T.SPECL_FL = '0'
   AND T.CHEM_TYPE = 'A'
               ]]>
	</query>

	<query id="MscChemDao.addChem" desc="新增成分标准">  
             <![CDATA[ 
                 INSERT INTO CRAFT_ORD_DESIGN_STD_CIC(
        DESGIN_KEY,
        CIC,
        USE_CODE,
        USE_DESC,
        SPECL_FL,
        INDEX_SEQ,
        CHEM_CODE,
        CHEM_NAME,
        CHEM_TYPE,
        CHEM_FORMULA,
        ISCHECK,
        ISJUDGE,
        ISQUOTE,
        COMPLEX_TYPE,
        STDMIN_SIGN,
        STDMIN,
        STDMAX_SIGN,
        STDMAX,
        STDTARGET,
        MODEL_CODE,
        MODEL_DESC,
        STDMEMO,
        ELE_CODE,
        ELE_NAME,
        ELE_MIN_SIGN,
        ELE_MIN,
        ELE_MAX_SIGN,
        ELE_MAX,
        SIZE_CODE2,
        SIZE_NAME2,
        SIZE_MIN_SIGN2,
        SIZE_MIN2,
        SIZE_MAX_SIGN2,
        SIZE_MAX2,
        SIZE_CODE,
        SIZE_NAME,
        SIZE_MIN_SIGN,
        SIZE_MIN,
        SIZE_MAX_SIGN,
        SIZE_MAX,
        SPEC_JG,
        SPEC_JG_DESC,
        VALIDFLAG,
        CREATE_NAME,
        CREATE_TIME,
        UPDATE_NAME,
        UPDATE_TIME,
        DELETE_NAME,
        DELETE_TIME,
        REP_CODE,
        REP_NAME,
        REP_MIN_SIGN,
        REP_MIN,
        REP_MAX_SIGN,
        REP_MAX,
        REP_VAL,
        MSC_PLINE,
        PROCESS_CODE,
        CIC_MEMO,
        GROUP_SEQ)
 VALUES( 
        '#DESGIN_KEY#',
        '#CIC#',
        '#USE_CODE#',
        '#USE_DESC#',
        '#SPECL_FL#',
        '#INDEX_SEQ#',
        '#CHEM_CODE#',
        '#CHEM_NAME#',
        '#CHEM_TYPE#',
        '#CHEM_FORMULA#',
        '#ISCHECK#',
        '#ISJUDGE#',
        '#ISQUOTE#',
        '#COMPLEX_TYPE#',
        '#STDMIN_SIGN#',
        '#STDMIN#',
        '#STDMAX_SIGN#',
        '#STDMAX#',
        '#STDTARGET#',
        '#MODEL_CODE#',
        '#MODEL_DESC#',
        '#STDMEMO#',
        '#ELE_CODE#',
        '#ELE_NAME#',
        '#ELE_MIN_SIGN#',
        '#ELE_MIN#',
        '#ELE_MAX_SIGN#',
        '#ELE_MAX#',
        '#SIZE_CODE2#',
        '#SIZE_NAME2#',
        '#SIZE_MIN_SIGN2#',
        '#SIZE_MIN2#',
        '#SIZE_MAX_SIGN2#',
        '#SIZE_MAX2#',
        '#SIZE_CODE#',
        '#SIZE_NAME#',
        '#SIZE_MIN_SIGN#',
        '#SIZE_MIN#',
        '#SIZE_MAX_SIGN#',
        '#SIZE_MAX#',
        '#SPEC_JG#',
        '#SPEC_JG_DESC#',
        '#VALIDFLAG#',
        '#CREATE_NAME#',
        SYSDATE,
        NULL,
        NULL,
        NULL,
        NULL,
        '#REP_CODE#',
        '#REP_NAME#',
        '#REP_MIN_SIGN#',
        '#REP_MIN#',
        '#REP_MAX_SIGN#',
        '#REP_MAX#',
        '#REP_VAL#',
         '#MSC_PLINE#',
        '#PROCESS_CODE#',
        '#CIC_MEMO#',
        '#GROUP_SEQ#')
               ]]>
	</query>

	<query id="MscChemDao.updateDesignStd" desc="修改交付标准索引号">
         <![CDATA[
      UPDATE CRAFT_ORD_DESIGN_STD T SET T.CIC = ?,T.SMELTING_CNT=?,T.PRODUCT_CNT=?,
       T.RATE = ?
       WHERE DESGIN_KEY = ?
             ]]>
	</query>

	<query id="MscChemDao.getExamineCic" desc="查詢已审批成分索引号">
         <![CDATA[
      SELECT P.CIC, P.MODEL_CODE
       FROM (SELECT T.CIC, NVL(T.MODEL_CODE, 'C001') MODEL_CODE
               FROM COM_MSC_STD_CIC T
              WHERE T.MSC = ?
                AND T.CODE_JG IS NULL
                AND T.VALIDFLAG = 3) P
      WHERE INSTR(P.MODEL_CODE, ?) > 0
        OR (P.MODEL_CODE = 'C001' AND NOT EXISTS
           (SELECT 1
             FROM (SELECT T.CIC, NVL(T.MODEL_CODE, 'C001') MODEL_CODE
                     FROM COM_MSC_STD_CIC T
                    WHERE T.MSC = ?
                      AND T.CODE_JG IS NULL
                      AND T.VALIDFLAG = 3) A
                    WHERE INSTR(A.MODEL_CODE, ?) > 0))
   ORDER BY P.MODEL_CODE DESC
             ]]>
	</query>

	<query id="MscChemDao.getValidCic" desc="查詢有效成分索引号">
         <![CDATA[
      SELECT P.CIC, P.MODEL_CODE
       FROM (SELECT T.CIC, NVL(T.MODEL_CODE, 'C001') MODEL_CODE
               FROM COM_MSC_STD_CIC T
              WHERE T.MSC = ?
                AND T.CODE_JG IS NULL
                AND T.VALIDFLAG != 0) P
      WHERE INSTR(P.MODEL_CODE, ?) > 0
        OR (P.MODEL_CODE = 'C001' AND NOT EXISTS
           (SELECT 1
             FROM (SELECT T.CIC, NVL(T.MODEL_CODE, 'C001') MODEL_CODE
                     FROM COM_MSC_STD_CIC T
                    WHERE T.MSC = ?
                      AND T.CODE_JG IS NULL
                      AND T.VALIDFLAG != 0) A
                    WHERE INSTR(A.MODEL_CODE, ?) > 0))
   ORDER BY P.MODEL_CODE DESC
             ]]>
	</query>

	<query id="MscChemDao.getCntByCic" desc="查询熔炼成分套数／成品成分套数">
         <![CDATA[
             SELECT T.SMELTING_CNT,T.PRODUCT_CNT, T.RATE FROM COM_MSC_STD_CIC T WHERE T.CIC=?
             ]]>
	</query>



</queryMap>