<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="权限功能表查询">

   <query id="CoreControlPointBasics.cancelGrouping" desc="获取顺序号最大值">
		<![CDATA[
			update COM_BASE_STATION set MONITOR_LV2='' where STATION_CODE=?
		]]>
	</query>
	
	<query id="CoreControlPointBasics.doGrouping" desc="获取顺序号最大值">
		<![CDATA[
			update COM_BASE_STATION set MONITOR_LV2=? where STATION_CODE=?
		]]>
	</query>
	
	<query id="CoreControlPointBasics.GetMaxGrouping" desc="获取顺序号最大值">
		<![CDATA[
			SELECT MAX(TO_NUMBER(MONITOR_LV2)) FROM COM_BASE_STATION
		]]>
	</query>

	<query id="CoreControlPointBasics.GetMaxStation" desc="获取顺序号最大值">
		<![CDATA[
			select max(STATION_ID) from COM_BASE_STATION
		]]>
	</query>
	
	<query id="CoreControlPointBasics.GetMaxCode" desc="获取代码最大值">
		<![CDATA[
			select max(STATION_CODE) from COM_BASE_STATION
		]]>
	</query>
	
	<query id="CoreControlPointBasics.GetName" desc="判断描述是否存在">
		<![CDATA[
			select STATION_DESC from COM_BASE_STATION where STATION_DESC=?
		]]>
	</query>

	<query id="CoreControlPointBasics.GetMonitorLv" desc="获取监制级别">
		<![CDATA[
			select BASECODE,BASENAME from com_base_info 
			where sortcode='4033' AND VALIDFLAG='1'
			order by BASECODE
		]]>
	</query>

	<query id="CoreControlPointBasics.GetProcess" desc="获取工序代码和描述">
		<![CDATA[
			select PROCESS_CODE, PROCESS_DESC 
			from COM_BASE_PROCESS 
            WHERE VALIDFLAG='1'
			order by PROCESS_CODE
		]]>
	</query>

	<query id="CoreControlPointBasics.GetPointType" desc="获取工序点代码和描述">
		<![CDATA[
			select BASECODE,BASENAME from com_base_info 
			where sortcode='4032' AND VALIDFLAG='1'
			order by BASECODE
		]]>
	</query>

	<query id="CoreControlPointBasics.QUERY" desc="权限功能">
		<![CDATA[
			SELECT  'FALSE' CHK,
					T.STATION_CODE,
				    T.STATION_DESC,
				    A.BASENAME STATION_TYPE,
				    A.BASECODE STATION_TYPE_CODE,
					T.STATION_ID,
					T.PROCESS_CODE,
					T.PROCESS_DESC,
					T.COST,
					T.CHOOSE,
					decode(T.CHOOSE,'1','是','否') CHOOSENAME,
					T.RETURN_RESULT,
					decode(T.RETURN_RESULT,'1','是','否') RETURN_RESULTNAME,
					T.SEND_CHECKPLAN,
					decode(T.SEND_CHECKPLAN,'1','是','否') SEND_CHECKPLANNAME,
					decode(T.COST_POINT,'1','是','否') COST_POINT,
					T.MONITOR_LV,
					T.MONITOR_LV2,
					T.CREATE_NAME,
					TO_CHAR(T.CREATE_TIME,'yyyy-mm-dd hh24:mi:ss') CREATE_TIME,
					T.UPDATE_NAME,
					TO_CHAR(T.UPDATE_TIME,'yyyy-mm-dd hh24:mi:ss') UPDATE_TIME,
					T.DELETE_NAME,
					TO_CHAR(T.DELETE_TIME,'yyyy-mm-dd hh24:mi:ss') DELETE_TIME,
					T.VALIDFLAG,
					decode(T.VALIDFLAG,'1','有效','无效') VALIDFLAGNAME,
					T.MEMO
				FROM COM_BASE_STATION T
				LEFT JOIN COM_BASE_INFO A ON A.BASECODE = T.STATION_TYPE
				   WHERE t.VALIDFLAG in ('1' , ?)
				   AND lower(t.STATION_DESC)||'&' LIKE '%' || lower(?) || '%'
				   AND DECODE(?, NULL, '1', T.STATION_TYPE) = DECODE(?, NULL, '1', ?)
				   ORDER BY STATION_CODE

		]]>
	</query>
	<query id="CoreControlPointBasics.ADD" desc="新增">
		<![CDATA[
			 INSERT INTO COM_BASE_STATION
							(STATION_CODE,
					        STATION_DESC,
					        STATION_TYPE,
					       
					        PROCESS_CODE,
					        PROCESS_DESC,
							COST,
							CHOOSE,
							RETURN_RESULT,
							SEND_CHECKPLAN,
							MONITOR_LV,
							STATION_ID,
					        CREATE_NAME,
					        CREATE_TIME,
					        VALIDFLAG,
					        MEMO,COST_POINT)
							VALUES(UPPER(?),?,?,?,?,
							?,?,?,?,?,?,
							?,SYSDATE,
							'1',?,?)
							
			  
		]]>
	</query>
	<query id="CoreControlPointBasics.MODIFY" desc="修改">
		<![CDATA[
			 UPDATE COM_BASE_STATION set
			 				STATION_CODE=?,
							STATION_DESC=?, 
							STATION_TYPE=?, 
							PROCESS_CODE = ?,
							PROCESS_DESC = ?,
							COST=?,
							CHOOSE=?,
							RETURN_RESULT=?,
							SEND_CHECKPLAN=?,
							MONITOR_LV=?,
							UPDATE_NAME=?, 
							UPDATE_TIME=SYSDATE,
							MEMO=?,
							STATION_ID = ?,
							COST_POINT = ?
							WHERE STATION_CODE=?
		]]>
	</query>
	
	<query id="CoreControlPointBasics.updateProcessCRStation" desc="修改工序点与二级工序关系">
		<![CDATA[
UPDATE COM_BASE_PROCESS_R_STATION T
   SET T.STATION_ID = '#STATION_ID#'
 WHERE T.STATION_CODE = '#STATION_CODE#'
		]]>
	</query>
	
	<query id="CoreControlPointBasics.DELETE" desc="作废">
		<![CDATA[
			 UPDATE COM_BASE_STATION T
			   SET T.DELETE_NAME = ?, T.DELETE_TIME = SYSDATE, T.VALIDFLAG = '0'
			 WHERE T.STATION_CODE = ?
		]]>
	</query>
	
	<query id="CoreControlPointBasics.RESUME" desc="恢复">
		<![CDATA[
			UPDATE COM_BASE_STATION T
               SET T.DELETE_NAME = '', T.DELETE_TIME = '', T.VALIDFLAG = '1'
             WHERE T.STATION_CODE = ?
		]]>
	</query>
	
	<query id="CoreControlPointBasics.IsExistStationId" desc="是否存在工序点顺序号">
		<![CDATA[
			SELECT COUNT(1) FROM com_base_station T WHERE T.STATION_ID = ?
		]]>
	</query>
	
	<query id="CoreControlPointBasics.IsExistStationCode" desc="是否存在工序点编码（修改）">
		<![CDATA[
			SELECT COUNT(1) FROM com_base_station T WHERE T.STATION_CODE != ? AND T.STATION_CODE = ?
		]]>
	</query>
	
	<query id="CoreControlPointBasics.IsExistStationCode2" desc="是否存在工序点编码(新增)">
		<![CDATA[
			SELECT COUNT(1) FROM com_base_station T WHERE T.STATION_CODE = ?
		]]>
	</query>
	
</queryMap>