<?xml version="1.0" encoding="UTF-8"?>
 
<queryMap desc="接箍钢级关联管理">
   <query id="JGRSteel.InitJGRSTEEL" desc="获取钢级代码、名称,已关联的条数">
		<![CDATA[ 
		SELECT T.STEELCODE, T.STEELNAME, COUNT(*) COLCOUNT
        FROM COM_BASE_STEEL T, COM_MSC_JG_R_STEEL T2
 		WHERE T.STEELCODE = T2.STEELCODE AND T.VALIDFLAG = '1' 
 		GROUP BY T.STEELCODE, T.STEELNAME
 		UNION
		SELECT T.STEELCODE, T.STEELNAME, 0 COLCOUNT
		FROM COM_BASE_STEEL T
		WHERE T.STEELCODE NOT IN
 		(SELECT STEELCODE FROM COM_MSC_JG_R_STEEL WHERE VALIDFLAG = '1')
		]]>
	</query>
	<query id="JGRSteel.QUERY" desc="接箍钢级关联查询">
		<![CDATA[
        SELECT 'TRUE' CHK,
        T2.STEELCODE,T2.STEELCODE_DESC,T2.STEELCODE_JG,T2.STEELCODE_JG_DESC,T2.CREATE_NAME,
        TO_CHAR(T2.CREATE_TIME,'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
        T2.UPDATE_NAME,
        TO_CHAR(T2.UPDATE_TIME,'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
        T2.DELETE_NAME,
        TO_CHAR(T2.DELETE_TIME,'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
        T2.VALIDFLAG ,T2.MEMO       
        FROM  COM_MSC_JG_R_STEEL T2 
        WHERE T2.STEELCODE=?   
        UNION 
        SELECT 'FALSE' CHK,
        T1.STEELCODE,T1.STEELNAME,T1.STEELCODE STEELCODE_JG,T1.STEELNAME STEELCODE_JG_DESC,'' CREATE_NAME,NULL CREATE_TIME,
        '' UPDATE_NAME,NULL UPDATE_TIME,'' DELETE_NAME,NULL DELETE_TIME
        , '' VALIDFLAG ,'' MEMO       
        FROM    COM_BASE_STEEL T1  
        WHERE   T1.VALIDFLAG='1'  AND T1.STEELCODE NOT IN
        (SELECT STEELCODE_JG FROM COM_MSC_JG_R_STEEL WHERE STEELCODE=?)
		]]>
	</query> 
	
	<query id="JGRSteel.DELETE" desc="删除存在钢级代码、描述">
		<![CDATA[ 
		       DELETE FROM COM_MSC_JG_R_STEEL  T
		       WHERE T.STEELCODE=?
		]]>
	</query>
	
	<query id="JGRSteel.ADD" desc="添加钢级代码、描述">
		<![CDATA[ 
		      INSERT INTO COM_MSC_JG_R_STEEL
		        (  STEELCODE
                  ,STEELCODE_JG
                  ,STEELCODE_DESC
                  ,STEELCODE_JG_DESC
                  ,CREATE_NAME
                  ,CREATE_TIME
                  ,MEMO
                 ) VALUES
                 (?,?,?,?,?,SYSDATE,?)
		]]>
	</query>
</queryMap>