<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="">

    <query id="CoreCastWell.GetDesignKey" desc="根据合同行号取得DesignKey">
         <![CDATA[
           SELECT DESGIN_KEY   FROM 
           SLM_ORD_DESIGN_MSC  T
           WHERE T.ORD_LN_PK = ?
           AND T.VALIDFLAG = '1'
         ]]>
	</query>
	
	<query id="CoreCastWell.GET_MSC_PL_PC" desc="质量设计-制程-生产周期主表">
         <![CDATA[
   SELECT DESGIN_KEY,
       ORD_LN_DLY_PK,
       MSC_PLINE,
       DELVRY_EDATE,
       DELVRY_QTY,
       ORDER_UNIT,
       RECEIV_NO,
       RECEIV_NM,
       RCMD_DELVRY_EDATE,
       PRD_CYC,
       PRD_CYC_BTCH,
       N_MATERIAL_FL,
       CYC_EDIT,
       CREATE_NAME,
       CREATE_TIME,
       UPDATE_NAME,
       UPDATE_TIME
  FROM SLM_ORD_DESIGN_MSC_PL_PC
  WHERE DESGIN_KEY = ? AND ORD_LN_DLY_PK = ?
         ]]>
	</query>
	
	
	<query id="CoreCastWell.GETSaleOrg" desc="取得合同的销售组织">
         <![CDATA[
              SELECT SALE_ORG,SALE_ORG_DESC,SUPPLY_UNIT
              FROM SLM_ORDER_HEAD T
              WHERE T.ORD_PK = ?
              AND T.VALIDFLAG = '1'
         ]]>
	</query>
	
	<query id="CoreCastWell.Get_MSC_PLPCLST" desc="查询生产周期从表数据">
        <![CDATA[ 
       SELECT DESGIN_KEY,
       ORD_LN_DLY_PK,
       MSC_PLINE,
       BACKLOG_SEQ,
       PROCESS_CODE,
       PROCESS_DESC,
       REVIEW_ASK,
       LST_PRD_DATE,
       PRD_CYC,
       PRD_CYC_BTCH
       FROM SLM_ORD_DESIGN_MSC_PL_PC_LST   T
       WHERE T.DESGIN_KEY = ? AND T.ORD_LN_DLY_PK = ?
       ORDER BY PROCESS_CODE DESC
         ]]>
	</query>
	
	<query id="CoreCastWell.GetWellCode" desc="取得产能井号">
        <![CDATA[ 
            SELECT WELL_CODE
       FROM SLM_ORD_DESIGN_MSC_PL_GX_PRL
       WHERE DESGIN_KEY = ?
        AND MSC_PLINE = ?
        AND PROCESS_CODE = ?
      
         ]]>
	</query>
	
	<query id="CoreCastWell.GetWellUseList" desc="产能井耗用">
        <![CDATA[ 
       SELECT WELL_CODE,
       WELL_NAME,
       WELL_YEAR,
       USE_MONTH,
       SALE_ORG,
       SALE_ORG_DESC,
       ORD_LN_DLY_PK,
       USE_OBJ,
       USE_TYPE,
       USE_WGT,
       CREATE_NAME,
       CREATE_TIME,
       UPDATE_NAME,
       UPDATE_TIME,
       DELETE_NAME,
       DELETE_TIME
  FROM SLM_WELL_USE_LIST T
  WHERE T.WELL_CODE = ?
  AND T.WELL_YEAR = TO_NUMBER(?)
  AND T.USE_MONTH = TO_NUMBER(?)
  AND T.SALE_ORG  = ?

         ]]>
	</query>
	
	<query id="CoreCastWell.GetWellResource" desc="产能井耗用">
        <![CDATA[ 
       SELECT SALE_ORG,
       SALE_ORG_DESC,
       PROCESS_CODE,
       PROCESS_DESC,
       YEAR,
       MONTH_1 MONTH1,
       MONTH_2 MONTH2,
       MONTH_3 MONTH3,
       MONTH_4 MONTH4,
       MONTH_5 MONTH5,
       MONTH_6 MONTH6,
       MONTH_7 MONTH7,
       MONTH_8 MONTH8,
       MONTH_9 MONTH9,
       MONTH_10 MONTH10,
       MONTH_11 MONTH11,
       MONTH_12 MONTH12,
       CREATE_NAME,
       CREATE_TIME,
       UPDATE_NAME,
       UPDATE_TIME,
       DELETE_NAME,
       DELETE_TIME,
       VALIDFLAG,
       MEMO
   FROM RES_BASE_RESOURCE_ALLOCATION T
   WHERE T.SALE_ORG = ?
   AND T.PROCESS_CODE = ?
   AND T.YEAR = TO_NUMBER(?)
   AND T.VALIDFLAG = '1'

         ]]>
	</query>
	
	<query id="CoreCastWell.GetDesignMscPl" desc="质量设计-制程">
        <![CDATA[ 
         SELECT MSC_PLINE,WHOLE_BACKLOG,WHOLE_BACKLOG_DESC 
         FROM SLM_ORD_DESIGN_MSC_PL T
         WHERE T.DESGIN_KEY = ?

         ]]>
	</query>
	
	<query id="CoreCastWell.DeleteWithDesignKey" desc="删除同一DesignKey的信息">
        <![CDATA[ 
          DELETE  FROM SLM_ORD_DESIGN_STS_PL_PC_LST  T
          WHERE T.DESGIN_KEY = ? AND ORD_LN_DLY_PK = ?

         ]]>
	</query>
	
	<query id="CoreCastWell.InsertPlPCLST" desc="插入生产周期状态">
        <![CDATA[ 
          INSERT INTO SLM_ORD_DESIGN_STS_PL_PC_LST
     (DESGIN_KEY,
     ORD_LN_PK,
     ORD_LN_DLY_PK,
     MSC_PLINE,
     WHOLE_BACKLOG,
     WHOLE_BACKLOG_DESC,
     PROCESS_CDOE,
     PROCESS_DESC,
     PRDCYC_MEET)
      VALUES
    (?, ?, ?, ?, ?, ?, ?, ?, ?)
          

         ]]>
	</query>
	
	
	
	<query id="CoreCastWell.DeletePLPC" desc="删除同一DesignKey的信息">
        <![CDATA[ 
          DELETE  FROM SLM_ORD_DESIGN_STS_PL_PC  T
          WHERE T.DESGIN_KEY = ?  AND ORD_LN_DLY_PK = ?

         ]]>
	</query>
	
	<query id="CoreCastWell.InsertPlPC" desc="插入生产周期状态">
        <![CDATA[ 
       INSERT INTO SLM_ORD_DESIGN_STS_PL_PC
  (DESGIN_KEY,
   ORD_LN_PK,
   ORD_LN_DLY_PK,
   MSC_PLINE,
   WHOLE_BACKLOG,
   WHOLE_BACKLOG_DESC,
   PRDCYC_MEET)
  VALUES
  (?, ?, ?, ?, ?, ?, ?)


         ]]>
	</query>
	
  <query id="CoreCastWell.SELECTWELLMONTH" desc="插入生产周期状态">
        <![CDATA[ 
        SELECT WELL_CODE,
       WELL_NAME,
       YEAR,
       MONTH_1 MONTH1,
       MONTH_2 MONTH2,
       MONTH_3 MONTH3,
       MONTH_4 MONTH4,
       MONTH_5 MONTH5,
       MONTH_6 MONTH6,
       MONTH_7 MONTH7,
       MONTH_8 MONTH8,
       MONTH_9 MONTH9,
       MONTH_10 MONTH10,
       MONTH_11 MONTH11,
       MONTH_12 MONTH12,
       CREATE_NAME,
       CREATE_TIME,
       UPDATE_NAME,
       UPDATE_TIME,
       DELETE_NAME,
       DELETE_TIME,
       VALIDFLAG,
       MEMO
  FROM COM_BASE_WELL_MONTH  T
  WHERE T.WELL_CODE = ?
  AND T.YEAR = TO_NUMBER(?)
        
         ]]>
	</query>
	
	<query id="CoreCastWell.UpdatePlPC" desc="插入生产周期状态">
        <![CDATA[ 
       UPDATE SLM_ORD_DESIGN_MSC_PL_PC
   SET RCMD_DELVRY_EDATE = TO_DATE(?,'YYYY-MM-DD')
       
   WHERE DESGIN_KEY = ?    
   AND ORD_LN_DLY_PK = ?
   
         ]]>
	</query>
	
	<query id="CoreCastWell.UpdatePlPCLST" desc="插入生产周期状态">
        <![CDATA[ 
         UPDATE SLM_ORD_DESIGN_MSC_PL_PC_LST
   SET LST_PRD_DATE =  TO_DATE(?,'YYYY-MM-DD') ,
       REVIEW_ASK = ?
   WHERE DESGIN_KEY = ?
   AND ORD_LN_DLY_PK = ?
   AND MSC_PLINE = ?
   AND PROCESS_CODE = ?
         
         ]]>
	</query>
	
	<query id="CoreCastWell.UpdatePlPCLSTNOASK" desc="插入生产周期状态">
        <![CDATA[ 
         UPDATE SLM_ORD_DESIGN_MSC_PL_PC_LST
   SET LST_PRD_DATE =  TO_DATE(?,'YYYY-MM-DD') 
     
   WHERE DESGIN_KEY = ?
   AND ORD_LN_DLY_PK = ?
   AND MSC_PLINE = ?
   AND PROCESS_CODE = ?
         
         ]]>
	</query>
	
	<query id="CoreCastWell.UpdatePlPCLSTNOLSTDATE" desc="插入生产周期状态">
        <![CDATA[ 
         UPDATE SLM_ORD_DESIGN_MSC_PL_PC_LST
    SET  
       REVIEW_ASK = ?
      
    WHERE 
    DESGIN_KEY = ?
    AND ORD_LN_DLY_PK = ?
    AND PROCESS_CODE = ?
         
         ]]>
	</query>
	
	<query id="CoreCastWell.SelectOrdLnPk" desc="插入生产周期状态">
        <![CDATA[ 
   
         SELECT ORD_LN_PK FROM SLM_ORDER_LINE 
         WHERE ORD_PK =? AND VALIDFLAG = '1'
         ]]>
	</query>
	
	<query id="CoreCastWell.SelectOrdLnPkMSC" desc="插入生产周期状态">
        <![CDATA[ 
   
         SELECT MSC FROM SLM_ORDER_LINE 
         WHERE ORD_LN_PK =? AND VALIDFLAG = '1'
         ]]>
	</query>
	
		<query id="CoreCastWell.getPlpcLstTime" desc="插入生产周期状态">
        <![CDATA[ 
   			SELECT SUM(NVL(PRD_CYC_BTCH, 0))
      FROM SLM_ORD_DESIGN_MSC_PL_PC_LST T
      WHERE T.DESGIN_KEY = ?
      AND T.ORD_LN_DLY_PK = ?
   			
          
         ]]>
	</query>
	
	

</queryMap>