<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="生产产线适用管理">
	<query id="CoreComMSCPlineRSpec.QUERY" desc="权限功能">
		<![CDATA[
		SELECT 
		T.PLINE_CODE,
       T.PLINE_NAME,
       T.PASS_CODE,
       T.PASS_NAME,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.INDEX_SEQ,
       T.SPEC_CODE,
       T.SPEC_NAME,
       T.MIN_D,
       T.MAX_D,
       T.MIN_H,
       T.MAX_H,
       T.WELL_CODE,
       T.WELL_NAME,
       T.CREATE_NAME,
       TO_CHAR(CREATE_TIME,'yyyy-mm-dd hh24:mi:ss') CREATE_TIME,
       T.UPDATE_NAME,
       TO_CHAR(UPDATE_TIME,'yyyy-mm-dd hh24:mi:ss') UPDATE_TIME,
       T.DELETE_NAME,
       TO_CHAR(DELETE_TIME,'yyyy-mm-dd hh24:mi:ss') DELETE_TIME,
	   decode(T.VALIDFLAG,'1','有效','无效') VALIDFLAGNAME,
	   T.MEMO,
	   T.PROCESS_STYLE,
	   (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = T.PROCESS_STYLE) PROCESS_STYLE_DESC,
       T.PROCESS_CDOE_C,
       T.PROCESS_DESC_C,
       T.MODEL_STYLE,
       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = T.MODEL_STYLE) MODEL_STYLE_DESC,
	   (SELECT REPLACE(TO_CHAR(WM_CONCAT(A.SPEC_CODE)), ',', ';')
          FROM COM_MSC_JG_R_SPEC A
         WHERE A.CODE_JG = TO_CHAR(T.INDEX_SEQ)) SPEC_JG,
       (SELECT REPLACE(WM_CONCAT(A.SPEC_NAME), ',', ';')
          FROM COM_MSC_JG_R_SPEC A
         WHERE A.CODE_JG = TO_CHAR(T.INDEX_SEQ)) SPEC_JG_DESC
		FROM COM_MSC_PLINE_R_SPEC T
		WHERE
		       VALIDFLAG in ('1' , '#VALIDFLAG#')
			   AND PLINE_NAME||'&' LIKE '%' || '#PLINE_NAME#' || '%'
			   AND PASS_NAME||'&' LIKE '%' || '#PASS_NAME#' || '%'
			   AND WELL_NAME||'&' LIKE '%' || '#WELL_NAME#' ||'%'
			   AND DECODE('#PLINE_CODE#', '1', '1', PLINE_CODE) IN ('#PLINE_CODE2#')
			   AND DECODE('#SPEC_CODE#', NULL, '1', SPEC_CODE) = DECODE('#SPEC_CODE#', NULL, '1', '#SPEC_CODE#')
			   AND DECODE('#DIMATER#', NULL, 1, MIN_D) <= DECODE('#DIMATER#', NULL , 2, TO_NUMBER('#DIMATER#'))
			   AND DECODE('#DIMATER#', NULL, 2, MAX_D) >= DECODE('#DIMATER#', NULL, 1, TO_NUMBER('#DIMATER#'))
			   AND DECODE('#HEIGHT#', NULL, 1, MIN_H) <= DECODE('#HEIGHT#', NULL, 2, TO_NUMBER('#HEIGHT#'))
			   AND DECODE('#HEIGHT#', NULL, 2, MAX_H) >= DECODE('#HEIGHT#', NULL, 1, TO_NUMBER('#HEIGHT#'))
	    ORDER BY T.INDEX_SEQ
		]]>
	</query>
