<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="工序层调整，重算交货行拆分排产量">
	<query id="CorePlnProcAdjust.getOrdLnCraftDesgin" desc="查询交货行质量设计">
		<![CDATA[
			SELECT T.DESGIN_KEY, M1.CRAFT_NAME, T.CRAFT_NO_V, T.CRAFT_NO
			  FROM CRAFT_ORD_DESIGN T
			  LEFT JOIN CRAFT_ORD_DESIGN_APPOINT M1
    			ON M1.ORD_LN_PK = T.ORD_LN_PK
			 WHERE T.ORD_LN_PK = ?
			   AND T.CRAFT_SEQ = ?
		]]>
	</query>
		
	<query id="CorePlnProcAdjust.getPlnSaleOrdInf" desc="查询排产表交货行信息">
		<![CDATA[
			SELECT T1.ORDER_QTY_D,
			       T1.ORDER_UNIT,
			       T1.PLAN_TOT_LEN_D,
			       T.LENGTHMAX,
			       T.LENGTHMIN,
			       T.OUTDIAMETER,
			       T.WALLTHICK,
			       NVL(T.WEIGH_TYPE,
			           (SELECT B.ASK_SUB_ITME_VAL_DESC
			              FROM SLM_ORDER_ADD_ASK B
			             WHERE B.ADD_ASK_NO = T.ADD_ASK_NO
			               AND B.ASK_ITME = '121005'
			               AND B.VALIDFLAG = '1')) WEIGH_TYPE,
			       (SELECT B.INSPECTION_VALUE
			          FROM SLM_ORDER_LINE B
			         WHERE B.VALIDFLAG = '1'
			           AND B.ORD_LN_PK = T.ORD_LN_PK) INSPECTION_VALUE,
			       T.DELVRY_RANGE_MIN,
			       T.DELVRY_RANGE_MAX,
			       T.DELVRY_RANGE_TPE,
			       T.MODEL_DESC,
			       T.SIGL_LEN,
			       T.SHORTEST,
			       T.SHRT_STOVE,
			       T.SHRT_LEN_RATO,
			       T.CODE_JG,
			       T.PRDCR_NO,
			       NVL(T.AVG_LEN_MIN, 0) AVG_LEN_MIN
			  FROM PLN_SALEORD T, PLN_SALEORD_PROC T1
			 WHERE T.ORD_LN_DLY_PK = T1.ORD_LN_DLY_PK
			   AND T1.ORD_LN_DLY_PK = ?
			   AND T1.PLN_DIVIDE_ID = ?
		]]>
	</query>
	
	<query id="CorePlnProcAdjust.getBomZgSpecInf" desc="查询BOM轧管规格">
		<![CDATA[
			SELECT T.GRADECODE,
			       T.D_IN_MATERIAL_NO,
			       T.D_OUT_MATERIAL_NO,
			       T.E_IN_MATERIAL_NO,
			       T.E_IN_MATERIAL_DESC,
			       T.E_OUT_MATERIAL_NO,
			       (SELECT B.DIMATER
			          FROM COM_BASE_SPEC B
			         WHERE B.SPEC_CODE = T.SPEC_CODE_R) DIMATER,
			       (SELECT B.HEIGHT
			          FROM COM_BASE_SPEC B
			         WHERE B.SPEC_CODE = T.SPEC_CODE_R) HEIGHT,
			       (SELECT B.DIMATER
			          FROM COM_BASE_SPEC B
			         WHERE B.SPEC_CODE = NVL(T.SPEC_CODE_D, T.SPEC_CODE_Z)) SPEC_BILT,
			       (SELECT LISTAGG(B.PLINE_NAME, ',') WITHIN GROUP(ORDER BY B.IN_MATERIAL_NO, B.OUT_MATERIAL_NO)
			          FROM SLM_BASE_MATERIAL_D_PL B
			         WHERE B.IN_MATERIAL_NO = T.D_IN_MATERIAL_NO
			           AND B.OUT_MATERIAL_NO = T.D_OUT_MATERIAL_NO
			           AND (B.DISABLE_FL != '1' OR B.DISABLE_FL IS NULL)) D_PLINE
			  FROM SLM_ORD_DESIGN_BOM T
			 WHERE T.BOM = ?
		]]>
	</query>
	
	<query id="CorePlnProcAdjust.getMscPlineGrade" desc="查询制程适用钢种">
		<![CDATA[
			SELECT LISTAGG(GRADENAME, ',') WITHIN GROUP(ORDER BY T.GRADECODE) GRADENAMEALL
			  FROM CRAFT_ORD_DESIGN_MSC_PL_GZ T
			 WHERE T.DESGIN_KEY = ?
			   AND T.MSC_PLINE = ?
		]]>
	</query>
	
	<query id="CorePlnProcAdjust.getComMscJg" desc="查询接箍信息">
		<![CDATA[
			SELECT T.WEIGHT_JG, T.CHECK_J_VAL
			  FROM COM_MSC_JG T
			 WHERE T.CODE_JG = ?
			   AND T.VALIDFLAG = '1'
		]]>
	</query>
	
	<query id="CorePlnProcAdjust.queryMscPlPrc" desc="查询工序内控标准索引号">
		<![CDATA[
			SELECT T.SIC, T.WHOLE_BACKLOG, T.PROCESS_CODE, T.PROCESS_DESC_C
			  FROM CRAFT_ORD_DESIGN_MSC_PL_PRC T
			 WHERE T.DESGIN_KEY = ?
			   AND T.MSC_PLINE = ?
		]]>
	</query>
	
	<query id="CorePlnProcAdjust.getZgBasePline" desc="查询BOM轧管规格">
		<![CDATA[
			SELECT PLINE_CODE,
			       PLINE_NAME,
			       PROCESS_CODE,
			       LENGTH_COLDBED,
			       LENGTH_MAX_RING,
			       LENGTH_MIN_RING,
			       BURNOUT_RATE,
			       NVL(T.LENGTH_MIN_TUBE, 0) LENGTH_MIN_TUBE,
                   NVL(T.LENGTH_MAX_TUBE, 0) LENGTH_MAX_TUBE,
                   NVL(T.TOLERANCE_ZONE, 0) TOLERANCE_ZONE
			  FROM COM_BASE_PLINE T
			 WHERE T.PROCESS_CODE = 'D'
			   AND T.PLINE_CODE = ?
			   AND T.VALIDFLAG = '1'
		]]>
	</query>
	
	<query id="CorePlnProcAdjust.getMaterialDPl" desc="查询轧管小时能力产线切头尾">
		<![CDATA[
			SELECT CROP_END, CROP_HEAD, TUBE_END_RATIO,
			       NVL(DBL_LEN_MAX,0) DBL_LEN_MAX
			  FROM SLM_BASE_MATERIAL_D_PL T
			 WHERE T.IN_MATERIAL_NO = ?
			   AND T.OUT_MATERIAL_NO = ?
			   AND T.PLINE_CODE = ?
			   AND (T.DISABLE_FL != '1' OR T.DISABLE_FL IS NULL)
		]]>
	</query>
	
	<query id="CorePlnProcAdjust.getMaterialEPl" desc="查询镦拔扩小时能力加长">
		<![CDATA[
			SELECT T.CROP_HEAD,
			       T.CROP_END,
			       T.UPSETTING_LENGTH,
			       T.PLINE_CODE,
			       B.BURNOUT_RATE
			  FROM SLM_BASE_MATERIAL_E_PL T
			  LEFT JOIN COM_BASE_PLINE B
			    ON B.PLINE_CODE = T.PLINE_CODE
			   AND B.VALIDFLAG = '1'
			 WHERE (T.DISABLE_FL != '1' OR T.DISABLE_FL IS NULL)
			   AND T.AUDIT_FLAG != '0'
			   AND T.IN_MATERIAL_NO = ?
			   AND T.OUT_MATERIAL_NO = ?
			   AND T.PLINE_CODE IN (SELECT B.PLINE_CODE
                                 FROM CRAFT_ORD_DESIGN_MSC_PL_GX_PRL B
                                WHERE B.PROCESS_CODE = 'E'
                                  AND B.DESGIN_KEY = ?
                                  AND B.MSC_PLINE = ?
                                  AND B.VALIDFLAG = '1')
			 ORDER BY T.PRD_RATE DESC
		]]>
	</query>
	
	<query id="CorePlnProcAdjust.getProcDivideId" desc="生产交货行拆分记录流水号">
		<![CDATA[
			SELECT LPAD(NVL(MAX(TO_NUMBER(B.PLN_DIVIDE_ID) + 1), 1), 2, '0') PLN_DIVIDE_ID
		     FROM PLN_SALEORD_PROC B
		    WHERE B.ORD_LN_DLY_PK = ?
		]]>
	</query>
		
	
	<query id="CorePlnProcAdjust.addProcOrd" desc="新增交货行拆分记录">
		<![CDATA[
			INSERT INTO PLN_SALEORD_PROC
				  (ORD_LN_DLY_PK,
				   PLN_DIVIDE_ID,
				   ORDER_SOURCE,
				   ORDER_NO,
				   ORDER_SEQ,
				   DELIVERY_NO,
				   PSC,
				   CRAFT_SEQ,
				   CRAFT_NO_V,
				   CRAFT_FILE_NO,
				   CRAFT_FILE_MAN,
				   MSC,
				   INDEX_SEQ,
				   PROCESS_SEQ,
				   BOM,
				   GRADECODE_ALL,
				   GRADECODE,
				   G_IS_OK,
				   GROUP_JGX,
				   F_IS_OK,
				   GROUP_RCL,
				   GROUP_ROLL_ALL,
				   GROUP_ROLL,
				   GROUP_ROLL_NAME,
				   BJ_TYPE,
				   E_IN_MATERIAL_NO,
				   E_IN_MATERIAL_DESC,
				   DIMATER_YLG,
				   HEIGHT_YLG,
				   MATERIAL_NO,
				   MATERIAL_DESC,
				   STUFF_PROPERTY,
				   GRADECODE_IS_OK,
				   D_IS_OK,
				   E_IS_OK,
				   WEIGHT_PER_M,
				   PLAN_WT_D,
				   PLAN_NUM_D,
				   FINISH_WT,
				   PLANSTATUS,
				   IF_ALLOW_ISSUE,
				   HEIGHT_NK_MIN,
				   HEIGHT_NK_MAX,
				   ORDER_QTY_D,
				   ORDER_UNIT,
				   PLAN_WT_BEGIN,
				   PLAN_NUM_BEGIN,
				   AIM_LEN_ROLL,
				   AIM_LEN_END,
				   PLAN_P_MAIN,
				   PLAN_TOT_LEN_D,
				   ISSUED_MAN,
				   ISSUED_TIME,
				   TOT_LEN_ONE_P,
				   CUT_NUM_P,
				   AIM_WALLTHICK,
				   ROLL_LENGTH,
				   PRDCRPRO)
				  SELECT B.ORD_LN_DLY_PK,
				         '#PLN_DIVIDE_ID#',
				         B.ORDER_SOURCE,
				         B.ORDER_NO,
				         B.ORDER_SEQ,
				         B.DELIVERY_NO,
				         B.PSC,
				         '#CRAFT_SEQ#',
				         '#CRAFT_NO_V#',
				         '#CRAFT_FILE_NO#',
				         '#CRAFT_FILE_MAN#',
				         B.MSC,
				         '#INDEX_SEQ#',
				         '#PROCESS_SEQ#',
				         '#BOM#',
				         '#GRADECODE_ALL#',
				         '#GRADECODE#',
				         B.G_IS_OK,
				         B.GROUP_JGX,
				         B.F_IS_OK,
				         B.GROUP_RCL,
				         '#GROUP_ROLL_ALL#',
				         '#GROUP_ROLL#',
				         (SELECT B.PLINE_NAME
				          FROM COM_BASE_PLINE B
				         WHERE B.PLINE_CODE = '#GROUP_ROLL#'),
				         NVL('#BJ_TYPE#', '/'),
				         '#E_IN_MATERIAL_NO#',
				         '#E_IN_MATERIAL_DESC#',
				         '#DIMATER_YLG#',
				         '#HEIGHT_YLG#',
				         B.MATERIAL_NO,
				         B.MATERIAL_DESC,
				         '#STUFF_PROPERTY#',
				         '1',
				         B.D_IS_OK,
				         B.E_IS_OK,
				         '#WEIGHT_PER_M#',
				         '#PLAN_WT_D#',
				         '#PLAN_NUM_D#',
				         '0',
				         '2',
				         '1',
				         '#HEIGHT_NK_MIN#',
				         '#HEIGHT_NK_MAX#',
				         '#ORDER_QTY_D#',
				         B.ORDER_UNIT,
				         '#PLAN_WT_D#',
				         '#PLAN_NUM_D#',
				         '#AIM_LEN_ROLL#',
				         '#AIM_LEN_END#',
				         '#PLAN_P_MAIN#',
				         '#PLAN_TOT_LEN_D#',
				         '#ISSUED_MAN#',
				         SYSDATE,
				         '#TOT_LEN_ONE_P#',
				         '#CUT_NUM_P#',
				         '#AIM_WALLTHICK#',
				         '#ROLL_LENGTH#',
				         '#PRDCRPRO#'
				    FROM PLN_SALEORD_PROC B
				   WHERE B.ORD_LN_DLY_PK = '#ORD_LN_DLY_PK#'
				     AND B.PLN_DIVIDE_ID = ?
		]]>
	</query>
		
</queryMap>