<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="冶金规范">
	<query id="CoreFrmProPSCMSC2.queryCom_Psc" desc="查询产品规范数据">
		<![CDATA[
			SELECT T.PSC,
		       T.PSC_DESC,
		       T.MEMO,
		       PRODUCCODE,
		       PRODUCNAME,
		       STD_CODE,
		       STD_NAME,
		       STEELCODE,
		       STEELNAME,
		       STD_STYLE,
		       STD_STYLE_DESC,
		       NEW_PROC_CODE,
		       NEW_PROC_DESC
		  FROM COM_PSC T
		 WHERE DECODE(?, NULL, '1', T.PSC) =
		       DECODE(?, NULL, '1', ?)
		   AND T.VALIDFLAG = '1'
		 ORDER BY PSC
		]]>
	</query>

	<query id="CoreFrmProPSCMSC2.queryCom_Psc2" desc="查询产品规范数据2">
		<![CDATA[
SELECT T.PSC,
       T.PSC_DESC,
       T.MEMO,
       T.PRODUCCODE,
       T.PRODUCNAME,
       T.STD_CODE,
       T.STD_NAME,
       T.STEELCODE,
       T.STEELNAME,
       T.STD_STYLE,
       T.STD_STYLE_DESC,
       T.NEW_PROC_CODE,
       T.NEW_PROC_DESC,
       A.PRODUC_HEAD,
       DECODE((SELECT B.PSC
                FROM COM_PSC_R_MSC B
               WHERE B.PSC = T.PSC
                 AND B.VALIDFLAG = '1'
                 AND ROWNUM = 1
                 AND EXISTS (SELECT 1
                        FROM COM_MSC
                       WHERE MSC = B.MSC
                         AND VALIDFLAG <> 'D')),
              NULL,
              'False',
              'True') HAVE_MSC
  FROM COM_PSC T
  LEFT JOIN COM_BASE_PRODUCT A
    ON A.PRODUCCODE = T.PRODUCCODE
 WHERE T.VALIDFLAG = '1'
   AND DECODE('#PRODUCCODE#', NULL, '1', T.PRODUCCODE) =
       DECODE('#PRODUCCODE#', NULL, '1', '#PRODUCCODE#')
   AND DECODE('#STD_NAME#', NULL, '1', LOWER(T.STD_NAME)) LIKE
       DECODE('#STD_NAME#', NULL, '1', '%' || LOWER('#STD_NAME#') || '%')
   AND DECODE('#STEELNAME#', NULL, '1', LOWER(T.STEELNAME)) LIKE
       DECODE('#STEELNAME#', NULL, '1', '%' || LOWER('#STEELNAME#') || '%')
   AND DECODE('#PSC#', NULL, '1', T.PSC) =
       DECODE('#PSC#', NULL, '1', '#PSC#')
   AND T.PSC IN (SELECT PSC
                   FROM COM_PSC_R_MSC B
                  WHERE B.MSC LIKE '%' || UPPER('#MSC#') || '%')
   AND ('#UNIT_DESC#' IS NULL OR EXISTS
        (SELECT 1
           FROM COM_PSC_R_MSC B, COM_MSC C
          WHERE B.PSC = T.PSC
            AND C.MSC = B.MSC
            AND C.VALIDFLAG <> 'D'
            AND C.UNIT_DESC LIKE '%#UNIT_DESC#%'))
   AND ('#USE_DESC#' IS NULL OR EXISTS
        (SELECT 1
           FROM COM_PSC_R_MSC B, COM_MSC C
          WHERE B.PSC = T.PSC
            AND B.MSC = C.MSC
            AND C.VALIDFLAG <> 'D'
            AND LOWER(C.USE_DESC) LIKE '%' || LOWER('#USE_DESC#') || '%'))
 ORDER BY PSC
		]]>
	</query>
	
	<query id="CoreFrmProPSCMSC2.queryCom_Msc" desc="根据产品规范码查询冶金规范">
		<![CDATA[
SELECT T.MSC,
       A.MSC_DESC,
       A.MSC_DESC OLD_MSC_DESC,
       A.USE_CODE,
       A.USE_CODE OLD_USE_CODE,
       A.USE_DESC,
       A.USE_DESC OLD_USE_DESC,
       A.UNIT_CODE_PROCESS,
       A.DEPARTMENT_CODE,
       A.DEPARTMENT_DESC,
       A.UNIT_CODE,
       A.UNIT_DESC,
       A.MSC_STYLE,
       A.USER_COUNT,
       A.MSC_SEQ,
       A.MSC_DESC_SEQ,
       A.MSC_SEQ OLD_MSC_SEQ,
       A.ALLOW_NK,
       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,
       A.MEMO,
       A.REMARK,
       TO_CHAR(A.AUDIT_TIME, 'YYYY-MM-DD HH24:MI:SS') AUDIT_TIME,
       A.AUDIT_NAME,
       A.VALIDFLAG_NK,
       DECODE(A.VALIDFLAG_NK,
              'A',
              '录入状态',
              'B',
              '提交审核',
              'C',
              '已生效',
              'D',
              '无效',
              'E',
              '提交修改',
              '未识别') VALIDFLAG_NK_NAME,
       A.AUDIT_NAME_NK,
       TO_CHAR(A.AUDIT_TIME_NK, 'YYYY-MM-DD HH24:MI:SS') AUDIT_TIME_NK,
       A.REMARK_NK,
       A.PRODUC_HEAD,
       A.VALIDFLAG,
       A.JUDGEFLAG,
       DECODE(A.VALIDFLAG,
              'A',
              '录入状态',
              'B',
              '提交审核',
              'C',
              '已生效',
              'D',
              '无效',
              'E',
              '提交修改',
              '未识别') VALIDFLAG_NAME,
       B.MEMO ALPHA_MEMO,
	   (SELECT COUNT(1) FROM SLM_ORDER_LINE WHERE MSC = T.MSC AND VALIDFLAG = '1' and ORDER_LN_STATUS >= '12020301') ORDER_LINE_COUNT,
	   '复制' COPY_MSC
  FROM COM_PSC_R_MSC T, COM_MSC A
  LEFT JOIN COM_BASE_STD_ALPHA B
    ON B.ALPHA_CODE = A.USE_CODE
 WHERE T.PSC = ?
   AND T.MSC = A.MSC
   AND A.VALIDFLAG IN ('A', 'B', 'C', 'E', ?)
   AND DECODE(?, NULL, '1', T.MSC) = DECODE(?, NULL, '1', ?)
   AND (T.MSC LIKE '%' || UPPER(?) || '%' OR A.MSC_SEQ IS NULL)
   AND (DECODE(?, NULL, '1', A.USE_CODE) = DECODE(?, NULL, '1', ?) OR
       A.USE_DESC = '/')
 ORDER BY T.MSC
		]]>
	</query>
	
	<query id="CoreFrmProPSCMSC2.loadAlpha" desc="加载Alpha">
		<![CDATA[
			(SELECT '' STD_CODE, '' STD_NAME, 0 IDX FROM DUAL)
			UNION ALL
	     		(
				SELECT STD_CODE, STD_NAME, ROWNUM IDX
				  FROM COM_BASE_STD
				 WHERE VALIDFLAG = '1'
				   AND STDSTYLE = 'K'
				)
	      ORDER BY IDX
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC2.loadMsc" desc="加载冶金规范码（MSC以000结尾的为标志MSC）">
		<![CDATA[
			SELECT A.MSC, A.MSC_DESC
			  FROM COM_PSC_R_MSC A
			  FULL JOIN COM_MSC B ON A.MSC = B.MSC
			 WHERE B.VALIDFLAG = 'C'
			   AND A.PSC = ?
			   AND B.MSC LIKE '__________000'
			 ORDER BY A.MSC
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC2.QueryClient" desc="查询标准代码下的所有客户">
		<![CDATA[
			SELECT T.CUST_NAME, T.CUST_CODE FROM com_base_std_r_cust t WHERE T.STD_CODE = ?
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC2.QueryStd_Name_Style" desc="查询MSC所属的标准名称和标准协会（用于树形结构）">
		<![CDATA[
			SELECT A.STD_CODE, A.STD_NAME, A.STD_STYLE, B.BASENAME STD_STYLE_NAME
			  FROM COM_BASE_STD A
			  LEFT JOIN COM_BASE_INFO B ON A.STD_STYLE = B.BASECODE
			 WHERE A.STD_CODE =
			       (SELECT B.STD_CODE
			          FROM com_psc B
			         WHERE B.PSC = (SELECT C.PSC
			                          FROM com_psc_r_msc C
			                         WHERE C.MSC = ?))
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC2.queryCom_Msc_Item" desc="查询冶金规范项目表">
		<![CDATA[
			 SELECT 
		       MSC,
		       INDEX_SEQ,
		       ITEM,
		       ITEM_C,
		       VALIDFLAG,
		       DECODE(VALIDFLAG, '1', '有效', '0', '无效', '未识别') VALIDFLAG_NAME,
		       MEMO,
		       CREATE_NAME
		 FROM COM_MSC_ITEM T
		 WHERE T.MSC = ?
		 AND T.VALIDFLAG IN ('1', ?)
		 ORDER BY T.MSC
		]]>
	</query>
	
	<query id="CoreFrmProPSCMSC2.queryMaxMscCode" desc="查询最大的冶金规范编码(规则：产品规范码后加3位流水号，并把PSC替换为MSC)">
		<![CDATA[
			 SELECT REPLACE(?, 'P', 'M') || LPAD(SUBSTR(NVL(MAX(T.MSC), ? || '000'), 11, 3) + DECODE(MAX(T.MSC), NULL, 0, 1), 3, '0')
			   FROM com_psc_r_msc T WHERE T.PSC = ?
		]]>
	</query>
	
	<query id="CoreFrmProPSCMSC2.queryMaxMscCode2" desc="查询最大的冶金规范编码(规则：备料码后加3位流水号，并把BL替换为MSC)">
		<![CDATA[
			 SELECT REPLACE(?, 'BL', 'MSC') || LPAD(SUBSTR(NVL(MAX(T.MSC), ? || '000'), 8, 3) + 1, 3, '0')
			   FROM com_psc_r_msc T WHERE T.PSC = ? AND T.USE_CODE IS NULL
		]]>
	</query>
	
	<query id="CoreFrmProPSCMSC2.queryMaxMscAlphaCode" desc="查询最大的Alpha冶金规范编码(规则：引用冶金规范码后加-开头的2位流水号)">
		<![CDATA[
			 SELECT ? || '-' || LPAD(SUBSTR(NVL(MAX(A.MSC), ? || '-00'), 15, 2) + 1, 2, '0') 
				FROM COM_MSC A WHERE A.MSC_SEQ = ? AND A.USE_CODE IS NOT NULL
		]]>
	</query>
	
	<query id="CoreFrmProPSCMSC2.queryMaxMscAlphaCode2" desc="查询最大的Alpha冶金规范编码(备料的冶金规范)(规则：引用冶金规范码后加-开头的2位流水号)">
		<![CDATA[
			 SELECT ? || '-' || LPAD(SUBSTR(NVL(MAX(A.MSC), ? || '-00'), 12, 2) + 1, 2, '0') 
				FROM COM_MSC A WHERE A.MSC_SEQ = ? AND A.USE_CODE IS NOT NULL
		]]>
	</query>
	
	<query id="CoreFrmProPSCMSC2.queryServerDate" desc="查询服务器时间">
		<![CDATA[
			 SELECT TO_CHAR(SYSDATE, 'YYYYMMDD') FROM DUAL T
		]]>
	</query>
	
	<query id="CoreFrmProPSCMSC2.insertCom_Psc_R_Msc" desc="新增产品规范与冶金规范关系">
		<![CDATA[
			 INSERT INTO COM_PSC_R_MSC(
			        PSC,
			        PSC_DESC,
			        USE_CODE,
			        USE_DESC,
			        MSC,
			        MSC_DESC,
			        CREATE_NAME,
			        CREATE_TIME,
			        VALIDFLAG)
			 VALUES( 
			        ?,
			        ?,
			        ?,
			        ?,
			        ?,
			        ?,
			        ?,
			        SYSDATE,
			        '1')
		]]>
	</query>
	
	<query id="CoreFrmProPSCMSC2.isExistAlpha" desc="冶金规范中是否存在Alpha">
		<![CDATA[
			 SELECT COUNT(1) FROM com_psc_r_msc T, COM_MSC A WHERE
			  T.PSC = ? AND A.USE_CODE = ? AND T.MSC = A.MSC
		]]>
	</query>
	
	<query id="CoreFrmProPSCMSC2.queryProductType" desc="查询品名类型">
		<![CDATA[
			 SELECT PRODUC_TYPE
			  FROM COM_BASE_PRODUCT T
			 WHERE T.PRODUCCODE = ?
		]]>
	</query>
	
	<query id="CoreFrmProPSCMSC.insertMsc" desc="新增冶金规范">
		<![CDATA[
				DECLARE 
				P_MSC COM_MSC.MSC%TYPE := ?;
				P_MSC_DESC COM_MSC.MSC_DESC%TYPE := ?;
				P_USE_CODE COM_MSC.USE_CODE%TYPE := ?;
				P_USE_DESC COM_MSC.USE_DESC%TYPE := ?;
				P_DEPARTMENT_CODE COM_MSC.DEPARTMENT_CODE%TYPE := ?;
				P_DEPARTMENT_DESC COM_MSC.DEPARTMENT_DESC%TYPE := ?;
				P_UNIT_CODE COM_MSC.UNIT_CODE%TYPE := ?;
				P_UNIT_DESC COM_MSC.UNIT_DESC%TYPE := ?;
				P_UNIT_CODE_PROCESS COM_MSC.UNIT_CODE_PROCESS%TYPE := ?;
				P_UNIT_DESC_PROCESS COM_MSC.UNIT_DESC_PROCESS%TYPE := ?;
				P_MSC_STYLE COM_MSC.MSC_STYLE%TYPE := ?;
				P_USER_COUNT COM_MSC.USER_COUNT%TYPE := ?;
				P_ALLOW_NK COM_MSC.ALLOW_NK%TYPE := ?;
				P_MSC_SEQ COM_MSC.MSC_SEQ%TYPE := ?;
				P_MSC_DESC_SEQ COM_MSC.MSC_DESC_SEQ%TYPE := ?;
				P_CREATE_NAME COM_MSC.CREATE_NAME%TYPE := ?;
				P_MEMO COM_MSC.MEMO%TYPE := ?;
				P_PRODUC_HEAD COM_MSC.PRODUC_HEAD%TYPE := ?;
				P_JUDGEFLAG COM_MSC.JUDGEFLAG%TYPE := ?;
				P_PRODUCCODE COM_MSC.PRODUCCODE%TYPE := ?;
				P_PRODUCNAME COM_MSC.PRODUCNAME%TYPE := ?;
				P_STD_CODE COM_MSC.STD_CODE%TYPE := ?;
				P_STD_NAME COM_MSC.STD_NAME%TYPE := ?;
				P_STEELCODE COM_MSC.STEELCODE%TYPE := ?;
				P_STEELNAME COM_MSC.STEELNAME%TYPE := ?;
				P_STD_STYLE COM_MSC.STD_STYLE%TYPE := ?;
				P_STD_STYLE_DESC COM_MSC.STD_STYLE_DESC%TYPE := ?;
				P_NEW_PROC_CODE COM_MSC.NEW_PROC_CODE%TYPE := ?;
				P_NEW_PROC_DESC COM_MSC.NEW_PROC_DESC%TYPE := ?;
				P_PSC COM_PSC_R_MSC.PSC%TYPE := ?;
				P_PSC_DESC COM_PSC_R_MSC.PSC_DESC%TYPE := ?;
				
				
				BEGIN
				INSERT INTO COM_MSC
				  (MSC,
				   MSC_DESC,
				   USE_CODE,
				   USE_DESC,
				   DEPARTMENT_CODE,
				   DEPARTMENT_DESC,
				   UNIT_CODE,
				   UNIT_DESC,
				   UNIT_CODE_PROCESS,
				   UNIT_DESC_PROCESS,
				   MSC_STYLE,
				   USER_COUNT,
				   ALLOW_NK,
				   MSC_SEQ,
				   MSC_DESC_SEQ,
				   CREATE_NAME,
				   MEMO,
				   PRODUC_HEAD,
				   PRODUCCODE,
				   PRODUCNAME,
				   STD_CODE,
				   STD_NAME,
				   STEELCODE,
				   STEELNAME,
				   STD_STYLE,
				   STD_STYLE_DESC,
				   NEW_PROC_CODE,
				   NEW_PROC_DESC,
				   JUDGEFLAG,
				   VALIDFLAG,
				   CREATE_TIME)
				VALUES
				  (P_MSC,
				   P_MSC_DESC,
				   P_USE_CODE,
				   P_USE_DESC,
				   P_DEPARTMENT_CODE,
				   P_DEPARTMENT_DESC,
				   P_UNIT_CODE,
				   P_UNIT_DESC,
				   P_UNIT_CODE_PROCESS,
				   P_UNIT_DESC_PROCESS,
				   P_MSC_STYLE,
				   P_USER_COUNT,
				   P_ALLOW_NK,
				   NVL(P_MSC_SEQ, ''),
				   P_MSC_DESC_SEQ,
				   P_CREATE_NAME,
				   P_MEMO,
				   P_PRODUC_HEAD,
				   P_PRODUCCODE,
				   P_PRODUCNAME,
				   P_STD_CODE,
				   P_STD_NAME,
				   P_STEELCODE,
				   P_STEELNAME,
				   P_STD_STYLE,
				   P_STD_STYLE_DESC,
				   P_NEW_PROC_CODE,
				   P_NEW_PROC_DESC,
				   P_JUDGEFLAG,
				   'A',
				   SYSDATE);
				   
				 INSERT INTO COM_PSC_R_MSC(
			        PSC,
			        PSC_DESC,
			        USE_CODE,
			        USE_DESC,
			        MSC,
			        MSC_DESC,
			        CREATE_NAME,
			        CREATE_TIME,
			        VALIDFLAG)
				 VALUES( 
				        P_PSC,
				        P_PSC_DESC,
				        P_USE_CODE,
				        P_USE_DESC,
				        P_MSC,
				        P_MSC_DESC,
				        P_CREATE_NAME,
				        SYSDATE,
				        '1');
				END;
		 ]]>
	</query> 
	
	<query id="CoreFrmProPSCMSC.copyMscData" desc="复制冶金规范数据到对其引用的带Alpha项的冶金规范中">
		<![CDATA[
			DECLARE
			P_COUNT NUMBER(5) := 0;
			P_MSC COM_MSC.MSC%TYPE := ?;
			P_MSC_SEQ COM_MSC.MSC%TYPE := ?;
			P_OLD_MSC_SEQ COM_MSC.MSC%TYPE := ?;
			P_NAME VARCHAR2(50) := ?;
			P_MAX_INDEX_SEQ COM_MSC_ITEM.INDEX_SEQ%TYPE;
			P_MAX_MSC_PLINE COM_MSC_BACKLOG.MSC_PLINE%TYPE;
			P_MAX_BACKLOG_SEQ COM_MSC_PROCESS.BACKLOG_SEQ%TYPE;
			
			BEGIN
			IF P_MSC_SEQ = ' ' THEN
				GOTO OVER;
			END IF;
			
			SELECT COUNT(1) INTO P_COUNT FROM COM_MSC_ITEM WHERE MSC = P_MSC;
			IF P_COUNT = 0  THEN
			   SELECT NVL(MAX(INDEX_SEQ), '0') INTO P_MAX_INDEX_SEQ 
			          FROM COM_MSC_ITEM WHERE MSC = P_MSC;
			   FOR VROW IN (SELECT T.BASECODE FROM COM_BASE_INFO T WHERE T.SORTCODE = '4030' AND T.VALIDFLAG = '1') LOOP
			      P_MAX_INDEX_SEQ := P_MAX_INDEX_SEQ + 1;
			      INSERT INTO COM_MSC_ITEM T
							  (T.MSC,
							   T.INDEX_SEQ,
							   T.ITEM,
							   T.ITEM_C,
							   T.CREATE_NAME,
							   T.CREATE_TIME,
							   T.VALIDFLAG)
			           VALUES(P_MSC, P_MAX_INDEX_SEQ, VROW.BASECODE, 
			           	(SELECT T.BASECODE FROM COM_BASE_INFO T WHERE T.SORTCODE = VROW.BASECODE AND T.BASENAME = '国家标准' AND T.VALIDFLAG = '1'), P_NAME,
			                  SYSDATE, 1);
			   END LOOP;
			   
			   FOR VROW IN (SELECT VALIDFLAG, MEMO, ITEM, ITEM_C FROM COM_MSC_ITEM WHERE MSC = P_MSC_SEQ) LOOP
			      UPDATE COM_MSC_ITEM T SET T.VALIDFLAG = VROW.VALIDFLAG, T.MEMO = VROW.MEMO
			       	   WHERE T.MSC = P_MSC_SEQ AND T.ITEM = VROW.ITEM AND T.ITEM_C = VROW.ITEM_C;
			   END LOOP;
			ELSIF P_OLD_MSC_SEQ <> P_MSC_SEQ THEN
			   FOR VROW IN (SELECT VALIDFLAG, MEMO, ITEM, ITEM_C FROM COM_MSC_ITEM WHERE MSC = P_MSC_SEQ) LOOP
			      UPDATE COM_MSC_ITEM T SET T.VALIDFLAG = VROW.VALIDFLAG, T.MEMO = VROW.MEMO
			       	   WHERE T.MSC = P_MSC AND T.ITEM = VROW.ITEM AND T.ITEM_C = VROW.ITEM_C;
			   END LOOP;
			END IF;
			
			
			IF P_OLD_MSC_SEQ <> P_MSC_SEQ THEN
			   SELECT NVL(MAX(MSC_PLINE), '0') INTO P_MAX_MSC_PLINE 
			          FROM COM_MSC_BACKLOG WHERE MSC = P_MSC;
			   FOR VROW IN (SELECT * FROM COM_MSC_BACKLOG WHERE MSC = P_MSC_SEQ) LOOP
			       P_MAX_MSC_PLINE := P_MAX_MSC_PLINE + 1;
			       INSERT INTO COM_MSC_BACKLOG T
			          (T.MSC,
			           T.MSC_PLINE,
			           T.WHOLE_BACKLOG,
			           T.WHOLE_BACKLOG_DESC,
			           T.CREATE_NAME,
			           T.CREATE_TIME,
			           T.VALIDFLAG,
			           T.MEMO)
			           VALUES(P_MSC, REPLACE(LPAD(P_MAX_MSC_PLINE, 6), ' ', '0'), VROW.WHOLE_BACKLOG, VROW.WHOLE_BACKLOG_DESC,
			                  P_NAME, SYSDATE, VROW.VALIDFLAG, VROW.MEMO);
			   END LOOP;
			END IF;
			
			
			IF P_OLD_MSC_SEQ <> P_MSC_SEQ THEN
			   FOR VROW IN (SELECT * FROM COM_MSC_PROCESS WHERE MSC = P_MSC_SEQ) LOOP
			       SELECT COUNT(1) INTO P_COUNT FROM COM_MSC_PROCESS A WHERE A.MSC = P_MSC AND A.MSC_PLINE = VROW.MSC_PLINE
			              AND A.PROCESS_CODE = VROW.PROCESS_CODE
			              AND A.PROCESS_SEQ = VROW.PROCESS_SEQ;
			       SELECT NVL(MAX(BACKLOG_SEQ) + 1, '1') INTO P_MAX_BACKLOG_SEQ FROM COM_MSC_PROCESS 
			       		WHERE MSC = P_MSC AND MSC_PLINE = VROW.MSC_PLINE;
			       IF P_COUNT = 0 THEN
			          INSERT INTO COM_MSC_PROCESS A
			          (A.INDEX_SEQ,
			           A.MSC,
			           A.MSC_PLINE,
			           A.BACKLOG_SEQ,
			           A.PROCESS_CODE,
			           A.PROCESS_DESC,
			           A.MINUTE_PRODUCT,
			           A.MINUTE_WAITE,
			           A.CREATE_NAME,
			           A.CREATE_TIME,
			           A.VALIDFLAG,
			           A.MEMO,
			           A.PROCESS_SEQ)
			           VALUES(VROW.INDEX_SEQ, P_MSC, VROW.MSC_PLINE, P_MAX_BACKLOG_SEQ, VROW.PROCESS_CODE, VROW.PROCESS_DESC,
			                  VROW.MINUTE_PRODUCT, VROW.MINUTE_WAITE, P_NAME, SYSDATE, VROW.VALIDFLAG,
			                  VROW.MEMO, VROW.PROCESS_SEQ);
			       ELSE
			          UPDATE COM_MSC_PROCESS A SET A.INDEX_SEQ = VROW.INDEX_SEQ, A.MINUTE_PRODUCT = VROW.MINUTE_PRODUCT, 
			                 A.MINUTE_WAITE = VROW.MINUTE_WAITE, A.UPDATE_NAME = P_NAME, A.UPDATE_TIME = SYSDATE,
			                 A.VALIDFLAG = VROW.VALIDFLAG, A.MEMO = VROW.MEMO;
			       END IF;
			   END LOOP;
			END IF;
			
			
			IF P_OLD_MSC_SEQ <> P_MSC_SEQ THEN
			   FOR VROW IN (SELECT * FROM COM_MSC_STATION WHERE MSC = P_MSC_SEQ) LOOP
			       SELECT COUNT(1) INTO P_COUNT FROM COM_MSC_STATION A WHERE A.MSC = P_MSC AND A.MSC_PLINE = VROW.MSC_PLINE
			             AND A.PROCESS_SEQ = VROW.PROCESS_SEQ AND A.PROCESS_CODE = VROW.PROCESS_CODE
			             AND A.STATION_CODE = VROW.STATION_CODE;
			       SELECT NVL(MAX(BACKLOG_SEQ) + 1, '1') INTO P_MAX_BACKLOG_SEQ FROM COM_MSC_STATION 
			       		WHERE MSC = P_MSC AND MSC_PLINE = VROW.MSC_PLINE AND PROCESS_CODE = VROW.PROCESS_CODE;
			       IF P_COUNT = 0 THEN
			          INSERT INTO COM_MSC_STATION A
			          (A.INDEX_SEQ,
			           A.MSC,
			           A.MSC_PLINE,
			           A.BACKLOG_SEQ,
			           A.PROCESS_CODE,
			           A.PROCESS_DESC,
			           A.STATION_CODE,
			           A.STATION_DESC,
			           A.STATION_TYPE,
			           A.STATION_ID,
			           A.COST,
			           A.CHOOSE,
			           A.RETURN_RESULT,
			           A.SEND_CHECKPLAN,
			           A.GROUP_SEQ,
			           A.CREATE_NAME,
			           A.CREATE_TIME,
			           A.VALIDFLAG,
			           A.MEMO,
			           A.PROCESS_SEQ)
			           VALUES(VROW.INDEX_SEQ, P_MSC, VROW.MSC_PLINE, P_MAX_BACKLOG_SEQ, VROW.PROCESS_CODE, VROW.PROCESS_DESC,
			                  VROW.STATION_CODE, VROW.STATION_DESC, VROW.STATION_TYPE, VROW.STATION_ID, VROW.COST, VROW.CHOOSE,
			                  VROW.RETURN_RESULT, VROW.SEND_CHECKPLAN, VROW.GROUP_SEQ, P_NAME, SYSDATE, VROW.VALIDFLAG,
			                  VROW.MEMO, VROW.PROCESS_SEQ);
			       ELSE
			           UPDATE COM_MSC_STATION A SET A.INDEX_SEQ = VROW.INDEX_SEQ, A.PROCESS_CODE = VROW.PROCESS_CODE,
			                  A.PROCESS_DESC = VROW.PROCESS_DESC, A.STATION_TYPE = VROW.STATION_TYPE, A.STATION_ID = VROW.STATION_ID,
			                  A.COST = VROW.COST, A.CHOOSE = VROW.CHOOSE, A.RETURN_RESULT = VROW.RETURN_RESULT, 
			                  A.SEND_CHECKPLAN = VROW.SEND_CHECKPLAN, A.GROUP_SEQ = VROW.GROUP_SEQ, A.UPDATE_NAME = P_NAME,
			                  A.UPDATE_TIME = SYSDATE, A.VALIDFLAG = VROW.VALIDFLAG, A.MEMO = VROW.MEMO
			           WHERE A.MSC = P_MSC AND A.MSC_PLINE = VROW.MSC_PLINE
			             AND A.PROCESS_SEQ = VROW.PROCESS_SEQ AND A.PROCESS_CODE = VROW.PROCESS_CODE
			             AND A.STATION_CODE = VROW.STATION_CODE;
			       END IF;
			   END LOOP;
			END IF;
			<<OVER>> P_COUNT := 0;
			END;
		 ]]>
	</query> 
	
	<query id="CoreFrmProPSCMSC.updateMsc" desc="更新冶金规范">
		<![CDATA[
				 DECLARE
				P_MSC_DESC COM_MSC.MSC_DESC%TYPE := ?;
				P_USE_CODE COM_MSC.USE_CODE%TYPE := ?;
				P_USE_DESC COM_MSC.USE_DESC%TYPE := ?;
				P_DEPARTMENT_CODE COM_MSC.DEPARTMENT_CODE%TYPE := ?;
				P_DEPARTMENT_DESC COM_MSC.DEPARTMENT_DESC%TYPE := ?;
				P_UNIT_CODE COM_MSC.UNIT_CODE%TYPE := ?;
				P_UNIT_DESC COM_MSC.UNIT_DESC%TYPE := ?;
				P_UNIT_CODE_PROCESS COM_MSC.UNIT_CODE_PROCESS%TYPE := ?;
				P_UNIT_DESC_PROCESS COM_MSC.UNIT_DESC_PROCESS%TYPE := ?;
				P_MSC_STYLE COM_MSC.MSC_STYLE%TYPE := ?;
				P_USER_COUNT COM_MSC.USER_COUNT%TYPE := ?;
				P_ALLOW_NK COM_MSC.ALLOW_NK%TYPE := ?;
				P_MSC_SEQ COM_MSC.MSC_SEQ%TYPE := ?;
				P_MSC_DESC_SEQ COM_MSC.MSC_DESC_SEQ%TYPE := ?;
				P_UPDATE_NAME COM_MSC.UPDATE_NAME%TYPE := ?;
				P_MEMO COM_MSC.MEMO%TYPE := ?;
				P_PRODUC_HEAD COM_MSC.PRODUC_HEAD%TYPE := ?;
				P_JUDGEFLAG COM_MSC.JUDGEFLAG%TYPE := ?;
				P_PRODUCCODE COM_MSC.PRODUCCODE%TYPE := ?;
				P_PRODUCNAME COM_MSC.PRODUCNAME%TYPE := ?;
				P_STD_CODE COM_MSC.STD_CODE%TYPE := ?;
				P_STD_NAME COM_MSC.STD_NAME%TYPE := ?;
				P_STEELCODE COM_MSC.STEELCODE%TYPE := ?;
				P_STEELNAME COM_MSC.STEELNAME%TYPE := ?;
				P_STD_STYLE COM_MSC.STD_STYLE%TYPE := ?;
				P_STD_STYLE_DESC COM_MSC.STD_STYLE_DESC%TYPE := ?;
				P_NEW_PROC_CODE COM_MSC.NEW_PROC_CODE%TYPE := ?;
				P_NEW_PROC_DESC COM_MSC.NEW_PROC_DESC%TYPE := ?;
				P_MSC COM_MSC.MSC%TYPE := ?;
				
				BEGIN
				
				UPDATE COM_MSC
								   SET 
								        MSC_DESC = P_MSC_DESC,
								        USE_CODE = P_USE_CODE,
								        USE_DESC = P_USE_DESC,
								        DEPARTMENT_CODE = P_DEPARTMENT_CODE,
								        DEPARTMENT_DESC = P_DEPARTMENT_DESC,
								        UNIT_CODE = P_UNIT_CODE,
								        UNIT_DESC = P_UNIT_DESC,
								        UNIT_CODE_PROCESS = P_UNIT_CODE_PROCESS,
								        UNIT_DESC_PROCESS = P_UNIT_DESC_PROCESS,
								        MSC_STYLE = P_MSC_STYLE,
								        USER_COUNT = P_USER_COUNT,
								        ALLOW_NK = P_ALLOW_NK,
								        MSC_SEQ = P_MSC_SEQ,
								        MSC_DESC_SEQ = P_MSC_DESC_SEQ,
								        UPDATE_NAME = P_UPDATE_NAME,
								        UPDATE_TIME = SYSDATE,
								        MEMO = P_MEMO,
								        PRODUC_HEAD = P_PRODUC_HEAD,
								        JUDGEFLAG = P_JUDGEFLAG,
								        PRODUCCODE = P_PRODUCCODE,
								        PRODUCNAME = P_PRODUCNAME,
								        STD_CODE = P_STD_CODE,
								        STD_NAME = P_STD_NAME,
								        STEELCODE = P_STEELCODE,
								        STEELNAME = P_STEELNAME,
								        STD_STYLE = P_STD_STYLE,
								        STD_STYLE_DESC = P_STD_STYLE_DESC,
								        NEW_PROC_CODE = P_NEW_PROC_CODE,
								        NEW_PROC_DESC = P_NEW_PROC_DESC
								 WHERE
								 MSC = P_MSC;
					UPDATE COM_PSC_R_MSC T SET T.USE_CODE = P_USE_CODE, T.USE_DESC = P_USE_DESC
					WHERE T.MSC = P_MSC;
				END;
		 ]]>
	</query> 
	
	<query id="CoreFrmProPSCMSC.deleteOrResumeMsc" desc="作废或者恢复冶金规范">
		<![CDATA[
DECLARE
  P_VALIDFLAG   COM_MSC.VALIDFLAG%TYPE := '#VALIDFLAG#';
  P_MSC         COM_MSC.MSC%TYPE := '#MSC#';
  P_NAME        COM_MSC.DELETE_NAME%TYPE := '#NAME#';
  P_ACTION_TYPE VARCHAR2(20) := '#ACTION_TYPE#';

BEGIN

  IF P_ACTION_TYPE <> 'Audit' THEN
    IF P_ACTION_TYPE = 'Delete' THEN
      UPDATE COM_MSC
         SET VALIDFLAG    = P_VALIDFLAG,
             DELETE_NAME  = P_NAME,
             DELETE_TIME  = SYSDATE,
             VALIDFLAG_NK = P_VALIDFLAG
       WHERE MSC = P_MSC;
      UPDATE COM_PSC_R_MSC T
         SET T.VALIDFLAG   = '0'
       WHERE T.MSC = '#MSC#';
      UPDATE COM_MSC_STD_CIC T
         SET T.VALIDFLAG   = '#VALIDFLAG2#'
       WHERE T.MSC = '#MSC#'
         AND T.VALIDFLAG <> '0';
      UPDATE COM_MSC_STD_PIC T
         SET T.VALIDFLAG   = '#VALIDFLAG2#'
       WHERE T.MSC = '#MSC#'
         AND T.VALIDFLAG <> '0';
      UPDATE COM_MSC_STD_DETECTION T
         SET T.VALIDFLAG   = '#VALIDFLAG2#'
       WHERE T.MSC = '#MSC#'
         AND T.VALIDFLAG <> '0';
      UPDATE COM_MSC_STD_SPEC T
         SET T.VALIDFLAG   = '#VALIDFLAG2#'
       WHERE T.MSC = '#MSC#'
         AND T.VALIDFLAG <> '0';
      UPDATE COM_MSC_STD_WATER T
         SET T.VALIDFLAG   = '#VALIDFLAG2#'
       WHERE T.MSC = '#MSC#'
         AND T.VALIDFLAG <> '0';
      UPDATE COM_MSC_STD_PROCESS T
         SET T.VALIDFLAG   = '#VALIDFLAG2#'
       WHERE T.MSC = '#MSC#'
         AND T.VALIDFLAG <> '0';
      UPDATE COM_MSC_BACKLOG T
         SET T.VALIDFLAG    = '#VALIDFLAG2#',
             T.VALIDFLAG_NK = '#VALIDFLAG2#'
       WHERE T.MSC = '#MSC#'
         AND T.VALIDFLAG <> '0';
      UPDATE COM_MSC_STD_CHEM T
         SET T.VALIDFLAG   = '0'
       WHERE T.CIC IN
             (SELECT A.CIC FROM COM_MSC_STD_CIC A WHERE A.MSC = '#MSC#');
      UPDATE COM_MSC_STD_PHY T
         SET T.VALIDFLAG   = '0'
       WHERE T.PIC IN
             (SELECT A.PIC FROM COM_MSC_STD_PIC A WHERE A.MSC = '#MSC#');
      UPDATE COM_MSC_STD_DETECTION_C T
         SET T.VALIDFLAG   = '0'
       WHERE T.DIC IN (SELECT A.DIC
                         FROM COM_MSC_STD_DETECTION A
                        WHERE A.MSC = '#MSC#');
      UPDATE COM_MSC_STD_SPEC_C T
         SET T.VALIDFLAG   = '0'
       WHERE T.SIC IN
             (SELECT A.SIC FROM COM_MSC_STD_SPEC A WHERE A.MSC = '#MSC#');
      UPDATE Com_Msc_Std_Water_C T
         SET T.VALIDFLAG   = '0'
       WHERE T.WIC IN
             (SELECT A.WIC FROM Com_Msc_Std_Water A WHERE A.MSC = '#MSC#');
      UPDATE Com_Msc_Std_Process_c T
         SET T.VALIDFLAG   = '0'
       WHERE T.GIC IN
             (SELECT A.GIC FROM Com_Msc_Std_Process A WHERE A.MSC = '#MSC#');
      UPDATE Com_Msc_Process T
         SET T.VALIDFLAG   = '0'
       WHERE T.MSC = '#MSC#';
      UPDATE Com_Msc_Station T
         SET T.VALIDFLAG   = '0'
       WHERE T.MSC = '#MSC#';
      UPDATE Com_Msc_Grade T
         SET T.VALIDFLAG   = '0'
       WHERE T.MSC = '#MSC#';
      UPDATE Com_Msc_Grade_r_Spec T
         SET T.VALIDFLAG   = '0'
       WHERE T.MSC = '#MSC#';
      UPDATE COM_MSC_R_JG T
         SET T.VALIDFLAG   = '0'
       WHERE T.MSC = '#MSC#';
      UPDATE COM_MSC_STD_CRAFT T
         SET T.VALIDFLAG   = '0'
       WHERE T.MSC = '#MSC#';
    ELSIF P_ACTION_TYPE = 'SubMitModify' THEN
      UPDATE COM_MSC
         SET VALIDFLAG   = P_VALIDFLAG,
             UPDATE_NAME = P_NAME,
             UPDATE_TIME = SYSDATE
       WHERE MSC = P_MSC;
    ELSIF P_ACTION_TYPE = 'Resume' THEN
      UPDATE COM_MSC
         SET VALIDFLAG    = P_VALIDFLAG,
             UPDATE_NAME  = P_NAME,
             UPDATE_TIME  = SYSDATE,
             VALIDFLAG_NK = P_VALIDFLAG
       WHERE MSC = P_MSC;
      UPDATE COM_PSC_R_MSC T
         SET T.VALIDFLAG   = '1'
       WHERE T.MSC = '#MSC#';
      UPDATE COM_MSC_STD_CIC T
         SET T.VALIDFLAG   = '#VALIDFLAG2#'
       WHERE T.MSC = '#MSC#';
      UPDATE COM_MSC_STD_PIC T
         SET T.VALIDFLAG   = '#VALIDFLAG2#'
       WHERE T.MSC = '#MSC#';
      UPDATE COM_MSC_STD_DETECTION T
         SET T.VALIDFLAG   = '#VALIDFLAG2#'
       WHERE T.MSC = '#MSC#';
      UPDATE COM_MSC_STD_SPEC T
         SET T.VALIDFLAG   = '#VALIDFLAG2#'
       WHERE T.MSC = '#MSC#';
      UPDATE COM_MSC_STD_WATER T
         SET T.VALIDFLAG   = '#VALIDFLAG2#'
       WHERE T.MSC = '#MSC#';
      UPDATE COM_MSC_STD_PROCESS T
         SET T.VALIDFLAG   = '#VALIDFLAG2#'
       WHERE T.MSC = '#MSC#';
      UPDATE COM_MSC_BACKLOG T
         SET T.VALIDFLAG    = '#VALIDFLAG2#',
             T.VALIDFLAG_NK = '#VALIDFLAG2#'
       WHERE T.MSC = '#MSC#';
      UPDATE COM_MSC_STD_CHEM T
         SET T.VALIDFLAG   = '1'
       WHERE T.CIC IN
             (SELECT A.CIC FROM COM_MSC_STD_CIC A WHERE A.MSC = '#MSC#');
      UPDATE COM_MSC_STD_PHY T
         SET T.VALIDFLAG   = '1'
       WHERE T.PIC IN
             (SELECT A.PIC FROM COM_MSC_STD_PIC A WHERE A.MSC = '#MSC#');
      UPDATE COM_MSC_STD_DETECTION_C T
         SET T.VALIDFLAG   = '1'
       WHERE T.DIC IN (SELECT A.DIC
                         FROM COM_MSC_STD_DETECTION A
                        WHERE A.MSC = '#MSC#');
      UPDATE COM_MSC_STD_SPEC_C T
         SET T.VALIDFLAG   = '1'
       WHERE T.SIC IN
             (SELECT A.SIC FROM COM_MSC_STD_SPEC A WHERE A.MSC = '#MSC#');
      UPDATE Com_Msc_Std_Water_C T
         SET T.VALIDFLAG   = '1'
       WHERE T.WIC IN
             (SELECT A.WIC FROM Com_Msc_Std_Water A WHERE A.MSC = '#MSC#');
      UPDATE Com_Msc_Std_Process_c T
         SET T.VALIDFLAG   = '1'
       WHERE T.GIC IN
             (SELECT A.GIC FROM Com_Msc_Std_Process A WHERE A.MSC = '#MSC#');
      UPDATE Com_Msc_Process T
         SET T.VALIDFLAG   = '1'
       WHERE T.MSC = '#MSC#';
      UPDATE Com_Msc_Station T
         SET T.VALIDFLAG   = '1'
       WHERE T.MSC = '#MSC#';
      UPDATE Com_Msc_Grade T
         SET T.VALIDFLAG   = '1'
       WHERE T.MSC = '#MSC#';
      UPDATE Com_Msc_Grade_r_Spec T
         SET T.VALIDFLAG   = '1'
       WHERE T.MSC = '#MSC#';
      UPDATE COM_MSC_R_JG T
         SET T.VALIDFLAG   = '1'
       WHERE T.MSC = '#MSC#';
      UPDATE COM_MSC_STD_CRAFT T
         SET T.VALIDFLAG   = '1'
       WHERE T.MSC = '#MSC#';
    ELSE
      UPDATE COM_MSC
         SET VALIDFLAG   = P_VALIDFLAG,
             UPDATE_NAME = P_NAME,
             UPDATE_TIME = SYSDATE,
             DELETE_NAME = '',
             DELETE_TIME = ''
       WHERE MSC = P_MSC;
      UPDATE COM_MSC_STD_CIC T
         SET T.VALIDFLAG   = '#VALIDFLAG2#'
       WHERE T.MSC = '#MSC#'
         AND T.VALIDFLAG <> '0';
      UPDATE COM_MSC_STD_PIC T
         SET T.VALIDFLAG   = '#VALIDFLAG2#'
       WHERE T.MSC = '#MSC#'
         AND T.VALIDFLAG <> '0';
      UPDATE COM_MSC_STD_DETECTION T
         SET T.VALIDFLAG   = '#VALIDFLAG2#'
       WHERE T.MSC = '#MSC#'
         AND T.VALIDFLAG <> '0';
      UPDATE COM_MSC_STD_SPEC T
         SET T.VALIDFLAG   = '#VALIDFLAG2#'
       WHERE T.MSC = '#MSC#'
         AND T.VALIDFLAG <> '0';
      UPDATE COM_MSC_STD_WATER T
         SET T.VALIDFLAG   = '#VALIDFLAG2#'
       WHERE T.MSC = '#MSC#'
         AND T.VALIDFLAG <> '0';
      UPDATE COM_MSC_STD_PROCESS T
         SET T.VALIDFLAG   = '#VALIDFLAG2#'
       WHERE T.MSC = '#MSC#'
         AND T.VALIDFLAG <> '0';
      UPDATE COM_MSC_BACKLOG T
         SET T.VALIDFLAG   = '#VALIDFLAG2#'
       WHERE T.MSC = '#MSC#'
         AND T.VALIDFLAG <> '0';
    END IF;
  ELSE
    UPDATE COM_MSC
       SET VALIDFLAG  = P_VALIDFLAG,
           AUDIT_NAME = P_NAME,
           AUDIT_TIME = SYSDATE
     WHERE MSC = P_MSC;
    UPDATE COM_MSC_STD_CIC T
       SET T.VALIDFLAG   = '#VALIDFLAG2#'
     WHERE T.MSC = '#MSC#'
       AND T.VALIDFLAG <> '0';
    UPDATE COM_MSC_STD_PIC T
       SET T.VALIDFLAG   = '#VALIDFLAG2#'
     WHERE T.MSC = '#MSC#'
       AND T.VALIDFLAG <> '0';
    UPDATE COM_MSC_STD_DETECTION T
       SET T.VALIDFLAG   = '#VALIDFLAG2#'
     WHERE T.MSC = '#MSC#'
       AND T.VALIDFLAG <> '0';
    UPDATE COM_MSC_STD_SPEC T
       SET T.VALIDFLAG   = '#VALIDFLAG2#'
     WHERE T.MSC = '#MSC#'
       AND T.VALIDFLAG <> '0';
    UPDATE COM_MSC_STD_WATER T
       SET T.VALIDFLAG   = '#VALIDFLAG2#'
     WHERE T.MSC = '#MSC#'
       AND T.VALIDFLAG <> '0';
    UPDATE COM_MSC_STD_PROCESS T
       SET T.VALIDFLAG   = '#VALIDFLAG2#'
     WHERE T.MSC = '#MSC#'
       AND T.VALIDFLAG <> '0';
    UPDATE COM_MSC_BACKLOG T
       SET T.VALIDFLAG   = '#VALIDFLAG2#'
     WHERE T.MSC = '#MSC#'
       AND T.VALIDFLAG <> '0';
  END IF;
END; 
		 ]]>
	</query> 
	
	<query id="CoreFrmProPSCMSC.updateMscNkFlg" desc="更新冶金规范内控状态位">
	UPDATE COM_MSC T
   SET T.VALIDFLAG_NK  = '#VALIDFLAG_NK#',
       T.AUDIT_NAME_NK = DECODE('#AUDIT_NAME_NK#', 'NoValue', T.AUDIT_NAME_NK, '#AUDIT_NAME_NK#'),
       T.AUDIT_TIME_NK    = TO_DATE(DECODE('#AUDIT_TIME_NK#', NULL, NULL, TO_CHAR(SYSDATE, 'YYYYMMDDHH24MISS')), 'YYYYMMDDHH24MISS'),
       T.REMARK_NK     = DECODE('#REMARK_NK#', 'NoValue', T.REMARK_NK, '#REMARK_NK#')
       WHERE T.MSC = '#MSC#'
	</query>
	
	<query id="CoreFrmProPSCMSC.updateBackLogNkFlg" desc="更新制程内控状态位">
	<![CDATA[
		UPDATE COM_MSC_BACKLOG T
   SET T.VALIDFLAG_NK   = '#VALIDFLAG_NK#',
       T.UPDATE_NAME = '#UPDATE_NAME#',
       T.UPDATE_TIME = SYSDATE,
       T.DELETE_NAME = '',
       T.DELETE_TIME = ''
 WHERE T.MSC = '#MSC#' AND T.VALIDFLAG_NK <> '0'
  	]]>
	</query>
	
	<query id="CoreFrmProPSCMSC.isDeleteMsc" desc="是否可以作废MSC数据">
		<![CDATA[
		 	 
SELECT *
  FROM (SELECT COUNT(1) CNT, '冶金规范项目' NAME
          FROM COM_MSC_ITEM
         WHERE MSC = 'MSC:'
           AND VALIDFLAG = '1'
        UNION ALL
        SELECT COUNT(1) CNT, '制程' NAME
          FROM COM_MSC_BACKLOG
         WHERE MSC = 'MSC:'
           AND VALIDFLAG = '1'
        UNION ALL
        SELECT COUNT(1) CNT, '成分标准' NAME
          FROM COM_MSC_STD_CIC
         WHERE MSC = 'MSC:'
           AND VALIDFLAG = '1'
        UNION ALL
        SELECT COUNT(1) CNT, '理化标准' NAME
          FROM COM_MSC_STD_PIC
         WHERE MSC = 'MSC:'
           AND VALIDFLAG = '1'
        UNION ALL
        SELECT COUNT(1) CNT, '探伤标准' NAME
          FROM COM_MSC_STD_DETECTION
         WHERE MSC = 'MSC:'
           AND VALIDFLAG = '1'
        UNION ALL
        SELECT COUNT(1) CNT, '公差标准' NAME
          FROM COM_MSC_STD_SPEC
         WHERE MSC = 'MSC:'
           AND VALIDFLAG = '1'
        UNION ALL
        SELECT COUNT(1) CNT, '水压标准' NAME
          FROM COM_MSC_STD_WATER
         WHERE MSC = 'MSC:'
           AND VALIDFLAG = '1'
        UNION ALL
        SELECT COUNT(1) CNT, '加工标准' NAME
          FROM COM_MSC_STD_PROCESS
         WHERE MSC = 'MSC:'
           AND VALIDFLAG = '1'
        UNION ALL
        SELECT COUNT(1) CNT, '接箍或者备料' NAME
          FROM COM_MSC_R_JG
         WHERE MSC = 'MSC:'
           AND VALIDFLAG = '1')
		 ]]>
	</query> 
	
	<query id="CoreFrmProPSCMSC.insertMscItem" desc="新增冶金规范项目">
		<![CDATA[
		    DECLARE
			  P_MSC         COM_MSC_ITEM.MSC%TYPE := ':MSC:';
			  P_ITEM        COM_MSC_ITEM.ITEM%TYPE := ':ITEM:';
			  P_ITEM_C      COM_MSC_ITEM.ITEM_C%TYPE := ':ITEM_C:';
			  P_CREATE_NAME COM_MSC_ITEM.CREATE_NAME%TYPE := ':CREATE_NAME:';
			  P_MEMO        COM_MSC_ITEM.MEMO%TYPE := ':MEMO:';
			  P_INDEX_SEQ   COM_MSC_ITEM.INDEX_SEQ%TYPE;
			  P_COUNT       NUMBER(3);
			BEGIN
			  SELECT NVL(MAX(INDEX_SEQ) + 1, '1')
			    INTO P_INDEX_SEQ
			    FROM COM_MSC_ITEM A
			   WHERE A.MSC = P_MSC;
			  INSERT INTO COM_MSC_ITEM T
			    (T.MSC,
			     T.INDEX_SEQ,
			     T.ITEM,
			     T.ITEM_C,
			     T.CREATE_NAME,
			     T.MEMO,
			     T.CREATE_TIME,
			     T.VALIDFLAG)
			  VALUES
			    (P_MSC,
			     P_INDEX_SEQ,
			     P_ITEM,
			     P_ITEM_C,
			     P_CREATE_NAME,
			     P_MEMO,
			     SYSDATE,
			     '1');
			END;
		 ]]>
	</query> 
	
	<query id="CoreFrmProPSCMSC.DeleteMscItem" desc="删除冶金规范项目">
		<![CDATA[
		DELETE FROM COM_MSC_ITEM WHERE MSC = ?
		 ]]>
	</query> 
	
	<query id="CoreFrmProPSCMSC.updateMscItem" desc="更新冶金规范项目">
		<![CDATA[
			UPDATE COM_MSC_ITEM T
			   SET T.ITEM        = ?,
			       T.ITEM_C      = ?,
			       T.UPDATE_NAME = ?,
			       T.UPDATE_TIME = SYSDATE,
			       T.MEMO        = ?
			 WHERE T.MSC = ? AND T.INDEX_SEQ = ?
		 ]]>
	</query> 
	
	<query id="CoreFrmProPSCMSC.deleteOrResumeMscItem" desc="作废或者恢复冶金规范项目">
		<![CDATA[
		    DECLARE
		    P_VALIDFLAG COM_MSC_ITEM.VALIDFLAG%TYPE := ?;
		    P_MSC COM_MSC_ITEM.MSC%TYPE := ?;
		    P_INDEX_SEQ COM_MSC_ITEM.INDEX_SEQ%TYPE := ?;
		    P_NAME COM_MSC_ITEM.UPDATE_NAME%TYPE := ?;
		    
		    BEGIN
		    	IF P_VALIDFLAG = 0 THEN
					UPDATE COM_MSC_ITEM T
					   SET T.VALIDFLAG = '0', DELETE_NAME = P_NAME, DELETE_TIME = SYSDATE
					 WHERE T.MSC = P_MSC AND T.INDEX_SEQ = P_INDEX_SEQ;
				ELSE
					UPDATE COM_MSC_ITEM T
					   SET T.VALIDFLAG = P_VALIDFLAG, UPDATE_NAME = P_NAME, UPDATE_TIME = SYSDATE,
					   DELETE_NAME = '', DELETE_TIME = ''
					 WHERE T.MSC = P_MSC AND T.INDEX_SEQ = P_INDEX_SEQ;
				END IF;
			END;
		 ]]>
	</query> 
	
	<query id="CoreFrmProPSCMSC.queryMscBackLog" desc="查询冶金规范产线">
		<![CDATA[
			SELECT MSC,
			       MSC_PLINE,
			       WHOLE_BACKLOG,
			       WHOLE_BACKLOG_DESC,
			       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,
			       VALIDFLAG,
			       DECODE(VALIDFLAG, '1', '录入状态', '2', '提交审核',  '3', '已审核', '0', '无效', '未识别') VALIDFLAG_NAME,
			       MEMO,
			       PROCESS_NO,
			       DECODE(CRAFT_PATH, NULL, '', '存在工艺文件') CRAFT_PATH,
			       AUTO_CRAFT,
			       '复制制程' COPY_MSC_PLINE
			  FROM COM_MSC_BACKLOG
			 WHERE MSC = ?
			 AND VALIDFLAG IN ('1', '2', '3', ?)
			 ORDER BY MSC_PLINE ASC
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC.queryMaxMscBackLogPline" desc="查询最大冶金规范产线号">
		<![CDATA[
			SELECT REPLACE(LPAD(NVL(MAX(MSC_PLINE + 1), '1'), 6), ' ', '0')
				      FROM COM_MSC_BACKLOG
				     WHERE MSC = ?
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC.insertMscBackLog" desc="新增冶金规范产线">
		<![CDATA[
			 INSERT INTO COM_MSC_BACKLOG
				  (MSC,
				   MSC_PLINE,
				   WHOLE_BACKLOG,
				   WHOLE_BACKLOG_DESC,
				   CREATE_NAME,
				   PROCESS_NO,
				   MEMO,
				   AUTO_CRAFT,
				   CREATE_TIME)
				VALUES
				  (?,
				   ?,
				   ?,
				   ?,
				   ?,
				   ?,
				   ?,
				   NVL(?, '0'),
				   SYSDATE)
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC.updateMscBackLog" desc="修改冶金规范产线">
		<![CDATA[
			 UPDATE COM_MSC_BACKLOG
		   SET WHOLE_BACKLOG = ?, WHOLE_BACKLOG_DESC = ?,
		   UPDATE_NAME = ?, UPDATE_TIME = SYSDATE, 
		   PROCESS_NO = ?,
		   MEMO = ?,
		   AUTO_CRAFT = ?
		 WHERE MSC = ?
		   AND MSC_PLINE = ?
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC.deleteOrResumeMscBackLog" desc="作废或者冶金规范产线">
		<![CDATA[
DECLARE
  P_VALIDFLAG COM_MSC_BACKLOG.VALIDFLAG%TYPE := ?;
  P_MSC       COM_MSC_BACKLOG.MSC%TYPE := ?;
  P_MSC_PLINE COM_MSC_BACKLOG.MSC_PLINE%TYPE := ?;
  P_NAME      COM_MSC_BACKLOG.UPDATE_NAME%TYPE := ?;

BEGIN
  IF P_VALIDFLAG = '1' THEN
    UPDATE COM_MSC_BACKLOG
       SET VALIDFLAG   = '1',
           UPDATE_NAME = P_NAME,
           UPDATE_TIME = SYSDATE,
           DELETE_NAME = '',
           DELETE_TIME = ''
     WHERE MSC = P_MSC
       AND MSC_PLINE = P_MSC_PLINE;
  
    UPDATE COM_MSC_PROCESS
       SET VALIDFLAG   = '1',
           UPDATE_NAME = P_NAME,
           UPDATE_TIME = SYSDATE,
           DELETE_NAME = '',
           DELETE_TIME = ''
     WHERE MSC = P_MSC
       AND MSC_PLINE = P_MSC_PLINE;
  
    UPDATE COM_MSC_STATION
       SET VALIDFLAG   = '1',
           UPDATE_NAME = P_NAME,
           UPDATE_TIME = SYSDATE,
           DELETE_NAME = '',
           DELETE_TIME = ''
     WHERE MSC = P_MSC
       AND MSC_PLINE = P_MSC_PLINE;
  
    UPDATE COM_MSC_GRADE
       SET VALIDFLAG   = '1',
           UPDATE_NAME = P_NAME,
           UPDATE_TIME = SYSDATE,
           DELETE_NAME = '',
           DELETE_TIME = ''
     WHERE MSC = P_MSC
       AND MSC_PLINE = P_MSC_PLINE;
  
    UPDATE COM_MSC_GRADE_R_SPEC
       SET VALIDFLAG   = '1',
           UPDATE_NAME = P_NAME,
           UPDATE_TIME = SYSDATE,
           DELETE_NAME = '',
           DELETE_TIME = ''
     WHERE MSC = P_MSC
       AND MSC_PLINE = P_MSC_PLINE;
  
  ELSIF P_VALIDFLAG = '0' THEN
    UPDATE COM_MSC_BACKLOG
       SET VALIDFLAG = '0', DELETE_NAME = P_NAME, DELETE_TIME = SYSDATE
     WHERE MSC = P_MSC
       AND MSC_PLINE = P_MSC_PLINE;
  
    UPDATE COM_MSC_PROCESS
       SET VALIDFLAG = '0', DELETE_NAME = P_NAME, DELETE_TIME = SYSDATE
     WHERE MSC = P_MSC
       AND MSC_PLINE = P_MSC_PLINE;
  
    UPDATE COM_MSC_STATION
       SET VALIDFLAG = '0', DELETE_NAME = P_NAME, DELETE_TIME = SYSDATE
     WHERE MSC = P_MSC
       AND MSC_PLINE = P_MSC_PLINE;
  
    UPDATE COM_MSC_GRADE
       SET VALIDFLAG = '0', DELETE_NAME = P_NAME, DELETE_TIME = SYSDATE
     WHERE MSC = P_MSC
       AND MSC_PLINE = P_MSC_PLINE;
  
    UPDATE COM_MSC_GRADE_R_SPEC
       SET VALIDFLAG = '0', DELETE_NAME = P_NAME, DELETE_TIME = SYSDATE
     WHERE MSC = P_MSC
       AND MSC_PLINE = P_MSC_PLINE;
  END IF;
END;
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC.isExistProcess" desc="制程下面是否存在工序">
		<![CDATA[
		 SELECT COUNT(1)
		  FROM COM_MSC_PROCESS T
		 WHERE T.MSC = ?
		   AND T.MSC_PLINE = ?
		   AND T.VALIDFLAG = '1'
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC.isExistGrade" desc="制程下面是否存在钢种">
		<![CDATA[
		 SELECT COUNT(1) FROM COM_MSC_GRADE T WHERE T.MSC = ? 
		 AND T.MSC_PLINE = ? AND T.VALIDFLAG = '1'
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC.queryBaseProcess" desc="查询工序基础">
		<![CDATA[
			SELECT BE.PROCESS_CODE,
			       BE.PROCESS_DESC,
			       DECODE(BE.STYLE, 'A', '一级工序', 'B', '二级工序', '未识别') STYLE,
			       BE.PROCESS_ID,
			       BE.COST,
			       BE.CREATE_NAME,
			       TO_CHAR(BE.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
			       BE.UPDATE_NAME,
			       TO_CHAR(BE.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
			       BE.DELETE_NAME,
			       TO_CHAR(BE.DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
			       BE.MINUTE_PRODUCT,
			       BE.MINUTE_WAITE,
			       BE.VALIDFLAG,
			       BE.BATCH_WAITE,
			       BE.MINUTE_PRODUCT_OUT,
			       BE.MINUTE_WAITE_OUT,
			       BE.BATCH_WAITE_OUT,
			       DECODE(BE.VALIDFLAG, '1', '有效', '0', '无效', '未识别') VALIDFLAG_NAME,
			       BE.MEMO,
			       BE.ICOUNT MAX_COUNT,
			       1 ICOUNT
			  FROM COM_BASE_PROCESS BE
			  WHERE BE.VALIDFLAG = '1'
			 ORDER BY PROCESS_ID
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC.queryBaseProcess2" desc="查询工序基础2（查询的内容不一样）">
		<![CDATA[
			SELECT BE.PROCESS_CODE,
			       BE.PROCESS_DESC,
			       BE.PROCESS_ID,
			       BE.ICOUNT MAX_COUNT
			  FROM COM_BASE_PROCESS BE
			  WHERE BE.VALIDFLAG = '1'
			 ORDER BY PROCESS_ID
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC.queryMscProcess" desc="查询工序基础">
		<![CDATA[
SELECT B.MINUTE_PRODUCT,
       B.MINUTE_WAITE,
       B.BATCH_WAITE,
       B.MINUTE_PRODUCT_OUT,
       B.MINUTE_WAITE_OUT,
       B.BATCH_WAITE_OUT,
       MS.MEMO,
       MS.MSC,
       MS.PROCESS_CODE,
       MS.BACKLOG_SEQ,
       MS.CIC,
       MS.PIC,
       MS.SIC,
       MS.DIC,
       MS.WIC,
       MS.GIC,
       NVL(MS.PROCESS_SEQ, '1') PROCESS_SEQ,
       NVL(MS.PROCESS_SEQ, '1') PROCESS_SEQ_OLD,
       MS.PROCESS_CODE_C,
       MS.PROCESS_CODE_C PROCESS_CODE_C_OLD,
       MS.PROCESS_DESC_C,
       MS.PROCESS_FILE,
       SUBSTR(MS.PROCESS_FILE, INSTR(MS.PROCESS_FILE, '/', 1, 4) + 1) PROCESS_FILE_NAME
  FROM COM_MSC_PROCESS MS
  LEFT JOIN COM_BASE_PROCESS_C B
    ON B.PROCESS_CDOE_C = MS.PROCESS_CODE_C
   AND B.VALIDFLAG = '1'
 WHERE MS.MSC = ?
   AND MS.MSC_PLINE = ?
   AND MS.VALIDFLAG = '1'
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC.queryMscProcess2" desc="查询工序基础（用于树形结构）">
		<![CDATA[
			SELECT 
			       MS.MSC,
			       MS.MSC_PLINE,
			       MS.PROCESS_CODE,
			       MS.CIC,
			       MS.PIC,
			       MS.SIC,
			       MS.DIC,
			       MS.WIC,
			       MS.GIC,
			       A.PROCESS_DESC,
			       BS.PROCESS_ID
			  FROM COM_MSC_PROCESS MS
			  LEFT JOIN COM_BASE_PROCESS BS ON MS.PROCESS_CODE = BS.PROCESS_CODE
			  LEFT JOIN COM_BASE_PROCESS A ON A.PROCESS_CODE = MS.PROCESS_CODE
			  WHERE MS.MSC = ? AND MS.VALIDFLAG = '1'
			  ORDER BY BS.PROCESS_ID ASC
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC.queryMaxMscProBkLog_seq" desc="查询最大的工序基础表seq">
			<![CDATA[
			   SELECT NVL(MAX(BACKLOG_SEQ) + 1, '1') BACKLOG_SEQ
				  FROM COM_MSC_PROCESS
				 WHERE MSC = ?
				   AND MSC_PLINE = ?
			]]>
	</query>
	
	<query id="CoreFrmProPSCMSC.insertMscProcess" desc="添加工序基础">
		<![CDATA[
		DECLARE
		P_COUNT NUMBER(5);
		P_DELETE_FLAG VARCHAR2(10) := ?;
		P_MSC COM_MSC_PROCESS.MSC%TYPE := ?;
		P_MSC_PLINE COM_MSC_PROCESS.MSC_PLINE%TYPE := ?;
		P_BACKLOG_SEQ COM_MSC_PROCESS.BACKLOG_SEQ%TYPE := ?;
		P_NAME COM_MSC_PROCESS.CREATE_NAME%TYPE := ?;
		P_PROCESS_CODE COM_MSC_PROCESS.PROCESS_CODE%TYPE := ?;
		P_PROCESS_DESC COM_MSC_PROCESS.PROCESS_DESC%TYPE := ?;
		P_MINUTE_PRODUCT COM_MSC_PROCESS.MINUTE_PRODUCT%TYPE := ?;
		P_MINUTE_WAITE COM_MSC_PROCESS.MINUTE_WAITE%TYPE := ?;
		P_BATCH_WAITE COM_MSC_PROCESS.BATCH_WAITE%TYPE := ?;
		P_MINUTE_PRODUCT_OUT COM_MSC_PROCESS.MINUTE_PRODUCT_OUT%TYPE := ?;
		P_MINUTE_WAITE_OUT COM_MSC_PROCESS.MINUTE_WAITE_OUT%TYPE := ?;
		P_BATCH_WAITE_OUT COM_MSC_PROCESS.BATCH_WAITE_OUT%TYPE := ?;
		P_COST COM_BASE_PROCESS.COST%TYPE := ?;
		P_CIC COM_MSC_PROCESS.CIC%TYPE := ?;
		P_PIC COM_MSC_PROCESS.PIC%TYPE := ?;
		P_SIC COM_MSC_PROCESS.SIC%TYPE := ?;
		P_DIC COM_MSC_PROCESS.DIC%TYPE := ?;
		P_WIC COM_MSC_PROCESS.WIC%TYPE := ?;
		P_GIC COM_MSC_PROCESS.GIC%TYPE := ?;
		P_MEMO COM_MSC_PROCESS.MEMO%TYPE := ?;
		P_PROCESS_CODE_C COM_MSC_PROCESS.PROCESS_CODE_C%TYPE := ?;
		P_PROCESS_DESC_C COM_MSC_PROCESS.PROCESS_DESC_C%TYPE := ?;
		P_PROCESS_SEQ COM_MSC_PROCESS.PROCESS_SEQ%TYPE := ?;
		P_PROCESS_FILE COM_MSC_PROCESS.PROCESS_FILE%TYPE := ?;
		
		BEGIN
		IF P_DELETE_FLAG IS NULL THEN
		   INSERT INTO COM_MSC_PROCESS
		  				  (MSC,
		  				   MSC_PLINE,
		  				   BACKLOG_SEQ,
		  				   CREATE_NAME,
		  				   PROCESS_CODE,
		  				   PROCESS_DESC,
		  				   MINUTE_PRODUCT,
		  				   MINUTE_WAITE,
		  				   BATCH_WAITE,
		  				   MINUTE_PRODUCT_OUT,
		  				   MINUTE_WAITE_OUT,
		  				   BATCH_WAITE_OUT,
		  				   CIC,
		  				   PIC,
		  				   SIC,
		  				   DIC,
		  				   WIC,
		  				   GIC,
		  				   MEMO,
		  				   PROCESS_CODE_C,
		  				   PROCESS_DESC_C,
		  				   PROCESS_SEQ,
		  				   CREATE_TIME,
		  				   PROCESS_FILE)
		  				VALUES
		  				  (P_MSC, P_MSC_PLINE, 
		  				  (SELECT NVL(MAX(BACKLOG_SEQ) + 1, '1') BACKLOG_SEQ
			    					  FROM COM_MSC_PROCESS
			    					 WHERE MSC = P_MSC
			    					   AND MSC_PLINE = P_MSC_PLINE), P_NAME, P_PROCESS_CODE, 
		            P_PROCESS_DESC, P_MINUTE_PRODUCT, P_MINUTE_WAITE, P_BATCH_WAITE,
		            P_MINUTE_PRODUCT_OUT, P_MINUTE_WAITE_OUT, P_BATCH_WAITE_OUT,
		            P_CIC, P_PIC, P_SIC, P_DIC, P_WIC,  P_GIC, P_MEMO, P_PROCESS_CODE_C, P_PROCESS_DESC_C,
		            P_PROCESS_SEQ, SYSDATE, P_PROCESS_FILE);
		END IF;
		END;
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC.deleteBaseProcess" desc="删除工序基础表">
		<![CDATA[
		 DELETE FROM COM_MSC_PROCESS WHERE MSC = ? AND MSC_PLINE = ?
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC.updateBaseProcess" desc="更新工序基础">
		<![CDATA[
			UPDATE com_base_process
				   SET COST = ?
				 WHERE process_code = ?
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC.updateMscProcess" desc="更新工序基础">
		<![CDATA[
			UPDATE com_base_process
				   SET COST = ?
				 WHERE process_code = ?
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC.queryMsc_Station" desc="查询工序点">
		<![CDATA[
			SELECT MS.MSC,
			       MS.MSC_PLINE,
			       MS.PROCESS_CODE,
			       MS.STATION_CODE,
			       MS.COST,
			       DECODE(MS.CHOOSE, '1', 'True', 'False') CHOOSE,
			       DECODE(MS.RETURN_RESULT, '1', 'True', 'False') RETURN_RESULT,
			       DECODE(MS.SEND_CHECKPLAN, '1', 'True', 'False') SEND_CHECKPLAN,
			       MS.GROUP_SEQ,
			       MS.PROCESS_SEQ,
			       MS.BACKLOG_SEQ,
			       MS.MEMO
			  FROM COM_MSC_STATION MS
              WHERE MS.MSC = ?
              AND MS.MSC_PLINE = ?
              AND MS.PROCESS_CODE = ?
              AND MS.VALIDFLAG = '1'
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC.queryMscStationTypeCount" desc="查询指定工序点类型的数目">
		<![CDATA[
			SELECT COUNT(1)
  FROM (SELECT 1
          FROM COM_MSC_STATION T
         WHERE T.MSC = ?
           AND T.MSC_PLINE = ?
           AND T.STATION_TYPE = ?
           AND T.PROCESS_CODE = ?
           AND T.VALIDFLAG = '1'
           AND T.CHOOSE = '0'
        UNION ALL
        SELECT 1
          FROM COM_BASE_STATION A
         WHERE A.STATION_TYPE = ?
           AND A.PROCESS_CODE = ?
           AND A.CHOOSE = '1'
           AND A.VALIDFLAG = '1')
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC.queryMsc_Station2" desc="查询工序点2(用于树形结构)">
		<![CDATA[
			SELECT MS.MSC,
			       MS.MSC_PLINE,
			       MS.PROCESS_CODE,
			       MS.STATION_CODE,
			       A.STATION_DESC,
			       MS.STATION_ID,
			       C.PROCESS_ID
			  FROM COM_MSC_STATION MS
			  LEFT JOIN COM_BASE_STATION A ON A.STATION_CODE = MS.STATION_CODE
			  LEFT JOIN COM_BASE_PROCESS C ON C.PROCESS_CODE = MS.PROCESS_CODE
			  AND C.VALIDFLAG = '1'
              WHERE MS.MSC = ? AND MS.VALIDFLAG = '1'
              ORDER BY C.PROCESS_ID, MS.PROCESS_SEQ, MS.STATION_ID
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC.queryBase_Station" desc="查询工序点">
		<![CDATA[
			SELECT
			       BS.STATION_CODE,
			       BS.STATION_DESC,
			       A.BASENAME STATION_TYPE,
			       A.BASECODE STATION_TYPE_CODE,
			       BS.STATION_ID,
			       BS.PROCESS_CODE,
			       BS.PROCESS_DESC,
			       B.PROCESS_CDOE_C PROCESS_CODE_C,
			       B.PROCESS_DESC_C,
			       DECODE(BS.CHOOSE, '1', 'True', 'False') CHOOSE,
			       DECODE(BS.RETURN_RESULT, '1', 'True', 'False') RETURN_RESULT,
			       DECODE(BS.SEND_CHECKPLAN, '1', 'True', 'False') SEND_CHECKPLAN,
			       BS.CREATE_NAME,
			       TO_CHAR(BS.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
			       BS.UPDATE_NAME,
			       TO_CHAR(BS.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
			       BS.DELETE_NAME,
			       TO_CHAR(BS.DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
			       BS.VALIDFLAG,
			       DECODE(BS.VALIDFLAG, '1', '有效', '0', '无效', '未识别') VALIDFLAG_NAME,
			       BS.COST
			  FROM COM_BASE_PROCESS_R_STATION B,COM_BASE_STATION BS
			  LEFT JOIN COM_BASE_INFO A ON A.BASECODE = BS.STATION_TYPE
			  WHERE BS.PROCESS_CODE = ?
			  AND B.PROCESS_CDOE_C = ?
			  AND BS.VALIDFLAG = '1'
			  AND B.STATION_CODE = BS.STATION_CODE
			  AND B.VALIDFLAG = '1'
			 ORDER BY BS.STATION_ID
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC.insertMsc_Station" desc="添加工序点">
		<![CDATA[
			DECLARE
			P_COUNT NUMBER(5);
			P_DELETE_FLAG VARCHAR2(10) := ?;
			P_MSC COM_MSC_STATION.MSC%TYPE := ?;
			P_MSC_PLINE COM_MSC_STATION.MSC_PLINE%TYPE := ?;
			P_BACKLOG_SEQ COM_MSC_STATION.BACKLOG_SEQ%TYPE := ?;
			P_PROCESS_CODE COM_MSC_STATION.PROCESS_CODE%TYPE := ?;
			P_PROCESS_DESC COM_MSC_STATION.PROCESS_DESC%TYPE := ?;
			P_STATION_CODE COM_MSC_STATION.STATION_CODE%TYPE := ?;
			P_STATION_DESC COM_MSC_STATION.STATION_DESC%TYPE := ?;
			P_STATION_TYPE COM_MSC_STATION.STATION_TYPE%TYPE := ?;
			P_STATION_ID COM_MSC_STATION.STATION_ID%TYPE := ?;
			P_COST COM_MSC_STATION.COST%TYPE := ?;
			p_CHOOSE COM_MSC_STATION.CHOOSE%TYPE := ?;
			P_RETURN_RESULT COM_MSC_STATION.RETURN_RESULT%TYPE := ?;
			P_SEND_CHECKPLAN COM_MSC_STATION.SEND_CHECKPLAN%TYPE := ?;
			P_NAME COM_MSC_STATION.CREATE_NAME%TYPE := ?;
			P_PROCESS_SEQ COM_MSC_STATION.PROCESS_SEQ%TYPE := ?;
			P_MEMO COM_MSC_STATION.MEMO%TYPE := ?;
			P_PROCESS_CODE_C COM_MSC_STATION.PROCESS_CODE_C%TYPE := ?;
			P_PROCESS_DESC_C COM_MSC_STATION.PROCESS_DESC_C%TYPE := ?;
			
			BEGIN
			IF P_DELETE_FLAG IS NULL THEN
			    INSERT INTO COM_MSC_STATION
			    				  (MSC,
			    				   MSC_PLINE,
			    				   BACKLOG_SEQ,
			    				   PROCESS_CODE,
			    				   PROCESS_DESC,
			    				   STATION_CODE,
			    				   STATION_DESC,
			    				   STATION_TYPE,
			    				   STATION_ID,
			    				   COST,
			    				   CHOOSE,
			    				   RETURN_RESULT,
			    				   SEND_CHECKPLAN,
			    				   CREATE_NAME,
			    				   PROCESS_SEQ,
			               		   MEMO,
			               		   PROCESS_CODE_C,
			               		   PROCESS_DESC_C,
			    				   CREATE_TIME)
			    				VALUES
			    				  (P_MSC, P_MSC_PLINE, 
			    				  (SELECT NVL(MAX(BACKLOG_SEQ) + 1, '1') BACKLOG_SEQ
			    					  FROM COM_MSC_STATION
			    					 WHERE MSC = P_MSC
			    					   AND MSC_PLINE = P_MSC_PLINE
			    					   AND PROCESS_CODE = P_PROCESS_CODE), 
			    				  P_PROCESS_CODE, P_PROCESS_DESC, P_STATION_CODE, P_STATION_DESC,
			              P_STATION_TYPE, P_STATION_ID, P_COST, P_CHOOSE, P_RETURN_RESULT,
			              P_SEND_CHECKPLAN, P_NAME, P_PROCESS_SEQ, P_MEMO,
			              P_PROCESS_CODE_C, P_PROCESS_DESC_C, SYSDATE);
			END IF;
			END;
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC.deleteMscStation" desc="删除工序点">
		<![CDATA[
		DELETE FROM COM_MSC_STATION T WHERE T.MSC = ? AND T.MSC_PLINE = ? AND T.PROCESS_CODE = ?
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC.copyMustStation" desc="复制工序点中的必选项数据到冶金规范工序点表">
		<![CDATA[
		DECLARE
		  P_PROCESS_CODE COM_BASE_PROCESS.PROCESS_CODE%TYPE := ?;
		  P_NAME         COM_BASE_PROCESS.CREATE_NAME%TYPE := ?;
		  P_MSC          COM_MSC_BACKLOG.MSC%TYPE := ?;
		  P_MSC_PLINE    COM_MSC_BACKLOG.MSC_PLINE%TYPE := ?;
		  P_PROCESS_CODE_C COM_MSC_PROCESS.PROCESS_CODE_C%TYPE := ?;
		  P_ICOUNT       COM_BASE_PROCESS.ICOUNT%TYPE := ?;
		  I              NUMBER(3);
		BEGIN
		  FOR VROW IN (SELECT A.*, B.PROCESS_DESC_C R_PROCESS_DESC_C
		                 FROM COM_BASE_STATION A, COM_BASE_PROCESS_R_STATION B
		                WHERE A.PROCESS_CODE = P_PROCESS_CODE
		                  AND A.VALIDFLAG = '1'
		                  AND A.CHOOSE = '1' 
		                  AND A.STATION_CODE = B.STATION_CODE
		                  AND B.VALIDFLAG = '1'
		                  AND B.PROCESS_CDOE_C = P_PROCESS_CODE_C) LOOP

		    FOR I IN 1 .. P_ICOUNT LOOP
		      INSERT INTO COM_MSC_STATION
		        (MSC,
		         MSC_PLINE,
		         BACKLOG_SEQ,
		         PROCESS_CODE,
		         PROCESS_DESC,
		         STATION_CODE,
		         STATION_DESC,
		         STATION_TYPE,
		         STATION_ID,
		         COST,
		         CHOOSE,
		         RETURN_RESULT,
		         SEND_CHECKPLAN,
		         CREATE_NAME,
		         PROCESS_SEQ,
		         PROCESS_CODE_C,
		         PROCESS_DESC_C,
		         MEMO,
		         CREATE_TIME)
		      VALUES
		        (P_MSC,
		         P_MSC_PLINE,
		         (SELECT NVL(MAX(BACKLOG_SEQ) + 1, '1') BACKLOG_SEQ
		            FROM COM_MSC_STATION
		           WHERE MSC = P_MSC
		             AND MSC_PLINE = P_MSC_PLINE
		             AND PROCESS_CODE = P_PROCESS_CODE),
		         VROW.PROCESS_CODE,
		         VROW.PROCESS_DESC,
		         VROW.STATION_CODE,
		         VROW.STATION_DESC,
		         VROW.STATION_TYPE,
		         VROW.STATION_ID,
		         VROW.COST,
		         VROW.CHOOSE,
		         VROW.RETURN_RESULT,
		         VROW.SEND_CHECKPLAN,
		         P_NAME,
		         I,
		         P_PROCESS_CODE_C,
		         VROW.R_PROCESS_DESC_C,
		         '',
		         SYSDATE);
		    END LOOP;
		  END LOOP;
		END;
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC.queryGrade" desc="查询钢种">
		<![CDATA[
			SELECT MSC,
		       MSC_PLINE,
		       GRADECODE,
		       GRADENAME,
		       ASSORTMENT_CODE,
		       ASSORTMENT_NAME,
		       CREATE_NAME,
		       CREATE_TIME,
		       UPDATE_NAME,
		       UPDATE_TIME,
		       DELETE_NAME,
		       DELETE_TIME,
		       VALIDFLAG,
		       MEMO,
		       STD_CODE,
		       STD_NAME,
		       CIC,
		       PRIORITY
		  FROM COM_MSC_GRADE
		 WHERE MSC = ?
		   AND MSC_PLINE = ?
		   AND VALIDFLAG = '1'
		 ]]>
	</query>
	
		<query id="CoreFrmProPSCMSC.queryGradeRSpec" desc="查询钢种下的规格表（从表）">
		<![CDATA[
SELECT MSC,
       MSC_PLINE,
       GRADECODE,
       GRADENAME,
       HEIGHT_MIN,
       DIMATER_MIN,
       DIMATER_MAX,
       HEIGHT_MIAX,
       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,
       VALIDFLAG,
       MEMO
  FROM COM_MSC_GRADE_R_SPEC T
 WHERE MSC = ?
   AND MSC_PLINE = ?
   AND VALIDFLAG = '1'
   AND EXISTS (SELECT 1
          FROM COM_MSC_GRADE A
         WHERE MSC = ?
           AND MSC_PLINE = ?
           AND VALIDFLAG = '1'
           AND  A.GRADECODE = T.GRADECODE)
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC.queryJG" desc="查询接箍">
		<![CDATA[
SELECT A.MSC,
       A.MSC_DESC,
       A.CODE_JG,
       A.STOCK_STYLE,
       B.PRODUCCODE,
       B.PRODUCNAME,
       B.STEELCODE_JG      STEELCODE,
       B.STEELCODE_JG_DESC STEELNAME,
       B.MIN_H_CP          MIN_H,
       B.MAX_H_CP          MAX_H,
       B.MIN_D_JG          MIN_D,
       B.MAX_D_JG          MAX_D,
       A.CREATE_NAME,
       A.CREATE_TIME,
       A.UPDATE_NAME,
       A.UPDATE_TIME,
       A.DELETE_NAME,
       A.DELETE_TIME,
       A.VALIDFLAG,
       A.MEMO,
       A.KEY_JG,
       A.CUST_ALPHA_NO,
       A.ORDER_SPECIAL_DESC,
       DET.BASENAME DEMAND_DETECTION,
       BON.BASENAME DEMAND_BONDERIZING,
       COP.BASENAME DEMAND_COPPER,
       BLA.BASENAME DEMAND_BLAST,
       A.ALPHA_CODE,
       AP.ALPHA_NAME
  FROM COM_MSC_R_JG A
  LEFT JOIN COM_MSC_JG B ON B.CODE_JG = A.CODE_JG
  LEFT JOIN COM_BASE_INFO DET ON DET.BASECODE = A.DEMAND_DETECTION
  LEFT JOIN COM_BASE_INFO BON ON BON.BASECODE = A.DEMAND_BONDERIZING
  LEFT JOIN COM_BASE_INFO COP ON COP.BASECODE = A.DEMAND_COPPER
  LEFT JOIN COM_BASE_INFO BLA ON BLA.BASECODE = A.DEMAND_BLAST
  LEFT JOIN COM_BASE_STD_ALPHA AP ON AP.ALPHA_CODE = A.ALPHA_CODE
 WHERE A.STOCK_STYLE = 'A'
   AND A.VALIDFLAG = '1'
   AND DECODE('#MSC#', NULL, '1', A.MSC) =
       DECODE('#MSC#', NULL, '1', '#MSC#')
   AND A.MSC LIKE '%' || UPPER('#MSC2#') || '%'
   AND EXISTS
 (SELECT 1
          FROM COM_MSC D
          LEFT JOIN COM_PSC_R_MSC C
            ON C.MSC = D.MSC
         WHERE A.MSC = D.MSC
           AND C.PSC = '#PSC#'
           AND D.VALIDFLAG IN ('A', 'B', 'C', 'E', '#VALIDFLAG#'))
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC.isCompleteMsc" desc="是否完整的MSC">
		<![CDATA[
SELECT DECODE(COUNT(1), 0, 0, 1) CNT, '制程' TYPE
  FROM COM_MSC_BACKLOG A
 WHERE A.MSC = '#MSC#'
   AND A.VALIDFLAG = '1'
UNION ALL
SELECT DECODE(COUNT(1), 0, 0, 1) CNT, '工序' TYPE
  FROM COM_MSC_PROCESS A
 WHERE A.MSC = '#MSC#'
   AND A.VALIDFLAG = '1'
UNION ALL
SELECT DECODE(COUNT(1), 0, 0, 1) CNT, '工序点' TYPE
  FROM COM_MSC_STATION A
 WHERE A.MSC = '#MSC#'
   AND A.VALIDFLAG = '1'
UNION ALL
SELECT DECODE(COUNT(1), 0, 0, 1) CNT, '钢种' TYPE
  FROM COM_MSC_GRADE A
 WHERE A.MSC = '#MSC#'
   AND A.VALIDFLAG = '1'
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC.isCompleteMsc2" desc="是否完整的MSC">
		<![CDATA[
SELECT SUM(CNT) CNT, '成分标准' TYPE
  FROM (SELECT DECODE(COUNT(1), 0, 0, 1) CNT
          FROM COM_MSC_STD_CIC A
         WHERE (A.MSC = '#MSC#' OR
               A.MSC =
               (SELECT B.MSC_SEQ FROM COM_MSC B WHERE B.MSC = '#MSC#'))
           AND A.VALIDFLAG <> '0'
        UNION ALL
        SELECT 1 CNT
          FROM DUAL
         WHERE NOT EXISTS (SELECT 1
                  FROM COM_MSC_STATION T
                 WHERE T.STATION_TYPE = '403201'
                   AND T.VALIDFLAG = '1'
                   AND T.MSC = '#MSC#'))
UNION ALL
SELECT SUM(CNT) CNT, '理化标准' TYPE
  FROM (SELECT DECODE(COUNT(1), 0, 0, 1) CNT
          FROM COM_MSC_STD_PIC A
         WHERE (A.MSC = '#MSC#' OR
               A.MSC =
               (SELECT B.MSC_SEQ FROM COM_MSC B WHERE B.MSC = '#MSC#'))
           AND A.VALIDFLAG <> '0'
        UNION ALL
        SELECT 1 CNT
          FROM DUAL
         WHERE NOT EXISTS (SELECT 1
                  FROM COM_MSC_STATION T
                 WHERE T.STATION_TYPE = '403202'
                   AND T.VALIDFLAG = '1'
                   AND T.MSC = '#MSC#'))
UNION ALL
SELECT SUM(CNT) CNT, '公差标准' TYPE
  FROM (SELECT DECODE(COUNT(1), 0, 0, 1) CNT
          FROM COM_MSC_STD_SPEC A
         WHERE (A.MSC = '#MSC#' OR
               A.MSC =
               (SELECT B.MSC_SEQ FROM COM_MSC B WHERE B.MSC = '#MSC#'))
           AND A.VALIDFLAG <> '0'
        UNION ALL
        SELECT 1 CNT
          FROM DUAL
         WHERE NOT EXISTS (SELECT 1
                  FROM COM_MSC_STATION T
                 WHERE T.STATION_TYPE = '403203'
                   AND T.VALIDFLAG = '1'
                   AND T.MSC = '#MSC#'))
UNION ALL
SELECT SUM(CNT) CNT, '探伤标准' TYPE
  FROM (SELECT DECODE(COUNT(1), 0, 0, 1) CNT
          FROM COM_MSC_STD_DETECTION A
         WHERE (A.MSC = '#MSC#' OR
               A.MSC =
               (SELECT B.MSC_SEQ FROM COM_MSC B WHERE B.MSC = '#MSC#'))
           AND A.VALIDFLAG <> '0'
        UNION ALL
        SELECT 1 CNT
          FROM DUAL
         WHERE NOT EXISTS (SELECT 1
                  FROM COM_MSC_STATION T
                 WHERE T.STATION_TYPE = '403204'
                   AND T.VALIDFLAG = '1'
                   AND T.MSC = '#MSC#'))
UNION ALL
SELECT SUM(CNT) CNT, '水压标准' TYPE
  FROM (SELECT DECODE(COUNT(1), 0, 0, 1) CNT
          FROM COM_MSC_STD_WATER A
         WHERE (A.MSC = '#MSC#' OR
               A.MSC =
               (SELECT B.MSC_SEQ FROM COM_MSC B WHERE B.MSC = '#MSC#'))
           AND A.VALIDFLAG <> '0'
        UNION ALL
        SELECT 1 CNT
          FROM DUAL
         WHERE NOT EXISTS (SELECT 1
                  FROM COM_MSC_STATION T
                 WHERE T.STATION_TYPE = '403205'
                   AND T.VALIDFLAG = '1'
                   AND T.MSC = '#MSC#'))
UNION ALL
SELECT SUM(CNT) CNT, '加工标准' TYPE
  FROM (SELECT DECODE(COUNT(1), 0, 0, 1) CNT
          FROM COM_MSC_STD_PROCESS A
         WHERE (A.MSC = '#MSC#' OR
               A.MSC =
               (SELECT B.MSC_SEQ FROM COM_MSC B WHERE B.MSC = '#MSC#'))
           AND A.VALIDFLAG <> '0'
        UNION ALL
        SELECT 1 CNT
          FROM DUAL
         WHERE NOT EXISTS (SELECT 1
                  FROM COM_MSC_STATION T
                 WHERE T.STATION_TYPE = '403208'
                   AND T.VALIDFLAG = '1'
                   AND T.MSC = '#MSC#'))

UNION ALL
SELECT SUM(CNT) CNT, '成分类工序点' TYPE
  FROM (SELECT DECODE(COUNT(1), 0, 0, 1) CNT
          FROM COM_MSC_STATION T
         WHERE T.STATION_TYPE = '403201'
           AND T.VALIDFLAG = '1'
           AND T.MSC = '#MSC#'
        UNION ALL
        SELECT 1 CNT
          FROM DUAL
         WHERE NOT EXISTS
         (SELECT 1
                  FROM COM_MSC_STD_CIC A
                 WHERE (A.MSC = '#MSC#' OR
                       A.MSC =
                       (SELECT B.MSC_SEQ FROM COM_MSC B WHERE B.MSC = '#MSC#'))
                   AND A.VALIDFLAG <> '0'))
UNION ALL
SELECT SUM(CNT) CNT, '理化类工序点' TYPE
  FROM (SELECT DECODE(COUNT(1), 0, 0, 1) CNT
          FROM COM_MSC_STATION T
         WHERE T.STATION_TYPE = '403202'
           AND T.VALIDFLAG = '1'
           AND T.MSC = '#MSC#'
        UNION ALL
        SELECT 1 CNT
          FROM DUAL
         WHERE NOT EXISTS
         (SELECT 1
                  FROM COM_MSC_STD_PIC A
                 WHERE (A.MSC = '#MSC#' OR
                       A.MSC =
                       (SELECT B.MSC_SEQ FROM COM_MSC B WHERE B.MSC = '#MSC#'))
                   AND A.VALIDFLAG <> '0'))
UNION ALL
SELECT SUM(CNT) CNT, '公差类工序点' TYPE
  FROM (SELECT DECODE(COUNT(1), 0, 0, 1) CNT
          FROM COM_MSC_STATION T
         WHERE T.STATION_TYPE = '403203'
           AND T.VALIDFLAG = '1'
           AND T.MSC = '#MSC#'
        UNION ALL
        SELECT 1 CNT
          FROM DUAL
         WHERE NOT EXISTS
         (SELECT 1
                  FROM COM_MSC_STD_SPEC A
                 WHERE (A.MSC = '#MSC#' OR
                       A.MSC =
                       (SELECT B.MSC_SEQ FROM COM_MSC B WHERE B.MSC = '#MSC#'))
                   AND A.VALIDFLAG <> '0'))
UNION ALL
SELECT SUM(CNT) CNT, '探伤类工序点' TYPE
  FROM (SELECT DECODE(COUNT(1), 0, 0, 1) CNT
          FROM COM_MSC_STATION T
         WHERE T.STATION_TYPE = '403204'
           AND T.VALIDFLAG = '1'
           AND T.MSC = '#MSC#'
        UNION ALL
        SELECT 1 CNT
          FROM DUAL
         WHERE NOT EXISTS
         (SELECT 1
                  FROM COM_MSC_STD_DETECTION A
                 WHERE (A.MSC = '#MSC#' OR
                       A.MSC =
                       (SELECT B.MSC_SEQ FROM COM_MSC B WHERE B.MSC = '#MSC#'))
                   AND A.VALIDFLAG <> '0'))
UNION ALL
SELECT SUM(CNT) CNT, '水压类工序点' TYPE
  FROM (SELECT DECODE(COUNT(1), 0, 0, 1) CNT
          FROM COM_MSC_STATION T
         WHERE T.STATION_TYPE = '403205'
           AND T.VALIDFLAG = '1'
           AND T.MSC = '#MSC#'
        UNION ALL
        SELECT 1 CNT
          FROM DUAL
         WHERE NOT EXISTS
         (SELECT 1
                  FROM COM_MSC_STD_WATER A
                 WHERE (A.MSC = '#MSC#' OR
                       A.MSC =
                       (SELECT B.MSC_SEQ FROM COM_MSC B WHERE B.MSC = '#MSC#'))
                   AND A.VALIDFLAG <> '0'))
UNION ALL
SELECT SUM(CNT) CNT, '加工类工序点' TYPE
  FROM (SELECT DECODE(COUNT(1), 0, 0, 1) CNT
          FROM COM_MSC_STATION T
         WHERE T.STATION_TYPE = '403208'
           AND T.VALIDFLAG = '1'
           AND T.MSC = '#MSC#'
        UNION ALL
        SELECT 1 CNT
          FROM DUAL
         WHERE NOT EXISTS
         (SELECT 1
                  FROM COM_MSC_STD_PROCESS A
                 WHERE (A.MSC = '#MSC#' OR
                       A.MSC =
                       (SELECT B.MSC_SEQ FROM COM_MSC B WHERE B.MSC = '#MSC#'))
                   AND A.VALIDFLAG <> '0'))
		 ]]>
	</query>

	<query id="CoreFrmProPSCMSC.saveMscImg" desc="保存图片路径到MSC表">
		<![CDATA[
		UPDATE com_msc T SET T.FILE_JPEG = ? WHERE T.MSC = ?
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC.queryMscImg" desc="查询MSC表图片路径">
		<![CDATA[
		SELECT T.FILE_JPEG FROM com_msc T WHERE T.MSC = ?
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC.queryProcessC" desc="查询二级工序">
		<![CDATA[
		SELECT T.PROCESS_CDOE_C, T.PROCESS_DESC_C, T.PROCESS_CDOE, T.PROCESS_DESC
		 from com_base_process_c t WHERE T.VALIDFLAG = '1'
		 ORDER BY T.PROCESS_DESC_C ASC
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC.updateMscMemo" desc="更改备注">
		<![CDATA[
		UPDATE COM_MSC T SET T.REMARK = ?
		WHERE T.MSC = ?
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC.saveMscRJg" desc="保存接箍和冶金规范关系表中的3个附加要求">
		<![CDATA[
UPDATE COM_MSC_R_JG T
   SET T.DEMAND_DETECTION   = '#DEMAND_DETECTION#',
       T.DEMAND_BONDERIZING = '#DEMAND_BONDERIZING#',
       T.DEMAND_COPPER      = '#DEMAND_COPPER#',
       T.DEMAND_BLAST       = '#DEMAND_BLAST#',
       T.UPDATE_NAME        = '#UPDATE_NAME#',
       T.UPDATE_TIME        = SYSDATE,
       T.MEMO               = '#MEMO#',
       T.TORQUE_UNIT        = '#TORQUE_UNIT#',
       T.TORQUE_MAX         = '#TORQUE_MAX#',
       T.TORQUE_MIN         = '#TORQUE_MIN#',
       T.TORQUE_BEST        = '#TORQUE_BEST#',
       T.POINT_MAX          = '#POINT_MAX#',
       T.POINT_MIN          = '#POINT_MIN#',
       T.M_STD_NO = '#M_STD_NO#',
       T.W_STD_NO = '#W_STD_NO#',
       T.M_PRINT_NO = '#M_PRINT_NO#',
       T.W_PRINT_NO = '#W_PRINT_NO#',
       T.FILE_PATH = '#FILE_PATH#',
       T.JG_MEMO = '#JG_MEMO#'
 WHERE T.MSC = '#MSC#'
   AND T.KEY_JG = '#KEY_JG#'
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC.updateJgPath" desc="修改接箍路径">
		<![CDATA[
UPDATE COM_MSC_R_JG T
   SET T.FILE_PATH = {0}, T.UPDATE_NAME = {1}, T.UPDATE_TIME = SYSDATE
 WHERE T.MSC = {2}
   AND T.KEY_JG = {3}
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC.queryUnitCodeByPsc" desc="查询PSC表科室">
		<![CDATA[
		SELECT T.UNIT_CODE, T.DEPARTMENT_CODE FROM COM_PSC T WHERE T.PSC = '#PSC#'
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC.queryIsExistStdMsc" desc="查询是否存在标准MSC">
		<![CDATA[
		SELECT COUNT(1) FROM COM_PSC_R_MSC T WHERE T.PSC = '#PSC#'
			AND T.MSC LIKE '__________000'
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC.getPscByMsc" desc="查询PSC">
		<![CDATA[
		SELECT T.PSC FROM COM_PSC_R_MSC T WHERE T.MSC = '#MSC#'
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC.getMscBackLogByMscMscPline" desc="查询冶金规范产线">
		<![CDATA[
SELECT DECODE(B.DESGIN_KEY, NULL, 'False', 'True') CHK,
       A.MSC,
       A.MSC_PLINE,
       A.WHOLE_BACKLOG,
       A.WHOLE_BACKLOG_DESC,
       A.MEMO,
       A.PROCESS_NO
  FROM COM_MSC_BACKLOG A
  LEFT JOIN SLM_ORD_DESIGN_MSC_PL B
    ON A.MSC_PLINE = B.MSC_PLINE
   AND B.ORD_LN_PK = '#ORD_LN_PK#'
 WHERE A.MSC = '#MSC#'
   AND A.VALIDFLAG IN ('1', '2', '3')
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC.getCraftOrdDesignMscPl" desc="查询工艺制程">
		<![CDATA[
SELECT DECODE(D.DESGIN_KEY, NULL, 'False', 'True') CHK,
       A.MSC,
       A.MSC_PLINE,
       A.WHOLE_BACKLOG,
       A.WHOLE_BACKLOG_DESC,
       A.MEMO,
       A.PROCESS_NO
  FROM COM_MSC_BACKLOG A
  LEFT JOIN (SELECT B.*
               FROM CRAFT_ORD_DESIGN_MSC_PL B, CRAFT_ORD_DESIGN C
              WHERE B.DESGIN_KEY = C.DESGIN_KEY
                AND C.ORD_LN_PK = '#ORD_LN_PK#'
                AND C.VALIDFLAG = '2') D
    ON A.MSC_PLINE = D.MSC_PLINE
 WHERE A.MSC = '#MSC#'
   AND A.VALIDFLAG IN ('1', '2', '3')
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC.insertDesignMscPl" desc="新增质量设计制程">
		<![CDATA[
 INSERT INTO SLM_ORD_DESIGN_MSC_PL(
        DESGIN_KEY,
        MSC_PLINE,
        WHOLE_BACKLOG,
        WHOLE_BACKLOG_DESC,
        SET_FL,
        WARN_DESC,
        ORD_LN_PK)
 VALUES( 
        '#DESGIN_KEY#',
        '#MSC_PLINE#',
        '#WHOLE_BACKLOG#',
        '#WHOLE_BACKLOG_DESC#',
        '1',
        '',
        '#ORD_LN_PK#')
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC.insertCraftDesingMscPl" desc="新增工艺制程">
		<![CDATA[
 INSERT INTO CRAFT_ORD_DESIGN_MSC_PL(
        DESGIN_KEY,
        MSC_PLINE,
        WHOLE_BACKLOG,
        WHOLE_BACKLOG_DESC,
        SET_FL,
        WARN_DESC,
        ORD_LN_PK)
 VALUES( 
        '#DESGIN_KEY#',
        '#MSC_PLINE#',
        '#WHOLE_BACKLOG#',
        '#WHOLE_BACKLOG_DESC#',
        '1',
        '',
        '#ORD_LN_PK#')
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC.deleteDesignMscPl" desc="删除质量设计制程">
		<![CDATA[
DELETE FROM SLM_ORD_DESIGN_MSC_PL T
 WHERE T.DESGIN_KEY = '#DESGIN_KEY#'
  -- AND T.MSC_PLINE = '#MSC_PLINE#'
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC.getCraftDesign" desc="查询工艺评审主表">
		<![CDATA[
 SELECT *
     FROM CRAFT_ORD_DESIGN C
    WHERE C.ORD_LN_PK = '#ORD_LN_PK#'
      AND C.CRAFT_SEQ = (SELECT MAX(CRAFT_SEQ) FROM CRAFT_ORD_DESIGN A WHERE A.ORD_LN_PK = '#ORD_LN_PK#')
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC.deleteCraftDesignMscPl" desc="删除工艺制程">
		<![CDATA[
DELETE FROM CRAFT_ORD_DESIGN_MSC_PL T
 WHERE T.DESGIN_KEY = '#DESGIN_KEY#'
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC.deleteDesignMscPl2" desc="删除质量设计制程2">
		<![CDATA[
DELETE FROM SLM_ORD_DESIGN_MSC_PL T
 WHERE T.SET_FL = '1'
   AND T.ORD_LN_PK = '#ORD_LN_PK#'
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC.getMscFjImg" desc="查询MSC附件图片">
		<![CDATA[
SELECT T.FILE_JPEG FROM COM_MSC T WHERE T.MSC = {0}
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC.getCraftFjImg" desc="查询Craft附件图片">
		<![CDATA[
SELECT T.FILE_JPEG FROM CRAFT_ORD_DESIGN_MSC_FJ_S T WHERE T.ORD_LN_PK = {0}
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC.deleteCraftFjImg" desc="删除Craft附件图片">
		<![CDATA[
DELETE FROM CRAFT_ORD_DESIGN_MSC_FJ_S T WHERE T.ORD_LN_PK = {0}
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC.insertCraftFjImg" desc="新增Craft附件图片">
		<![CDATA[
INSERT INTO CRAFT_ORD_DESIGN_MSC_FJ_S (ORD_LN_PK, FILE_JPEG) VALUES ({0}, {1})
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC.getComMscByMsc" desc="通过MSC查询MSC表">
		<![CDATA[
SELECT * FROM COM_MSC T WHERE T.MSC = '#MSC#'
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC.getStdStyle" desc="通过PSC查询标准类型">
		<![CDATA[
SELECT T.STDSTYLE
  FROM COM_BASE_STD T, COM_PSC A
 WHERE T.STD_CODE = A.STD_CODE
   AND A.PSC = '#PSC#'
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC.deleteMscStdCraft" desc="删除工艺参数">
		<![CDATA[
DELETE FROM COM_MSC_STD_CRAFT T
 WHERE NOT EXISTS (SELECT 1
          FROM COM_MSC_STATION A
         WHERE A.STATION_CODE = T.STATION_CODE
           AND A.MSC = T.MSC
           AND A.MSC_PLINE = T.MSC_PLINE)
   AND T.MSC = '#MSC#'
   AND T.MSC_PLINE = '#MSC_PLINE#'
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC2.queryMscBackLog" desc="查询制程">
		<![CDATA[
SELECT PROCESS_NAME,
       MSC,
       MSC_PLINE,
       WHOLE_BACKLOG,
       WHOLE_BACKLOG_DESC,
       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,
       VALIDFLAG,
       MEMO,
       MSC_OLD,
       MSC_PLINE_OLD,
       PROCESS_NO,
       VALIDFLAG_NK
  FROM COM_MSC_BACKLOG t
 WHERE T.MSC = '#MSC#'
   AND T.VALIDFLAG <> '0'
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC2.insertMscBackLog" desc="新增制程">
		<![CDATA[
INSERT INTO COM_MSC_BACKLOG
  (PROCESS_NAME,
   MSC,
   MSC_PLINE,
   WHOLE_BACKLOG,
   WHOLE_BACKLOG_DESC,
   CREATE_NAME,
   CREATE_TIME,
   VALIDFLAG,
   MEMO,
   PROCESS_NO,
   VALIDFLAG_NK)
VALUES
  ('#PROCESS_NAME#',
   '#MSC#',
   '#MSC_PLINE#',
   '#WHOLE_BACKLOG#',
   '#WHOLE_BACKLOG_DESC#',
   '#CREATE_NAME#',
   SYSDATE,
   '#VALIDFLAG#',
   '#MEMO#',
   '#PROCESS_NO#',
   '#VALIDFLAG_NK#')
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC2.queryComMsc" desc="查询MSC">
		<![CDATA[
SELECT MSC,
       MSC_DESC,
       USE_CODE,
       USE_DESC,
       DEPARTMENT_CODE,
       DEPARTMENT_DESC,
       UNIT_CODE,
       UNIT_DESC,
       MSC_STYLE,
       USER_COUNT,
       PRODUCCODE,
       PRODUCNAME,
       STD_CODE,
       STD_NAME,
       STEELCODE,
       STEELNAME,
       STD_STYLE,
       STD_STYLE_DESC,
       NEW_PROC_CODE,
       NEW_PROC_DESC,
       ALLOW_NK,
       MSC_SEQ,
       MSC_DESC_SEQ,
       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,
       VALIDFLAG,
       MEMO,
       PRODUC_HEAD,
       FILE_JPEG,
       UNIT_CODE_PROCESS,
       UNIT_DESC_PROCESS,
       MSC_OLD,
       USE_CODE_OLD,
       REMARK,
       AUDIT_NAME,
       TO_CHAR(AUDIT_TIME, 'YYYY-MM-DD HH24:MI:SS') AUDIT_TIME,
       VALIDFLAG_NK,
       AUDIT_NAME_NK,
       TO_CHAR(AUDIT_TIME_NK, 'YYYY-MM-DD HH24:MI:SS') AUDIT_TIME_NK,
       REMARK_NK
  FROM COM_MSC T
 WHERE T.MSC = '#MSC#'
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC2.queryMscProcess" desc="查询工序">
		<![CDATA[
SELECT MINUTE_PRODUCT_OUT,
       MINUTE_WAITE_OUT,
       BATCH_WAITE,
       BATCH_WAITE_OUT,
       INDEX_SEQ,
       MSC,
       MSC_PLINE,
       BACKLOG_SEQ,
       PROCESS_CODE,
       PROCESS_DESC,
       MINUTE_PRODUCT,
       MINUTE_WAITE,
       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,
       VALIDFLAG,
       MEMO,
       PROCESS_SEQ,
       CIC,
       PIC,
       SIC,
       DIC,
       WIC,
       PROCESS_CODE_C,
       PROCESS_DESC_C,
       GIC,
       MSC_PLINE_OLD
  FROM COM_MSC_PROCESS T
 WHERE T.MSC = '#MSC#'
 AND T.VALIDFLAG = '1'
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC2.insertMscProcess" desc="新增工序">
		<![CDATA[
INSERT INTO COM_MSC_PROCESS
  (MINUTE_PRODUCT_OUT,
   MINUTE_WAITE_OUT,
   BATCH_WAITE,
   BATCH_WAITE_OUT,
   INDEX_SEQ,
   MSC,
   MSC_PLINE,
   BACKLOG_SEQ,
   PROCESS_CODE,
   PROCESS_DESC,
   MINUTE_PRODUCT,
   MINUTE_WAITE,
   CREATE_NAME,
   CREATE_TIME,
   VALIDFLAG,
   MEMO,
   PROCESS_SEQ,
   CIC,
   PIC,
   SIC,
   DIC,
   WIC,
   PROCESS_CODE_C,
   PROCESS_DESC_C,
   GIC)
VALUES
  ('#MINUTE_PRODUCT_OUT#',
   '#MINUTE_WAITE_OUT#',
   '#BATCH_WAITE#',
   '#BATCH_WAITE_OUT#',
   '#INDEX_SEQ#',
   '#MSC#',
   '#MSC_PLINE#',
   '#BACKLOG_SEQ#',
   '#PROCESS_CODE#',
   '#PROCESS_DESC#',
   '#MINUTE_PRODUCT#',
   '#MINUTE_WAITE#',
   '#CREATE_NAME#',
   SYSDATE,
   '#VALIDFLAG#',
   '#MEMO#',
   '#PROCESS_SEQ#',
   '#CIC#',
   '#PIC#',
   '#SIC#',
   '#DIC#',
   '#WIC#',
   '#PROCESS_CODE_C#',
   '#PROCESS_DESC_C#',
   '#GIC#')
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC2.queryMscStation" desc="查询工序点">
		<![CDATA[
SELECT INDEX_SEQ,
       MSC,
       MSC_PLINE,
       BACKLOG_SEQ,
       PROCESS_CODE,
       PROCESS_DESC,
       STATION_CODE,
       STATION_DESC,
       STATION_TYPE,
       STATION_ID,
       COST,
       CHOOSE,
       RETURN_RESULT,
       SEND_CHECKPLAN,
       GROUP_SEQ,
       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,
       VALIDFLAG,
       MEMO,
       PROCESS_SEQ,
       PROCESS_CODE_C,
       PROCESS_DESC_C
  FROM COM_MSC_STATION T
 WHERE T.MSC = '#MSC#'
 AND T.VALIDFLAG = '1'
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC2.insertMscStation" desc="新增工序点">
		<![CDATA[
INSERT INTO COM_MSC_STATION
  (INDEX_SEQ,
   MSC,
   MSC_PLINE,
   BACKLOG_SEQ,
   PROCESS_CODE,
   PROCESS_DESC,
   STATION_CODE,
   STATION_DESC,
   STATION_TYPE,
   STATION_ID,
   COST,
   CHOOSE,
   RETURN_RESULT,
   SEND_CHECKPLAN,
   GROUP_SEQ,
   CREATE_NAME,
   CREATE_TIME,
   VALIDFLAG,
   MEMO,
   PROCESS_SEQ,
   PROCESS_CODE_C,
   PROCESS_DESC_C)
VALUES
  ('#INDEX_SEQ#',
   '#MSC#',
   '#MSC_PLINE#',
   '#BACKLOG_SEQ#',
   '#PROCESS_CODE#',
   '#PROCESS_DESC#',
   '#STATION_CODE#',
   '#STATION_DESC#',
   '#STATION_TYPE#',
   '#STATION_ID#',
   '#COST#',
   '#CHOOSE#',
   '#RETURN_RESULT#',
   '#SEND_CHECKPLAN#',
   '#GROUP_SEQ#',
   '#CREATE_NAME#',
   SYSDATE,
   '#VALIDFLAG#',
   '#MEMO#',
   '#PROCESS_SEQ#',
   '#PROCESS_CODE_C#',
   '#PROCESS_DESC_C#')
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC2.queryMscGrade" desc="查询钢种">
		<![CDATA[
SELECT MSC,
       MSC_PLINE,
       CIC,
       GRADECODE,
       GRADENAME,
       ASSORTMENT_CODE,
       ASSORTMENT_NAME,
       STD_CODE,
       STD_NAME,
       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,
       VALIDFLAG,
       MEMO,
       GRADECODE_OLD
  FROM COM_MSC_GRADE T
 WHERE T.MSC = '#MSC#'
 AND T.VALIDFLAG = '1'
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC2.insertMscGrade" desc="新增钢种">
		<![CDATA[
INSERT INTO COM_MSC_GRADE
  (MSC,
   MSC_PLINE,
   CIC,
   GRADECODE,
   GRADENAME,
   ASSORTMENT_CODE,
   ASSORTMENT_NAME,
   STD_CODE,
   STD_NAME,
   CREATE_NAME,
   CREATE_TIME,
   VALIDFLAG,
   MEMO)
VALUES
  ('#MSC#',
   '#MSC_PLINE#',
   '#CIC#',
   '#GRADECODE#',
   '#GRADENAME#',
   '#ASSORTMENT_CODE#',
   '#ASSORTMENT_NAME#',
   '#STD_CODE#',
   '#STD_NAME#',
   '#CREATE_NAME#',
   SYSDATE,
   '#VALIDFLAG#',
   '#MEMO#')
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC2.queryMscGradeRSpec" desc="查询钢种与规格关系">
		<![CDATA[
SELECT MSC,
       MSC_PLINE,
       GRADECODE,
       GRADENAME,
       HEIGHT_MIN,
       DIMATER_MIN,
       DIMATER_MAX,
       HEIGHT_MIAX,
       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,
       VALIDFLAG,
       MEMO
  FROM COM_MSC_GRADE_R_SPEC T
 WHERE T.MSC = '#MSC#'
   AND T.VALIDFLAG = '1'
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC2.insertMscGradeRSpec" desc="新增钢种与规格关系">
		<![CDATA[
INSERT INTO COM_MSC_GRADE_R_SPEC
  (MSC,
   MSC_PLINE,
   GRADECODE,
   GRADENAME,
   HEIGHT_MIN,
   DIMATER_MIN,
   DIMATER_MAX,
   HEIGHT_MIAX,
   CREATE_NAME,
   CREATE_TIME,
   VALIDFLAG,
   MEMO)
VALUES
  ('#MSC#',
   '#MSC_PLINE#',
   '#GRADECODE#',
   '#GRADENAME#',
   '#HEIGHT_MIN#',
   '#DIMATER_MIN#',
   '#DIMATER_MAX#',
   '#HEIGHT_MIAX#',
   '#CREATE_NAME#',
   SYSDATE,
   '#VALIDFLAG#',
   '#MEMO#')
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC2.queryMscStdCraft" desc="查询工艺参数">
		<![CDATA[
SELECT CRAFTITEM_CDOE,
       CRAFTITEM_DESC,
       ALLOW_COUNT,
       MIN_VALUE,
       MAX_VALUE,
       CRAFTITEM_CDOE1,
       CRAFTITEM_DESC1,
       MIN_VALUE1,
       MAX_VALUE1,
       CRAFTITEM_CDOE2,
       CRAFTITEM_DESC2,
       MIN_VALUE2,
       MAX_VALUE2,
       CRAFTITEM_CDOE3,
       CRAFTITEM_DESC3,
       MIN_VALUE3,
       MAX_VALUE3,
       CRAFTITEM_CDOE4,
       CRAFTITEM_DESC4,
       MIN_VALUE4,
       MAX_VALUE4,
       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,
       VALIDFLAG,
       MEMO,
       MSC,
       MSC_PLINE,
       BACKLOG_SEQ,
       PROCESS_CDOE,
       PROCESS_DESC,
       PROCESS_CDOE_C,
       PROCESS_DESC_C,
       STATION_CODE,
       STATION_DESC,
       MIN_D,
       MAX_D,
       MIN_H,
       MAX_H,
       MODEL_CODE,
       MODEL_DESC,
       SPEC_JG,
       SPEC_JG_DESC
  FROM COM_MSC_STD_CRAFT T
 WHERE T.MSC = '#MSC#'
   AND T.VALIDFLAG = '1'
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC2.insertMscStdCraft" desc="新增工艺参数">
		<![CDATA[
INSERT INTO COM_MSC_STD_CRAFT
  (CRAFTITEM_CDOE,
   CRAFTITEM_DESC,
   ALLOW_COUNT,
   MIN_VALUE,
   MAX_VALUE,
   CRAFTITEM_CDOE1,
   CRAFTITEM_DESC1,
   MIN_VALUE1,
   MAX_VALUE1,
   CRAFTITEM_CDOE2,
   CRAFTITEM_DESC2,
   MIN_VALUE2,
   MAX_VALUE2,
   CRAFTITEM_CDOE3,
   CRAFTITEM_DESC3,
   MIN_VALUE3,
   MAX_VALUE3,
   CRAFTITEM_CDOE4,
   CRAFTITEM_DESC4,
   MIN_VALUE4,
   MAX_VALUE4,
   CREATE_NAME,
   CREATE_TIME,
   VALIDFLAG,
   MEMO,
   MSC,
   MSC_PLINE,
   BACKLOG_SEQ,
   PROCESS_CDOE,
   PROCESS_DESC,
   PROCESS_CDOE_C,
   PROCESS_DESC_C,
   STATION_CODE,
   STATION_DESC,
   MIN_D,
   MAX_D,
   MIN_H,
   MAX_H,
   MODEL_CODE,
   MODEL_DESC,
   SPEC_JG,
   SPEC_JG_DESC,
   GRADE_SEQ)
VALUES
  ('#CRAFTITEM_CDOE#',
   '#CRAFTITEM_DESC#',
   '#ALLOW_COUNT#',
   '#MIN_VALUE#',
   '#MAX_VALUE#',
   '#CRAFTITEM_CDOE1#',
   '#CRAFTITEM_DESC1#',
   '#MIN_VALUE1#',
   '#MAX_VALUE1#',
   '#CRAFTITEM_CDOE2#',
   '#CRAFTITEM_DESC2#',
   '#MIN_VALUE2#',
   '#MAX_VALUE2#',
   '#CRAFTITEM_CDOE3#',
   '#CRAFTITEM_DESC3#',
   '#MIN_VALUE3#',
   '#MAX_VALUE3#',
   '#CRAFTITEM_CDOE4#',
   '#CRAFTITEM_DESC4#',
   '#MIN_VALUE4#',
   '#MAX_VALUE4#',
   '#CREATE_NAME#',
   SYSDATE,
   '#VALIDFLAG#',
   '#MEMO#',
   '#MSC#',
   '#MSC_PLINE#',
   '#BACKLOG_SEQ#',
   '#PROCESS_CDOE#',
   '#PROCESS_DESC#',
   '#PROCESS_CDOE_C#',
   '#PROCESS_DESC_C#',
   '#STATION_CODE#',
   '#STATION_DESC#',
   '#MIN_D#',
   '#MAX_D#',
   '#MIN_H#',
   '#MAX_H#',
   '#MODEL_CODE#',
   '#MODEL_DESC#',
   '#SPEC_JG#',
   '#SPEC_JG_DESC#',
   '#GRADE_SEQ#')
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC2.queryExistBackLog" desc="查询是否存在制程">
		<![CDATA[
SELECT 1 FROM COM_MSC_BACKLOG T WHERE T.MSC = '#MSC#'
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC2.queryComMscBacklogByPk" desc="根据主键查询制程">
		<![CDATA[
SELECT * FROM COM_MSC_BACKLOG T WHERE T.MSC = '#MSC#' AND T.MSC_PLINE = '#MSC_PLINE#'
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC2.queryComBaseProcessCByPk" desc="通过主键查询二级工序">
		<![CDATA[
SELECT * FROM COM_BASE_PROCESS_C T WHERE T.PROCESS_CDOE_C = '#PROCESS_CDOE_C#'
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC2.isSameComMscProcess" desc="是否相同的工序">
		<![CDATA[
SELECT COUNT(1) COUNT
     FROM COM_MSC_PROCESS T
    WHERE T.PROCESS_CODE = '#PROCESS_CODE#'
      AND T.BACKLOG_SEQ = '#BACKLOG_SEQ#'
      AND T.PROCESS_CODE_C = '#PROCESS_CODE_C#'
      AND T.MSC = '#MSC#'
      AND T.MSC_PLINE = '#MSC_PLINE#'
      AND T.VALIDFLAG = '1'
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC2.comMscProcessTotalCnt" desc="制程向下的工序个数是否一致">
		<![CDATA[
SELECT COUNT(1) COUNT
        FROM COM_MSC_PROCESS T
       WHERE T.MSC = '#MSC#'
         AND T.MSC_PLINE = '#MSC_PLINE#'
         AND T.VALIDFLAG = '1'
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC2.isSameComMscStation" desc="是否相同的工序点">
		<![CDATA[
SELECT COUNT(1) COUNT
           FROM COM_MSC_STATION T
          WHERE T.MSC = '#MSC#'
            AND T.MSC_PLINE = '#MSC_PLINE#'
            AND T.PROCESS_CODE = '#PROCESS_CODE#'
            AND T.STATION_CODE = '#STATION_CODE#'
            AND T.RETURN_RESULT = '#RETURN_RESULT#'
            AND T.SEND_CHECKPLAN = '#SEND_CHECKPLAN#'
            AND T.PROCESS_SEQ = '#PROCESS_SEQ#'
            AND T.VALIDFLAG = '1'
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC2.comMscStationTotalCnt" desc="查询制程工序向下的工序点数目">
		<![CDATA[
SELECT COUNT(1) COUNT
              FROM COM_MSC_STATION T
             WHERE T.MSC = '#MSC#'
               AND T.MSC_PLINE = '#MSC_PLINE#'
               AND T.PROCESS_CODE IN (#PROCESS_CODE#)
               AND T.VALIDFLAG = '1'
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC2.isExistSlmOrdDesignPlControl" desc="是否被MSP引用">
		<![CDATA[
SELECT COUNT(1) COUNT
  FROM SLM_ORD_DESIGN_PL_CONTROL T
 WHERE T.MSC = '#MSC#'
   AND T.MSC_PLINE = '#MSC_PLINE#'
   AND T.ORD_LN_PK <> '#ORD_LN_PK#'
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC2.updateCraftPath" desc="修改工艺路径">
		<![CDATA[
UPDATE COM_MSC_BACKLOG T
   SET T.CRAFT_PATH = '#CRAFT_PATH#'
 WHERE T.MSC = '#MSC#'
   AND T.MSC_PLINE = '#MSC_PLINE#'
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC2.getMscRJgCnt" desc="接箍和冶金规范管理关系数目">
		<![CDATA[
SELECT COUNT(1)
  FROM COM_MSC_R_JG T
 WHERE T.CODE_JG = '#CODE_JG#'
   AND NVL(T.DEMAND_DETECTION, '1') = NVL('#DEMAND_DETECTION#', '1')
   AND NVL(T.DEMAND_BONDERIZING, '1') = NVL('#DEMAND_BONDERIZING#', '1')
   AND NVL(T.DEMAND_COPPER, '1') = NVL('#DEMAND_COPPER#', '1')
   AND NVL(T.DEMAND_BLAST, '1') = NVL('#DEMAND_BLAST#', '1')
   AND NVL(T.ORDER_SPECIAL_DESC, '1') = NVL('#ORDER_SPECIAL_DESC#', '1')
   AND NVL(T.ALPHA_CODE, '/') = NVL('#ALPHA_CODE#', '/')
   AND T.KEY_JG <> '#KEY_JG#'
   AND T.MSC = '#MSC#'
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC2.getBackLogDescCnt" desc="获取制程描述的数目">
		<![CDATA[
SELECT COUNT(1)
  FROM COM_MSC_BACKLOG T
 WHERE T.MSC = '#MSC#'
   AND T.WHOLE_BACKLOG_DESC = '#WHOLE_BACKLOG_DESC#'
   AND DECODE('#STR_ACTION#', 'Update', T.MSC_PLINE, '1') <> DECODE('#STR_ACTION#', 'Update', '#MSC_PLINE#', '2')
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC2.getDesignBomCnt" desc="获取Bom的数目">
		<![CDATA[
SELECT COUNT(1)
     FROM SLM_ORD_DESIGN_BOM T
    WHERE T.MSC = '#MSC#'
      AND T.MSC_PLINE = '#MSC_PLINE#'
		 ]]>
	</query>
	
	<query id="CoreFrmProPSCMSC2.getComMscByPk" desc="通过主键查询冶金规范记录">
		<![CDATA[
SELECT * FROM COM_MSC T WHERE T.MSC = ?
		 ]]>
	</query>
	<query id="CoreFrmProPSCMSC2.getSlmOrderLineByPk" desc="通过主键查询合同行">
		<![CDATA[
SELECT * FROM SLM_ORDER_LINE T WHERE T.ORD_LN_PK = {0}
		 ]]>
	</query>
	<query id="CoreFrmProPSCMSC2.getComMsc0" desc="查询某个产品向下的MSC0">
		<![CDATA[
SELECT *
  FROM COM_PSC_R_MSC T, COM_MSC A
 WHERE T.PSC = {0}
   AND A.MSC = T.MSC
   AND A.MSC_SEQ IS NULL
		 ]]>
	</query>
	<query id="CoreFrmProPSCMSC2.isExistsBackLog" desc="是否存在全程途径码">
		<![CDATA[
SELECT COUNT(1)
  FROM Com_Msc_Backlog T
 WHERE T.MSC = {0}
   AND T.MSC_PLINE <> {1}
   AND T.WHOLE_BACKLOG_DESC = {2}
		 ]]>
	</query>
	<query id="CoreFrmProPSCMSC2.updateProcessFile" desc="修改工序贴图">
		<![CDATA[
UPDATE COM_MSC_PROCESS T
      SET T.PROCESS_FILE = {0}
    WHERE T.MSC = {1}
      AND T.MSC_PLINE = {2}
      AND T.PROCESS_CODE = {3}
		 ]]>
	</query>
	<query id="CoreFrmProPSCMSC2.deletePlineGrade" desc="删除制程向下的钢种">
		<![CDATA[
DELETE FROM (SELECT *
               FROM COM_MSC_GRADE T
              WHERE T.MSC = {0}
                AND T.MSC_PLINE = {1}
                AND T.GRADECODE = {2})
		 ]]>
	</query>
</queryMap>