<?xml version="1.0" encoding="UTF-8"?>
 
<queryMap desc="接箍钢级关联管理">
   <query id="CoreComBaseProessRStation.QueryProcess" desc="获取钢级代码、名称,已关联的条数">
		<![CDATA[ 
		 SELECT PROCESS_CDOE_C, PROCESS_DESC_C,
         PROCESS_CDOE, PROCESS_DESC
         FROM COM_BASE_PROCESS_C
         WHERE VALIDFLAG = '1'
		    
		]]>
	</query>
	<query id="CoreComBaseProessRStation.QueryStation" desc="工序点查询">
		<![CDATA[
SELECT 'TRUE' CHK,
       T2.STATION_CODE,
       A.STATION_DESC,
       T2.STATION_TYPE,
       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = T2.STATION_TYPE) STATION_TYPE_DESC,
       T2.STATION_ID,
       T2.PROCESS_CDOE AS PROCESS_CODE,
       T2.PROCESS_DESC,
       T2.COST,
       DECODE(T2.CHOOSE, '1', 'TRUE', 'FALSE') CHOOSE,
       DECODE(T2.RETURN_RESULT, '1', 'TRUE', 'FALSE') RETURN_RESULT,
       DECODE(T2.SEND_CHECKPLAN, '1', 'TRUE', 'FALSE') SEND_CHECKPLAN,
       T2.MONITOR_LV,
       T2.MONITOR_LV2,
       T2.MEMO
  FROM COM_BASE_PROCESS_R_STATION T2
  LEFT JOIN COM_BASE_STATION A
  ON A.STATION_CODE = T2.STATION_CODE
 WHERE T2.PROCESS_CDOE = ?
   AND T2.PROCESS_CDOE_C = ?
UNION
SELECT 'FALSE' CHK,
       STATION_CODE,
       STATION_DESC,
       STATION_TYPE,
       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = T1.STATION_TYPE) STATION_TYPE_DESC,
       STATION_ID,
       PROCESS_CODE,
       PROCESS_DESC,
       COST,
       DECODE(CHOOSE, '1', 'TRUE', 'FALSE') CHOOSE,
       DECODE(RETURN_RESULT, '1', 'TRUE', 'FALSE') RETURN_RESULT,
       DECODE(SEND_CHECKPLAN, '1', 'TRUE', 'FALSE') SEND_CHECKPLAN,
       MONITOR_LV,
       MONITOR_LV2,
       MEMO
  FROM COM_BASE_STATION T1
 WHERE T1.VALIDFLAG = '1'
   AND T1. PROCESS_CODE = ?
   AND T1.STATION_CODE NOT IN
       (SELECT STATION_CODE
          FROM COM_BASE_PROCESS_R_STATION
         WHERE PROCESS_CDOE = ?
           AND PROCESS_CDOE_C = ?)
		]]>
	</query> 
	
	<query id="CoreComBaseProessRStation.DELETE" desc="删除存在钢级代码、描述">
		<![CDATA[ 
		       DELETE FROM COM_BASE_PROCESS_R_STATION  T
		       WHERE T.PROCESS_CDOE=? AND T.PROCESS_CDOE_C=?
		]]>
	</query>
	
	<query id="CoreComBaseProessRStation.ADD" desc="添加钢级代码、描述">
		<![CDATA[ 
		      INSERT INTO COM_BASE_PROCESS_R_STATION
  (STATION_CODE,
   STATION_DESC,
   STATION_TYPE,
   STATION_ID,
   PROCESS_CDOE,
   PROCESS_DESC,
   PROCESS_CDOE_C,
   PROCESS_DESC_C,
   COST,
   CHOOSE,
   RETURN_RESULT,
   SEND_CHECKPLAN,
   MONITOR_LV,
   MONITOR_LV2,
   CREATE_NAME,
   CREATE_TIME,
   VALIDFLAG,
   MEMO)
   VALUES
   (?, ?, ?,?, ?,?,?,?, ?,?,?, ?,?, ?, ?,SYSDATE,'1', ?)
		]]>
	</query>
</queryMap>