<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="后台线程监制信息维护">

	<query id="CoreOrderLinePrdcrTask.selectOrderLineEntity" desc="获取合同行的信息">
		<![CDATA[
		
	SELECT T.ORDER_LN_STATUS,
       ORD_PK,
       ORD_LN_PK,
       ORDER_SEQ,
       CUST_ALPHA_NO,
       PSC,
       PSC_DESC,
       MSC,
       MSC_DESC,
       MSC_STYLE,
       USE_CODE,
       USE_DESC,
       PRD_CLS,
       PRODUCCODE,
       PRODUCNAME,
       STD_CODE,
       STD_NAME,
       STEELCODE,
       STEELNAME,
       STD_STYLE,
       STD_STYLE_DESC,
       ORDER_SPEC_CODE,
       ORDER_SPEC_DESC,
       SPEC_CODE,
       SPEC_NAME,
       DIMATER,
       HEIGHT,
       MODEL_CODE,
       MODEL_DESC,
       LEN_NO,
       LEN_DESC,
       LEN_UNIT,
       LEN_MIN,
       LEN_MAX,
       SHRT_LEN_RATO,
       SHORTEST,
       LONG_LEN_RATO,
       LONGEST,
       SHRT_STOVE,
       AVG_LEN_MIN,
       DIFRNC_LEN_MAX,
       ENDLEN_SPECSTD,
       SIGL_LEN,
       ORDER_UNIT,
       ORDER_QTY,
       ORD_ENSU_TOTL_LEN,
       PRDCT_WGT,
       DELVRY_RANGE_TPE,
       DELVRY_RANGE_MIN,
       DELVRY_RANGE_MAX,
       FINAL_USER,
       FINAL_USER_DESC,
       OUTS_BILLET_FL,
       OUTS_STL_PIPE_FL,
       ASSEL_FL,
       PRODUCER_FL,
       PRDCR_NO,
       PRDCR_DESC,
       MPS_FL,
       MPS_NO,
       MPS_DESC,
       DELVRY_BDATE,
       DELVRY_EDATE,
       DELVRY_DESC,
       TRANS_DESC,
       ADD_ASK_NO,
       ORDER_ADD_DESC,
       ORDER_SPECIAL_FL,
       ORDER_SPECIAL_HEAD,
       ORDER_SPECIAL_PATH,
       ORDER_SPECIAL_DESC,
       ZBS,
       ORDER_PRICE,
       TRANS_PRICE,
       TEST_ID,
       TEST_PRICE,
       OUT_PRICE,
       BALNCE_PRICE,
       BE_ORDER_LN_STATUS,
       BE_OBJ_STS_OP,
       ORDER_LN_STATUS,
       OBJ_STS_OP,
       MEMO,
       VALIDFLAG,
       CREATE_NAME,
       CREATE_TIME,
       UPDATE_NAME,
       UPDATE_TIME,
       DELETE_NAME,
       DELETE_TIME,
       ORD_LN_PK_OLD,
       ISLOCK,
       CUST_ALPHA_NO2,
       ORDER_CHGE_NO,
       CHGE_ORD_LN_PK,
       BALNCE_PRICE_STS,
       BALNCE_PRICE_ORG,
       BALNCE_PRICE_ORG_STS
   FROM SLM_ORDER_LINE T
   WHERE T.VALIDFLAG = '1'
   AND T.ORDER_LN_STATUS >= '12020202'
   AND T.ORDER_LN_STATUS < '12020401'
   AND T.ORDER_LN_STATUS !='12020203'
   AND LENGTH(T.ORDER_LN_STATUS) = 8
   AND (T.PRDCR_NO IS NULL OR T.PRDCR_NO = '')
   AND T.PRODUCER_FL = '1'
		
		]]>
	</query>
	
	<query id="CoreOrderLinePrdcrTask.selectOrderLineDesignKey" desc="获取设计key">
		<![CDATA[
			SELECT DESGIN_KEY FROM SLM_ORD_DESIGN_MSC T
			WHERE T.ORD_LN_PK = ? AND T.VALIDFLAG = '1'
			]]>
	</query>
	
	<query id="CoreOrderLinePrdcrTask.selectDesignMscPl" desc="获取全制程">
		<![CDATA[
		SELECT DESGIN_KEY,
       MSC_PLINE,
       WHOLE_BACKLOG,
       WHOLE_BACKLOG_DESC,
       SET_FL,
       WARN_DESC,
       ORD_LN_PK
      FROM SLM_ORD_DESIGN_MSC_PL T
      WHERE T.DESGIN_KEY = ?
		
			]]>
	</query>
	
	<query id="CoreOrderLinePrdcrTask.selectDesignMscJgPl" desc="获取全制程">
		<![CDATA[
		SELECT DESGIN_KEY,
       CODE_JG,
       MSC_PLINE,
       WHOLE_BACKLOG,
       WHOLE_BACKLOG_DESC,
       SET_FL,
       WARN_DESC,
       ORD_LN_PK
       FROM SLM_ORD_DESIGN_MSC_JG_PL T
       WHERE T.DESGIN_KEY = ?
       AND T.CODE_JG = ?

		
			]]>
	</query>
	
	<query id="CoreOrderLinePrdcrTask.generatePrdcrNo" desc="生成监制编号">
	<![CDATA[
		SELECT ? ||
        LPAD(TO_NUMBER(NVL(SUBSTR(MAX(PRDCR_NO), 36, 3), '0')) + 1, 3, '0')
        FROM SLM_ORDER_LINE_PRDCR T
        WHERE SUBSTR(PRDCR_NO, 1, 35) = ?
		
			]]>
	</query>
	
	<query id="CoreOrderLinePrdcrTask.generatePrdcrNoIndex" desc="生成监制编号">
	<![CDATA[
	  SELECT NVL(MAX(PRDCR_INDEX), 0) + 1
      FROM SLM_ORDER_LINE_PRDCR
      WHERE PRDCR_NO = ?
		
	 ]]>
	</query>
	
	<query id="CoreOrderLinePrdcrTask.InsertOrderLinePrdcr" desc="插入监制主表">
		<![CDATA[
			INSERT INTO SLM_ORDER_LINE_PRDCR
  (PRDCR_NO,
   PSC,
   PSC_DESC,
   STD_CODE,
   STD_NAME,
   MPS,
   FINAL_USER,
   MSC_PLINE,
   MSC_PLINE_DESC,
   CREATE_NAME,
   CREATE_TIME,
   CODE_JG,
   CODE_BL,
   PRDCR_INDEX)
   VALUES
  ('#PRDCR_NO#',
   '#PSC#',
   '#PSC_DESC#',
   '#STD_CODE#',
   '#STD_NAME#',
   '#MPS#',
   '#FINAL_USER#',
   '#MSC_PLINE#',
   '#MSC_PLINE_DESC#',
   '#CREATE_NAME#',
    SYSDATE,
   '#CODE_JG#',
   '#CODE_BL#',
   TO_NUMBER('#PRDCR_INDEX#')
   )
			
			]]>
	</query>
	
	<query id="CoreOrderLinePrdcrTask.selectDesignMscPlSti" desc="制程工序点信息">
		<![CDATA[
			SELECT DESGIN_KEY,
       MSC_PLINE,
       WHOLE_BACKLOG,
       WHOLE_BACKLOG_DESC,
       BACKLOG_SEQ,
       PROCESS_CODE,
       PROCESS_DESC,
       PROCESS_SEQ,
       PROCESS_CODE_C,
       PROCESS_DESC_C,
       STATION_ID,
       STATION_CODE,
       STATION_DESC,
       STATION_TYPE,
       CRAFTITEM_CODE,
       CRAFTITEM_DESC
  FROM SLM_ORD_DESIGN_MSC_PL_STI T
  WHERE T.DESGIN_KEY = ?
  AND T.MSC_PLINE = ?
			
			]]>
	</query>
 
    <query id="CoreOrderLinePrdcrTask.selectDesignMscJgPlSti" desc="制程工序点信息">
		<![CDATA[
	  SELECT DESGIN_KEY,
       CODE_JG,
       MSC_PLINE,
       WHOLE_BACKLOG,
       WHOLE_BACKLOG_DESC,
       BACKLOG_SEQ,
       PROCESS_CODE,
       PROCESS_DESC,
       PROCESS_SEQ,
       PROCESS_CODE_C,
       PROCESS_DESC_C,
       STATION_ID,
       STATION_CODE,
       STATION_DESC,
       STATION_TYPE
     FROM SLM_ORD_DESIGN_MSC_JG_PL_STI T
     WHERE T.DESGIN_KEY = ?
     AND T.CODE_JG = ?
     AND T.MSC_PLINE = ?
	 			
	]]>
	</query>
 
   <query id="CoreOrderLinePrdcrTask.InsertOrderLinePrdcrLst" desc="插入监制从表信息">
		<![CDATA[
		INSERT INTO SLM_ORDER_LINE_PRDCR_LST
  (PRDCR_NO,
   PROCESS_CODE,
   PROCESS_DESC,
   PROCESS_CODE_C,
   PROCESS_DESC_C,
   STATION_CODE,
   STATION_DESC,
   PRDCR_INDEX)
  VALUES
  ('#PRDCR_NO#',
   '#PROCESS_CODE#',
   '#PROCESS_DESC#',
   '#PROCESS_CODE_C#',
   '#PROCESS_DESC_C#',
   '#STATION_CODE#',
   '#STATION_DESC#',
   TO_NUMBER('#PRDCR_INDEX#'))
		
			]]>
	</query>
	
	<query id="CoreOrderLinePrdcrTask.selectOrderLineJgCode" desc="获取全制程工序点信息">
		<![CDATA[
		SELECT KEY_JG  FROM  SLM_ORD_DESIGN_MSC_JG T
		WHERE T.DESGIN_KEY = ?
			]]>
	</query>
	
	<query id="CoreOrderLinePrdcrTask.selectOrderLineJgRBlCode" desc="接箍码关联的备料码">
		<![CDATA[
		 SELECT DESGIN_KEY, CODE_JG, PSC_BL, DESGIN_KEY_BL
       FROM SLM_ORD_DESIGN_MSC_JG_BL T
       WHERE T.DESGIN_KEY = ?
       AND CODE_JG = ?
		 
			]]>
	</query>
	
	<query id="CoreOrderLinePrdcrTask.selectDesignMscBlEntity" desc="获取全制程工序点信息">
		<![CDATA[
		 SELECT DESGIN_KEY, GROUP_NUM, PSC_BL, DESGIN_KEY_BL
         FROM SLM_ORD_DESIGN_MSC_BL T
         WHERE T.DESGIN_KEY = ?
		 
			]]>
	</query>
	
	<query id="CoreOrderLinePrdcrTask.setOrderLinePrdcrNo" desc="获取全制程工序点信息">
		<![CDATA[
		  UPDATE SLM_ORDER_LINE T
		  SET T.PRDCR_NO = ?
		  WHERE T.ORD_LN_PK = ?
		  AND T.PRODUCER_FL = '1'
		  AND T.VALIDFLAG = '1'
		 
			]]>
	</query>
	
</queryMap>