<query id="CoreComMSCPlineRSpec.ADD" desc="权限功能">
		<![CDATA[
		
  INSERT INTO COM_MSC_PLINE_R_SPEC T(
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.PASS_CODE,
       T.PASS_NAME,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.MIN_D,
       T.MAX_D,
       T.MIN_H,
       T.MAX_H,
       T.SPEC_JG,
       T.SPEC_JG_DESC,
       T.WELL_CODE,
       T.WELL_NAME,
       T.CREATE_NAME,
       T.CREATE_TIME,
       T.UPDATE_NAME,
       T.UPDATE_TIME,
       T.DELETE_NAME,
       T.DELETE_TIME,
       T.VALIDFLAG,
       T.MEMO,
       T.SPEC_CODE,
       T.SPEC_NAME,
       T.PROCESS_STYLE,
       T.PROCESS_CDOE_C,
       T.PROCESS_DESC_C,
       T.MODEL_STYLE,
       T.INDEX_SEQ
       ) 
       VALUES(?,?,NVL(?,' '),?,?,?,?,?,?,?,?,?,?,?,?,SYSDATE,'',NULL,'',NULL,DEFAULT,?
       ,NVL(?,' '),?,?,?,?,?,?)
		]]>
	</query>
	
	<query id="CoreComMSCPlineRSpec.getMaxIndex" desc="获取最大的索引号">
		<![CDATA[
SELECT NVL(MAX(INDEX_SEQ),'0')+1 MAX_VALUE FROM COM_MSC_PLINE_R_SPEC
		]]>
	</query>
	
<query id="CoreComMSCPlineRSpec.UPDATE" desc="权限功能">
		<![CDATA[
		
  UPDATE   COM_MSC_PLINE_R_SPEC T
      SET 
       T.PLINE_CODE=?,
       T.PLINE_NAME=?,
       T.PASS_CODE=NVL(?,' '),
       T.PASS_NAME=?,
       T.MODEL_CODE=?,
       T.MODEL_DESC=?,
       T.MIN_D=?,
       T.MAX_D=?,
       T.MIN_H=?,
       T.MAX_H=?,
       T.SPEC_JG=?,
       T.SPEC_JG_DESC=?,
       T.WELL_CODE=?,
       T.WELL_NAME=?,
       T.UPDATE_NAME=?,
       T.UPDATE_TIME=SYSDATE,
       T.MEMO=?,
       T.SPEC_CODE =NVL(?,' '),
       T.SPEC_NAME =?,
       PROCESS_STYLE = ?,
       PROCESS_CDOE_C = ?,
       PROCESS_DESC_C  =?,
       MODEL_STYLE = ?
       
       WHERE T.INDEX_SEQ=?
		]]>
	</query>
		
	
<query id="CoreComMSCPlineRSpec.DELETE" desc="权限功能">
		<![CDATA[
		UPDATE COM_MSC_PLINE_R_SPEC T 
		SET T.DELETE_NAME=?,T.DELETE_TIME=SYSDATE,T.VALIDFLAG='0' 
		WHERE T.INDEX_SEQ=?
		]]>
	</query>
