<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="化学成分标准">
	<query id="CoreChemStandard.MAXCICG" desc="主表成分索引号 交互">
		<![CDATA[
SELECT MAX(SUBSTR(CIC, 5, 6)) FROM COM_MSC_STD_CIC WHERE CIC  LIKE 'CICG%'	
		]]>
	</query>
	
	<query id="CoreChemStandard.MAXCICN" desc="主表成分索引号 内控">
		<![CDATA[
SELECT MAX(SUBSTR(CIC, 5, 6)) FROM COM_MSC_STD_CIC WHERE STDSTYLE = 'N'
		]]>
	</query>
	
	<query id="CoreChemStandard.MAXCICK" desc="主表成分索引号  Alpha">
		<![CDATA[
SELECT MAX(SUBSTR(CIC, 5, 6)) FROM COM_MSC_STD_CIC WHERE CIC  LIKE 'CICK%'
		]]>
	</query>
	
	<query id="CoreChemStandard.MAXCICS" desc="主表成分索引号  其它标准">
		<![CDATA[
SELECT MAX(SUBSTR(CIC, 5, 6)) FROM COM_MSC_STD_CIC WHERE CIC  LIKE 'CICS%'	
		]]>
	</query>
		
	<query id="CoreChemStandard.MAXINDEXSEQ" desc="从表化学成分序号">
		<![CDATA[
			SELECT INDEX_SEQ
              FROM COM_MSC_STD_CHEM
             WHERE INDEX_SEQ =
                   (SELECT MAX(INDEX_SEQ) INDEX_SEQ FROM COM_MSC_STD_CHEM WHERE CIC = ?)
		]]>
	</query>
	
    <query id="CoreChemStandard.QUERYG" desc="主表查询 交互标准">
		<![CDATA[
SELECT *
  FROM (SELECT C.CIC,
               C.PSC,
               C.MSC,
               NVL(P.PSC_DESC,
                   D.PRODUCNAME || ',' || D.STD_NAME || ',' || D.STEELNAME || ',' ||
                   D.STD_STYLE_DESC || ',' || D.MODEL_DESC || ',' || D.MIN_D || ',' ||
                   D.MIN_H || ',' || D.USE_DESC) PSC_DESC,
               DECODE(C.STDSTYLE, 'G', '订货标准', 'X', '协议标准', '') STDSTYLE,
               C.STD_CODE_NK,
               C.STD_NAME_NK,
               C.PROCESS_CODE,
               C.PROCESS_DESC,
               C.MODEL_CODE,
               C.MODEL_DESC,
               C.GRADECODE,
               C.GRADENAME,
               C.STD_CODE,
               C.STD_NAME,
               C.CREATE_NAME,
               TO_CHAR(C.CREATE_TIME, 'yyyy-mm-dd hh24:mi:ss') CREATE_TIME,
               C.UPDATE_NAME,
               TO_CHAR(C.UPDATE_TIME, 'yyyy-mm-dd hh24:mi:ss') UPDATE_TIME,
               C.DELETE_NAME,
               TO_CHAR(C.DELETE_TIME, 'yyyy-mm-dd hh24:mi:ss') DELETE_TIME,
               DECODE(C.VALIDFLAG,
                      '1',
                      '录入状态',
                      '0',
                      '无效',
                      '2',
                      '提交审核',
                      '3',
                      '已审核') VALIDFLAG,
               C.MEMO,
               C.PRODUC_HEAD,
               NVL(P.PRODUCNAME, D.PRODUCNAME) PRODUCNAME,
               NVL(P.STD_NAME, D.STD_NAME) STD_NAME_B,
               NVL(P.STEELNAME, D.STEELNAME) STEELNAME,
               NVL(P.STD_STYLE_DESC, D.STD_STYLE_DESC) STD_STYLE_DESC,
               SMELTING_CNT,
               PRODUCT_CNT,
               C.MIN_D,
               C.MAX_D,
               C.MIN_H,
               C.MAX_H,
               C.MIN_D_SIGN,
               C.MAX_D_SIGN,
               C.MIN_H_SIGN,
               C.MAX_H_SIGN,
               C.RATE
          FROM COM_MSC_STD_CIC C
          LEFT JOIN COM_PSC P
            ON C.PSC = P.PSC
          LEFT JOIN COM_MSC_BL D
            ON C.PSC = D.PSC_BL
         WHERE lower(C.MSC) || '&' LIKE '%' || lower('#MSC#') || '%'
           AND C.VALIDFLAG in ('1', '2', '3', '#VALIDFLAG#')
           AND DECODE('#STD_CODE_NK#', NULL, '1', C.STD_CODE_NK) =
               DECODE('#STD_CODE_NK#', NULL, '1', '#STD_CODE_NK#')
           AND C.STDSTYLE in ('G', 'X')
           AND DECODE('#CIC#', NULL, '1', C.CIC) =
               DECODE('#CIC#', NULL, '1', '#CIC#')
           AND DECODE('#MSC2#', NULL, '1', C.MSC) =
               DECODE('#MSC2#', NULL, '1', '#MSC2#')
           AND DECODE('#CODE_JG#', NULL, '1', 'DefaultValue', '1', C.CODE_JG) =
               DECODE('#CODE_JG#',
                      NULL,
                      '1',
                      'DefaultValue',
                      '1',
                      '#CODE_JG#')
           AND DECODE('#CODE_JG#', NULL, C.CODE_JG, NULL) IS NULL)
 WHERE lower(STD_NAME) || '&' LIKE '%' || lower('#STD_NAME#') || '%'
 ORDER BY CIC
		]]>
	</query>
	
	<query id="CoreChemStandard.QUERYOTHER" desc="主表查询 其它标准">
       <![CDATA[
SELECT C.CIC,
       C.PSC,
       C.MSC,
       DECODE(C.STDSTYLE,
              'N',
              '内控',
              'K',
              'Alpha',
              'S',
              '试验标准',
              'P',
              '成分偏差标准',
              '') STDSTYLE,
       C.STD_CODE_NK,
       C.STD_NAME_NK,
       C.PROCESS_CODE,
       C.PROCESS_DESC,
       C.GRADECODE,
       C.GRADENAME,
       C.STD_CODE,
       C.STD_NAME,
       C.MODEL_CODE,
       C.MODEL_DESC,
       C.CREATE_NAME,
       TO_CHAR(C.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       C.UPDATE_NAME,
       TO_CHAR(C.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       C.DELETE_NAME,
       TO_CHAR(C.DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
       DECODE(C.VALIDFLAG,
              '1',
              '录入状态',
              '0',
              '无效',
              '2',
              '提交审核',
              '3',
              '已审核') VALIDFLAG,
       C.MEMO,
       C.PRODUC_HEAD,
       C.STEELCODE_NK,
       C.STEELNAME_NK,
       C.MODEL_CODE_NK,
       C.MODEL_DESC_NK,
       C.PRODUCCODE_NK,
       C.PRODUCNAME_NK,
       C.MIN_D,
       C.MAX_D,
       C.MIN_H,
       C.MAX_H,
       C.MIN_D_SIGN,
       C.MAX_D_SIGN,
       C.MIN_H_SIGN,
       C.MAX_H_SIGN
  FROM COM_MSC_STD_CIC C
 WHERE UPPER(C.STD_NAME_NK) || '&' LIKE
       UPPER('%' || '#STD_NAME_NK#' || '%')
   AND C.VALIDFLAG IN ('1', '2', '3', '#VALIDFLAG#')
   AND DECODE('#STD_CODE_NK#', NULL, '1', C.STD_CODE_NK) =
       DECODE('#STD_CODE_NK#', NULL, '1', '#STD_CODE_NK#')
   AND DECODE('#CIC#', NULL, '1', C.CIC) =
       DECODE('#CIC#', NULL, '1', '#CIC#')
   AND DECODE('#MSC2#', NULL, '1', C.MSC) =
       DECODE('#MSC2#', NULL, '1', '#MSC2#')
   AND DECODE('#CODE_JG#', NULL, '1', 'DefaultValue', '1', C.CODE_JG) =
       DECODE('#CODE_JG#', NULL, '1', 'DefaultValue', '1', '#CODE_JG#')
   AND DECODE('#CODE_JG#', NULL, C.CODE_JG, NULL) IS NULL
   AND C.STDSTYLE IN
       (DECODE('#STDSTYLE#', '2', 'N', '3', 'K', 'P'),
        DECODE('#STDSTYLE#', '2', '', '3', '', 'S'))
   AND NVL(INSTR(C.PRODUCCODE_NK, '#PRODUCCODE_NK#'), 1) > 0
   AND NVL(INSTR(C.STEELCODE_NK, '#STEELCODE_NK#'), 1) > 0
   AND NVL(INSTR(C.PROCESS_CODE, '#PROCESS_CODE#'), 1) > 0
   AND NVL(INSTR(C.MODEL_CODE_NK, '#MODEL_CODE_NK#'), 1) > 0 #WHERE#
 ORDER BY C.CIC
		]]>
	</query>	
	
	<query id="CoreChemStandard.QUERYCG" desc="从表查询 交互标准">
		<![CDATA[
			SELECT A.CIC,
                   A.INDEX_SEQ,
                   A.CHEM_CODE,
                   TO_NUMBER(SUBSTR(A.CHEM_CODE, 2, 3)) XH,
                   A.CHEM_NAME,
                   DECODE(A.CHEM_TYPE, 'A', '单一元素', '复合元素') CHEM_TYPE,
                   A.CHEM_FORMULA,
                   DECODE(A.ISCHECK, '1', 'TRUE', 'FALSE') ISCHECK,
                   DECODE(A.ISJUDGE, '1', 'TRUE', 'FALSE') ISJUDGE,
                   DECODE(A.ISQUOTE, '1', 'TRUE', 'FALSE') ISQUOTE,
                   DECODE(A.COMPLEX_TYPE, '1', 'TRUE', 'FALSE') COMPLEX_TYPE,
                   A.STDMIN_SIGN,
                   A.STDMIN,
                   A.STDMAX_SIGN,
                   A.STDMAX,
                   A.STDTARGET,
                   A.MODEL_CODE,
                   A.MODEL_DESC,
                   A.STDMEMO,
                   A.ELE_CODE,
                   A.ELE_NAME,
                   A.ELE_MIN_SIGN,
                   A.ELE_MIN,
                   A.ELE_MAX_SIGN,
                   A.ELE_MAX,
                   A.SIZE_CODE2,
                   A.SIZE_NAME2,
                   A.SIZE_MIN_SIGN2,
                   A.SIZE_MIN2,
                   A.SIZE_MAX_SIGN2,
                   A.SIZE_MAX2,
                   A.SIZE_CODE,
                   A.SIZE_NAME,
                   A.SIZE_MIN_SIGN,
                   A.SIZE_MIN,
                   A.SIZE_MAX_SIGN,
                   A.SIZE_MAX,
                   A.SPEC_JG,
                   A.REP_CODE,
                   A.REP_NAME,
                    A.REP_MIN_SIGN,
                    A.REP_MIN,
                    A.REP_MAX_SIGN,
                    A.REP_MAX,
                    A.REP_VAL,
                   A.SPEC_JG_DESC,
                   A.CREATE_NAME,
                   TO_CHAR(A.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
                   A.UPDATE_NAME,
                   TO_CHAR(A.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
                   A.DELETE_NAME,
                   TO_CHAR(A.DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
                   DECODE(A.VALIDFLAG, '1', '有效', '无效') VALIDFLAG,
                   A.GROUP_SEQ
              FROM COM_MSC_STD_CHEM A
       WHERE EXISTS
           (SELECT 1
              FROM COM_MSC_STD_CIC B
             WHERE UPPER(B.STD_NAME_NK) || '&' LIKE UPPER('%' || '#STD_NAME_NK#' || '%')
               AND UPPER(B.MSC) || '&' LIKE UPPER('%' || '#MSC#' || '%')
               AND B.VALIDFLAG IN ('1','2','3', '#VALIDFLAG#')
               AND DECODE('#STD_CODE_NK#', NULL, '1', B.STD_CODE_NK) = DECODE('#STD_CODE_NK#', NULL, '1', '#STD_CODE_NK#')
               AND DECODE('#CIC#', NULL, '1', B.CIC) = DECODE('#CIC#', NULL, '1', '#CIC#')
               AND DECODE('#MSC2#', NULL, '1', B.MSC) = DECODE('#MSC2#', NULL, '1', '#MSC2#')
               AND DECODE('#CODE_JG#', NULL, '1', 'DefaultValue', '1', B.CODE_JG) = DECODE('#CODE_JG#', NULL, '1', 'DefaultValue', '1', '#CODE_JG#')
               AND DECODE('#CODE_JG#', NULL, B.CODE_JG, NULL) IS NULL
               AND B.STDSTYLE IN ('G','X')
               AND A.CIC = B.CIC)
               AND A.VALIDFLAG IN ('1','#VALIDFLAG#')
          ORDER BY A.CIC, XH
		]]>
	</query>
	
	<query id="CoreChemStandard.QUERYCOTHER" desc="从表查询 其它标准">
		<![CDATA[
SELECT A.CIC,
       A.INDEX_SEQ,
       A.CHEM_CODE,
       TO_NUMBER(SUBSTR(A.CHEM_CODE, 2, 3)) XH,
       A.CHEM_NAME,
       DECODE(A.CHEM_TYPE, 'A', '单一元素', '复合元素') CHEM_TYPE,
       A.CHEM_FORMULA,
       DECODE(A.ISCHECK, '1', 'TRUE', 'FALSE') ISCHECK,
       DECODE(A.ISJUDGE, '1', 'TRUE', 'FALSE') ISJUDGE,
       DECODE(A.ISQUOTE, '1', 'TRUE', 'FALSE') ISQUOTE,
       DECODE(A.COMPLEX_TYPE, '1', 'TRUE', 'FALSE') COMPLEX_TYPE,
       A.STDMIN_SIGN,
       A.STDMIN,
       A.STDMAX_SIGN,
       A.STDMAX,
       A.STDTARGET,
       A.MODEL_CODE,
       A.MODEL_DESC,
       A.STDMEMO,
       A.ELE_CODE,
       A.ELE_NAME,
       A.ELE_MIN_SIGN,
       A.ELE_MIN,
       A.ELE_MAX_SIGN,
       A.ELE_MAX,
       A.REP_CODE,
       A.REP_NAME,
       A.REP_MIN_SIGN,
       A.REP_MIN,
       A.REP_MAX_SIGN,
       A.REP_MAX,
       A.REP_VAL,
       A.SIZE_CODE2,
       A.SIZE_NAME2,
       A.SIZE_MIN_SIGN2,
       A.SIZE_MIN2,
       A.SIZE_MAX_SIGN2,
       A.SIZE_MAX2,
       A.SIZE_CODE,
       A.SIZE_NAME,
       A.SIZE_MIN_SIGN,
       A.SIZE_MIN,
       A.SIZE_MAX_SIGN,
       A.SIZE_MAX,
       A.SPEC_JG,
       A.SPEC_JG_DESC,
       A.CREATE_NAME,
       TO_CHAR(A.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       A.UPDATE_NAME,
       TO_CHAR(A.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       A.DELETE_NAME,
       TO_CHAR(A.DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
       DECODE(A.VALIDFLAG, '1', '有效', '无效') VALIDFLAG,
       A.GROUP_SEQ
  FROM COM_MSC_STD_CHEM A
 WHERE EXISTS
 (SELECT 1
          FROM COM_MSC_STD_CIC B
         WHERE UPPER(B.STD_NAME_NK) || '&' LIKE
               UPPER('%' || '#STD_NAME_NK#' || '%')
           AND B.VALIDFLAG IN ('1', '2', '3', '#VALIDFLAG#')
           AND DECODE('#STD_CODE_NK#', NULL, '1', B.STD_CODE_NK) =
               DECODE('#STD_CODE_NK#', NULL, '1', '#STD_CODE_NK#')
           AND DECODE('#CIC#', NULL, '1', B.CIC) =
               DECODE('#CIC#', NULL, '1', '#CIC#')
           AND DECODE('#MSC#', NULL, '1', B.MSC) =
               DECODE('#MSC#', NULL, '1', '#MSC#')
           AND DECODE('#CODE_JG#', NULL, '1', 'DefaultValue', '1', B.CODE_JG) =
               DECODE('#CODE_JG#',
                      NULL,
                      '1',
                      'DefaultValue',
                      '1',
                      '#CODE_JG#')
           AND DECODE('#CODE_JG#', NULL, B.CODE_JG, NULL) IS NULL
           AND B.STDSTYLE IN
               (DECODE('#STDSTYLE#', '2', 'N', '3', 'K', 'P'),
                DECODE('#STDSTYLE#', '2', '', '3', '', 'S'))
         #WHERE#
           AND NVL(INSTR(B.PRODUCCODE_NK, '#PRODUCCODE_NK#'), 1) > 0
           AND NVL(INSTR(B.STEELCODE_NK, '#STEELCODE_NK#'), 1) > 0
           AND NVL(INSTR(B.PROCESS_CODE, '#PROCESS_CODE#'), 1) > 0
           AND NVL(INSTR(B.MODEL_CODE_NK, '#MODEL_CODE_NK#'), 1) > 0
           AND A.CIC = B.CIC)
   AND A.VALIDFLAG IN ('1', '#VALIDFLAG#')
 ORDER BY A.CIC, XH
		]]>
	</query>
	
	<query id="CoreChemStandard.ADD" desc="主表增加">
		<![CDATA[
			INSERT INTO COM_MSC_STD_CIC
                       (CIC,
                        PSC,
                        MSC,
                        STDSTYLE,
                        STD_CODE_NK,
                        STD_NAME_NK,
                        PROCESS_CODE,
                        PROCESS_DESC,
                        GRADECODE,
                        GRADENAME,
                        STD_CODE,
                        STD_NAME,
                        CREATE_NAME,
                        CREATE_TIME,
                        MODEL_CODE,
                        MODEL_DESC,
                        VALIDFLAG,
                        MEMO,
                        PRODUC_HEAD,
                        CODE_JG,
                        STEELCODE_NK,
                        STEELNAME_NK,
                        MODEL_CODE_NK,
                        MODEL_DESC_NK,
                        PRODUCCODE_NK,
                        PRODUCNAME_NK,
                        SMELTING_CNT,
                        PRODUCT_CNT,
                        MIN_D,
                        MAX_D,
                        MIN_H,
                        MAX_H,
                        MIN_D_SIGN,
                        MAX_D_SIGN,
                        MIN_H_SIGN,
                        MAX_H_SIGN,
                        RATE)
                 VALUES
                       (?,?,?,?, ?, ?, ?, ?, ?, ?, ?, ?, ?, SYSDATE,?,?, DEFAULT, ?, ?,?,
                       ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
		]]>
	</query>
	
	<query id="CoreChemStandard.ADD1" desc="从表增加">
		<![CDATA[
			INSERT INTO COM_MSC_STD_CHEM
                  (CIC,
                   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,
                   CREATE_NAME,
                   CREATE_TIME,
                   VALIDFLAG,
                    REP_CODE,
                    REP_NAME,
                    REP_MIN_SIGN,
                    REP_MIN,
                    REP_MAX_SIGN,
                    REP_MAX,
                    REP_VAL)
              VALUES
                   (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,
                    ?,?,?,?,?,?,?,?,?,?,?,?,SYSDATE,DEFAULT,?,?,?,?,?,?,?)
		]]>
	</query>
	
	<query id="CoreChemStandard.UPDATE" desc="主表修改">
		<![CDATA[		
             UPDATE COM_MSC_STD_CIC
                SET CIC          = ?,
                    PSC          = ?,
                    MSC          = ?,
                    STDSTYLE     = ?,
                    STD_CODE_NK  = ?,
                    STD_NAME_NK  = ?,
                    PROCESS_CODE = ?,
                    PROCESS_DESC = ?,
                    GRADECODE    = ?,
                    GRADENAME    = ?,
                    STD_CODE     = ?,
                    STD_NAME     = ?,
                    UPDATE_NAME  = ?,
                    MODEL_CODE   = ?,
                    MODEL_DESC   = ?,
                    UPDATE_TIME  = SYSDATE,
                    MEMO         = ?,
                    PRODUC_HEAD = ?,
                    CODE_JG = ?,
                    STEELCODE_NK = ?,
                    STEELNAME_NK = ?,
                    MODEL_CODE_NK = ?,
                    MODEL_DESC_NK = ?,
                    PRODUCCODE_NK = ?,
                    PRODUCNAME_NK = ?,
                    SMELTING_CNT = ?,
                    PRODUCT_CNT = ?,
                    MIN_D = ?,
                    MAX_D = ?,
                    MIN_H = ?,
                    MAX_H = ?,
                    MIN_D_SIGN = ?,
                    MAX_D_SIGN = ?,
                    MIN_H_SIGN = ?,
                    MAX_H_SIGN = ?,
                    RATE = ?
              WHERE CIC = ?
		]]>
	</query>
	
	<query id="CoreChemStandard.UPDATE1" desc="从表修改">
		<![CDATA[		
        UPDATE COM_MSC_STD_CHEM
                    SET CIC            = ?,
                        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   = ?,
                        UPDATE_NAME    = ?,
                        UPDATE_TIME    = SYSDATE,
                        REP_CODE       =?,
                        REP_NAME       =?,
                        REP_MIN_SIGN   =?,
                        REP_MIN        =?,
                        REP_MAX_SIGN   =?,
                        REP_MAX        =?,
                        REP_VAL        =?
                  WHERE CIC = ?
                    AND INDEX_SEQ = ?
		]]>
	</query>
	
	<query id="CoreChemStandard.DELETE" desc="主表删除">
		<![CDATA[
		 UPDATE 	COM_MSC_STD_CIC
		SET VALIDFLAG='0',DELETE_NAME=?,DELETE_TIME=SYSDATE
		WHERE CIC = ? AND VALIDFLAG ='1'
		]]>
	</query>
	
	
	<query id="CoreChemStandard.RESUME" desc="主表恢复">
		<![CDATA[
			UPDATE 	COM_MSC_STD_CIC
		SET VALIDFLAG='1',DELETE_NAME='',DELETE_TIME=NULL
		WHERE CIC = ? AND VALIDFLAG ='0'
		]]>
	</query>
	
	<query id="CoreChemStandard.DELETE1" desc="从表删除">
		<![CDATA[
			UPDATE 	COM_MSC_STD_CHEM
		SET VALIDFLAG='0',DELETE_NAME=?,DELETE_TIME=SYSDATE
		WHERE CIC = ?   AND INDEX_SEQ = ? AND VALIDFLAG='1'
		AND (SELECT VALIDFLAG FROM COM_MSC_STD_CIC
                          WHERE  CIC = ?) IN ('1', '0')
             
		]]>
	</query>
	
	<query id="CoreChemStandard.RESUME1" desc="从表恢复">
		<![CDATA[
			UPDATE 	COM_MSC_STD_CHEM
		SET VALIDFLAG='1',DELETE_NAME='',DELETE_TIME=NULL
		WHERE CIC = ?   AND INDEX_SEQ = ? AND VALIDFLAG='0'
		]]>
	</query>
	
	<query id="CoreChemStandard.getMscCicByCic" desc="通过主键查询成分表">
		<![CDATA[
SELECT * FROM COM_MSC_STD_CIC T WHERE T.CIC = '#CIC#'
		]]>
	</query>
	
	<query id="CoreChemStandard.insertComMscStdCicRProduct" desc="新增成分与品名关系">
		<![CDATA[
INSERT INTO COM_MSC_STD_CIC_R_PRODUCT
  (CIC, PRODUCCODE, CREATE_NAME, CREATE_TIME, VALIDFLAG)
VALUES
  (?,
   ?,
   ?,
   SYSDATE,
   '1')
		]]>
	</query>
	
	<query id="CoreChemStandard.deleteComMscStdCicRProduct" desc="删除成分与品名关系">
		<![CDATA[
DELETE FROM COM_MSC_STD_CIC_R_PRODUCT T WHERE T.CIC = ?
		]]>
	</query>
	
	<query id="CoreChemStandard.queryMscStdCicByCic" desc="获取CIC对应的品名">
		<![CDATA[
SELECT CIC, PRODUCCODE
  FROM COM_MSC_STD_CIC_R_PRODUCT T
 WHERE T.CIC = '#CIC#'
   AND T.VALIDFLAG = '1'
		]]>
	</query>
	
	<query id="CoreChemStandard.getPurchaseAgreementCic" desc="获取采购标准对应的成分主表">
		<![CDATA[
SELECT C.CIC,
       C.PSC,
       C.MSC,
       DECODE(C.STDSTYLE,
              'N',
              '内控',
              'K',
              'Alpha',
              'S',
              '试验标准',
              'P',
              '成分偏差标准',
              '') STDSTYLE,
       C.STD_CODE_NK,
       C.STD_NAME_NK,
       C.PROCESS_CODE,
       C.PROCESS_DESC,
       C.GRADECODE,
       C.GRADENAME,
       C.STD_CODE,
       C.STD_NAME,
       C.MODEL_CODE,
       C.MODEL_DESC,
       C.CREATE_NAME,
       TO_CHAR(C.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       C.UPDATE_NAME,
       TO_CHAR(C.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       C.DELETE_NAME,
       TO_CHAR(C.DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
       DECODE(C.VALIDFLAG,
              '1',
              '录入状态',
              '0',
              '无效',
              '2',
              '提交审核',
              '3',
              '已审核') VALIDFLAG,
       C.MEMO,
       C.PRODUC_HEAD,
       C.STEELCODE_NK,
       C.STEELNAME_NK,
       C.MODEL_CODE_NK,
       C.MODEL_DESC_NK,
       C.PRODUCCODE_NK,
       C.PRODUCNAME_NK
  FROM COM_MSC_STD_CIC C, COM_BASE_STD A
 WHERE A.PURCHASE_STD = '1'
   AND A.VALIDFLAG = '1'
   AND A.STD_CODE = C.STD_CODE_NK
   AND C.VALIDFLAG = '1'
   AND C.STD_CODE_NK = {0}
 ORDER BY C.CIC
		]]>
	</query>
	
	<query id="CoreChemStandard.getPurchaseAgreementChem" desc="获取采购标准对应的成分从表">
		<![CDATA[
SELECT A.CIC,
       A.INDEX_SEQ,
       A.CHEM_CODE,
       TO_NUMBER(SUBSTR(A.CHEM_CODE, 2, 3)) XH,
       A.CHEM_NAME,
       DECODE(A.CHEM_TYPE, 'A', '单一元素', '复合元素') CHEM_TYPE,
       A.CHEM_FORMULA,
       DECODE(A.ISCHECK, '1', 'TRUE', 'FALSE') ISCHECK,
       DECODE(A.ISJUDGE, '1', 'TRUE', 'FALSE') ISJUDGE,
       DECODE(A.ISQUOTE, '1', 'TRUE', 'FALSE') ISQUOTE,
       DECODE(A.COMPLEX_TYPE, '1', 'TRUE', 'FALSE') COMPLEX_TYPE,
       A.STDMIN_SIGN,
       A.STDMIN,
       A.STDMAX_SIGN,
       A.STDMAX,
       A.STDTARGET,
       A.MODEL_CODE,
       A.MODEL_DESC,
       A.STDMEMO,
       A.ELE_CODE,
       A.ELE_NAME,
       A.ELE_MIN_SIGN,
       A.ELE_MIN,
       A.ELE_MAX_SIGN,
       A.ELE_MAX,
       A.REP_CODE,
       A.REP_NAME,
       A.REP_MIN_SIGN,
       A.REP_MIN,
       A.REP_MAX_SIGN,
       A.REP_MAX,
       A.REP_VAL,
       A.SIZE_CODE2,
       A.SIZE_NAME2,
       A.SIZE_MIN_SIGN2,
       A.SIZE_MIN2,
       A.SIZE_MAX_SIGN2,
       A.SIZE_MAX2,
       A.SIZE_CODE,
       A.SIZE_NAME,
       A.SIZE_MIN_SIGN,
       A.SIZE_MIN,
       A.SIZE_MAX_SIGN,
       A.SIZE_MAX,
       A.SPEC_JG,
       A.SPEC_JG_DESC,
       A.CREATE_NAME,
       TO_CHAR(A.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       A.UPDATE_NAME,
       TO_CHAR(A.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       A.DELETE_NAME,
       TO_CHAR(A.DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
       DECODE(A.VALIDFLAG, '1', '有效', '无效') VALIDFLAG
  FROM COM_MSC_STD_CHEM A, COM_MSC_STD_CIC B, COM_BASE_STD C
 WHERE C.PURCHASE_STD = '1'
   AND C.VALIDFLAG = '1'
   AND C.STD_CODE = B.STD_CODE_NK
   AND B.VALIDFLAG = '1'
   AND B.CIC = A.CIC
   AND A.VALIDFLAG = '1'
   AND B.STD_CODE_NK = {0}
 ORDER BY A.CIC, XH
		]]>
	</query>
	
	<query id="CoreChemStandard.getChemByGrade" desc="获取钢种之下的所有成分">
		<![CDATA[
SELECT A.CHEM_CODE, A.CIC
  FROM COM_MSC_STD_CHEM A, COM_MSC_STD_CIC B
 WHERE B.STD_CODE_NK = {0}
   AND B.CIC = A.CIC
   AND B.GRADECODE = {1}
   AND B.VALIDFLAG = '1'
   AND A.VALIDFLAG = '1'
   AND B.CIC <> {2}
 GROUP BY A.CHEM_CODE, A.CIC
		]]>
	</query>
	
	<query id="CoreChemStandard.group" desc="分组">
		<![CDATA[
UPDATE COM_MSC_STD_CHEM T
   SET T.GROUP_SEQ = {0}
 WHERE T.CIC = {1}
   AND T.INDEX_SEQ IN ('0'#INDEX_SEQ#)
		]]>
	</query>
	
	<query id="CoreChemStandard.cancelGroup" desc="取消分组">
		<![CDATA[
UPDATE COM_MSC_STD_CHEM T
   SET T.GROUP_SEQ = null
 WHERE T.CIC = {0}
   AND T.INDEX_SEQ IN ('0'#INDEX_SEQ#)
		]]>
	</query>


	<query id="CoreChemStandard.getComChemNK" desc="主表内控">
		<![CDATA[
SELECT C.CIC,
       C.PSC,
       C.MSC,
       DECODE(C.STDSTYLE,
              'N',
              '内控',
              'K',
              'Alpha',
              'S',
              '试验标准',
              'P',
              '成分偏差标准',
              '') STDSTYLE,
       C.STD_CODE_NK,
       C.STD_NAME_NK,
       C.PROCESS_CODE,
       C.PROCESS_DESC,
       C.GRADECODE,
       C.GRADENAME,
       C.STD_CODE,
       C.STD_NAME,
       C.MODEL_CODE,
       C.MODEL_DESC,
       C.CREATE_NAME,
       TO_CHAR(C.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       C.UPDATE_NAME,
       TO_CHAR(C.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       C.DELETE_NAME,
       TO_CHAR(C.DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
       DECODE(C.VALIDFLAG,
              '1',
              '录入状态',
              '0',
              '无效',
              '2',
              '提交审核',
              '3',
              '已审核') VALIDFLAG,
       C.MEMO,
       C.PRODUC_HEAD,
       C.STEELCODE_NK,
       C.STEELNAME_NK,
       C.MODEL_CODE_NK,
       C.MODEL_DESC_NK,
       C.PRODUCCODE_NK,
       C.PRODUCNAME_NK,
       C.MIN_D,
       C.MAX_D,
       C.MIN_H,
       C.MAX_H,
       C.MIN_D_SIGN,
       C.MAX_D_SIGN,
       C.MIN_H_SIGN,
       C.MAX_H_SIGN
  			FROM
				COM_MSC_STD_CIC C
			WHERE
				VALIDFLAG = '1' and
				CIC IN (
				SELECT
					TO_CHAR(REGEXP_SUBSTR( CIC, '[^,]+', 1, LEVEL )) CIC
				FROM
					( SELECT WM_CONCAT ( CIC ) CIC, MSC FROM COM_MSC_PROCESS B WHERE B.MSC = '#MSC#' GROUP BY MSC ) CONNECT BY LEVEL <= REGEXP_COUNT ( CIC, ',' ) + 1
					AND MSC = PRIOR MSC
					AND PRIOR DBMS_RANDOM.VALUE IS NOT NULL
			)
 ORDER BY C.CIC
		]]>
	</query>

	<query id="CoreChemStandard.getComChemNKC" desc="从表内控">
		<![CDATA[
SELECT A.CIC,
       A.INDEX_SEQ,
       A.CHEM_CODE,
       TO_NUMBER(SUBSTR(A.CHEM_CODE, 2, 3)) XH,
       A.CHEM_NAME,
       DECODE(A.CHEM_TYPE, 'A', '单一元素', '复合元素') CHEM_TYPE,
       A.CHEM_FORMULA,
       DECODE(A.ISCHECK, '1', 'TRUE', 'FALSE') ISCHECK,
       DECODE(A.ISJUDGE, '1', 'TRUE', 'FALSE') ISJUDGE,
       DECODE(A.ISQUOTE, '1', 'TRUE', 'FALSE') ISQUOTE,
       DECODE(A.COMPLEX_TYPE, '1', 'TRUE', 'FALSE') COMPLEX_TYPE,
       A.STDMIN_SIGN,
       A.STDMIN,
       A.STDMAX_SIGN,
       A.STDMAX,
       A.STDTARGET,
       A.MODEL_CODE,
       A.MODEL_DESC,
       A.STDMEMO,
       A.ELE_CODE,
       A.ELE_NAME,
       A.ELE_MIN_SIGN,
       A.ELE_MIN,
       A.ELE_MAX_SIGN,
       A.ELE_MAX,
       A.REP_CODE,
       A.REP_NAME,
       A.REP_MIN_SIGN,
       A.REP_MIN,
       A.REP_MAX_SIGN,
       A.REP_MAX,
       A.REP_VAL,
       A.SIZE_CODE2,
       A.SIZE_NAME2,
       A.SIZE_MIN_SIGN2,
       A.SIZE_MIN2,
       A.SIZE_MAX_SIGN2,
       A.SIZE_MAX2,
       A.SIZE_CODE,
       A.SIZE_NAME,
       A.SIZE_MIN_SIGN,
       A.SIZE_MIN,
       A.SIZE_MAX_SIGN,
       A.SIZE_MAX,
       A.SPEC_JG,
       A.SPEC_JG_DESC,
       A.GROUP_SEQ
  FROM COM_MSC_STD_CHEM A
  where
 			VALIDFLAG = '1' and
			CIC IN (
				SELECT
					TO_CHAR(REGEXP_SUBSTR( CIC, '[^,]+', 1, LEVEL )) CIC
				FROM
					( SELECT WM_CONCAT ( CIC ) CIC, MSC FROM COM_MSC_PROCESS B WHERE B.MSC = '#MSC#' GROUP BY MSC ) CONNECT BY LEVEL <= REGEXP_COUNT ( CIC, ',' ) + 1
					AND MSC = PRIOR MSC
					AND PRIOR DBMS_RANDOM.VALUE IS NOT NULL
			)
 ORDER BY A.CIC, XH
		]]>
	</query>
</queryMap>