<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="外购坯查询等业务操作    ">
	<query id="GlOrderManage.doQuery" desc="获取管坯采购需求清单">
	<![CDATA[
       		SELECT  T1.ORD_PK,T1.ORDER_NO,T1.GL_ORDER_NO,T1.TRADE_TYPE,T1.ORDER_TYP,T1.ORDER_TYP_DESC,
				T1.ORDER_YEAR,T1.SIGN_ADDRESS,T1.SUPPLY_UNIT,T1.CUSTOMER_NO,T1.CUSTOMER_NM,
				T1.STLMT_UNIT_NO,T1.STLMT_UNIT_NM,T1.RECEIV_NO,T1.RECEIV_NM,TO_CHAR(T1.SIGN_DATE,'YYYY/MM/DD') SIGN_DATE,
				T1.DELVRY_ADDR,T1.DELVRY_TYPE,T1.TRANSIT_TYPE,T1.PACK_TYPE,T1.MNY_ASK_DESC,
				T1.MNY_ASK_TYP,T1.LOCAL_LAW,T1.LOCAL_ORHER,T1.LOCAL_ZY,T1.ORHER_INFO,
				T1.ORDER_SPECIAL_DESC,T1.MEMO,T1.CREATE_NAME,T1.CREATE_DEPT,T1.CREATE_TIME,
				T1.VALIDFLAG,T1.APPROVALFLAG,T2.APPROVAL_NO,T2.APPROVAL_DESC
             FROM  SLM_GL_ORDER_HEAD T1
             LEFT JOIN SLM_GL_APPROVAL T2
             ON  T1.APPROVAL_NO=T2.APPROVAL_NO         
             WHERE  ORDER_NO ||'&' LIKE '%' || ? || '%' 
             AND CREATE_TIME>=TO_DATE(?,'YYYY-MM-DD HH24:MI:SS') 
             AND CREATE_TIME <=TO_DATE(?,'YYYY-MM-DD HH24:MI:SS') 
             AND VALIDFLAG != '00'
		]]>
	</query>
	
		<query id="GlOrderManage.QueryByOrdPk" desc="获取管坯采购需求清单">
	<![CDATA[
       		SELECT  T1.ORD_PK,T1.ORDER_NO,T1.GL_ORDER_NO,T1.TRADE_TYPE,T1.ORDER_TYP,T1.ORDER_TYP_DESC,
				T1.ORDER_YEAR,T1.SIGN_ADDRESS,T1.SUPPLY_UNIT,T1.CUSTOMER_NO,T1.CUSTOMER_NM,
				T1.STLMT_UNIT_NO,T1.STLMT_UNIT_NM,T1.RECEIV_NO,T1.RECEIV_NM,TO_CHAR(T1.SIGN_DATE,'YYYY/MM/DD') SIGN_DATE,
				T1.DELVRY_ADDR,T1.DELVRY_TYPE,T1.TRANSIT_TYPE,T1.PACK_TYPE,T1.MNY_ASK_DESC,
				T1.MNY_ASK_TYP,T1.LOCAL_LAW,T1.LOCAL_ORHER,T1.LOCAL_ZY,T1.ORHER_INFO,
				T1.ORDER_SPECIAL_DESC,T1.MEMO,T1.CREATE_NAME,T1.CREATE_DEPT,T1.CREATE_TIME,
				T1.VALIDFLAG
             FROM  SLM_GL_ORDER_HEAD T1     
             WHERE  T1.ORD_PK = ? 
		]]>
	</query>
	
	<query id="GlOrderManage.doQueryLine" desc="获取合同行主信息">
		<![CDATA[
		  SELECT ORD_PK, ORD_LN_PK, ORDER_SEQ, PSC, PSC_DESC,
			     PRODUCCODE, PRODUCNAME, STD_CODE, STD_NAME, STEELCODE, STEELNAME,GRADECODE,GRADENAME,
			     ORDER_SPEC_CODE, ORDER_SPEC_DESC, SPEC_CODE, SPEC_NAME, LEN_DESC, LEN_UNIT, LEN_MIN,
			     LEN_MAX, ORDER_UNIT, ORDER_QTY, DELVRY_RANGE_TPE, DELVRY_RANGE_MIN,
			     DELVRY_RANGE_MAX, STD_STYLE,STD_STYLE_DESC,PRODUCER_FL,
			     TO_CHAR (DELVRY_EDATE, 'YYYY-MM-DD') DELVRY_EDATE, 
			     ORDER_PRICE, TRANS_PRICE,  OUT_PRICE, BALNCE_PRICE,BALNCE_TOL_PRICE,
			     MEMO,VALIDFLAG, CREATE_NAME, CREATE_TIME, UPDATE_NAME, UPDATE_TIME,
			     DELETE_NAME, DELETE_TIME, 
			        '(-'
			     || TO_CHAR (DELVRY_RANGE_MIN)
			     || DECODE (DELVRY_RANGE_TPE, '%', '%', ORDER_UNIT)
			     || ','
			     || TO_CHAR (DELVRY_RANGE_MAX)
			     || DECODE (DELVRY_RANGE_TPE, '%', '%', ORDER_UNIT)
			     || ')' MIN_MAX_TPE,
			     PRO_ORDER_NO,PRO_PLAN_ID,DIMATER,HEIGHT,ORDER_COUNT,PLN_ORDER_NO,
			     PROD_STANDARD,OUTPUT_STANDARD,CRAFT_NO
			FROM SLM_GL_ORDER_line LE WHERE ORD_PK = ? AND VALIDFLAG='10' 
		]]>
	</query>

	<query id="GlOrderManage.getFilePath" desc="获取路径">
		<![CDATA[
  SELECT  B.CRAFT_PATH
  FROM CRAFT_ORD_DESIGN B
 WHERE B.CRAFT_NO=?
		]]>
	</query>
	
	<query id="GlOrderManage.doQueryMould" desc="获取管坯采购需求清单">
	<![CDATA[
       		SELECT  MOULD_NO,MOULD_NAME,TRADE_TYPE,ORDER_TYP,ORDER_TYP_DESC,
					ORDER_YEAR,SIGN_ADDRESS,SUPPLY_UNIT,CUSTOMER_NO,CUSTOMER_NM,
					STLMT_UNIT_NO,STLMT_UNIT_NM,RECEIV_NO,RECEIV_NM,SIGN_DATE,
					DELVRY_ADDR,DELVRY_TYPE,TRANSIT_TYPE,PACK_TYPE,MNY_ASK_DESC,
					MNY_ASK_TYP,LOCAL_LAW,LOCAL_ORHER,LOCAL_ZY,ORHER_INFO,
					ORDER_SPECIAL_DESC,MEMO
             FROM  SLM_GL_ORDER_MOULD          
		]]>
	</query>
	
		<query id="GlOrderManage.doAdd" desc="">
		<![CDATA[
				INSERT INTO SLM_GL_ORDER_HEAD(
					            ORD_PK,ORDER_NO,GL_ORDER_NO,TRADE_TYPE,ORDER_TYP,ORDER_TYP_DESC,
								ORDER_YEAR,SIGN_ADDRESS,SUPPLY_UNIT,CUSTOMER_NO,CUSTOMER_NM,
								STLMT_UNIT_NO,STLMT_UNIT_NM,RECEIV_NO,RECEIV_NM,SIGN_DATE,
								DELVRY_ADDR,DELVRY_TYPE,TRANSIT_TYPE,PACK_TYPE,MNY_ASK_DESC,
								MNY_ASK_TYP,LOCAL_LAW,LOCAL_ORHER,LOCAL_ZY,ORHER_INFO,
								ORDER_SPECIAL_DESC,MEMO,CREATE_NAME,CREATE_DEPT,CREATE_TIME,
								VALIDFLAG
								) 
					            VALUES
					            (?,?,?,?,?,?,
					            ?,?,?,?,?,
					            ?,?,?,?,TO_DATE(?,'YYYY/MM/DD'),
					            ?,?,?,?,?,
					            ?,?,?,?,?,
					            ?,?,?,?,SYSDATE,
					            '10')
					          
		]]>
	</query>
	
			<query id="GlOrderManage.doUpdate" desc="">
		<![CDATA[
		UPDATE SLM_GL_ORDER_HEAD SET 
			ORDER_NO = ?,
			GL_ORDER_NO = ?,
			TRADE_TYPE = ?,
			ORDER_TYP = ?,
			ORDER_TYP_DESC = ?,
			ORDER_YEAR = ?,
			SIGN_ADDRESS = ?,
			SUPPLY_UNIT = ?,
			CUSTOMER_NO = ?,
			CUSTOMER_NM = ?,
			STLMT_UNIT_NO = ?,
			STLMT_UNIT_NM = ?,
			RECEIV_NO = ?,
			RECEIV_NM = ?,
			SIGN_DATE = TO_DATE(?,'YYYY/MM/DD'),
			DELVRY_ADDR = ?,
			DELVRY_TYPE = ?,
			TRANSIT_TYPE = ?,
			PACK_TYPE = ?,
			MNY_ASK_DESC = ?,
			MNY_ASK_TYP = ?,
			LOCAL_LAW = ?,
			LOCAL_ORHER = ?,
			LOCAL_ZY = ?,
			ORHER_INFO = ?,
			ORDER_SPECIAL_DESC = ?,
			MEMO = ?,
			UPDATE_NAME = ?,
			UPDATE_TIME = SYSDATE
			WHERE ORD_PK=?
		]]>
	</query>
	
		<query id="GlOrderManage.QueryInList" desc="获取管坯采购需求清单">
	<![CDATA[
       		select T.JUDGE_STOVE_NO,T.BATCH_NO,t.BATCH_GROUD_NO,T.MATERIAL_NO,T.MATERIAL_NAME,T.PRODUCCODE,
       		T.PRODUCNAME,T.STD_CODE,T.STD_NAME,T.GRADECODE,T.GRADENAME,T.STEELCODE,
       		T.STEELNAME,T.STD_STYLE,T.STD_STYLE_DESC,T.SPEC_CODE,T.SPEC_NAME,
       		SUM(T.ACT_LEN)ACT_LEN,MIN(T.ACT_LEN_MIN)ACT_LEN_MIN,MAX(T.ACT_LEN_MAX)ACT_LEN_MAX,
       		SUM(T.ACT_COUNT)ACT_COUNT,SUM(T.ACT_WEIGHT)ACT_WEIGHT,'2' TYPE_FLAG
       		 from YDM_BC_INLIST t
             WHERE  JUDGE_STOVE_NO ||'&' LIKE '%' || ? || '%' 
             AND PRODUCNAME ||'&' LIKE '%' || ? || '%' 
             AND SPEC_NAME ||'&' LIKE '%' || ? || '%' 
             and t.instock_type_code='800703' 
             AND INSTOCK_TIME>=TO_DATE(?,'YYYY-MM-DD HH24:MI:SS') 
             AND INSTOCK_TIME <=TO_DATE(?,'YYYY-MM-DD HH24:MI:SS') 

             GROUP BY T.JUDGE_STOVE_NO,T.BATCH_NO,t.BATCH_GROUD_NO,T.MATERIAL_NO,T.MATERIAL_NAME,T.PRODUCCODE,
       		T.PRODUCNAME,T.STD_CODE,T.STD_NAME,T.GRADECODE,T.GRADENAME,T.STEELCODE,
       		T.STEELNAME,T.STD_STYLE,T.STD_STYLE_DESC,T.SPEC_CODE,T.SPEC_NAME
		]]>
	</query>
	
			<query id="GlOrderManage.QueryGpList" desc="获取管坯采购需求清单">
	<![CDATA[
       		select T.JUDGE_STOVE_NO,T.MATERIAL_NO,T.MATERIAL_NAME,T.MATERIAL_NO PRODUCCODE,
           T.MATERIAL_NAME PRODUCNAME,T.STD_CODE,T.STD_NAME,T.GRADECODE,T.GRADENAME,T.DIMATER SPEC_NAME,
           SUM(T.ACT_LEN)ACT_LEN,
           SUM(T.ACT_COUNT)ACT_COUNT,SUM(T.ACT_WEIGHT)ACT_WEIGHT,'1' TYPE_FLAG
            from YDM_GP_INLIST t
             WHERE  JUDGE_STOVE_NO ||'&' LIKE '%' || ? || '%' 
             AND PRODUCNAME ||'&' LIKE '%' || ? || '%' 
             AND DIMATER ||'&' LIKE '%' || ? || '%' 
             and t.instock_type_code='800703' 
             AND INSTOCK_TIME>=TO_DATE(?,'YYYY-MM-DD HH24:MI:SS') 
             AND INSTOCK_TIME <=TO_DATE(?,'YYYY-MM-DD HH24:MI:SS') 
			GROUP BY T.JUDGE_STOVE_NO,T.MATERIAL_NO,T.MATERIAL_NAME,T.STD_CODE,T.STD_NAME,T.GRADECODE,T.GRADENAME,t.DIMATER
		]]>
	</query>
	
		<query id="GlOrderManage.GetGlOrderLinePk" desc="合同行新增时LnPk">
		<![CDATA[
    SELECT ? || LPAD(TO_NUMBER(NVL(MAX(SUBSTR(ORD_LN_PK, 33, 3)), '0')) + 1,
                   3,
                   '0')
  
    FROM Slm_Gl_Order_Line
    WHERE ORD_PK = ?

		]]>
	</query>
	
		
	
	<query id="GlOrderManage.updateInLIst" desc="利库修改材料状态信息">
	<![CDATA[
	  UPDATE Ydm_Bc_Inlist T
   SET T.BILL_NO         = '#ORD_LN_PK#'
    WHERE 
    T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
    AND T.BATCH_NO = '#BATCH_NO#'
    AND T.BATCH_GROUD_NO = '#BATCH_GROUD_NO#'
    AND T.instock_type_code = '800703'

	]]>
    </query>
    
    <query id="GlOrderManage.updateGpLIst" desc="利库修改材料状态信息">
	<![CDATA[
	  UPDATE YDM_GP_INLIST T
   SET T.GL_ORD_LN_PK         = '#ORD_LN_PK#'
    WHERE 
    T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
    AND T.instock_type_code = '800703'

	]]>
    </query>
    
    <query id="GlOrderManage.deleteInLIst" desc="利库修改材料状态信息">
	<![CDATA[
	  UPDATE Ydm_Bc_Inlist T
   SET T.BILL_NO = null
    WHERE T.BILL_NO=?
	]]>
    </query>
    
    <query id="GlOrderManage.deleteGpLIst" desc="利库修改材料状态信息">
	<![CDATA[
	  UPDATE YDM_GP_INLIST T
   SET T.GL_ORD_LN_PK = null
    WHERE T.GL_ORD_LN_PK=?
	]]>
    </query>
	
	<query id="GlOrderManage.getGlOrderHeadStatus" desc="合同头状态">
		<![CDATA[
	     SELECT VALIDFLAG 
	     FROM SLM_GL_ORDER_HEAD 
	     WHERE ORD_PK  = ?
				
		]]>
	</query>
	
		<query id="GlOrderManage.getGlApproveStatus" desc="合同头状态">
		<![CDATA[
	     SELECT APPROVALFLAG 
	     FROM SLM_GL_ORDER_HEAD 
	     WHERE ORD_PK  = ?
				
		]]>
	</query>
	
	<query id="GlOrderManage.getGlOrderLinePrice" desc="合同头状态">
		<![CDATA[
	     SELECT  COUNT(1) 
	     FROM SLM_GL_ORDER_LINE 
	     WHERE ORD_PK  = ?
		 AND VALIDFLAG='10'
		 AND BALNCE_TOL_PRICE IS NOT NULL
		]]>
	</query>
	
		<query id="GlOrderManage.getGlOrderLineCount" desc="合同头状态">
		<![CDATA[
	     SELECT  COUNT(1) 
	     FROM SLM_GL_ORDER_LINE 
	     WHERE ORD_PK  = ?
		 AND VALIDFLAG='10'
		]]>
	</query>
	
	<query id="GlOrderManage.deleteLine" desc="合同头状态">
		<![CDATA[
	     UPDATE Slm_Gl_Order_Line T
	     SET T.VALIDFLAG ='00'
	     WHERE ORD_LN_PK  = ?
				
		]]>
	</query>
	
	<query id="GlOrderManage.deleteLineByOrdPk" desc="合同头状态">
		<![CDATA[
	     UPDATE Slm_Gl_Order_Line T
	     SET T.VALIDFLAG ='00'
	     WHERE ORD_PK  = ?
				
		]]>
	</query>
	
		<query id="GlOrderManage.deleteHead" desc="合同头状态">
		<![CDATA[
	     UPDATE SLM_GL_ORDER_HEAD T
	     SET T.VALIDFLAG ='00'
	     WHERE ORD_PK  = ?
				
		]]>
	</query>
	
	<query id="GlOrderManage.doSavePrice" desc="合同头状态">
		<![CDATA[
	     UPDATE SLM_GL_ORDER_LINE T
	     SET T.BALNCE_PRICE =?,
	     T.BALNCE_TOL_PRICE=?
	     WHERE ORD_LN_PK  = ?
				
		]]>
	</query>
	
		<query id="GlOrderManage.doConfirm" desc="合同头状态">
		<![CDATA[
	     UPDATE SLM_GL_ORDER_HEAD T
	     SET T.VALIDFLAG ='20',
	     APPROVALFLAG ='00'
	     WHERE ORD_PK  = ?	
		]]>
	</query>
	
		<query id="GlOrderManage.cancelConfirm" desc="合同头状态">
		<![CDATA[
	     UPDATE SLM_GL_ORDER_HEAD T
	     SET T.VALIDFLAG ='10'
	     WHERE ORD_PK  = ?	
		]]>
	</query>
	
		<query id="GlOrderManage.doApprove" desc="合同头状态">
		<![CDATA[
	     UPDATE SLM_GL_ORDER_HEAD T
	     SET T.APPROVAL_NO = ?,
	     T.APPROVALFLAG =?,
	     T.VALIDFLAG = ?
	     WHERE ORD_PK  = ?	
		]]>
		</query>
		
		<query id="GlOrderManage.doReturn" desc="合同头状态">
		<![CDATA[
	     UPDATE SLM_GL_ORDER_HEAD T
	     SET T.APPROVAL_NO = NULL,
	     T.APPROVALFLAG ='00',
	     T.VALIDFLAG = '20'
	     WHERE ORD_PK  = ?	
		]]>
		</query>
	
		<query id="GlOrderManage.getMouldNo" desc="生成变更单号">
	<![CDATA[
	
	  SELECT 'MD' || LPAD(TO_NUMBER(NVL(MAX(SUBSTR(MOULD_NO, 3, 5)), '0')) + 1,
            5,
            '0') MOULD
        FROM SLM_GL_ORDER_MOULD
	
	]]>
	</query>
	
	<query id="GlOrderManage.getApproveNo" desc="生成变更单号">
	<![CDATA[
	
	  SELECT 'RE' || ? ||
        LPAD(TO_NUMBER(NVL(MAX(SUBSTR(APPROVAL_NO, 9, 5)), '0')) + 1,
            5,
            '0')
        FROM SLM_GL_APPROVAL
        WHERE SUBSTR(APPROVAL_NO, 3, 6) = ?
	
	]]>
	</query>
	
		<query id="GlOrderManage.getMouldCount" desc="生成变更单号">
	<![CDATA[
	
	  SELECT count(1) from  SLM_GL_ORDER_MOULD  where MOULD_NAME= ?
	
	]]>
	</query>
	
	<query id="GlOrderManage.doSaveModel" desc="">
		<![CDATA[
				INSERT INTO SLM_GL_ORDER_MOULD(
					            MOULD_NO,MOULD_NAME,TRADE_TYPE,ORDER_TYP,ORDER_TYP_DESC,
								ORDER_YEAR,SIGN_ADDRESS,SUPPLY_UNIT,CUSTOMER_NO,CUSTOMER_NM,
								STLMT_UNIT_NO,STLMT_UNIT_NM,RECEIV_NO,RECEIV_NM,SIGN_DATE,
								DELVRY_ADDR,DELVRY_TYPE,TRANSIT_TYPE,PACK_TYPE,MNY_ASK_DESC,
								MNY_ASK_TYP,LOCAL_LAW,LOCAL_ORHER,LOCAL_ZY,ORHER_INFO,
								ORDER_SPECIAL_DESC,MEMO
								) 
					            VALUES
					            (?,?,?,?,?,
					            ?,?,?,?,?,
					            ?,?,?,?,TO_DATE(?,'YYYY/MM/DD'),
					            ?,?,?,?,?,
					            ?,?,?,?,?,
					            ?,?)
					          
		]]>
	</query>


	<query id="GlOrderManage.insertApprove" desc="">
		<![CDATA[
				INSERT INTO SLM_GL_APPROVAL(
					            APPROVAL_NO,
					            APPROVAL_RESULT,
					            APPROVAL_DESC,
					            APPROVAL_MANID,
					            APPROVAL_NAME,
								APPROVAL_ETIME,
								ORD_PK
								) 
					            VALUES
					            (?,
					            ?,
					            ?,
					            ?,
					            ?,
					            SYSDATE,
					            ?)
					          
		]]>
	</query>
	
		<query id="GlOrderManage.deleteApprove" desc="">
		<![CDATA[
				DELETE SLM_GL_APPROVAL
			WHERE ORD_PK= ?
					          
		]]>
	</query>
	
	<query id="GlOrderManage.QueryPlnOrderInfoSale" desc="获取管坯采购需求清单">
	<![CDATA[
       		SELECT T1.*,(SELECT L.PRODUCER_FL FROM SLM_ORDER_LINE L WHERE T1.ORD_LN_DLY_PK LIKE L.ORD_LN_PK||'%') PRODUCER_FL,
       		T2.PRODUCCODE,
	        T2.PRODUCNAME
	        --T2.SPEC_CODE,
	        --T2.SPEC_NAME
       		 FROM (SELECT '轧管' PROCESS,
       		   T.GPREQ_ID PRO_ORDER_NO,
	           T.PRO_PLAN_ID,
	           T.ORDER_NO || '/' || T.ORDER_SEQ PLN_ORDER_NO,
	           --T.STEELCODE,
	           --T.STEELNAME,
	           T.GRADECODE,
	           T.GRADENAME,
	           T.PLINE_NAME,
	           T.DIAMETER_GP SPEC_NAME,
	           to_char(T.AIMOUTDIAMETER) OUTDIAMETER,
	           to_char(T.AIMWALLTHICK) WALLTHICK,
	           T.LENGTHDISC,
	           T.INWL_ID OUTWL_ID,
	           T.INWL_DESC OUTWL_DESC,
	           SUM(T.GPREQ_WEIGHT) WEIGTH_S,
	           SUM(T.GPREQ_NUM) NUM_S,
	           MAX(T.ORD_LN_DLY_PK) ORD_LN_DLY_PK
	      FROM PLN_ORDER_ZG_S T
	     WHERE T.GPREQ_ID IS NOT NULL
		 
         AND T.PLINE_CODE='C072'
         AND T.ORDER_NO || '/' || T.ORDER_SEQ LIKE '%'|| ? ||'%'
         AND T.IS_PLAN_OK='1'
         --AND T.EXE_STATUS='0'
         AND T.OUTS_BILLET_FL='0'
         AND NOT EXISTS (SELECT 1
          FROM SLM_GL_ORDER_LINE A,
          SLM_GL_ORDER_HEAD B
         WHERE A.ORD_PK=B.ORD_PK
         AND A.PRO_PLAN_ID = T.PRO_PLAN_ID
         AND A.VALIDFLAG = '10'
         AND B.VALIDFLAG !='00'
         AND B.TRADE_TYPE='122301' )
         GROUP BY T.PRO_PLAN_ID,
         	   T.GPREQ_ID,
	           T.PRO_PLAN_ID,
	           T.ORDER_NO,
	           T.ORDER_SEQ,
	           T.STEELCODE,
	           T.STEELNAME,
	           T.GRADECODE,
	           T.GRADENAME,
	           T.PLINE_NAME,
	           T.DIAMETER_GP,
	           T.AIMOUTDIAMETER,
	           T.AIMWALLTHICK,
	           T.LENGTHDISC,
	           T.INWL_ID,
	           T.INWL_DESC)T1
	        LEFT JOIN PLN_SALEORD T2
	        ON T1.ORD_LN_DLY_PK=T2.ORD_LN_DLY_PK
	        ORDER BY T1.PLINE_NAME,T1.PROCESS,T1.OUTDIAMETER,T1.WALLTHICK,T1.GRADENAME
		]]>
	</query>
	
		<query id="GlOrderManage.QueryPlnOrderInfoBuy" desc="获取管坯采购需求清单">
	<![CDATA[
       	SELECT T1.*,L.PRODUCER_FL,
       		( SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = H.FST_DRAWEE_UNIT ) FST_DRAWEE_UNIT,
	        ( SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = H.SUPPLY_UNIT ) SUPPLY_UNIT,
       	    C.CRAFT_NO,
       		T2.PRODUCCODE,
	        T2.PRODUCNAME,
	        DECODE(PROD_STANDARD1,NULL,T2.STD_NAME,PROD_STANDARD1) PROD_STANDARD,
	        DECODE(OUTPUT_STANDARD1,NULL,T2.STD_NAME,OUTPUT_STANDARD1) OUTPUT_STANDARD
       		 FROM (SELECT '轧管' PROCESS,
	           T.PRO_PLAN_ID,
	           T.ORDER_NO || '/' || T.ORDER_SEQ PLN_ORDER_NO,
	           T.STEELCODE,
	           T.STEELNAME,
	           T.GRADECODE,
	           T.GRADENAME,
	           T.PLINE_NAME,
	           to_char(T.AIMOUTDIAMETER) || 'x' || to_char(T.AIMWALLTHICK) SPEC_NAME,
	           to_char(T.AIMOUTDIAMETER) OUTDIAMETER,
	           to_char(T.AIMWALLTHICK) WALLTHICK,
	           T.LENGTHDISC,
	           T.OUTWL_ID,
	           T.OUTWL_DESC,
	           T.PROD_STANDARD PROD_STANDARD1,
	           T.OUTPUT_STANDARD OUTPUT_STANDARD1,
	           SUM(T.WEIGTH_S) WEIGTH_S,
	           SUM(T.NUM_S) NUM_S,
	           MAX(T.ORD_LN_DLY_PK) ORD_LN_DLY_PK
	      FROM PLN_ORDER_ZG_S T
	     WHERE  
         --AND T.EXE_STATUS='0'
          T.IS_PLAN_OK='1'
         AND T.PLINE_NAME LIKE '天淮%'
         AND T.DECISION!='A'
         AND T.ORDER_NO || '/' || T.ORDER_SEQ LIKE '%'|| ? ||'%'
         AND NOT EXISTS (SELECT 1
          FROM SLM_GL_ORDER_LINE A,
          SLM_GL_ORDER_HEAD B
         WHERE A.ORD_PK=B.ORD_PK
         AND A.PRO_PLAN_ID = T.PRO_PLAN_ID
         AND A.VALIDFLAG = '10'
         AND B.VALIDFLAG !='00'
         AND B.TRADE_TYPE='122302' )
         AND NOT EXISTS (SELECT 1
         FROM  PLN_ORDER_RCL_S S
	     WHERE
	     --S.IS_PLAN_OK='1' AND
         S.PLINE_NAME LIKE '天淮%'
         AND S.DECISION!='A'
         AND S.ord_ln_dly_pk=T.ord_ln_dly_pk
         )
         GROUP BY T.PRO_PLAN_ID,
	           T.ORDER_NO,
	           T.ORDER_SEQ,
	           T.PLINE_NAME,
	           T.STEELCODE,
	           T.STEELNAME,
	           T.GRADECODE,
	           T.GRADENAME,
	           T.AIMOUTDIAMETER,
	           T.AIMWALLTHICK,
	           T.LENGTHDISC,
	           T.OUTWL_ID,
	           T.OUTWL_DESC,
	           T.PROD_STANDARD,
	           T.OUTPUT_STANDARD
         UNION ALL 
         SELECT '热处理' PROCESS,
	           T.PRO_PLAN_ID,
	           T.ORDER_NO || '/' || T.ORDER_SEQ PLN_ORDER_NO,
	           T.STEELCODE,
	           T.STEELNAME,
	           T.GRADECODE,
	           T.GRADENAME,
	           T.PLINE_NAME,
	           to_char(T.OUTDIAMETER) || 'x' || to_char(T.WALLTHICK) SPEC_NAME,
	           to_char(T.OUTDIAMETER) OUTDIAMETER,
	           to_char(T.WALLTHICK) WALLTHICK,
	           T.LENGTHDISC,
	           T.OUTWL_ID,
	           T.OUTWL_DESC,
	           NULL PROD_STANDARD1,
	           NULL OUTPUT_STANDARD1,
	           SUM(T.WEIGTH_S) WEIGTH_S,
	           SUM(T.NUM_S) NUM_S,
	           MAX(T.ORD_LN_DLY_PK) ORD_LN_DLY_PK
	      FROM PLN_ORDER_RCL_S T
	     WHERE 
         --AND T.EXE_STATUS='0'
          T.IS_PLAN_OK='1'
         AND T.PLINE_NAME LIKE '天淮%'
         AND T.DECISION!='A'
         AND T.ORDER_NO || '/' || T.ORDER_SEQ LIKE '%'|| ? ||'%'
         AND NOT EXISTS (SELECT 1
          FROM SLM_GL_ORDER_LINE A,
          SLM_GL_ORDER_HEAD B
         WHERE A.ORD_PK=B.ORD_PK
         AND A.PRO_PLAN_ID = T.PRO_PLAN_ID
         AND A.VALIDFLAG = '10'
         AND B.VALIDFLAG !='00'
         AND B.TRADE_TYPE='122302' )
         GROUP BY T.PRO_PLAN_ID,
	           T.ORDER_NO,
	           T.ORDER_SEQ,
	           T.STEELCODE,
	           T.STEELNAME,
	           T.GRADECODE,
	           T.GRADENAME,
	           T.PLINE_NAME,
	           T.OUTDIAMETER,
	           T.WALLTHICK,
	           T.LENGTHDISC,
	           T.OUTWL_ID,
	           T.OUTWL_DESC)T1
	           LEFT JOIN PLN_SALEORD T2
	        	ON T1.ORD_LN_DLY_PK=T2.ORD_LN_DLY_PK
	           LEFT JOIN SLM_ORDER_LINE L
	           ON T2.ORD_LN_PK=L.ORD_LN_PK
	           LEFT JOIN CRAFT_ORD_DESIGN C
	           ON C.ORD_LN_PK=T2.ORD_LN_PK
	           AND C.VALIDFLAG='1'
	           LEFT JOIN SLM_ORDER_HEAD H 
	           ON T2.ORD_PK=H.ORD_PK
	           WHERE DECODE(H.SUPPLY_UNIT,NULL,'120501',H.SUPPLY_UNIT)='120501'
	           AND DECODE(H.FST_DRAWEE_UNIT,NULL,'1',H.FST_DRAWEE_UNIT) !='120607'
	          
		]]>
	</query>
	
	<query id="GlOrderManage.doAddGlLine" desc="合同行新增">
		<![CDATA[
			INSERT INTO Slm_Gl_Order_Line
		  (ORD_PK,ORD_LN_PK,ORDER_SEQ,
		   PSC,PSC_DESC,PRODUCCODE,PRODUCNAME,STD_CODE,
		   STD_NAME,STEELCODE,STEELNAME,STD_STYLE,STD_STYLE_DESC,
		   ORDER_SPEC_CODE,ORDER_SPEC_DESC,SPEC_CODE,SPEC_NAME,DIMATER,
		   HEIGHT,LEN_DESC,ORDER_QTY,ORDER_COUNT,CREATE_TIME,
		   CREATE_NAME,DELVRY_RANGE_TPE,DELVRY_RANGE_MIN,DELVRY_RANGE_MAX,PRODUCER_FL,
		   DELVRY_EDATE,VALIDFLAG,PRO_ORDER_NO,PRO_PLAN_ID,PLN_ORDER_NO,
		   GRADECODE,GRADENAME,PROD_STANDARD,OUTPUT_STANDARD,CRAFT_NO)
		   VALUES
		   ( ?,?,
		   (SELECT DECODE(MAX(ORDER_SEQ),'','001',LPAD(MAX(ORDER_SEQ) + 1, 3, '0')) FROM Slm_Gl_Order_Line
		     WHERE ORD_PK = ?
		       AND VALIDFLAG != '00'),
		   ?,?,?,?,?,
		   ?,?,?,?,?,
		   ?,?,?,?,?,
		   ?,?,?,?,SYSDATE,
		   ?,?,?,?,?,
		   TO_DATE(?,'YYYY/MM/DD'),'10',?,?,?,
		   ?,?,?,?,?)
		]]>
	</query>
	
		<query id="GlOrderManage.getBalanceInfo" desc="合同行新增">
		<![CDATA[
				SELECT T2.ORDER_NO,
			       T2.ORDER_TYP,
			       T2.ORDER_TYP_DESC,
			       T2.CUSTOMER_NO,
			       T2.CUSTOMER_NM,
			       T2.SUPPLY_UNIT,
			       T2.STLMT_UNIT_NO,
			       T2.STLMT_UNIT_NM,
			       T2.FST_DRAWEE_UNIT,
			       (SELECT T.BASENAME FROM COM_BASE_INFO T WHERE T.BASECODE=T2.FST_DRAWEE_UNIT) FST_DRAWEE_NAME,
			       TO_CHAR(T2.SIGN_DATE,'YYYY/MM/DD'),
			       T2.ORDER_YEAR,
			       T2.MEMO,
			       SUM(T1.MONEY_ORG) ORDER_MNY_TAX,
			       SUM(T1.MONEY) ORDER_MNY_NTAX
			  FROM SLM_BALANCEINFO T1, SLM_ORDER_HEAD T2,
			  SLM_ORDER_LINE T3
			 WHERE T1.ORD_PK = T2.ORD_PK
			 AND T1.ORD_LN_PK=T3.ORD_LN_PK
			 AND DECODE(?,'1',T1.INVOICENO_ORG,'2',T1.INVOICENO)=?
			 AND T2.SUPPLY_UNIT='120504'
			 GROUP BY T2.ORDER_NO,
			          T2.ORDER_TYP,
			          T2.ORDER_TYP_DESC,
			          T2.CUSTOMER_NO,
			          T2.CUSTOMER_NM,
			          T2.SUPPLY_UNIT,
			          T2.STLMT_UNIT_NO,
			          T2.STLMT_UNIT_NM,
			          T2.SIGN_DATE,
			          T2.ORDER_YEAR,
			          T2.MEMO,
			          T2.FST_DRAWEE_UNIT
		]]>
	</query>
	
	
	<query id="GlOrderManage.insertGlInfo" desc="合同行新增">
		<![CDATA[
				INSERT INTO SLM_GL_ORDER_BALANCE
				  (BALANCE_NO,ORDER_NO,ORDER_TYP,ORDER_TYP_DESC,BALANCE_TPYE_CODE,
				   BALANCE_TPYE_DESC,COST_TPYE_CODE,COST_TPYE_DESC,PAY_FLAG,SUPPLY_UNIT,
				   CUSTOMER_NO,CUSTOMER_NM,STLMT_UNIT_NO,STLMT_UNIT_NM,SIGN_DATE,
				   ORDER_YEAR,VALIDFLAG,CREATE_NAME,BALNCE_TOL_PRICE,CREATE_TIME,
				   INVOICENO,BALANCE_TYPE)
				VALUES
				  ((SELECT 'JS' || TO_CHAR(SYSDATE, 'YYMMDD') ||
       LPAD(TO_CHAR(NVL(SUBSTR(MAX(T.BALANCE_NO), 9), 0) + 1), 5, 0) 
  FROM SLM_GL_ORDER_BALANCE T  WHERE T.BALANCE_NO LIKE ? || '%'),?,?,?,?,
				  ?,?,?,?,?,
				  ?,?,?,?,TO_DATE(?,'YYYY/MM/DD'),
				  ?,'1',?,?,SYSDATE,
				  ?,?)
		]]>
	</query>
	
		<query id="GlOrderManage.getMaxBalanceNo" desc="合同行新增">
		<![CDATA[
				SELECT 'JS' || TO_CHAR(SYSDATE, 'YYMMDD') ||
       LPAD(TO_CHAR(NVL(SUBSTR(MAX(T.BALANCE_NO), 9), 0) + 1), 5, 0) 
  FROM SLM_GL_ORDER_BALANCE T  WHERE T.BALANCE_NO LIKE ? || '%'
		]]>
	</query>
	
	<query id="GlOrderManage.insertGlInfoCarry" desc="合同行新增">
		<![CDATA[
				INSERT INTO SLM_GL_ORDER_BALANCE
				  (BALANCE_NO,ORDER_NO,ORDER_TYP,ORDER_TYP_DESC,BALANCE_TPYE_CODE,
				   BALANCE_TPYE_DESC,COST_TPYE_CODE,COST_TPYE_DESC,PAY_FLAG,SUPPLY_UNIT,
				   CUSTOMER_NO,CUSTOMER_NM,STLMT_UNIT_NO,STLMT_UNIT_NM,SIGN_DATE,
				   ORDER_YEAR,VALIDFLAG,CREATE_NAME,BALNCE_TOL_PRICE,CREATE_TIME,
				   INVOICENO,BALANCE_TYPE,ORD_LN_PK,CG_ORDER_NO)
				VALUES
				  (?,?,?,?,?,
				  ?,?,?,?,?,
				  ?,?,?,?,TO_DATE(?,'YYYY/MM/DD'),
				  ?,'1',?,?,SYSDATE,
				  ?,?,?,?)
		]]>
	</query>
	
	<query id="GlOrderManage.getOrderInfo" desc="合同行新增">
		<![CDATA[
				SELECT T.SUPPLY_UNIT,T.FST_DRAWEE_UNIT FROM SLM_ORDER_HEAD t WHERE T.ORD_PK=?
		]]>
	</query>
	
	
	<query id="GlOrderManage.QueryHeadAndLine" desc="获取管坯采购需求清单">
	<![CDATA[
       		SELECT T.ORD_PK, T.ORD_LN_PK,T1.ORDER_NO,T1.GL_ORDER_NO,T.ORDER_SEQ, T.PSC, T.PSC_DESC,
			     T.PRODUCCODE, T.PRODUCNAME, T.STD_CODE, T.STD_NAME, T.STEELCODE, T.STEELNAME,T.GRADECODE, T.GRADENAME,
			     T.ORDER_SPEC_CODE, T.ORDER_SPEC_DESC, T.SPEC_CODE, T.SPEC_NAME, T.LEN_DESC, T.LEN_UNIT, T.LEN_MIN,
			     T.LEN_MAX, T.ORDER_UNIT, T.ORDER_QTY, T.DELVRY_RANGE_TPE, T.DELVRY_RANGE_MIN,
			     T.DELVRY_RANGE_MAX, T.STD_STYLE,T.STD_STYLE_DESC,T.PRODUCER_FL,
			     TO_CHAR (T.DELVRY_EDATE, 'YYYY-MM-DD') DELVRY_EDATE, 
			     T.ORDER_PRICE, T.TRANS_PRICE,  T.OUT_PRICE, T.BALNCE_PRICE,T.BALNCE_TOL_PRICE,
			     T.MEMO,T.VALIDFLAG, T.CREATE_NAME, T.CREATE_TIME, T.UPDATE_NAME, T.UPDATE_TIME,
			     T.DELETE_NAME, T.DELETE_TIME, 
			        '(-'
			     || TO_CHAR (T.DELVRY_RANGE_MIN)
			     || DECODE (T.DELVRY_RANGE_TPE, '%', '%', T.ORDER_UNIT)
			     || ','
			     || TO_CHAR (T.DELVRY_RANGE_MAX)
			     || DECODE (T.DELVRY_RANGE_TPE, '%', '%', T.ORDER_UNIT)
			     || ')' MIN_MAX_TPE,
			     T.PRO_ORDER_NO,T.PRO_PLAN_ID,T.DIMATER,T.HEIGHT,T.ORDER_COUNT,T.PLN_ORDER_NO,
			     (SELECT SUM(ACT_COUNT) FROM YDM_BC_OUTLIST T2,slm_gl_order_balance t3 
			     WHERE T2.BALANCE_NO=T3.BALANCE_NO and t3.ORD_LN_PK=t.ORD_LN_PK) ACT_COUNT,
			     (SELECT SUM(PONDER_GROSS_WT) FROM YDM_BC_OUTLIST T2,slm_gl_order_balance t3 
			     WHERE T2.BALANCE_NO=T3.BALANCE_NO and t3.ORD_LN_PK=t.ORD_LN_PK) ACT_WEIGHT
			FROM SLM_GL_ORDER_line T,
				slm_gl_order_head T1
			WHERE  T.ORD_PK=T1.ORD_PK
			AND T.VALIDFLAG='10' 
			AND T1.VALIDFLAG='20' AND T1.APPROVALFLAG='10'
			AND T1.TRADE_TYPE='122302'
			AND T1.ORDER_NO ||'&' LIKE '%' || ? || '%' 
            AND T.CREATE_TIME>=TO_DATE(?,'YYYY-MM-DD HH24:MI:SS') 
            AND T.CREATE_TIME <=TO_DATE(?,'YYYY-MM-DD HH24:MI:SS') 
		]]>
	</query>
	
		<query id="GlOrderManage.QueryBcOutList" desc="获取管坯采购需求清单">
	<![CDATA[
		 SELECT T.JUDGE_STOVE_NO,
		       T.BATCH_NO,
		       T.PRODUCNAME,
		       T.STD_NAME,
		       T.GRADENAME,
		       T.STEELNAME,
		       T.SPEC_NAME,
		       T.MODEL_DESC,
		       T.PLINE_NAME,
		       SUM(T.ACT_COUNT) ACT_COUNT,
		       SUM(T.PONDER_GROSS_WT) ACT_WEIGHT,
		       T.ORDER_NO,
		       T.VEHICLE_NO,
		       T.OUTSTOCK_DOC
		  FROM YDM_BC_OUTLIST T
		  WHERE T.PRO_ORDER_ID=?
		  AND T.BALANCE_NO IS  NULL
		  AND EXISTS (SELECT 1 FROM YDM_BS_STORAGE T1 WHERE T1.SEAM_AREA='0' AND T1.STORAGE_NO=T.TAR_STORAGE_NO)
		  AND EXISTS (SELECT 1 FROM YDM_BS_STORAGE T1 WHERE T1.SEAM_AREA='1' AND T1.STORAGE_NO=T.STORAGE_NO)
		  GROUP BY 
		       T.JUDGE_STOVE_NO,
		       T.BATCH_NO,
		       T.PRODUCNAME,
		       T.STD_NAME,
		       T.GRADENAME,
		       T.STEELNAME,
		       T.SPEC_NAME,
		       T.MODEL_DESC,
		       T.PLINE_NAME,
		       T.ORDER_NO,
		       T.VEHICLE_NO,
		       T.OUTSTOCK_DOC 
		]]>
	</query>
	
	
	<query id="GlOrderManage.getOutWeight" desc="获取管坯采购需求清单">
	<![CDATA[
		 SELECT  SUM(T.PONDER_GROSS_WT) ACT_WEIGHT,max(BALANCE_NO) BALANCE_NO
		 FROM YDM_BC_OUTLIST T
		  WHERE T.OUTSTOCK_DOC=?
		  AND T.PRO_ORDER_ID=?
		]]>
	</query>
	
	<query id="GlOrderManage.QueryByOrdLnPk" desc="获取管坯采购需求清单">
	<![CDATA[
       		SELECT  T1.ORD_PK,T1.ORDER_NO,T1.GL_ORDER_NO,T1.TRADE_TYPE,T1.ORDER_TYP,T1.ORDER_TYP_DESC,
				T1.ORDER_YEAR,T1.SIGN_ADDRESS,T1.SUPPLY_UNIT,T1.CUSTOMER_NO,T1.CUSTOMER_NM,
				T1.STLMT_UNIT_NO,T1.STLMT_UNIT_NM,T1.RECEIV_NO,T1.RECEIV_NM,TO_CHAR(T1.SIGN_DATE,'YYYY/MM/DD') SIGN_DATE,
				T1.DELVRY_ADDR,T1.DELVRY_TYPE,T1.TRANSIT_TYPE,T1.PACK_TYPE,T1.MNY_ASK_DESC,
				T1.MNY_ASK_TYP,T1.LOCAL_LAW,T1.LOCAL_ORHER,T1.LOCAL_ZY,T1.ORHER_INFO,
				T1.ORDER_SPECIAL_DESC,T1.MEMO,T1.CREATE_NAME,T1.CREATE_DEPT,
				T1.VALIDFLAG,T2.BALNCE_PRICE
             FROM  SLM_GL_ORDER_HEAD T1,SLM_GL_ORDER_LINE T2     
             WHERE  T1.ORD_PK=T2.ORD_PK
             AND T2.ORD_LN_PK = ? 
		]]>
	</query>
	
	<query id="GlOrderManage.updateOutInfo" desc="获取管坯采购需求清单">
	<![CDATA[
		 UPDATE  YDM_BC_OUTLIST T SET BALANCE_NO=?
		  WHERE T.OUTSTOCK_DOC=?
		  AND T.PRO_ORDER_ID=?
		]]>
	</query>
	
	<query id="GlOrderManage.QueryBalanceInfo" desc="获取数据">
	<![CDATA[
		SELECT
		T.BALANCE_NO,
		T.ORDER_NO,
		T.ORDER_TYP_DESC,
		T.BALANCE_TPYE_CODE,
		T.BALANCE_TPYE_DESC,
		T.COST_TPYE_CODE,
		T.COST_TPYE_DESC,
		DECODE(T.PAY_FLAG,'0','待支付','1','已支付') PAY_FLAG,
		T.BILLS_KEY,
		T.CUSTOMER_NO,
		T.CUSTOMER_NM,
		(SELECT BASENAME FROM COM_BASE_INFO  WHERE VALIDFLAG='1' AND BASECODE = T.SUPPLY_UNIT) SUPPLY_UNIT,
		T.STLMT_UNIT_NO,
		T.STLMT_UNIT_NM,
		TO_CHAR(T.SIGN_DATE, 'YYYY-MM-DD') SIGN_DATE,
		T.ORDER_YEAR,
		T.MEMO,
		DECODE(T.VALIDFLAG,'0','无效','1','有效') VALIDFLAG,
		T.CREATE_NAME,
		T.CREATE_DEPT,
		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,
		TO_CHAR(T.BALNCE_TOL_PRICE,'FM999,999,999,999,990.00') BALNCE_TOL_PRICE,
		T.BILLS_NOS,
		T.CG_ORDER_NO
		FROM SLM_GL_ORDER_BALANCE T
		WHERE T.VALIDFLAG='1'
		AND T.BALANCE_TYPE='1'
		AND T.BALANCE_NO||'&'  LIKE '%' || ? || '%' 
		AND T.ORDER_NO||'&'  LIKE '%' || ? || '%' 
		AND CREATE_TIME>=TO_DATE(?,'YYYY-MM-DD HH24:MI:SS') 
        AND CREATE_TIME <=TO_DATE(?,'YYYY-MM-DD HH24:MI:SS') 
        ]]>
	</query>
	
	<query id="GlOrderManage.doCancelCarry" desc="获取管坯采购需求清单">
	<![CDATA[
		 delete  SLM_GL_ORDER_BALANCE T 
		  WHERE T.BALANCE_NO=?
		]]>
	</query>
	
	<query id="GlOrderManage.updateOutInfoBalance" desc="获取管坯采购需求清单">
	<![CDATA[
		 UPDATE  YDM_BC_OUTLIST T SET BALANCE_NO=null
		  WHERE T.BALANCE_NO=?
		]]>
	</query>
	
	<query id="GlOrderManage.getMaxPrintId" desc="合同行新增">
		<![CDATA[
				SELECT TO_CHAR(SYSDATE, 'YYMMDD') ||
       LPAD(TO_CHAR(NVL(SUBSTR(MAX(T.BALANCE_NO), 7), 0) + 1), 3, 0) 
  FROM SLM_GL_ORDER_BALANCE T  WHERE T.PRINT_NO LIKE ? || '%'
		]]>
	</query>
	
	<query id="GlOrderManage.updatePrint" desc="获取管坯采购需求清单">
	<![CDATA[
		 UPDATE  SLM_GL_ORDER_BALANCE T SET PRINT_NO=?
		  WHERE T.BALANCE_NO=?
		]]>
	</query>
	
	
			<query id="GlOrderManage.QueryGpOutList" desc="获取管坯采购需求清单">
	<![CDATA[
		 SELECT T.JUDGE_STOVE_NO,
		       T.GRADENAME,
		       T.DIMATER,
		       SUM(T.ACT_COUNT) ACT_COUNT,
		       SUM(T.PONDER_GROSS_WT) ACT_WEIGHT,
		       T.ORDER_NO,
		       T.VEHICLE_NO,
		       T.OUTSTOCK_DOC,
		       T.PRO_PLAN_ID,
		       T.PRO_PLAN_ID_ZG
		  FROM YDM_GP_OUTLIST T
		  WHERE T.GRADECODE=?
		  AND T.DIMATER=?
		  AND T.BALANCE_NO IS  NULL
		  AND EXISTS (SELECT 1 FROM YDM_BS_STORAGE T1 WHERE T1.SEAM_AREA='1' AND T1.STORAGE_NO=T.TAR_STORAGE_NO)
		  AND EXISTS (SELECT 1 FROM YDM_BS_STORAGE T1 WHERE T1.SEAM_AREA='0' AND T1.STORAGE_NO=T.STORAGE_NO)
		  GROUP BY 
		       T.JUDGE_STOVE_NO,
		       T.GRADENAME,
		       T.DIMATER,
		       T.ORDER_NO,
		       T.VEHICLE_NO,
		       T.OUTSTOCK_DOC,
		       T.PRO_PLAN_ID,
		       T.PRO_PLAN_ID_ZG
		]]>
	</query>
	
	
		<query id="GlOrderManage.QueryHeadAndLineGp" desc="获取管坯采购需求清单">
	<![CDATA[
       		SELECT T.ORD_PK, T.ORD_LN_PK,T1.ORDER_NO,T1.GL_ORDER_NO,T.ORDER_SEQ, T.PSC, T.PSC_DESC,
			     T.PRODUCCODE, T.PRODUCNAME, T.STD_CODE, T.STD_NAME, T.STEELCODE, T.STEELNAME,T.GRADECODE, T.GRADENAME,
			     T.ORDER_SPEC_CODE, T.ORDER_SPEC_DESC, T.SPEC_CODE, T.SPEC_NAME, T.LEN_DESC, T.LEN_UNIT, T.LEN_MIN,
			     T.LEN_MAX, T.ORDER_UNIT, T.ORDER_QTY, T.DELVRY_RANGE_TPE, T.DELVRY_RANGE_MIN,
			     T.DELVRY_RANGE_MAX, T.STD_STYLE,T.STD_STYLE_DESC,T.PRODUCER_FL,
			     TO_CHAR (T.DELVRY_EDATE, 'YYYY-MM-DD') DELVRY_EDATE, 
			     T.ORDER_PRICE, T.TRANS_PRICE,  T.OUT_PRICE, T.BALNCE_PRICE,T.BALNCE_TOL_PRICE,
			     T.MEMO,T.VALIDFLAG, T.CREATE_NAME, T.CREATE_TIME, T.UPDATE_NAME, T.UPDATE_TIME,
			     T.DELETE_NAME, T.DELETE_TIME, 
			        '(-'
			     || TO_CHAR (T.DELVRY_RANGE_MIN)
			     || DECODE (T.DELVRY_RANGE_TPE, '%', '%', T.ORDER_UNIT)
			     || ','
			     || TO_CHAR (T.DELVRY_RANGE_MAX)
			     || DECODE (T.DELVRY_RANGE_TPE, '%', '%', T.ORDER_UNIT)
			     || ')' MIN_MAX_TPE,
			     T.PRO_ORDER_NO,T.PRO_PLAN_ID,T.DIMATER,T.HEIGHT,T.ORDER_COUNT,T.PLN_ORDER_NO,
			     (SELECT SUM(ACT_COUNT) FROM YDM_BC_OUTLIST T2,slm_gl_order_balance t3 
			     WHERE T2.BALANCE_NO=T3.BALANCE_NO and t3.ORD_LN_PK=t.ORD_LN_PK) ACT_COUNT,
			     (SELECT SUM(PONDER_GROSS_WT) FROM YDM_BC_OUTLIST T2,slm_gl_order_balance t3 
			     WHERE T2.BALANCE_NO=T3.BALANCE_NO and t3.ORD_LN_PK=t.ORD_LN_PK) ACT_WEIGHT
			FROM SLM_GL_ORDER_line T,
				slm_gl_order_head T1
			WHERE  T.ORD_PK=T1.ORD_PK
			AND T.VALIDFLAG='10' 
			-- AND T1.VALIDFLAG='20' AND T1.APPROVALFLAG='10'
			AND T1.TRADE_TYPE='122301'
			AND T1.ORDER_NO ||'&' LIKE '%' || ? || '%' 
            AND T.CREATE_TIME>=TO_DATE(?,'YYYY-MM-DD HH24:MI:SS') 
            AND T.CREATE_TIME <=TO_DATE(?,'YYYY-MM-DD HH24:MI:SS') 
		]]>
	</query>
	
		<query id="GlOrderManage.updateGpOutInfo" desc="获取管坯采购需求清单">
	<![CDATA[
		 UPDATE  YDM_GP_OUTLIST T SET BALANCE_NO=?
		  WHERE T.OUTSTOCK_DOC=?
		  AND T.GRADECODE=? 
		  AND T.DIMATER=?
		]]>
	</query>
	
		<query id="GlOrderManage.getGpOutWeight" desc="获取管坯采购需求清单">
	<![CDATA[
		 SELECT  SUM(T.PONDER_GROSS_WT) ACT_WEIGHT,max(BALANCE_NO) BALANCE_NO
		 FROM YDM_GP_OUTLIST T
		  WHERE T.OUTSTOCK_DOC=?
		  AND T.GRADECODE=?
		  AND T.DIMATER=?
		]]>
	</query>
	
		<query id="GlOrderManage.updateOutInfoBalanceGp" desc="获取管坯采购需求清单">
	<![CDATA[
		 UPDATE  YDM_GP_OUTLIST T SET BALANCE_NO=null
		  WHERE T.BALANCE_NO=?
		]]>
	</query>
	
</queryMap>