<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="合同生效管理界面查询">

<query id="frmOrderEffect.GetPrdcrStsIsNullCount" desc="获取合同头下面，合同行勾选监制，但监制状态不通过的合同行Count">
       <![CDATA[
             SELECT COUNT(*)
			   FROM SLM_ORDER_LINE
			  WHERE ORD_PK = ?
			    AND PRODUCER_FL = '1'
			    AND PRDCR_NO IS NULL
       ]]>
</query>


<query id="frmOrderEffect.GetNoPrdcrStsCount" desc="获取合同头下面，合同行勾选监制，但监制状态不通过的合同行Count">
        <![CDATA[
             SELECT COUNT(*)
			  FROM SLM_ORDER_LINE_PRDCR
			 WHERE PRDCR_NO IN (SELECT PRDCR_NO
			                      FROM SLM_ORDER_LINE
			                     WHERE ORD_PK = ?
			                       AND PRODUCER_FL = '1')
			   AND PRDCR_STS != 'S'

        ]]>
        </query>

<query id="frmOrderEffect.CoreOrderEffectHeadQuery" desc="合同生效界面信息">
        <![CDATA[
             SELECT ORDER_STS,
			       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = ORDER_STS AND VALIDFLAG = '1' ) ORDER_STS_DESC,
			       	(
					SELECT
						BASENAME
					FROM
						COM_BASE_INFO
					WHERE
						BASECODE = ( SELECT ORDER_STS FROM SLM_ORDER_HEAD WHERE ORDER_NO = B3.CUSTM_ORDER_NO AND VALIDFLAG = '1' )
						AND VALIDFLAG = '1'
					) CUSTM_ORDER_STS,
			       BE_ORDER_STS,
			       BE_ORDER_STS_DESC,
			       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 TYPE_CODE,
			       B3.SALE_AREA_DESC SALE_AREA_NO,
			       B3.ORDER_YEAR,
			       TO_CHAR(B3.SIGN_DATE,'YYYY-MM-DD') 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,
			       CLOSE_TIME,
			       TO_CHAR(B3.EFFECT_TIME,'YYYY-MM-DD HH24:MI:SS') EFFECT_TIME,
			       TO_CHAR(B3.APPROVAL_TIME,'YYYY-MM-DD') APPROVAL_TIME,
			       TO_CHAR(B3.DELETE_TIME,'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
			       B3.DELETE_NAME,
			       TO_CHAR(B3.UPDATE_TIME,'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
			       B3.UPDATE_NAME,
			       TO_CHAR(B3.CREATE_TIME,'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
			       B3.CREATE_NAME,
			       DECODE(B3.VALIDFLAG, '1', '有效', '0', '无效') VALIDFLAG,
			       B3.ORDER_MODEL_DESC,
			       (select t.order_model_desc from SLM_ORDER_MODEL_HEAD t where t.order_model_no=B3.ORDER_MODEL_NO) ORDER_MODEL_NO,
			       B3.MNY_ASK_DESC,
			       B3.MANAG_NO,
			       B3.CUSTOMER_NM,
			       B3.CUSTOMER_NO,
			       B3.MEMO,
			       B3.PRINT_PRICE,
			       (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,
			       B3.CUSTOMER_MODEL_FL
			  FROM SLM_ORDER_HEAD B3
			 WHERE 1 = 1   AND B3.VALIDFLAG = '1'
        ]]>
        </query>
    <query id="frmOrderEffect.CoreOrderEffectSqeQuery" 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,
			        '(-' || TO_CHAR(DELVRY_RANGE_MIN) ||
			        DECODE(DELVRY_RANGE_TPE, '%', '%', ORDER_UNIT) || ',' ||
			        TO_CHAR(DELVRY_RANGE_MAX) ||
			        DECODE(DELVRY_RANGE_TPE, '%', '%', ORDER_UNIT) || ')' 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,
			        T. OUTS_BILLET_FL,
			        T. OUTS_STL_PIPE_FL,
			        T. ASSEL_FL,
			        T. ORDER_ADD_DESC,
			        T. CUST_ALPHA_NO
			   FROM SLM_ORDER_LINE T
			  WHERE T.ORD_PK = ?  AND T.VALIDFLAG = '1'
     ]]>
    </query>
    <query id="frmOrderEffect.orderStatus" desc="合同状态信息">
        <![CDATA[
            SELECT BASENAME,BASECODE FROM COM_BASE_INFO WHERE BASECODE like '1202%' and basecode > 120223 
        ]]>
    </query>
     
    <query id="frmOrderEffect.CoreOrderEffectinfo" desc="合同生效管理界面合同条目信息">
        <![CDATA[
            SELECT MODEL_SEQ, MODEL_ITM,MODEL_ITM_VAL
			  FROM SLM_ORDER_MODEL_ITEM
			 WHERE ORDER_MODEL_NO = ?
        ]]>
    </query>
    <query id="frmOrderEffect.orderEffectPriceQuery" desc="合同生效界面价格说明">
        <![CDATA[
            SELECT PRICE_BASE FROM SLM_ORDER_PRICE WHERE ORD_PK = ?
        ]]>
    </query>
    <query id="frmOrderEffect.orderEffectAdd" desc="合同生效界面生效操作">
        <![CDATA[
            UPDATE SLM_ORDER_HEAD SET ORDER_STS = '12020301',ORDER_STS_DESC = '生效',EFFECT_MAN = ?,EFFECT_TIME = SYSDATE,UPDATE_NAME= ? , UPDATE_TIME = SYSDATE WHERE ORD_PK = ?
        ]]>
    </query>
    <query id="frmOrderEffect.orderEffectUpdate" desc="合同生效界面撤销操作">
        <![CDATA[
            UPDATE SLM_ORDER_HEAD SET ORDER_STS = '12020207',ORDER_STS_DESC = '评审通过',UPDATE_NAME= ? , UPDATE_TIME = SYSDATE WHERE ORD_PK = ?
        ]]>
    </query>
    
    <query id="frmOrderEffect.upOrderHead2" desc="修改合同头状态">
		<![CDATA[
				UPDATE SLM_ORDER_HEAD SET ORDER_STS = ?,ORDER_STS_DESC = ?,BE_ORDER_STS = ?,BE_ORDER_STS_DESC= ? ,obj_sts_op = ?,BE_OBJ_STS_OP=OBJ_STS_OP WHERE ORD_PK=? 
		]]>
	</query>
	
	<query id="frmOrderEffect.upOrderLine" desc="修改合同行状态">
		<![CDATA[  
					UPDATE SLM_ORDER_LINE
			   SET ORDER_LN_STATUS = ?,
			       BE_ORDER_LN_STATUS = ?,
			       BE_OBJ_STS_OP = ?, 
			       OBJ_STS_OP = BE_OBJ_STS_OP
			 WHERE ORD_PK = ?
 	]]>
	</query>
	
	<query id="frmOrderEffect.upOrderDelivery" desc="修改合同交货发运要求状态">
		<![CDATA[ 
			UPDATE slm_order_line_delivery
				   SET delivery_status = ?,
				       be_delivery_status = ?,
				       be_obj_sts_op = ?, 
				       obj_sts_op =be_obj_sts_op 
				 WHERE ORD_PK = ?
		]]>
	</query>
	
	<query id="CoreOrderManager.upOrderHead" desc="修改合同头状态">
		<![CDATA[
				UPDATE SLM_ORDER_HEAD SET 
				ORDER_STS = ?,ORDER_STS_DESC = ?,
				BE_ORDER_STS = ?,obj_sts_op = ?,
				BE_OBJ_STS_OP=OBJ_STS_OP 
				WHERE ORD_PK=? 
		]]>
	</query>
    
    
    <query id="frmOrderEffect.queryPriceInfo" desc="修改合同头状态">
		<![CDATA[
				 SELECT PRICE_BASE  FROM  SLM_ORDER_PRICE T
				 WHERE T.PRICE_NO = (SELECT PRICE_NO FROM SLM_ORDER_HEAD 
				 WHERE ORD_PK = ?)
		]]>
	</query>
	
	
	<query id="frmOrderEffect.queryOrdLnDlyPkStatus" desc="修改合同头状态">
		<![CDATA[
				  SELECT DELIVERY_STATUS FROM  SLM_ORDER_LINE_DELIVERY T
				  WHERE T.ORD_PK = ? AND T.VALIDFLAG = '1'
		]]>
	</query>
	
	<query id="frmOrderEffect.queryOrderLineLockStatus" desc="修改合同头状态">
		<![CDATA[
				  SELECT ISLOCK FROM  SLM_ORDER_LINE T
				  WHERE T.ORD_PK = ?  
		]]>
	</query>
	
	<query id="frmOrderEffect.queryBlaPriceStatus" desc="修改合同头状态">
		<![CDATA[
			
    SELECT COUNT(1) - NVL(SUM(TO_NUMBER(T.BALNCE_PRICE_STS)), '0')
     FROM SLM_ORDER_LINE T
     WHERE T.ORD_PK = ?
     AND T.VALIDFLAG = '1'
			
		]]>
	</query>
	
	<query id="frmOrderEffect.insertProcessOrder" desc="生效插入进程表">
	   <![CDATA[
		 INSERT INTO PROCESS_ORDER_M
   (ORD_PK, ORD_LN_PK, ORD_LN_DLY_PK, DELVRY_QTY, ORDER_UNIT, ENSU_TOTL_LEN)
   SELECT ORD_PK,
         ORD_LN_PK,
         ORD_LN_DLY_PK,
         DELVRY_QTY,
         ORDER_UNIT,
         ENSU_TOTL_LEN
    FROM SLM_ORDER_LINE_DELIVERY T
    WHERE T.ORD_PK = ?
     AND T.VALIDFLAG = '1'
		 		
	   ]]>
	</query>
	
	<query id="frmOrderEffect.clearProcessOrder" desc="生效插入进程表">
	   <![CDATA[
		 DELETE FROM PROCESS_ORDER_M T WHERE T.ORD_PK = ?
      		
	   ]]>
	</query>
	
	<query id="frmOrderEffect.queryOrderMat" desc="生效插入进程表">
	   <![CDATA[
	   
		 SELECT 1 FROM mat_zc_m T
		 WHERE T.ORD_PK = ?
         AND ROWNUM=1
	   ]]>
	</query>
	
	<query id="frmOrderEffect.updateProcessOrderCharge" desc="生效插入进程表">
	   <![CDATA[
	   
		 UPDATE PROCESS_ORDER_M T
   SET T.CHARGE_NUM =
       (SELECT SUM(NVL(T1.ACT_COUNT, 0))
          FROM MAT_ZC_M T1
         WHERE T.ORD_LN_PK = T1.ORD_LN_PK
           AND T.ORD_PK = T1.ORD_PK),
       T.CHARGE_WGT =
       (SELECT SUM(NVL(T1.ACT_WEIGHT, 0))
          FROM MAT_ZC_M T1
         WHERE T.ORD_LN_PK = T1.ORD_LN_PK
           AND T.ORD_PK = T1.ORD_PK)
    WHERE T.ORD_PK = ? 
    AND (SELECT ORDER_TYP FROM SLM_ORDER_HEAD A WHERE A.ORD_PK = ? )='120102'
		 
	   ]]>
	</query>
	
	<query id="frmOrderEffect.getPurLineMemoStatus" desc="生效插入进程表">
	   <![CDATA[
	   
		SELECT TO_CHAR(WM_CONCAT(T.AFFIRM_STATUS)) AFFIRM_STATUS
        FROM SLM_ORDER_LINE_PURCHASE T
        WHERE T.ORD_PK = ?
		 	
	   ]]>
	</query>
	
	<query id="frmOrderEffect.clearPurLineMemoStatus" desc="生效插入进程表">
	   <![CDATA[
	   
		 UPDATE SLM_ORDER_LINE_PURCHASE T
		 SET T.AFFIRM_STATUS = 'L'
		 WHERE T.ORD_PK = ?
		 	
	   ]]>
	</query>
	
	
	<query id="frmOrderEffect.CoreOrderInsidePriceQuery" desc="合同内部结算价维护">
        <![CDATA[
             SELECT ORDER_STS,
			       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = ORDER_STS AND VALIDFLAG = '1' ) ORDER_STS_DESC,
			       BE_ORDER_STS,
			       BE_ORDER_STS_DESC,
			       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 TYPE_CODE,
			       B3.SALE_AREA_DESC SALE_AREA_NO,
			       B3.ORDER_YEAR,
			       TO_CHAR(B3.SIGN_DATE,'YYYY-MM-DD') 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,
			       CLOSE_TIME,
			       TO_CHAR(B3.EFFECT_TIME,'YYYY-MM-DD HH24:MI:SS') EFFECT_TIME,
			       TO_CHAR(B3.APPROVAL_TIME,'YYYY-MM-DD') APPROVAL_TIME,
			       TO_CHAR(B3.DELETE_TIME,'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
			       B3.DELETE_NAME,
			       TO_CHAR(B3.UPDATE_TIME,'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
			       B3.UPDATE_NAME,
			       TO_CHAR(B3.CREATE_TIME,'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
			       B3.CREATE_NAME,
			       DECODE(B3.VALIDFLAG, '1', '有效', '0', '无效') VALIDFLAG,
			       B3.ORDER_MODEL_DESC,
			       (select t.order_model_desc from SLM_ORDER_MODEL_HEAD t where t.order_model_no=B3.ORDER_MODEL_NO) ORDER_MODEL_NO,
			       B3.MNY_ASK_DESC,
			       B3.MANAG_NO,
			       B3.CUSTOMER_NM,
			       B3.CUSTOMER_NO,
			       B3.MEMO,
			       B3.PRINT_PRICE,
			       (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,
			       B3.CUSTOMER_MODEL_FL
			  FROM SLM_ORDER_HEAD B3
			 WHERE 1 = 1   AND B3.VALIDFLAG = '1'
			 AND B3.ORDER_NO ||'&' LIKE '%' || ? || '%' 
             AND B3.CREATE_TIME>=TO_DATE(?,'YYYY-MM-DD HH24:MI:SS') 
             AND B3.CREATE_TIME <=TO_DATE(?,'YYYY-MM-DD HH24:MI:SS')
             AND B3.ORDER_STS >= 12020301
             AND B3.SUPPLY_UNIT='120504'
             AND B3.FST_DRAWEE_UNIT IN ('120604','120605')
        ]]>
        </query>
        
        <query id="frmOrderEffect.CoreOrderPriceQueryTh" desc="合同内部结算价维护">
        <![CDATA[
             SELECT ORDER_STS,
			       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = ORDER_STS AND VALIDFLAG = '1' ) ORDER_STS_DESC,
			       BE_ORDER_STS,
			       BE_ORDER_STS_DESC,
			       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 TYPE_CODE,
			       B3.SALE_AREA_DESC SALE_AREA_NO,
			       B3.ORDER_YEAR,
			       TO_CHAR(B3.SIGN_DATE,'YYYY-MM-DD') 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,
			       CLOSE_TIME,
			       TO_CHAR(B3.EFFECT_TIME,'YYYY-MM-DD HH24:MI:SS') EFFECT_TIME,
			       TO_CHAR(B3.APPROVAL_TIME,'YYYY-MM-DD') APPROVAL_TIME,
			       TO_CHAR(B3.DELETE_TIME,'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
			       B3.DELETE_NAME,
			       TO_CHAR(B3.UPDATE_TIME,'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
			       B3.UPDATE_NAME,
			       TO_CHAR(B3.CREATE_TIME,'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
			       B3.CREATE_NAME,
			       DECODE(B3.VALIDFLAG, '1', '有效', '0', '无效') VALIDFLAG,
			       B3.ORDER_MODEL_DESC,
			       (select t.order_model_desc from SLM_ORDER_MODEL_HEAD t where t.order_model_no=B3.ORDER_MODEL_NO) ORDER_MODEL_NO,
			       B3.MNY_ASK_DESC,
			       B3.MANAG_NO,
			       B3.CUSTOMER_NM,
			       B3.CUSTOMER_NO,
			       B3.MEMO,
			       B3.PRINT_PRICE,
			       (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,
			       B3.CUSTOMER_MODEL_FL
			  FROM SLM_ORDER_HEAD B3
			 WHERE 1 = 1   AND B3.VALIDFLAG = '1'
			 AND B3.ORDER_NO ||'&' LIKE '%' || ? || '%' 
             AND B3.CREATE_TIME>=TO_DATE(?,'YYYY-MM-DD HH24:MI:SS') 
             AND B3.CREATE_TIME <=TO_DATE(?,'YYYY-MM-DD HH24:MI:SS')
             AND B3.ORDER_STS >= 12020301
             AND B3.SUPPLY_UNIT='120504'
        ]]>
        </query>
        
        <query id="frmOrderEffect.saveInsidePrice" desc="合同头状态">
		<![CDATA[
	     UPDATE SLM_ORDER_LINE T
	     SET T.BALNCE_PRICE_ORG =?
	     WHERE ORD_LN_PK  = ?
				
		]]>
	</query>
	
	    <query id="frmOrderEffect.CoreOrderInsideSqeQuery" 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,
			        '(-' || TO_CHAR(DELVRY_RANGE_MIN) ||
			        DECODE(DELVRY_RANGE_TPE, '%', '%', ORDER_UNIT) || ',' ||
			        TO_CHAR(DELVRY_RANGE_MAX) ||
			        DECODE(DELVRY_RANGE_TPE, '%', '%', ORDER_UNIT) || ')' 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,
			        T. OUTS_BILLET_FL,
			        T. OUTS_STL_PIPE_FL,
			        T. ASSEL_FL,
			        T. ORDER_ADD_DESC,
			        T. CUST_ALPHA_NO,
			        T.BALNCE_PRICE_ORG,
			        T.OUT_PRICE,
			        T.BALNCE_PRICE,
			        T.ORD_LN_PK
			   FROM SLM_ORDER_LINE T
			  WHERE T.ORD_PK = ?  AND T.VALIDFLAG = '1'
			  ORDER BY T.ORDER_SEQ 
     ]]>
    </query>
	
	<query id="frmOrderEffect.CoreOrderCarryPriceQuery" desc="合同内部结算价维护">
        <![CDATA[
             SELECT ORDER_STS,
			       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = ORDER_STS AND VALIDFLAG = '1' ) ORDER_STS_DESC,
			       BE_ORDER_STS,
			       BE_ORDER_STS_DESC,
			       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 TYPE_CODE,
			       B3.SALE_AREA_DESC SALE_AREA_NO,
			       B3.ORDER_YEAR,
			       TO_CHAR(B3.SIGN_DATE,'YYYY-MM-DD') 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,
			       CLOSE_TIME,
			       TO_CHAR(B3.EFFECT_TIME,'YYYY-MM-DD HH24:MI:SS') EFFECT_TIME,
			       TO_CHAR(B3.APPROVAL_TIME,'YYYY-MM-DD') APPROVAL_TIME,
			       TO_CHAR(B3.DELETE_TIME,'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
			       B3.DELETE_NAME,
			       TO_CHAR(B3.UPDATE_TIME,'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
			       B3.UPDATE_NAME,
			       TO_CHAR(B3.CREATE_TIME,'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
			       B3.CREATE_NAME,
			       DECODE(B3.VALIDFLAG, '1', '有效', '0', '无效') VALIDFLAG,
			       B3.ORDER_MODEL_DESC,
			       (select t.order_model_desc from SLM_ORDER_MODEL_HEAD t where t.order_model_no=B3.ORDER_MODEL_NO) ORDER_MODEL_NO,
			       B3.MNY_ASK_DESC,
			       B3.MANAG_NO,
			       B3.CUSTOMER_NM,
			       B3.CUSTOMER_NO,
			       B3.MEMO,
			       B3.PRINT_PRICE,
			       (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,
			       B3.CUSTOMER_MODEL_FL
			  FROM SLM_ORDER_HEAD B3
			 WHERE 1 = 1   AND B3.VALIDFLAG = '1'
			 AND B3.ORDER_NO ||'&' LIKE '%' || ? || '%' 
             AND B3.CREATE_TIME>=TO_DATE(?,'YYYY-MM-DD HH24:MI:SS') 
             AND B3.CREATE_TIME <=TO_DATE(?,'YYYY-MM-DD HH24:MI:SS')
             AND B3.ORDER_STS >= 12020301
             AND B3.SUPPLY_UNIT='120504'
             AND B3.FST_DRAWEE_UNIT IN ('120604','120605')
        ]]>
        </query>
        
        <query id="frmOrderEffect.CoreOrderCarrySqeQuery" desc="合同生效管理合同行信息">
        <![CDATA[
            SELECT T.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,
			        '(-' || 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) || ')' 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,
			        T.OUTS_BILLET_FL,
			        T.OUTS_STL_PIPE_FL,
			        T.ASSEL_FL,
			        T.ORDER_ADD_DESC,
			        T.CUST_ALPHA_NO,
			        T.BALNCE_PRICE_ORG,
			        T.OUT_PRICE,
			        T.BALNCE_PRICE,
			        T.ORD_LN_PK,
			        NVL(M.ACT_WT,0) ACT_WT,
			        (SELECT NVL(SUM(C.CARRY_WT),0) FROM SLM_ORDER_CARRYORG C WHERE  T.ORD_LN_PK=C.ORD_LN_PK) CARRY_WT
			   FROM SLM_ORDER_LINE T
			   LEFT JOIN YDM_ZC_BILL_M M
			   ON T.ORD_LN_PK=M.ORD_LN_PK
			   AND M.VALIDFLAG = '1'
			  WHERE T.ORD_PK = ?  AND T.VALIDFLAG = '1'
			  ORDER BY T.ORDER_SEQ 
     ]]>
    </query>
    
     <query id="frmOrderEffect.CoreOrderCarryOrgInfo" desc="合同生效管理合同行信息">
        <![CDATA[
            SELECT  T.ID,
			        T.ORD_LN_PK,
			        T.CARRY_WT,
			        T.CARRY_DATE,
			        T.CREATE_NAME,
			        T.CREATE_TIME,
			        T.CARRY_PRICE,
			        T.CARRY_MONEY
			   FROM SLM_ORDER_CARRYORG T
			  WHERE T.ORD_LN_PK = ? 
			  ORDER BY T.CARRY_DATE 
     ]]>
    </query>
    
     <query id="frmOrderEffect.getCarryCount" desc="合同生效管理合同行信息">
        <![CDATA[
            SELECT  COUNT(1)
			   FROM SLM_ORDER_CARRYORG T
			  WHERE T.ORD_LN_PK = ? 
			  AND T.CARRY_DATE = ?
     ]]>
    </query>
    
     <query id="frmOrderEffect.saveCarryOrgInfo" desc="合同生效管理合同行信息">
        <![CDATA[
           INSERT INTO SLM_ORDER_CARRYORG 
			  (CARRY_PRICE ,
			  CARRY_WT,
			  CARRY_MONEY,
			  ORD_LN_PK,
			  CARRY_DATE,
			  CREATE_NAME,
			  CREATE_TIME)
			  VALUES 
			  (?,
			  ?,
			  ?,
			  ?,
			  ?,
			  ?,
			  SYSDATE)
     ]]>
    </query>
    
    
</queryMap>
