<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="现货合同未提单处理">

	<query id="CoreOrderLineSpotLineTask.GetLineSql" desc="获取合同行的信息>9">
		<![CDATA[
	 	 SELECT T1.ORD_PK, T1.ORD_LN_PK, T1.CREATE_TIME

  FROM SLM_ORDER_HEAD T, SLM_ORDER_LINE T1
 WHERE T1.ORD_PK = T.ORD_PK
   AND T1.CREATE_TIME >=
       TO_DATE('2016-02-24 00:00:01', 'YYYY-MM-DD HH24:MI:SS')
   AND (TO_DATE(TO_CHAR(SYSDATE, 'YYYY-MM-DD'), 'YYYY-MM-DD') -
       TO_DATE(TO_CHAR(T1.CREATE_TIME, 'YYYY-MM-DD'), 'YYYY-MM-DD')) > 18
   AND T.ORDER_TYP = '120102'
   AND T1.BALNCE_PRICE_STS = '0'
   AND T1.VALIDFLAG = '1'
   AND T.VALIDFLAG = '1'
	 	 
		]]>
	</query>
	
	<query id="CoreOrderLineSpotLineTask.IsExistsBill" desc="合同是否存在提单">
		<![CDATA[
	 	 
	 	 SELECT 1 FROM YDM_ZC_BILL_M T WHERE T.ORD_PK = ?

		]]>
	</query>
	
	<query id="CoreOrderLineSpotLineTask.TakeOffLine" desc="合同是否存在提单">
		<![CDATA[
	 	 
	 	 UPDATE MAT_ZC_M T
	 	 
   SET T.ORDER_NO      = '',
       T.ORDER_SEQ     = '',
       T.ORDER_SEQ_NO  = '',
       T.ORD_PK        = '',
       T.ORD_LN_PK     = '',
       T.ORD_LN_DLY_PK = '',
       T.PRODUCT_FLAG  = '801402',
       T.MAT_STATUS    = '80150202'
    WHERE T.ORD_LN_PK = ?
    AND T.PRODUCT_FLAG = '801403'
    AND T.MAT_STATUS = '80150301'

		]]>
	</query>
	
	<query id="CoreOrderLineSpotLineTask.DeleteLineDlyLineTransit" desc="合同是否存在提单">
		<![CDATA[
	 	 
	 	 DECLARE
  BEGIN

   UPDATE SLM_ORDER_LINE T
     SET T.VALIDFLAG = '0',
         T.MEMO      = TO_CHAR(SYSDATE, 'YYYY-MM-DD') || ' 现货合同到期合同行作废'
   WHERE T.ORD_LN_PK = ?;

   UPDATE SLM_ORDER_LINE_DELIVERY T
     SET T.VALIDFLAG  = '0',
         T.OBJ_STS_OP = TO_CHAR(SYSDATE, 'YYYY-MM-DD') || ' 现货合同到期交货行作废'
   WHERE T.ORD_LN_PK = ?;

   UPDATE SLM_ORDER_DELIVERY_TRANSIT T
     SET T.VALIDFLAG = '0'
   WHERE T.ORD_LN_PK = ?;
   
   DELETE FROM  PROCESS_ORDER_M T
   WHERE T.ORD_LN_PK = ?;
   
   DELETE FROM SLM_LAW_REVIEW_RECORD T
   WHERE T.ORD_PK = ?;
   
   UPDATE SLM_ORDER_HEAD T
   SET T.ORDER_STS = '12020101',
       T.ORDER_STS_DESC = '录入',
       T.PRICE_NO = ''
   WHERE T.ORD_PK = ?;

  END;
	 	 		
		]]>
	</query>
	
	 
	 
</queryMap>
