<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="公差标准">

<query id="CoreTolerancesStandard.QUERYMAXG" desc="公差标准主表 最大索引号(交付标准) ">
		<![CDATA[
SELECT MAX(SUBSTR(SIC, 5, 6)) FROM COM_MSC_STD_SPEC WHERE STDSTYLE IN ('G','X')
		]]>
	</query>
	
<query id="CoreTolerancesStandard.QUERYMAXN" desc="公差标准主表 最大索引号(内控等) ">
		<![CDATA[
SELECT MAX(SUBSTR(SIC, 5, 6)) FROM COM_MSC_STD_SPEC WHERE STDSTYLE='N'
		]]>
	</query>
	
<query id="CoreTolerancesStandard.QUERYMAXK" desc="公差标准主表 最大索引号(Alpha) ">
		<![CDATA[
SELECT MAX(SUBSTR(SIC, 5, 6)) FROM COM_MSC_STD_SPEC WHERE STDSTYLE='K'
		]]>
	</query>
	
<query id="CoreTolerancesStandard.QUERYMAXS" desc="公差标准主表 最大索引号(其他标准) ">
		<![CDATA[
SELECT MAX(SUBSTR(SIC, 5, 6)) FROM COM_MSC_STD_SPEC WHERE STDSTYLE IN ('P','S')
		]]>
	</query>		
	
<query id="CoreTolerancesStandard.QUERYMAX1" desc="公差标准从表 序号 最大值">
		<![CDATA[
        SELECT INDEX_SEQ FROM  COM_MSC_STD_SPEC_C
         WHERE INDEX_SEQ=( SELECT MAX(INDEX_SEQ) FROM COM_MSC_STD_SPEC_C WHERE SIC=?) 
		]]>
	</query>
	
