<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="合同审批管理界面查询">
<query id="CoreOrderReviewManager.CoreOrderReviewManagerHeadQuery" desc="合同审批界面信息">
        <![CDATA[
             SELECT B3.ORDER_NO,
       B3.ORD_PK,
       B3.CUSTM_ORDER_NO,
       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = B3.ORDER_TYP) ORDER_TYP,
       ORDER_TYP ORDER_TYPCODE,
       B3.SALE_AREA_DESC SALE_AREA_NO,
       B3.ORDER_YEAR,
       B3.SIGN_DATE,
       B3.SIGN_ADDRESS,
       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = B3.SUPPLY_UNIT) SUPPLY_UNIT,
       (SELECT CUSTOMER_NM
          FROM SLM_BASE_CUSTOMER
         WHERE CUSTOMER_NO = B3.STLMT_UNIT_NO) STLMT_UNIT_NO,
       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = B3.MNY_ASK_TYP) MNY_ASK_TYP,
       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = B3.CURRENCY) CURRENCY,
       	CASE	WHEN SUPPLY_UNIT = '120504' and ORDER_STS >= 12020210 and ORDER_STS < 12020212 THEN
            (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = B3.ORDER_STS) || DECODE(TH_EXAMINE_STATUS,'1','(待部门领导审批)','2','(待分管领导审批)','(待计划审批)')
        ELSE
            (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = B3.ORDER_STS)
		END ORDER_STS,
       CLOSE_TIME,
       B3.EFFECT_TIME,
       B3.APPROVAL_TIME,
       B3.DELETE_TIME,
       B3.DELETE_NAME,
       B3.UPDATE_TIME,
       B3.UPDATE_NAME,
       B3.CREATE_TIME,
       B3.CREATE_NAME,
       DECODE(B3.VALIDFLAG, '1', '有效', '0', '无效') VALIDFLAG,
       B3.ORDER_MODEL_DESC,
       B3.ORDER_MODEL_NO,
       B3.MNY_ASK_DESC,
       B3.MANAG_NO,
       B3.CUSTOMER_NM CUSTOMER_NO,
       B3.MEMO,
       (SELECT BASENAME
          FROM COM_BASE_INFO
         WHERE BASECODE = B3.FST_DRAWEE_UNIT) FST_DRAWEE_UNIT,
       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = B3.PRICE_FL) PRICE_FL,
       DECODE(B3.CUSTOMER_MODEL_FL,'1','TRUE','FALSE') CUSTOMER_MODEL_FL
  FROM SLM_ORDER_HEAD B3
 WHERE LOWER(B3.ORDER_NO) || '&' LIKE '%' || LOWER(?) || '%'
   AND DECODE(?, NULL, '1', B3.ORDER_STS) = DECODE(?, NULL, '1', ?)
   AND (B3.ORDER_STS = '12020102' OR B3.ORDER_STS LIKE '120202%')
   AND B3.VALIDFLAG = '1'
   AND B3.CREATE_TIME BETWEEN TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') AND
       TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')
        ]]>
        </query>
        <query id="CoreOrderReviewManager.CoreOrderReviewManagerSqeQuery" desc="合同生效管理合同行信息">
        <![CDATA[
                SELECT ORDER_SEQ,
			            (SELECT BASENAME
			               FROM COM_BASE_INFO
			              WHERE BASECODE = T. ORDER_LN_STATUS) ORDER_LN_STATUS,
			            T. PRODUCNAME,
			            T. ORDER_SPEC_DESC,
			            T. MODEL_DESC,
			            T. LEN_DESC,
			            T. ORDER_QTY,
			            T. ORDER_UNIT,
			            T. PRDCT_WGT,
			            '(﹣' || T.DELVRY_RANGE_MIN ||T.DELVRY_RANGE_TPE|| '~' || T.DELVRY_RANGE_MAX ||
                        T.DELVRY_RANGE_TPE ||')' DELVRY_RANGE,
			            T. FINAL_USER_DESC,
			            T. VALIDFLAG,
			            T. CREATE_NAME,
			            T. CREATE_TIME,
			            T. UPDATE_NAME,
			            T. UPDATE_TIME,
			            T. DELETE_NAME,
			            T. DELETE_TIME,
			            (SELECT BASENAME
			               FROM COM_BASE_INFO
			              WHERE BASECODE = T. OUTS_BILLET_FL) OUTS_BILLET_FL,
			            (SELECT BASENAME
			               FROM COM_BASE_INFO
			              WHERE BASECODE = T. OUTS_STL_PIPE_FL) OUTS_STL_PIPE_FL,
			            T. ASSEL_FL,
			            T. ORDER_ADD_DESC,
			            T. CUST_ALPHA_NO,
			            T.ORD_LN_PK,
			            T.MPS_FL,
			            T.MPS_NO,
			            T.MPS_DESC,
			            T.PRODUCER_FL,
			            T.PRDCR_NO,
			            T.PRDCR_DESC,
			            T.DELVRY_EDATE,
			            T.MSC,
			            T.MSC_DESC,
			            T.MSC_STYLE
			       FROM SLM_ORDER_LINE T
			      WHERE T.ORD_PK = ? AND VALIDFLAG = '1'
           
     ]]>
    </query>
    
        <query id="CoreOrderReviewManager.CoreOrderReviewManagerAdd" desc="合同审批界面提报功能评审主表">
        <![CDATA[
            insert into SLM_ORDER_REVIEW(
			  review_src,
			  ord_pk,
			  review_status,
			  reveiw_bdate,
			  reveiw_asker,
			  reveiw_ask_time,
			  validflag,
			  create_name,
			  create_time,
			  review_no)
            values('H',?,'D',sysdate,?,sysdate,'1',?,sysdate,?)
        ]]>
        </query>
        
         <query id="CoreOrderReviewManager.CoreOrderReviewManagerAdd2" desc="合同审批界面提报功能从表">
        <![CDATA[
            insert into SLM_ORDER_REVIEW_ITEM(
				  review_status,
				  reveiw_bdate,
				  validflag,
				  create_name,
				  create_time,
				 review_no,review_itm,review_item_desc)
            values('D',sysdate,'1',?,sysdate,?,?,?)
        ]]>
        </query>
        
         <query id="CoreOrderReviewManager.CoreOrderReviewManagerAdd3" desc="合同审批界面提报功能明细表">
        <![CDATA[
            insert into SLM_ORDER_REVIEW_ITEM_LIST(
                  review_status,
                  create_time,
                  is_curt_review,
                  create_name,
                  review_no,
				  review_itm,
				  RT_REVIEW_ITM,
				  list_typ,
				  list_pk_val,
				  review_times,
				  review_man,
				  REVIEW_BDATE)
            values('D',sysdate,'1',?,?,?,?,?,?,?,?,SYSDATE)
        ]]>
        </query>
        
        <query id="CoreOrderReviewManager.CoreOrderReviewManagerReviewQuery" desc="合同审批界面评审信息查询">
        <![CDATA[
             select REVIEW_ITEM_DESC REVIEW_ITM, decode(REVIEW_STATUS,'L','封锁','W','待审','D','评审中','S','评审通过','F','评审失败') REVIEW_STATUS, REVEIW_BDATE, REVEIW_EDATE
    from SLM_ORDER_REVIEW_ITEM
   where REVIEW_NO =
         (select * from (select REVIEW_NO
          from SLM_ORDER_REVIEW
         where ORD_PK = ?) where rownum <2)
        ]]>
        </query>
        
         <query id="CoreOrderReviewManager.CoreOrderReviewManagerDelete" desc="合同审批界面撤销功能">
         <![CDATA[
             select REVIEW_ITEM_DESC REVIEW_ITM, decode(REVIEW_STATUS,'L','封锁','W','待审','D','评审中','S','评审通过','F','评审失败') REVIEW_STATUS, REVEIW_BDATE, REVEIW_EDATE
    from SLM_ORDER_REVIEW_ITEM
   where REVIEW_NO =
         (select * from (select REVIEW_NO
          from SLM_ORDER_REVIEW
         where ORD_PK = ?) where rownum <2)
        ]]>
        </query>
        
      <query id="CoreOrderReviewManager.getOrderDesignKey" desc="合同审批界面撤销功能">
         <![CDATA[
      SELECT COUNT(A.ORD_LN_PK) - COUNT(T.DESGIN_KEY) RN
      FROM SLM_ORD_DESIGN_MSC T, SLM_ORDER_LINE A
      WHERE T.ORD_PK = ?
      AND T.ORD_PK = A.ORD_PK
      AND T.ORD_LN_PK = A.ORD_LN_PK
      AND A.VALIDFLAG = '1'
      AND T.VALIDFLAG = '1'
		
        ]]>
      </query>
        
      
        </queryMap>