<query id="CoreComMSCPlineRSpec.RESUME" desc="权限功能">
		<![CDATA[
		UPDATE COM_MSC_PLINE_R_SPEC T 
		SET T.DELETE_NAME='',T.DELETE_TIME=NULL,T.VALIDFLAG='1' 
		WHERE T.INDEX_SEQ=?
		]]>
	</query>
	
	<query id="CoreComMSCPlineRSpec.GetSpec" desc="权限功能">
		<![CDATA[
		SELECT SPEC_NAME,SPEC_CODE
		FROM COM_BASE_SPEC 
		WHERE MSC_STYLE IN ('B', 'D') 
		AND VALIDFLAG='1'
		]]>
	</query>
	
	<query id="CoreComMSCPlineRSpec.GetStationID" desc="权限功能">
		<![CDATA[
		 SELECT T.PROCESS_CODE
         FROM COM_BASE_PLINE T
         WHERE T.PLINE_CODE = ?
         AND VALIDFLAG = '1'
		 
		]]>
	</query>
	
	<query id="CoreComMSCPlineRSpec.getMscPlines" desc="查询产线">
		<![CDATA[
		 SELECT T.PLINE_CODE FROM COM_BASE_PLINE T WHERE T.PROCESS_CODE = '#PROCESS_CODE#' AND T.VALIDFLAG = '1'
		]]>
	</query>
	
	<query id="CoreComMSCPlineRSpec.getProcessStyle" desc="查询产线">
		<![CDATA[
		 SELECT BASENAME,BASECODE FROM COM_BASE_INFO T WHERE T.SORTCODE = '4072' AND T.VALIDFLAG = '1'
		]]>
	</query>
	
	<query id="CoreComMSCPlineRSpec.getModelStyle" desc="查询产线">
		<![CDATA[
		 SELECT BASENAME,BASECODE FROM COM_BASE_INFO T WHERE T.SORTCODE = '4051' AND T.VALIDFLAG = '1'
		]]>
	</query>
	
	<query id="CoreComMSCPlineRSpec.IsReapt" desc="查询新增数据是否重复">
		<![CDATA[
		   
   SELECT 1
  FROM COM_MSC_PLINE_R_SPEC

  WHERE '&' || TRIM(PLINE_CODE) = '&' || ?
   AND '&' || TRIM(PASS_CODE) = '&' || ?
   AND '&' || TRIM(MODEL_CODE) = '&' || ?
   AND DECODE(?, NULL, '1', TRIM(MIN_D)) = DECODE(?, NULL, '1',TO_NUMBER(?))
   AND DECODE(?, NULL, TRIM(MIN_D), NULL) IS NULL
      
   AND DECODE(?, NULL, '1', TRIM(MAX_D)) = DECODE(?, NULL, '1',TO_NUMBER(?))
   AND DECODE(?, NULL, TRIM(MAX_D), NULL) IS NULL
      
   AND DECODE(?, NULL, '1', TRIM(MIN_H)) = DECODE(?, NULL, '1',TO_NUMBER(?))
   AND DECODE(?, NULL, TRIM(MIN_H), NULL) IS NULL
      
   AND DECODE(?, NULL, '1', TRIM(MAX_H)) = DECODE(?, NULL, '1',TO_NUMBER(?))
   AND DECODE(?, NULL, TRIM(MAX_H), NULL) IS NULL
   AND '&' || TRIM(WELL_CODE) = '&' || ?
   AND '&' || TRIM(SPEC_CODE) = '&' || ?
   AND '&' || TRIM(MODEL_STYLE) = '&' || ?
   AND '&' || TRIM(PROCESS_CDOE_C) = '&' || ?
   AND '&' || TRIM(PROCESS_STYLE) = '&' || ?

		   
		]]>
	</query>
	
	<query id="CoreComMSCPlineRSpec.IsReaptUpdate" desc="查询修改数据是否重复">
		<![CDATA[
	SELECT 1
  FROM COM_MSC_PLINE_R_SPEC

 WHERE '&' || TRIM(PLINE_CODE) = '&' || ?
   AND '&' || TRIM(PASS_CODE) = '&' || ?
   AND '&' || TRIM(MODEL_CODE) = '&' || ?
   AND DECODE(?, NULL, '1', TRIM(MIN_D)) = DECODE(?, NULL, '1',TO_NUMBER(?))
   AND DECODE(?, NULL, TRIM(MIN_D), NULL) IS NULL
      
   AND DECODE(?, NULL, '1', TRIM(MAX_D)) = DECODE(?, NULL, '1',TO_NUMBER(?))
   AND DECODE(?, NULL, TRIM(MAX_D), NULL) IS NULL
      
   AND DECODE(?, NULL, '1', TRIM(MIN_H)) = DECODE(?, NULL, '1',TO_NUMBER(?))
   AND DECODE(?, NULL, TRIM(MIN_H), NULL) IS NULL
      
   AND DECODE(?, NULL, '1', TRIM(MAX_H)) = DECODE(?, NULL, '1',TO_NUMBER(?))
   AND DECODE(?, NULL, TRIM(MAX_H), NULL) IS NULL
   AND '&' || TRIM(WELL_CODE) = '&' || ?
   AND '&' || TRIM(SPEC_CODE) = '&' || ?
   AND '&' || TRIM(MODEL_STYLE) = '&' || ?
   AND '&' || TRIM(PROCESS_CDOE_C) = '&' || ?
   AND '&' || TRIM(PROCESS_STYLE) = '&' || ?

   AND INDEX_SEQ != TO_NUMBER(?)
		]]>
	</query>
	
</queryMap>