<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="权限功能表查询">
<query id="CoreFrmProPSCMSC.QUERYJGAndMSC" desc="查询">
		<![CDATA[ 
	    SELECT MSC,
        MSC_DESC,
        CODE_JG,
        STOCK_STYLE,
        PRODUCCODE,
        PRODUCNAME,
        STEELCODE,
        STEELNAME,
        MIN_H,
        MAX_H,
        MIN_D,
        MAX_D,
        CREATE_NAME,
        CREATE_TIME,
        UPDATE_NAME,
        UPDATE_TIME,
        DELETE_NAME,
        DELETE_TIME,
        VALIDFLAG,
        MEMO
   FROM COM_MSC_R_JG
   WHERE MSC = ? AND VALIDFLAG IN('1',?) 
		]]>
	</query>
	
	<query id="CoreFrmProPSCMSC.QUERY" desc="权限功能">
		<![CDATA[ 
			 SELECT psc, psc_desc, msc, mscdesc
  FROM (SELECT pmc.psc, pmc.psc_desc, pmc.msc, pmc.mscdesc, item.item,
               (SELECT basename
                  FROM com_base_info
                 WHERE basecode = item.item) basename, item.item_c,
               (SELECT basename
                  FROM com_base_info
                 WHERE basecode = item.item_c) basename_c
          FROM (SELECT   a.psc,
                            a.producname
                         || '+'
                         || a.std_name
                         || '+'
                         || a.steelname
                         || '+'
                         || a.std_style_desc psc_desc,
                         b.msc, b.msc || '-' || b.use_desc mscdesc
                    FROM com_psc a FULL JOIN com_psc_r_msc b
                         ON a.validflag = '1'
                       AND b.validflag = '1'
                       AND a.psc = b.psc
                ORDER BY a.psc, b.msc) pmc
               FULL JOIN
               (SELECT   msc, item, item_c
                    FROM com_msc_item
                ORDER BY item_c ASC) item
               ON pmc.msc = item.msc AND pmc.psc IS NOT NULL
               ) group by psc, psc_desc, msc, mscdesc order by psc
		]]>
	</query> 
	<query id="CoreFrmProPSCMSC.QUERYMSC" desc="权限功能">
		<![CDATA[
		 SELECT   msc 代码, MAX (msc_desc) 代码描述
				  FROM com_msc
				  WHERE validflag = 'C'
				  GROUP BY msc
				  ORDER BY msc
		 ]]>
	</query> 
    <query id="CoreFrmProPSCMSC.QUERYSTD" desc="权限功能">
		<![CDATA[
		 SELECT   std_code 代码, MAX (std_name) 代码描述
			      FROM com_base_std
				  WHERE validflag = '1' AND stdstyle = 'K'
				  GROUP BY std_code
				  ORDER BY std_code
		 ]]>
	</query> 
	 <query id="CoreFrmProPSCMSC.QUERYTYPE" desc="权限功能">
		<![CDATA[
		  SELECT '钢管' 代码描述, 'A' 代码
				  FROM DUAL
				UNION ALL
		  SELECT '其他' 代码描述, 'B' 代码
				  FROM DUAL
		 ]]>
	</query> 
	 <query id="CoreFrmProPSCMSC.QUERYLKAK" desc="权限功能">
		<![CDATA[
		  SELECT '需要' 代码描述
			  FROM DUAL
		  UNION ALL
		  SELECT '不需要' 代码描述
			  FROM DUAL 
		 ]]>
	</query> 
	<query id="CoreFrmProPSCMSC.UPDATEPSCRMSCIS" desc="权限功能">
		<![CDATA[
		  update  com_psc_r_msc set VALIDFLAG = ? where MSC = ?
		 ]]>
	</query> 
	<query id="CoreFrmProPSCMSC.UPDATEVALIDFLAG" desc="权限功能">
		<![CDATA[
		  update  com_msc set validflag = ? where msc  = ?
		 ]]>
	</query> 
	<query id="CoreFrmProPSCMSC.QUERYVALIDFLAG" desc="权限功能">
		<![CDATA[
		  SELECT '录入状态' 代码描述
			  FROM DUAL
		  UNION ALL
		  SELECT '提交审核' 代码描述
			  FROM DUAL
		  UNION ALL
		  SELECT '已生效' 代码描述
			  FROM DUAL
		  UNION ALL
		  SELECT '无效' 代码描述
			  FROM DUAL
		 ]]>
	</query> 
    <query id="CoreFrmProPSCMSC.QUERYCOMMSC" desc="权限功能">
		<![CDATA[
		            SELECT msc, msc_desc, use_code, use_desc, department_code, department_desc,
                 unit_code, unit_desc, case 
                                         when msc_style = 'A' then '钢管'
                                         when msc_style = 'B' then '其他' end msc_style, user_count, produccode, producname,
                 std_code, std_name, steelcode, steelname, std_style, std_style_desc,
                 new_proc_code, new_proc_desc,case when allow_nk = '1' then '需要'
                                                     when allow_nk = '0' then '不需要'
                                                end allow_nk, msc_seq, msc_desc_seq,
                 create_name, create_time, update_name, update_time, delete_name,
                 delete_time, 
                 case when validflag = 'A' then '录入状态'
                        when validflag = 'B' then '提交审核'
                        when validflag = 'C' then '已生效'
                        when validflag = 'D' then '无效' 
                        when validflag = 'E' then '申请修改'
                        when validflag = 'F' then '申请作废'
                        when validflag = 'G' then '申请恢复'
                        when validflag = 'H' then '申请审核'
                        end validflag, memo
              FROM com_msc where msc in (select msc from com_psc_r_msc where psc = ? )
		 ]]>
	</query> 
	<query id="CoreFrmProPSCMSC.QUERYCOM_MSC_PSCRMSC" desc="查询状态">
		<![CDATA[
		  select case when validflag = 'A' then '录入状态'
                        when validflag = 'B' then '提交审核'
                        when validflag = 'C' then '已生效'
                        when validflag = 'D' then '无效' 
                        when validflag = 'E' then '申请修改'
                        when validflag = 'F' then '申请作废'
                        when validflag = 'G' then '申请恢复'
                        when validflag = 'H' then '申请审核'
                        end validflag from  com_msc where msc  = ?
		 ]]>
	</query> 
	
	<query id="CoreFrmProPSCMSC.InsertPSCRMSC" desc="权限功能">
		<![CDATA[
		  INSERT INTO com_psc_r_msc
		              (psc, psc_desc, use_code, use_desc, msc, msc_desc, create_name,
		               validflag, memo,create_time
		               )
		        VALUES (?, ?, ?, ?, ?, ?, ?,
		                ?, ?,sysdate)
		 ]]>
	</query> 
	<query id="CoreFrmProPSCMSC.InsertMSC" desc="权限功能">
		<![CDATA[
	 INSERT INTO com_msc
            (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,
             validflag, memo,create_time
            )
     VALUES  (?, ?, ?, ?, ?,
             ?, ?, ?, ?, ?,
             ?, ?, ?, ?, ?,
             ?, ?, ?, ?,
             ?, ?, ?, ?, ?,
             ?, ?,sysdate
            )
		 ]]>
	</query> 
	<query id="CoreFrmProPSCMSC.QUERYStaPsc" desc="权限功能">
		<![CDATA[ 
		SELECT psc, psc_desc, produccode, producname, std_code, std_name, steelcode,
		       steelname, std_style, std_style_desc, new_proc_code, new_proc_desc,
		       department_code, department_desc, unit_code, unit_desc
		  FROM com_psc
		  WHERE psc = ? and VALIDFLAG = '1'
		 ]]>
	</query> 
	<query id="CoreFrmProPSCMSC.QUERYStaPscflg" desc="查询冶金规范码状态">
		<![CDATA[ 
		 
		 ]]>
	</query> 
	<query id="CoreFrmProPSCMSC.QUERYPSCORMSCCOUNT" desc="权限功能">
		<![CDATA[ 
		SELECT  COUNT(1)
          FROM com_psc_r_msc
          WHERE psc = ? and msc = ?
		 ]]>
	</query> 
	<query id="CoreFrmProPSCMSC.QUERYStaMsc" desc="权限功能">
		<![CDATA[ 
		 SELECT    'MSC'
			       || TO_CHAR (SYSDATE, 'yyyyMMdd')
			       || REPLACE (LPAD (seq_com_mscno.NEXTVAL, 9), ' ', '0') msc
			  FROM DUAL
		 ]]>
	</query> 
	<query id="CoreFrmProPSCMSC.SETUPDATECOMMSC" desc="权限功能">
		<![CDATA[
			UPDATE com_msc
				   SET department_code = ?,
				       department_desc = ?,
				       unit_code = ?,
				       unit_desc = ?,
				       msc_style = ?,
				       user_count = ?,
				       allow_nk = ?,
				       msc_seq = ?,
				       msc_desc_seq = ?, 
				       update_name = ?,
				       memo = ?,
				       use_code = ?,
				       use_desc = ?,
				       update_time = sysdate
				 WHERE msc = ?
		]]>
	</query> 
	<query id="CoreFrmProPSCMSC.INSERTCOM_MSC_BACKLOG" desc="新增全程数据">
		<![CDATA[
		    INSERT INTO com_msc_backlog
            (msc,
             msc_pline,
             create_name, create_time, memo
            )
		     VALUES (?,
		             (SELECT REPLACE (LPAD (NVL (MAX (msc_pline + 1), '1'), 6),
		                              ' ',
		                              '0'
		                             )
		                FROM com_msc_backlog
		               WHERE msc = ?),
		               ?, SYSDATE, ?
		            )
		]]>
	</query>   
	<query id="CoreFrmProPSCMSC.QUERYSCOM_MSC_BACKLOG" desc="查询全程数据表">
			<![CDATA[
			   SELECT  msc, msc_pline, whole_backlog, whole_backlog_desc, create_name,
				       create_time, update_name, update_time, delete_name, delete_time,
				       validflag, memo
				  FROM com_msc_backlog
				  WHERE msc = ?
			]]>
		</query>
			<query id="CoreFrmProPSCMSC.QUERYSCOM_MSC_BACKLOGS" desc="查询全程数据表">
			<![CDATA[
			   SELECT  msc, msc_pline, whole_backlog, whole_backlog_desc, create_name,
				       create_time, update_name, update_time, delete_name, delete_time,
				       validflag, memo
				  FROM com_msc_backlog
				  WHERE msc = ? and msc_pline = ?
			]]>
		</query>
	<query id="CoreFrmProPSCMSC.QUERYSCOM_BASE_INFO" desc="查询项目规范项">
			<![CDATA[
			   SELECT   basecode, basename
					    FROM com_base_info
					    WHERE validflag = '1' AND sortcode = '4030'
					ORDER BY basecode
			]]>
	</query>
	<query id="getLineListQUERYSCOM_BASE_INFO_SORT" desc="查询项目规范子项">
			<![CDATA[
			   SELECT   basecode,max(basename) basename
					    FROM com_base_info
					    WHERE SORTCODE = ?
						GROUP BY basecode
			]]>
	</query>
	<query id="CoreFrmProPSCMSC.QUERYSCOM_BASE_INFO_SORT_BASE" desc="查询项目规范主项">
			<![CDATA[
			   SELECT   basecode,max(basename) basename
					    FROM com_base_info
					    WHERE basecode = ?
						GROUP BY basecode
			]]>
	</query>
	<query id="CoreFrmProPSCMSC.QUERYSCOM_COM_ITEM" desc="根据MSC查询项目规范码表">
			<![CDATA[
			   SELECT msc, index_seq, item, item_c, create_name, create_time, update_name,
				      update_time, delete_name, delete_time, validflag, memo
				  	  FROM com_msc_item
				 	  WHERE msc IN (?)
			]]>
	</query>
	<query id="CoreFrmProPSCMSC.INSERTCOM_MSC_ITEM" desc="新增项目规范数据ITEM">
			<![CDATA[ 
						INSERT INTO com_msc_item
					            (msc, index_seq, item, item_c, create_name,
					             create_time, validflag, memo
					            )
					     VALUES (?, (SELECT NVL (MAX (index_seq) + 1, '1')
					                   FROM com_msc_item
					                  WHERE msc = ?), ?, ?, ?,
					             SYSDATE, ?, ?
					            )
			]]>
	</query>
	<query id="CoreFrmProPSCMSC.INSERTCOM_MSC_STD_CIC" desc="新增成分表数据">
			<![CDATA[
			   INSERT INTO com_msc_std_cic
				           (cic, psc, stdstyle, create_name, create_time)
				     VALUES (?||REPLACE (LPAD (SEQ_COM_MSC_STD_CICPK.NEXTVAL, 6), ' ', '0'), ?, ?, ?, SYSDATE
				            )
			]]>
	</query>
	<query id="CoreFrmProPSCMSC.INSERTCOM_MSC_STD_PIC" desc="新增材质表数据">
			<![CDATA[
			   INSERT INTO COM_MSC_STD_PIC (pic, psc, stdstyle, create_name, create_time)
     				  VALUES (?||REPLACE (LPAD (SEQ_COM_MSC_STD_PIC.NEXTVAL, 6), ' ', '0'), ?, ?, ?, SYSDATE
            		  )
			]]>
	</query>
	<query id="CoreFrmProPSCMSC.QUERYSCOM_MSC_PROCESS" desc="查询全工序基础">
			<![CDATA[ 
				SELECT   be.process_code, be.process_desc, be.style, be.process_id, be.COST,
				         be.create_name, be.create_time, be.update_name, be.update_time,
				         be.delete_name, be.delete_time,
				         DECODE (ms.minute_product,
				                 0, be.minute_product,
				                 ms.minute_product
				                ) minute_product,
				         DECODE (ms.minute_waite,
				                 0, be.minute_waite,
				                 ms.minute_waite
				                ) minute_waite,
				         DECODE (be.validflag, '0', '无效', '有效') validflag,
				         DECODE (ms.memo, '', be.memo, ms.memo) memo, ms.msc, be.icount,
				         1 process_seq
				    FROM com_base_process be
				         full JOIN
				         (SELECT   minute_waite, minute_product, process_code, msc, msc_pline,
				                   memo
				              FROM com_msc_process
				             WHERE msc = ? AND msc_pline = ?
				          GROUP BY minute_waite,
				                   minute_product,
				                   process_code,
				                   msc,
				                   msc_pline,
				                   memo) ms
				         ON be.validflag = '1'
				       AND ms.process_code = be.process_code
				       AND ms.msc = ?
				       AND ms.msc_pline = ?
				ORDER BY process_id
			]]>
	</query>
	<query id="CoreFrmProPSCMSC.QUERYSCOM_MSC_STATION" desc="查询工序点基础-作废">
			<![CDATA[
			   SELECT  station_code, station_desc, station_type, station_id, process_code,
				       process_desc, process_code_c, process_desc_c, COST, choose,
				       return_result, send_checkplan, monitor_lv, create_name, create_time,
				       update_name, update_time, delete_name, delete_time, validflag, memo 
					   FROM com_base_station
					   WHERE process_code IN (?) 
			]]>
	</query>
	<query id="CoreFrmProPSCMSC.SELECTCOM_MSC_PRO_SEQ" desc="查询PRO工序基础表seq">
			<![CDATA[
			   SELECT nvl(max(backlog_seq)+1,'1')backlog_seq
					  FROM com_msc_process
					  WHERE msc = ? AND msc_pline = ?
			]]>
	</query>
	<query id="CoreFrmProPSCMSC.INSERTCOM_MSC_PRO" desc="新增PRO工序基础表">
			<![CDATA[
			   INSERT INTO com_msc_process
			               (msc, msc_pline, backlog_seq, create_name, process_code,
			                process_desc, minute_product, minute_waite, create_time
			                )
			                VALUES (?, ?, ?, ?, ?,
			             			?, ?, ?, SYSDATE
			            			)
			]]>
	</query>
    <query id="CoreFrmProPSCMSC.SELECTCOM_MSC_STA" desc="查询STA工序基础表seq">
			<![CDATA[ 
					SELECT nvl(max(backlog_seq)+1,'1')backlog_seq
				    FROM com_msc_station
				    WHERE msc = ? AND msc_pline = ?
			]]>
	</query>
    <query id="CoreFrmProPSCMSC.SELECTCOM_MSC_STA_SAVEROW" desc="查询STA工序基础表是否存在">
			<![CDATA[ 
						SELECT count(1)
						  	FROM com_msc_station
						 	WHERE msc = ?
						   	AND msc_pline = ?
						   	AND process_code = ?
						   	AND station_code = ?
						   	AND station_type = ?
   			]]>
	</query>
	 <query id="CoreFrmProPSCMSC.SELECTCOM_MSC_PRO_SAVEROW" desc="查询PRO工序基础表是否存在">
			<![CDATA[ 
					SELECT msc, msc_pline, backlog_seq, create_name, process_code, process_desc,
					       minute_product, minute_waite, create_time
					  FROM com_msc_process
					 WHERE validflag = '1' AND msc = ? AND msc_pline = ? AND process_desc = ?
   			]]>
	</query>
    <query id="CoreFrmProPSCMSC.INSERTCOM_MSC_STA" desc="新增STA工序基础表">
			<![CDATA[ 
				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, create_time
				            )
				     VALUES (?, ?, ?, ?, ?,
				             ?, ?, ?, ?, ?,
				             ?, ?, ?, ?, SYSDATE
				            )
			]]>
	</query> 
	<query id="CoreFrmProPSCMSC.QUERYSCOM_MSC_GRADE" desc="查询全程工序与钢种关系表">
			<![CDATA[ 
					 SELECT  gradecode, gradename, assortment_code, assortment_name,
				     create_name, create_time, update_name, update_time,
				     delete_name, delete_time, validflag, memo
				     FROM com_base_grade
			]]>
	</query> 
	
	<query id="CoreFrmProPSCMSC.QUERYSCOM_MSC_GRADE_ROWS" 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
					  FROM  com_msc_grade
					 WHERE  msc = ? AND msc_pline = ? AND CIC = ?
			]]>
	</query> 
	
    <query id="CoreFrmProPSCMSC.QUERYSGRADE_ROWS" 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
					  FROM  com_msc_grade
					 WHERE  msc = ? AND msc_pline = ? 
			]]>
	</query> 
	
	<query id="CoreFrmProPSCMSC.QUERYSGRADE_PLINE_ROWS" 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
					  FROM  com_msc_grade
					 WHERE  msc = ?
			]]>
	</query> 
	
	<query id="CoreFrmProPSCMSC.INSERTCOM_MSC_GRADE" 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 (?, ?, ?, ?, ?, (SELECT MAX (assortment_code) assortment_code
						                               FROM com_base_grade
						                              WHERE gradecode = ?),
						             (SELECT MAX (assortment_name) assortment_name
						                FROM com_base_grade
						               WHERE gradecode = ?), ?, ?, ?,
						             SYSDATE, ?, ?
						            )
			]]>
	</query> 
	<query id="CoreFrmProPSCMSC.UPDATECOM_MSC_GRADE" desc="作废或者恢复">
			<![CDATA[ 
					UPDATE com_msc_grade
						   SET validflag = ?
					WHERE index_seq = ? AND gradecode = ?
			]]>
	</query> 
	<query id="CoreFrmProPSCMSC.QUERYSCOM_BASE_STD_NK" desc="获取内控标准">
			<![CDATA[ 
					SELECT   std_code, std_name
						     FROM com_base_std
						     WHERE stdstyle = 'N'
						GROUP BY std_code, std_name
						ORDER BY std_code
			]]>
	</query> 
	<query id="CoreFrmProPSCMSC.UPDATECOM_MSC_BACKLOG" desc="更新backlog">
			<![CDATA[ 
					UPDATE com_msc_backlog
						   SET whole_backlog = ?,
						       whole_backlog_desc = ?
						   WHERE msc = ? AND msc_pline = ?
			]]>
	</query> 
	<query id="CoreFrmProPSCMSC.UPDATECOM_BASE_PROCESSCOST" desc="更新BASE_PROCESS_COST">
			<![CDATA[ 
					UPDATE com_base_process
						   SET COST = ?
						 WHERE process_code = ?
			]]>
	</query> 
	
	<query id="CoreFrmProPSCMSC.DELETE_MSC_PROCESS" desc="删除大工序表">
			<![CDATA[ 
			DELETE      com_msc_process
      		WHERE msc = ? AND msc_pline = ?
			]]>
	</query> 
	
	<query id="CoreFrmProPSCMSC.DELETE_MSC_STATION" desc="删除工序点表">
			<![CDATA[ 
			DELETE      com_msc_station
     	    WHERE msc = ? AND msc_pline = ?
			]]>
	</query> 
	<query id="CoreFrmProPSCMSC.SELECT_MSC_STATION_DESC" desc="查询全程工序点">
			<![CDATA[ 
			SELECT  PROCESS_CODE,STATION_CODE,STATION_DESC
				    FROM com_msc_station
				   WHERE msc = ? AND msc_pline = ?
				ORDER BY station_id ASC
			]]>
	</query> 
	<query id="CoreFrmProPSCMSC.SELECT_MSC_STATION_ITEMCODE" desc="查询冶金规范项目树节点">
			<![CDATA[ 
			SELECT   item.item, (SELECT basename
                       FROM com_base_info
                      WHERE basecode = item.item) basename,
			         (SELECT basename
			            FROM com_base_info
			           WHERE basecode = item.item_c) basename_c
			    FROM com_msc_item item
			   	WHERE msc = ?
				ORDER BY item
			]]>
	</query> 
	<query id="CoreFrmProPSCMSC.SELECT_MSC_STATION_PROCESSDESC" desc="查询工序树节点">
			<![CDATA[ 
			SELECT   PROCESS_CODE, process_desc, station_code, station_desc
				     FROM com_msc_station
				    WHERE msc = ? AND msc_pline = ?
				UNION ALL
			SELECT   PROCESS_CODE, process_desc, ' ' station_code, ' ' station_desc
				     FROM com_msc_process
				    WHERE msc = ? AND msc_pline = ?
				     AND PROCESS_CODE NOT IN (
				                   SELECT PROCESS_CODE
				                     FROM com_msc_station
				                    WHERE msc = ? AND msc_pline = ?)
				ORDER BY PROCESS_CODE
			]]>
	</query> 
	<query id="CoreFrmProPSCMSC.SELECT_MSC_STATION_GRADECODE" desc="查询钢种树节点xwl">
			<![CDATA[ 
			SELECT gradecode, gradename,std_name
				   FROM com_msc_grade
				   WHERE msc = ? AND msc_pline = ?
			]]>
	</query> 
</queryMap>