<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="评审注销单">
	<query id="FrmSingleReview.getDoQueryRev" desc="查询注销单">
<![CDATA[
SELECT T.REVIEW_NO,
       DECODE(T.REVIEW_SRC, 'X', '合同注销') REVIEW_SRC,
       DECODE(T.REVIEW_STATUS,
              'L',
              '封锁',
              'W',
              '待审',
              'S',
              '评审通过',
              'F',
              '评审不通过') REVIEW_STATUS,
       TO_CHAR(T.REVEIW_BDATE, 'YYYY-MM-DD HH24:MI:SS') REVEIW_BDATE,
       TO_CHAR(T.REVEIW_EDATE, 'YYYY-MM-DD HH24:MI:SS') REVEIW_EDATE,
       T.REVEIW_MAN,
       T.REVEIW_CONTENT,
       T.REVEIW_ASKER,
       TO_CHAR(T.REVEIW_ASK_TIME, 'YYYY-MM-DD HH24:MI:SS') REVEIW_ASK_TIME,
       T.MEMO,
       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
  FROM SLM_ORDER_LOGOUT_REVIEW T
 WHERE 1 = 1
]]></query>
<query id="FrmSingleReview.getDoQueryOrderRev" desc="查询注销单详情">
<![CDATA[SELECT T.REVIEW_NO,
       DECODE(T.REVIEW_SRC, 'X', '合同注销') REVIEW_SRC,
       T.ORD_LN_PK,
       H.ORDER_NO || '/' || T1.ORDER_SEQ ORDER_SEQ,
       DECODE(T.REVIEW_STATUS,
              'L',
              '封锁',
              'W',
              '待审',
              'S',
              '评审通过',
              'F',
              '评审不通过') REVIEW_STATUS,
       TO_CHAR(T.REVEIW_BDATE, 'YYYY-MM-DD HH24:MI:SS') REVEIW_BDATE,
       TO_CHAR(T.REVEIW_EDATE, 'YYYY-MM-DD HH24:MI:SS') REVEIW_EDATE,
       T.REVEIW_MAN,
       T.REVEIW_CONTENT,
       T.REVEIW_ASKER,
       TO_CHAR(T.REVEIW_ASK_TIME, 'YYYY-MM-DD HH24:MI:SS') REVEIW_ASK_TIME,
       T.MEMO,
       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
  FROM SLM_ORDER_LOGOUT_REVIEW T, SLM_ORDER_LINE T1, SLM_ORDER_HEAD H
 WHERE T.ORD_LN_PK = T1.ORD_LN_PK
   AND T1.ORD_PK = H.ORD_PK
   AND T.REVIEW_NO = ?

]]></query>
	<query id="FrmSingleReview.queryLoagoutRevStart" desc="注销单状态">
<![CDATA[
SELECT T.REVIEW_NO,
       T.REVIEW_SRC,
       T.ORD_LN_PK,
       H.ORD_PK,
       T.REVIEW_STATUS,
       TO_CHAR(T.REVEIW_BDATE, 'YYYY-MM-DD HH24:MI:SS') REVEIW_BDATE,
       TO_CHAR(T.REVEIW_EDATE, 'YYYY-MM-DD HH24:MI:SS') REVEIW_EDATE,
       T.REVEIW_MAN,
       T.REVEIW_CONTENT,
       T.REVEIW_ASKER,
       TO_CHAR(T.REVEIW_ASK_TIME, 'YYYY-MM-DD HH24:MI:SS') REVEIW_ASK_TIME,
       T.MEMO,
       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
  FROM SLM_ORDER_LOGOUT_REVIEW T, SLM_ORDER_LINE T1, SLM_ORDER_HEAD H
 WHERE T.ORD_LN_PK = T1.ORD_LN_PK
   AND T1.ORD_PK = H.ORD_PK
   AND T.REVIEW_NO = ?
   AND T.REVIEW_SRC = ?
]]></query>
	<query id="FrmSingleReview.UpdateRevNo" desc="修改注销单">
<![CDATA[
UPDATE SLM_ORDER_LOGOUT_REVIEW
   SET REVIEW_STATUS   = ?,
       REVEIW_MAN    = ?,
       REVEIW_EDATE = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')
 WHERE REVIEW_NO = ?

]]></query>
	<query id="FrmSingleReview.updateOrdLnPkRevNo" desc="修改合同行注销单">
<![CDATA[
  UPDATE SLM_ORDER_LINE T
     SET T.LOGOUT_REVIEW_NO = ?
   WHERE T.ORD_LN_PK = ?
   AND T.VALIDFLAG='1'
]]></query>
	<query id="FrmSingleReview.UpdateOrderSeqZx" desc="修改合同行有效标志">
<![CDATA[
DECLARE
BEGIN
  UPDATE SLM_ORDER_LINE T
     SET T.VALIDFLAG   = ?,
         T.DELETE_NAME = ?,
         T.DELETE_TIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')
   WHERE T.ORD_LN_PK = ?;
  UPDATE SLM_ORDER_LINE_DELIVERY T
     SET T.VALIDFLAG   = ?,
         T.DELETE_NAME = ?,
         T.DELETE_TIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')
   WHERE T.ORD_LN_PK = ?;
   DELETE SLM_WELL_USE_LIST T
 WHERE EXISTS (SELECT 1
          FROM SLM_ORDER_LINE_DELIVERY A
         WHERE A.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
           AND A.ORD_LN_PK = ?);   
END;
]]></query>
	<query id="FrmSingleReview.QueryOrderMatNo" desc="是否存在库存">
<![CDATA[
SELECT COUNT(*) COUNT
  FROM MAT_ZC_M T
 WHERE T.ORD_LN_PK = ?
   AND T.PRODUCT_FLAG = '801403'
]]></query>
	<query id="FrmSingleReview.QueryOrdNo" desc="查询合同状态">
<![CDATA[
SELECT COUNT (*)  COUNT FROM(
SELECT  T.ORD_PK, T.ORDER_LN_STATUS
  FROM SLM_ORDER_LINE T
 WHERE T.ORD_PK =?
   AND T.VALIDFLAG = '1'
GROUP BY T.ORD_PK,T.ORDER_LN_STATUS)
]]>
	</query>
	<query id="FrmSingleReview.UpdateOrderZx" desc="修改合同頭有效标志">
<![CDATA[
DECLARE
BEGIN
  UPDATE SLM_ORDER_HEAD T
     SET T.VALIDFLAG   = ?,
         T.DELETE_NAME = ?,
         T.DELETE_TIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')
   WHERE T.ORD_PK = ?;
END;
]]></query>
</queryMap>