<query id="CoreTolerancesStandard.QUERYG" desc="公差标准主表  查询 交付标准">
		<![CDATA[
		SELECT *
  FROM (SELECT S.SIC,
               S.PSC,
               S.MSC,
               S.STD_NAME,
               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(S.STDSTYLE, 'G', '订货标准', 'X', '协议标准', '') STDSTYLE,
               S.MODEL_CODE,
               S.MODEL_DESC,
               S.STDMEMO,
               S.PRODUC_HEAD,
               S.CREATE_NAME,
               TO_CHAR(S.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
               S.UPDATE_NAME,
               TO_CHAR(S.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
               S.DELETE_NAME,
               TO_CHAR(S.DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
               DECODE(S.VALIDFLAG, '1', '录入状态','0','无效','2','提交审核','3','已审核') VALIDFLAG,
               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
          FROM COM_MSC_STD_SPEC S
          LEFT JOIN COM_PSC P ON S.PSC = P.PSC
          LEFT JOIN COM_MSC_BL D ON S.PSC = D.PSC_BL
         WHERE LOWER(S.MSC) || '&' LIKE '%' || LOWER('#MSC#') || '%'
           AND S.VALIDFLAG IN ('1','2','3', '#VALIDFLAG#')
           AND DECODE('#STD_CODE#', NULL, '1', S.STD_CODE) = DECODE('#STD_CODE#', NULL, '1', '#STD_CODE#')
           AND DECODE('#SIC#', NULL, '1', S.SIC) = DECODE('#SIC#', NULL, '1', '#SIC#')
           AND DECODE('#MSC2#', NULL, '1', S.MSC) = DECODE('#MSC2#', NULL, '1', '#MSC2#')
           AND DECODE('#CODE_JG#', NULL, '1', 'DefaultValue', '1', S.CODE_JG) = DECODE('#CODE_JG#', NULL, '1', 'DefaultValue', '1', '#CODE_JG#')
           AND DECODE('#CODE_JG#', NULL, S.CODE_JG, NULL) IS NULL
           AND S.STDSTYLE IN ('G', 'X'))
 WHERE LOWER(STD_NAME) || '&' LIKE '%' || LOWER('#STD_NAME#') || '%'
 ORDER BY SIC
		]]>
	</query>

<query id="CoreTolerancesStandard.QUERYN" desc="公差标准主表  查询 内控">
		<![CDATA[
SELECT SIC,
       DECODE(STDSTYLE,
              'N',
              '内控',
              'K',
              'Alpha',
              'S',
              '试验标准',
              'P',
              '成分偏差标准',
              '') STDSTYLE,
       STD_CODE,
       STD_NAME,
       PROCESS_CODE,
       PROCESS_DESC,
       MODEL_CODE,
       MODEL_DESC,
       STDMEMO,
       PRODUC_HEAD,
       CREATE_NAME,
       TO_CHAR(CREATE_TIME, 'yyyy-mm-dd hh24:mi:ss') CREATE_TIME,
       UPDATE_NAME,
       TO_CHAR(UPDATE_TIME, 'yyyy-mm-dd hh24:mi:ss') UPDATE_TIME,
       DELETE_NAME,
       TO_CHAR(DELETE_TIME, 'yyyy-mm-dd hh24:mi:ss') DELETE_TIME,
       DECODE(VALIDFLAG,
              '1',
              '录入状态',
              '0',
              '无效',
              '2',
              '提交审核',
              '3',
              '已审核') VALIDFLAG,
       DECODE(SPECIAL_PATH, '1', 'True', 'False') SPECIAL_PATH,
       STEELCODE_NK,
       STEELNAME_NK,
       MODEL_CODE_NK,
       MODEL_DESC_NK,
       PRODUCCODE_NK,
       PRODUCNAME_NK
  FROM COM_MSC_STD_SPEC T
 WHERE lower(STD_NAME) || '&' LIKE '%' || lower('#STD_NAME#') || '%'
   AND VALIDFLAG in ('1', '2', '3', '#VALIDFLAG#')
   AND DECODE('#STD_CODE#', NULL, '1', STD_CODE) =
       DECODE('#STD_CODE#', NULL, '1', '#STD_CODE#')
   AND DECODE('#SIC#', NULL, '1', SIC) =
       DECODE('#SIC#', NULL, '1', '#SIC#')
   AND DECODE('#MSC2#', NULL, '1', MSC) =
       DECODE('#MSC2#', NULL, '1', '#MSC2#')
   AND DECODE('#CODE_JG#', NULL, '1', 'DefaultValue', '1', CODE_JG) =
       DECODE('#CODE_JG#', NULL, '1', 'DefaultValue', '1', '#CODE_JG#')
   AND DECODE('#CODE_JG#', NULL, CODE_JG, NULL) IS NULL
   AND NVL(INSTR(PRODUCCODE_NK, '#PRODUCCODE_NK#'), 1) > 0
   AND NVL(INSTR(STEELCODE_NK, '#STEELCODE_NK#'), 1) > 0
   AND NVL(INSTR(PROCESS_CODE, '#PROCESS_CODE#'), 1) > 0
   AND NVL(INSTR(T.MODEL_CODE_NK, '#MODEL_CODE_NK#'), 1) > 0
   AND STDSTYLE IN
       (DECODE('#STDSTYLE#', '2', 'N', '3', 'K', 'P'),
        DECODE('#STDSTYLE#', '2', '', '3', '', 'S'))
 ORDER BY SIC
		]]>
	</query>	
	
<query id="CoreTolerancesStandard.QUERYK" desc="公差标准主表  查询 Alpha">
		<![CDATA[
		SELECT SIC,
               DECODE(STDSTYLE,'K','Alpha','') STDSTYLE,
               STD_CODE,
               STD_NAME,
               PROCESS_CODE,
               PROCESS_DESC,
               MODEL_CODE,
               MODEL_DESC,
               STDMEMO,
               CREATE_NAME,
               TO_CHAR(CREATE_TIME, 'yyyy-mm-dd hh24:mi:ss') CREATE_TIME,
               UPDATE_NAME,
               TO_CHAR(UPDATE_TIME, 'yyyy-mm-dd hh24:mi:ss') UPDATE_TIME,
               DELETE_NAME,
               TO_CHAR(DELETE_TIME, 'yyyy-mm-dd hh24:mi:ss') DELETE_TIME,
               DECODE(VALIDFLAG, '1', '录入状态','0','无效','2','提交审核','3','已审核') VALIDFLAG,
          FROM COM_MSC_STD_SPEC
         WHERE 
               lower(STD_NAME) || '&' LIKE '%' || lower(?) || '%' AND
               VALIDFLAG in ('1','2','3', ?)
           AND STDSTYLE='K' 
      ORDER BY SIC
		]]>
	</query>	
	
	<query id="CoreTolerancesStandard.QUERYS" desc="公差标准主表  查询其它标准">
		<![CDATA[
		SELECT SIC,
               DECODE(STDSTYLE,'S','试验标准','成分偏差标准') STDSTYLE,
               STD_CODE,
               STD_NAME,
               PROCESS_CODE,
               PROCESS_DESC,
               MODEL_CODE,
               MODEL_DESC,
               STDMEMO,
               CREATE_NAME,
               TO_CHAR(CREATE_TIME, 'yyyy-mm-dd hh24:mi:ss') CREATE_TIME,
               UPDATE_NAME,
               TO_CHAR(UPDATE_TIME, 'yyyy-mm-dd hh24:mi:ss') UPDATE_TIME,
               DELETE_NAME,
               TO_CHAR(DELETE_TIME, 'yyyy-mm-dd hh24:mi:ss') DELETE_TIME,
               DECODE(VALIDFLAG, '1', '录入状态','0','无效','2','提交审核','3','已审核') VALIDFLAG,
          FROM COM_MSC_STD_SPEC
         WHERE 
               lower(STD_NAME) || '&' LIKE '%' || lower(?) || '%' AND
               VALIDFLAG in ('1','2','3', ?)
           AND STDSTYLE IN ('P','S') 
      ORDER BY SIC
		]]>
	</query>	
	
<query id="CoreTolerancesStandard.QUERYOTHERC" desc="公差标准从表 ">
		<![CDATA[
SELECT SIC,
       INDEX_SEQ,
       BIAS_CODE,
       BIAS_NAME,
       LV,
       BIAS_CODE_Z,
       BIAS_NAME_Z,
       ZMIN_SIGN,
       ZMIN,
       ZMAX_SIGN,
       ZMAX,
       BIAS_CODE_C,
       BIAS_NAME_C,
       CMIN_SIGN,
       CMIN,
       CMAX_SIGN,
       CMAX,
       BIAS_CODE_S,
       BIAS_NAME_S,
       SMIN_SIGN,
       SMIN,
       SMAX_SIGN,
       SMAX,
       DECODE(ISCHECK, '1', 'TRUE', 'FALSE') ISCHECK,
       STD_MIN_VAL,
       STD_MAX_VAL,
       STD_MIN_IN,
       STD_MAX_IN,
       STD_MIN_PERCENT,
       STD_MAX_PERCENT,
       STD_MIN_FORMULA,
       STD_MAX_FORMULA,
       DECODE(STD_MIN_FORMULA_V, '1', 'TRUE', 'FALSE') STD_MIN_FORMULA_V,
       DECODE(STD_MAX_FORMULA_V, '1', 'TRUE', 'FALSE') STD_MAX_FORMULA_V,
       STDMEMO,
       CREATE_NAME,
       TO_CHAR(CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       UPDATE_NAME,
       TO_CHAR(UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       DELETE_NAME,
       TO_CHAR(DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
       DECODE(VALIDFLAG, '1', '有效', '无效') VALIDFLAG,
       A.GROUP_SEQ
  FROM COM_MSC_STD_SPEC_C A
 WHERE VALIDFLAG IN ('1', '#VALIDFLAG#')
   AND EXISTS
 (SELECT 1
          FROM COM_MSC_STD_SPEC B
         WHERE B.VALIDFLAG IN ('1', '2', '3', '#VALIDFLAG#')
           AND DECODE('#STD_CODE#', NULL, '1', B.STD_CODE) =
               DECODE('#STD_CODE#', NULL, '1', '#STD_CODE#')
           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 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 B.STDSTYLE NOT IN ('G', 'X')
           AND A.SIC = B.SIC)
 ORDER BY SIC, INDEX_SEQ
		]]>
	</query>
	
<query id="CoreTolerancesStandard.QUERYGC" desc="公差标准从表 ">
		<![CDATA[
          SELECT SIC,
                 INDEX_SEQ,
                 BIAS_CODE,
                 BIAS_NAME,
                 LV,
                 BIAS_CODE_Z,
                 BIAS_NAME_Z,
                 ZMIN_SIGN,
                 ZMIN,
                 ZMAX_SIGN,
                 ZMAX,
                 BIAS_CODE_C,
                 BIAS_NAME_C,
                 CMIN_SIGN,
                 CMIN,
                 CMAX_SIGN,
                 CMAX,
                 BIAS_CODE_S,
                 BIAS_NAME_S,
                 SMIN_SIGN,
                 SMIN,
                 SMAX_SIGN,
                 SMAX,
                 DECODE(ISCHECK, '1', 'TRUE', 'FALSE') ISCHECK,
                 STD_MIN_VAL,
                 STD_MAX_VAL,
                 STD_MIN_IN,
                 STD_MAX_IN,
                 STD_MIN_PERCENT,
                 STD_MAX_PERCENT,
                 STD_MIN_FORMULA,
                 STD_MAX_FORMULA,
                 DECODE(STD_MIN_FORMULA_V, '1', 'TRUE', 'FALSE') STD_MIN_FORMULA_V,
                 DECODE(STD_MAX_FORMULA_V, '1', 'TRUE', 'FALSE') STD_MAX_FORMULA_V,
                 STDMEMO,
                 CREATE_NAME,
                 TO_CHAR(CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
                 UPDATE_NAME,
                 TO_CHAR(UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
                 DELETE_NAME,
                 TO_CHAR(DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
                 DECODE(VALIDFLAG, '1', '有效', '无效') VALIDFLAG,
                 A.GROUP_SEQ
            FROM COM_MSC_STD_SPEC_C A
           WHERE VALIDFLAG IN ('1', '#VALIDFLAG#')
           AND EXISTS
    (SELECT 1
       FROM COM_MSC_STD_SPEC B
      WHERE B.VALIDFLAG IN ('1','2','3', '#VALIDFLAG#')
        AND DECODE('#STD_CODE#', NULL, '1', B.STD_CODE) = DECODE('#STD_CODE#', NULL, '1', '#STD_CODE#')
        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 NVL(INSTR(B.PRODUCCODE_NK, '#PRODUCCODE_NK#'), 1) > 0
        AND NVL(INSTR(B.STEELCODE_NK, '#STEELCODE_NK#'), 1) > 0
        AND B.STDSTYLE IN ('G', 'X')
        AND A.SIC = B.SIC)
        ORDER BY SIC, INDEX_SEQ
		]]>
	</query>
	
<query id="CoreTolerancesStandard.ADD" desc="公差标准主表 ">
		<![CDATA[
        INSERT INTO COM_MSC_STD_SPEC
  (SIC,
   PSC,
   MSC,
   STDSTYLE,
   STD_CODE,
   STD_NAME,
   PROCESS_CODE,
   PROCESS_DESC,
   MODEL_CODE,
   MODEL_DESC,
   STDMEMO,
   PRODUC_HEAD,
   CODE_JG,
   CREATE_NAME,
   CREATE_TIME,
   VALIDFLAG,
   SPECIAL_PATH,
   STEELCODE_NK,
   STEELNAME_NK,
   MODEL_CODE_NK,
   MODEL_DESC_NK,
   PRODUCCODE_NK,
   PRODUCNAME_NK)
VALUES
  (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, SYSDATE, DEFAULT,?,
  ?, ?, ?, ?, ?, ?)
		]]>
	</query>
	
<query id="CoreTolerancesStandard.ADD1" desc="公差标准从表 ">
		<![CDATA[
      INSERT INTO COM_MSC_STD_SPEC_C
  (SIC,
   INDEX_SEQ,
   BIAS_CODE,
   BIAS_NAME,
   LV,
   BIAS_CODE_Z,
   BIAS_NAME_Z,
   ZMIN_SIGN,
   ZMIN,
   ZMAX_SIGN,
   ZMAX,
   BIAS_CODE_C,
   BIAS_NAME_C,
   CMIN_SIGN,
   CMIN,
   CMAX_SIGN,
   CMAX,
   BIAS_CODE_S,
   BIAS_NAME_S,
   SMIN_SIGN,
   SMIN,
   SMAX_SIGN,
   SMAX,
   ISCHECK,
   STD_MIN_VAL,
   STD_MAX_VAL,
   STD_MIN_IN,
   STD_MAX_IN,
   STD_MIN_PERCENT,
   STD_MAX_PERCENT,
   STD_MIN_FORMULA,
   STD_MAX_FORMULA,
   STD_MIN_FORMULA_V,
   STD_MAX_FORMULA_V,
   STDMEMO,
   CREATE_NAME,
   CREATE_TIME,
   VALIDFLAG,
   GROUP_SEQ)
VALUES
  (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,
   ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,
   SYSDATE,DEFAULT, ?)
		]]>
	</query>
	
<query id="CoreTolerancesStandard.UPDATE" desc="公差标准主表">
		<![CDATA[
      UPDATE COM_MSC_STD_SPEC
   SET SIC          = ?,
       PSC          = ?,
       MSC          = ?,
       STDSTYLE     = ?,
       STD_CODE     = ?,
       STD_NAME     = ?,
       PROCESS_CODE = ?,
       PROCESS_DESC = ?,
       MODEL_CODE   = ?,
       MODEL_DESC   = ?,
       STDMEMO      = ?,
       PRODUC_HEAD = ?,
       CODE_JG = ?,
       UPDATE_NAME  = ?,
       UPDATE_TIME  = SYSDATE,
       SPECIAL_PATH = ?,
       STEELCODE_NK = ?,
       STEELNAME_NK = ?,
       MODEL_CODE_NK = ?,
       MODEL_DESC_NK = ?,
       PRODUCCODE_NK = ?,
       PRODUCNAME_NK = ?
 WHERE SIC = ?
		]]>
	</query>
	
<query id="CoreTolerancesStandard.UPDATE1" desc="公差标准从表">
		<![CDATA[
      UPDATE COM_MSC_STD_SPEC_C
   SET SIC               = ?,
       INDEX_SEQ         = ?,
       BIAS_CODE         = ?,
       BIAS_NAME         = ?,
       LV                = ?,
       BIAS_CODE_Z       = ?,
       BIAS_NAME_Z       = ?,
       ZMIN_SIGN         = ?,
       ZMIN              = ?,
       ZMAX_SIGN         = ?,
       ZMAX              = ?,
       BIAS_CODE_C       = ?,
       BIAS_NAME_C       = ?,
       CMIN_SIGN         = ?,
       CMIN              = ?,
       CMAX_SIGN         = ?,
       CMAX              = ?,
       BIAS_CODE_S       = ?,
       BIAS_NAME_S       = ?,
       SMIN_SIGN         = ?,
       SMIN              = ?,
       SMAX_SIGN         = ?,
       SMAX              = ?,
       ISCHECK           = ?,
       STD_MIN_VAL       = ?,
       STD_MAX_VAL       = ?,
       STD_MIN_IN        = ?,
       STD_MAX_IN        = ?,
       STD_MIN_PERCENT   = ?,
       STD_MAX_PERCENT   = ?,
       STD_MIN_FORMULA   = ?,
       STD_MAX_FORMULA   = ?,
       STD_MIN_FORMULA_V = ?,
       STD_MAX_FORMULA_V = ?,
       STDMEMO           = ?,
       UPDATE_NAME       = ?,
       UPDATE_TIME       = SYSDATE,
       GROUP_SEQ = ?
   WHERE SIC = ?
   AND INDEX_SEQ = ?
		]]>
	</query>
	
	
<query id="CoreTolerancesStandard.DELETE" desc="公差标准主表 ">
		<![CDATA[
       UPDATE COM_MSC_STD_SPEC 
       SET VALIDFLAG='0',DELETE_NAME=?,DELETE_TIME=SYSDATE
       WHERE SIC=?   AND VALIDFLAG = '1'
      
		]]>
	</query>
	
<query id="CoreTolerancesStandard.DELETE1" desc="公差标准从表 ">
		<![CDATA[
       UPDATE COM_MSC_STD_SPEC_C 
       SET VALIDFLAG='0',DELETE_NAME=?,DELETE_TIME=SYSDATE
       WHERE SIC=? AND INDEX_SEQ = ?  AND VALIDFLAG = '1'
        AND (SELECT VALIDFLAG FROM COM_MSC_STD_SPEC 
        WHERE SIC = ? ) IN ('1', '0')
		]]>
	</query>
	
<query id="CoreTolerancesStandard.RESUME" desc="公差标准主表 ">
		<![CDATA[
       UPDATE COM_MSC_STD_SPEC 
       SET VALIDFLAG='1',DELETE_NAME=?,DELETE_TIME=null
       WHERE SIC=? AND VALIDFLAG = '0'
		]]>
	</query>
	
<query id="CoreTolerancesStandard.RESUME1" desc="公差标准从表 ">
		<![CDATA[
       UPDATE COM_MSC_STD_SPEC_C 
       SET VALIDFLAG='1',DELETE_NAME=?,DELETE_TIME=NULL
       WHERE SIC=? AND INDEX_SEQ = ?   AND VALIDFLAG = '0'
		]]>
	</query>
	
	<query id="CoreTolerancesStandard.group" desc="公差分组">
		<![CDATA[
       DECLARE
		  P_MAX_GOUP_SEQ VARCHAR2(6);
		BEGIN
		  SELECT NVL(MAX(A.GROUP_SEQ), 0) + 1
		    INTO P_MAX_GOUP_SEQ
		    FROM COM_MSC_STD_SPEC_C A
		   WHERE A.SIC = '#SIC#';
		  UPDATE COM_MSC_STD_SPEC_C T
		     SET T.GROUP_SEQ = P_MAX_GOUP_SEQ
		   WHERE T.SIC = '#SIC#'
		   AND T.INDEX_SEQ IN ('#INDEX_SEQS#');
		END;
		]]>
	</query>
	
	<query id="CoreTolerancesStandard.cancelGroup" desc="公差取消分组">
		<![CDATA[
		  UPDATE COM_MSC_STD_SPEC_C T
		     SET T.GROUP_SEQ = ''
		   WHERE T.SIC = '#SIC#'
		   AND T.INDEX_SEQ IN ('#INDEX_SEQS#')
		]]>
	</query>
	
	<query id="CoreTolerancesStandard.getComSicBySic" desc="通过SIC获取公差表">
		<![CDATA[
SELECT * FROM Com_Msc_Std_Spec T WHERE T.SIC = '#SIC#'
		]]>
	</query>
	<query id="CoreTolerancesStandard.getPurchaseAgreementSic" desc="获取采购的公差主表">
		<![CDATA[
SELECT A.SIC,
       DECODE(A.STDSTYLE,
              'N',
              '内控',
              'K',
              'Alpha',
              'S',
              '试验标准',
              'P',
              '成分偏差标准',
              '') STDSTYLE,
       A.STD_CODE,
       A.STD_NAME,
       A.PROCESS_CODE,
       A.PROCESS_DESC,
       A.MODEL_CODE,
       A.MODEL_DESC,
       A.STDMEMO,
       A.PRODUC_HEAD,
       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',
              '录入状态',
              '0',
              '无效',
              '2',
              '提交审核',
              '3',
              '已审核') VALIDFLAG,
       DECODE(A.SPECIAL_PATH, '1', 'True', 'False') SPECIAL_PATH,
       A.STEELCODE_NK,
       A.STEELNAME_NK,
       A.MODEL_CODE_NK,
       A.MODEL_DESC_NK,
       A.PRODUCCODE_NK,
       A.PRODUCNAME_NK
  FROM COM_MSC_STD_SPEC A, COM_BASE_STD C
 WHERE C.PURCHASE_STD = '1'
   AND C.VALIDFLAG = '1'
   AND C.STD_CODE = A.STD_CODE
   AND A.VALIDFLAG = '1'
   AND A.STD_CODE = {0}
 ORDER BY SIC
		]]>
	</query>
	<query id="CoreTolerancesStandard.getPurchaseAgreementSpec" desc="获取采购的公差从表">
		<![CDATA[
SELECT A.SIC,
       A.INDEX_SEQ,
       A.BIAS_CODE,
       A.BIAS_NAME,
       A.LV,
       A.BIAS_CODE_Z,
       A.BIAS_NAME_Z,
       A.ZMIN_SIGN,
       A.ZMIN,
       A.ZMAX_SIGN,
       A.ZMAX,
       A.BIAS_CODE_C,
       A.BIAS_NAME_C,
       A.CMIN_SIGN,
       A.CMIN,
       A.CMAX_SIGN,
       A.CMAX,
       A.BIAS_CODE_S,
       A.BIAS_NAME_S,
       A.SMIN_SIGN,
       A.SMIN,
       A.SMAX_SIGN,
       A.SMAX,
       DECODE(A.ISCHECK, '1', 'TRUE', 'FALSE') ISCHECK,
       A.STD_MIN_VAL,
       A.STD_MAX_VAL,
       A.STD_MIN_IN,
       A.STD_MAX_IN,
       A.STD_MIN_PERCENT,
       A.STD_MAX_PERCENT,
       A.STD_MIN_FORMULA,
       A.STD_MAX_FORMULA,
       DECODE(A.STD_MIN_FORMULA_V, '1', 'TRUE', 'FALSE') STD_MIN_FORMULA_V,
       DECODE(A.STD_MAX_FORMULA_V, '1', 'TRUE', 'FALSE') STD_MAX_FORMULA_V,
       A.STDMEMO,
       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_SPEC_C A, COM_MSC_STD_SPEC B, COM_BASE_STD C
 WHERE C.PURCHASE_STD = '1'
   AND C.VALIDFLAG = '1'
   AND C.STD_CODE = B.STD_CODE
   AND B.VALIDFLAG = '1'
   AND B.SIC = A.SIC
   AND A.VALIDFLAG = '1'
   AND B.STD_CODE = {0}
 ORDER BY SIC, INDEX_SEQ
		]]>
	</query>


	<query id="CoreTolerancesStandard.getComSpecNK" desc="公差标准主表内控">
		<![CDATA[
SELECT SIC,
       DECODE(STDSTYLE,
              'N',
              '内控',
              'K',
              'Alpha',
              'S',
              '试验标准',
              'P',
              '成分偏差标准',
              '') STDSTYLE,
       STD_CODE,
       STD_NAME,
       PROCESS_CODE,
       PROCESS_DESC,
       MODEL_CODE,
       MODEL_DESC,
       STDMEMO,
       PRODUC_HEAD,
       CREATE_NAME,
       TO_CHAR(CREATE_TIME, 'yyyy-mm-dd hh24:mi:ss') CREATE_TIME,
       UPDATE_NAME,
       TO_CHAR(UPDATE_TIME, 'yyyy-mm-dd hh24:mi:ss') UPDATE_TIME,
       DELETE_NAME,
       TO_CHAR(DELETE_TIME, 'yyyy-mm-dd hh24:mi:ss') DELETE_TIME,
       DECODE(VALIDFLAG,
              '1',
              '录入状态',
              '0',
              '无效',
              '2',
              '提交审核',
              '3',
              '已审核') VALIDFLAG,
       DECODE(SPECIAL_PATH, '1', 'True', 'False') SPECIAL_PATH,
       STEELCODE_NK,
       STEELNAME_NK,
       MODEL_CODE_NK,
       MODEL_DESC_NK,
       PRODUCCODE_NK,
       PRODUCNAME_NK
  FROM COM_MSC_STD_SPEC T
 WHERE
	VALIDFLAG = '1'
	AND SIC IN (
	SELECT
		TO_CHAR( REGEXP_SUBSTR( SIC, '[^,]+', 1, LEVEL ) ) SIC
	FROM
		( SELECT WM_CONCAT ( SIC ) SIC, MSC FROM COM_MSC_PROCESS B WHERE B.MSC = 'MSC0005573032' GROUP BY MSC ) CONNECT BY LEVEL <= REGEXP_COUNT ( SIC, ',' ) + 1
		AND MSC = PRIOR MSC
	AND PRIOR DBMS_RANDOM.VALUE IS NOT NULL
	)
 ORDER BY SIC
		]]>
	</query>

	<query id="CoreTolerancesStandard.getComSpecNKC" desc="公差标准从表内控">
		<![CDATA[
SELECT SIC,
       INDEX_SEQ,
       BIAS_CODE,
       BIAS_NAME,
       LV,
       BIAS_CODE_Z,
       BIAS_NAME_Z,
       ZMIN_SIGN,
       ZMIN,
       ZMAX_SIGN,
       ZMAX,
       BIAS_CODE_C,
       BIAS_NAME_C,
       CMIN_SIGN,
       CMIN,
       CMAX_SIGN,
       CMAX,
       BIAS_CODE_S,
       BIAS_NAME_S,
       SMIN_SIGN,
       SMIN,
       SMAX_SIGN,
       SMAX,
       DECODE(ISCHECK, '1', 'TRUE', 'FALSE') ISCHECK,
       STD_MIN_VAL,
       STD_MAX_VAL,
       STD_MIN_IN,
       STD_MAX_IN,
       STD_MIN_PERCENT,
       STD_MAX_PERCENT,
       STD_MIN_FORMULA,
       STD_MAX_FORMULA,
       DECODE(STD_MIN_FORMULA_V, '1', 'TRUE', 'FALSE') STD_MIN_FORMULA_V,
       DECODE(STD_MAX_FORMULA_V, '1', 'TRUE', 'FALSE') STD_MAX_FORMULA_V,
       STDMEMO,
       A.GROUP_SEQ
  FROM COM_MSC_STD_SPEC_C A
  WHERE
	VALIDFLAG = '1'
	AND SIC IN (
	SELECT
		TO_CHAR( REGEXP_SUBSTR( SIC, '[^,]+', 1, LEVEL ) ) SIC
	FROM
		( SELECT WM_CONCAT ( SIC ) SIC, MSC FROM COM_MSC_PROCESS B WHERE B.MSC = 'MSC0005573032' GROUP BY MSC ) CONNECT BY LEVEL <= REGEXP_COUNT ( SIC, ',' ) + 1
		AND MSC = PRIOR MSC
	AND PRIOR DBMS_RANDOM.VALUE IS NOT NULL
	)
 ORDER BY SIC, INDEX_SEQ
		]]>
	</query>
</queryMap>