<?xml version="1.0" encoding="UTF-8"?>
 
<queryMap desc="模铸与连铸对应管理">


<query id="CoreMscCastRForg.GetSpec" desc="删除存在钢级代码、描述">
		<![CDATA[ 
		      SELECT SPEC_CODE,SPEC_NAME,
		      DECODE(MSC_STYLE,'A','钢管','B','管坯','C','其他','D','钢锭') MSC_STYLE,
		      CREATE_NAME,
		      TO_CHAR(CREATE_TIME,'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
		      UPDATE_NAME,
		      TO_CHAR(UPDATE_TIME,'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME
		      FROM COM_BASE_SPEC 
		      WHERE MSC_STYLE='B'
		      AND VALIDFLAG='1'
		      AND DECODE('#SPEC_CODE#', NULL, '1', SPEC_CODE) = DECODE('#SPEC_CODE#', NULL, '1', '#SPEC_CODE#')
		]]>
	</query>
	
   <query id="CoreMscCastRForg.GetSpecB" desc="获取钢级代码、名称,已关联的条数">
		<![CDATA[ 
		 SELECT  
       'TRUE' CHK,
       SPEC_CODE,
       SPEC_NAME,
       CREATE_NAME,
		   TO_CHAR(CREATE_TIME,'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
		   UPDATE_NAME,
		   TO_CHAR(UPDATE_TIME,'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME
       
       FROM COM_MSC_CAST_R_FORG T
        WHERE T.SPEC_CODE_FORG= ? AND T.SPEC_CODE !=' '
       UNION
       SELECT  
      'FALSE' CHK,
      SPEC_CODE,
       SPEC_NAME,
      CREATE_NAME,
	  TO_CHAR(CREATE_TIME,'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
	  UPDATE_NAME,
	  TO_CHAR(UPDATE_TIME,'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME
  
     FROM COM_BASE_SPEC T1
     WHERE T1.VALIDFLAG='1'  AND T1.MSC_STYLE='B'
     AND T1.SPEC_CODE NOT IN
     (SELECT T2.SPEC_CODE FROM COM_MSC_CAST_R_FORG T2 WHERE T2.SPEC_CODE_FORG= ?)
		 
		]]>
	</query>
	
	 <query id="CoreMscCastRForg.GetSpecD" desc="获取钢级代码、名称,已关联的条数">
		<![CDATA[ 
		 SELECT ID_,
       'TRUE' CHK,
       SPEC_CODE_INGOT SPEC_CODE,
       SPEC_NAME_INGOT SPEC_NAME,
      
       CREATE_NAME,
	   TO_CHAR(CREATE_TIME,'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
	   UPDATE_NAME,
	   TO_CHAR(UPDATE_TIME,'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME
       
       FROM COM_MSC_CAST_R_FORG T 
       WHERE T.SPEC_CODE_FORG= ?  AND T.SPEC_CODE_INGOT !=' '
       UNION
       SELECT '' ID_,
       'FALSE' CHK,
       SPEC_CODE,
       SPEC_NAME,
       CREATE_NAME,
       TO_CHAR(CREATE_TIME,'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       UPDATE_NAME,
       TO_CHAR(UPDATE_TIME,'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME
  
       FROM COM_BASE_SPEC T1
       WHERE T1.VALIDFLAG='1'  AND T1.MSC_STYLE='D'
       AND T1.SPEC_CODE NOT IN
       (SELECT T2.SPEC_CODE_INGOT FROM COM_MSC_CAST_R_FORG T2 WHERE T2.SPEC_CODE_FORG=?)
		 
		]]>
	</query>
	
 
	
	<query id="CoreMscCastRForg.DELETE" desc="删除存在钢级代码、描述">
		<![CDATA[ 
		       DELETE FROM COM_MSC_CAST_R_FORG  T
		       WHERE T.SPEC_CODE_FORG=?
		]]>
	</query>
	
	<query id="CoreMscCastRForg.ADD" desc="添加钢级代码、描述">
		<![CDATA[ 
		  INSERT INTO COM_MSC_CAST_R_FORG
          (ID_,
           SPEC_CODE_FORG,
           SPEC_NAME_FORG,
           SPEC_CODE_INGOT,
           SPEC_NAME_INGOT,
           SPEC_CODE,
           SPEC_NAME,
           CREATE_NAME,
           CREATE_TIME)
           VALUES (?,?,?,?,?,?,?,?,SYSDATE)
		      
		]]>
	</query>
</queryMap>