<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="工序合同组订单">
	<query id="CorePlnGxOrdM.getSendVersionNo" desc="生成工序下发版次号">
		<![CDATA[
	SELECT TO_CHAR(SYSDATE, 'YYYYMMDD') ||
       LPAD(NVL(MAX(TO_NUMBER(SUBSTR(T.VERSION_NO, 9, 3))) + 1, 1), 3, '0') VERSION_NO
  FROM PLN_GXORD_VERSION T
 WHERE SUBSTR(T.VERSION_NO, 0, 8) = TO_CHAR(SYSDATE, 'YYYYMMDD')
		]]>
	</query>
	
	<query id="CorePlnGxOrdM.addIussedVersion" desc="新增下发版次记录">
		<![CDATA[
			INSERT INTO PLN_GXORD_VERSION
			  (VERSION_NO, VERSION_TYPE, OPERATE_NAME, OPERATE_TIME)
			VALUES
			  ('#VERSION_NO#', '#VERSION_TYPE#', '#OPERATE_NAME#', SYSDATE)
		]]>
	</query>
	
	
	<query id="CorePlnGxOrdM.queryJgxGxOrd" desc="查询加工工序合同">
		<![CDATA[
			SELECT T1.ROLL_MONTH,
			       T1.CRAFT_SEQ,
			       T2.ORD_LN_PK,
			       T2.OUTS_STL_PIPE_FL,
			       T.ORDERWEIGHT,
			       T.ORDERNUM,
			       ABS(DECODE(T2.DELVRY_RANGE_TPE,
			                  '绝对值',
			                  T2.DELVRY_RANGE_MAX * 100 / T2.ORDER_QTY,
			                  T2.DELVRY_RANGE_MAX)) DELVRY_RANGE_MAX,
			       ABS(DECODE(T2.DELVRY_RANGE_TPE,
			                  '绝对值',
			                  T2.DELVRY_RANGE_MIN * 100 / T2.ORDER_QTY,
			                  T2.DELVRY_RANGE_MIN)) DELVRY_RANGE_MIN,
			       (SELECT LISTAGG(PR.STATION_DESC, ',') WITHIN GROUP(ORDER BY PR.STATION_CODE ASC)
			          FROM SLM_ORDER_LINE_PRDCR_LST PR
			         WHERE PR.PRDCR_NO = P.PRDCR_NO
			           AND PR.PRDCR_INDEX = P.PRDCR_INDEX
			           AND PR.PRDCR_PRC_FL = '1'
			           AND PR.PROCESS_CODE = 'G') MONITOR_POINT,
			       T.PLAN_GROUP_ID,
			       T.PREVIOUS_GX_CODE
			  FROM PLN_ORDER_JGX T
			  LEFT JOIN SLM_ORDER_LINE_PRDCR P
			    ON P.PRDCR_NO = T.PRDCR_NO
			   AND P.MSC_PLINE = T.INDEX_SEQ
			   AND P.CODE_JG IS NULL
			   AND P.CODE_BL IS NULL, PLN_SALEORD_PROC T1, PLN_SALEORD T2
			 WHERE T2.ORD_LN_DLY_PK = T1.ORD_LN_DLY_PK
			   AND T1.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
			   AND T1.PLN_DIVIDE_ID = T.PLN_DIVIDE_ID
			   AND T.PRO_ORDER_NO = ?
		]]>
	</query>
	
	<query id="CorePlnGxOrdM.queryRclGxOrd" desc="查询热处理工序合同">
		<![CDATA[
			SELECT T1.ROLL_MONTH,
			       T1.CRAFT_SEQ,
			       T2.ORD_LN_PK,
			       T2.OUTS_STL_PIPE_FL,
			       T.ORDERWEIGHT,
			       T.ORDERNUM,
			       ABS(DECODE(T2.DELVRY_RANGE_TPE,
			                  '绝对值',
			                  T2.DELVRY_RANGE_MAX * 100 / T2.ORDER_QTY,
			                  T2.DELVRY_RANGE_MAX)) DELVRY_RANGE_MAX,
			       ABS(DECODE(T2.DELVRY_RANGE_TPE,
			                  '绝对值',
			                  T2.DELVRY_RANGE_MIN * 100 / T2.ORDER_QTY,
			                  T2.DELVRY_RANGE_MIN)) DELVRY_RANGE_MIN,
			       (SELECT LISTAGG(PR.STATION_DESC, ',') WITHIN GROUP(ORDER BY PR.STATION_CODE ASC)
			          FROM SLM_ORDER_LINE_PRDCR_LST PR
			         WHERE PR.PRDCR_NO = P.PRDCR_NO
			           AND PR.PRDCR_INDEX = P.PRDCR_INDEX
			           AND PR.PRDCR_PRC_FL = '1'
			           AND PR.PROCESS_CODE = 'F') MONITOR_POINT,
			       T.PLAN_GROUP_ID,
			       T.PREVIOUS_GX_CODE
			  FROM PLN_ORDER_RCL T
			  LEFT JOIN SLM_ORDER_LINE_PRDCR P
			    ON P.PRDCR_NO = T.PRDCR_NO
			   AND P.MSC_PLINE = T.INDEX_SEQ
			   AND P.CODE_JG IS NULL
			   AND P.CODE_BL IS NULL, PLN_SALEORD_PROC T1, PLN_SALEORD T2
			 WHERE T2.ORD_LN_DLY_PK = T1.ORD_LN_DLY_PK
			   AND T1.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
			   AND T1.PLN_DIVIDE_ID = T.PLN_DIVIDE_ID
			   AND T.PRO_ORDER_NO = ?
		]]>
	</query>
	
	<query id="CorePlnGxOrdM.queryDbkGxOrd" desc="查询镦拔扩工序合同">
		<![CDATA[
			SELECT T1.ROLL_MONTH,
			       T1.CRAFT_SEQ,
			       T2.ORD_LN_PK,
			       T2.OUTS_STL_PIPE_FL,
			       T.ORDERWEIGHT,
			       T.ORDERNUM,
			       ABS(DECODE(T2.DELVRY_RANGE_TPE,
			                  '绝对值',
			                  T2.DELVRY_RANGE_MAX * 100 / T2.ORDER_QTY,
			                  T2.DELVRY_RANGE_MAX)) DELVRY_RANGE_MAX,
			       ABS(DECODE(T2.DELVRY_RANGE_TPE,
			                  '绝对值',
			                  T2.DELVRY_RANGE_MIN * 100 / T2.ORDER_QTY,
			                  T2.DELVRY_RANGE_MIN)) DELVRY_RANGE_MIN,
			       (SELECT LISTAGG(PR.STATION_DESC, ',') WITHIN GROUP(ORDER BY PR.STATION_CODE ASC)
			          FROM SLM_ORDER_LINE_PRDCR_LST PR
			         WHERE PR.PRDCR_NO = P.PRDCR_NO
			           AND PR.PRDCR_INDEX = P.PRDCR_INDEX
			           AND PR.PRDCR_PRC_FL = '1'
			           AND PR.PROCESS_CODE = 'E') MONITOR_POINT,
			       T.PLAN_GROUP_ID,
			       T.PREVIOUS_GX_CODE
			  FROM PLN_ORDER_DBK T
			  LEFT JOIN SLM_ORDER_LINE_PRDCR P
			    ON P.PRDCR_NO = T.PRDCR_NO
			   AND P.MSC_PLINE = T.INDEX_SEQ
			   AND P.CODE_JG IS NULL
			   AND P.CODE_BL IS NULL, PLN_SALEORD_PROC T1, PLN_SALEORD T2
			 WHERE T2.ORD_LN_DLY_PK = T1.ORD_LN_DLY_PK
			   AND T1.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
			   AND T1.PLN_DIVIDE_ID = T.PLN_DIVIDE_ID
			   AND T.PRO_ORDER_NO = ?
		]]>
	</query>
	
	<query id="CorePlnGxOrdM.queryZgGxOrd" desc="查询轧管工序合同">
		<![CDATA[
			SELECT T1.ROLL_MONTH,
			       T1.CRAFT_SEQ,
			       T2.ORD_LN_PK,
			       T2.OUTS_STL_PIPE_FL,
			       T.ORDERWEIGHT,
			       T.ORDERNUM,
			       ABS(DECODE(T2.DELVRY_RANGE_TPE,
			                  '绝对值',
			                  T2.DELVRY_RANGE_MAX * 100 / T2.ORDER_QTY,
			                  T2.DELVRY_RANGE_MAX)) DELVRY_RANGE_MAX,
			       ABS(DECODE(T2.DELVRY_RANGE_TPE,
			                  '绝对值',
			                  T2.DELVRY_RANGE_MIN * 100 / T2.ORDER_QTY,
			                  T2.DELVRY_RANGE_MIN)) DELVRY_RANGE_MIN,
			       (SELECT LISTAGG(PR.STATION_DESC, ',') WITHIN GROUP(ORDER BY PR.STATION_CODE ASC)
			          FROM SLM_ORDER_LINE_PRDCR_LST PR
			         WHERE PR.PRDCR_NO = P.PRDCR_NO
			           AND PR.PRDCR_INDEX = P.PRDCR_INDEX
			           AND PR.PRDCR_PRC_FL = '1'
			           AND PR.PROCESS_CODE = 'D') MONITOR_POINT,
			       T.PLAN_GROUP_ID,
			       M1.CIC,
			       M1.PIC,
			       M1.SIC,
			       M1.DIC,
			       M1.WIC
			  FROM PLN_ORDER_ZG T
			  LEFT JOIN SLM_ORDER_LINE_PRDCR P
			    ON P.PRDCR_NO = T.PRDCR_NO
			   AND P.MSC_PLINE = T.INDEX_SEQ
			   AND P.CODE_JG IS NULL
			   AND P.CODE_BL IS NULL
			  LEFT JOIN PLN_SALEORD_PROC T1
			    ON T1.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
			   AND T1.PLN_DIVIDE_ID = T.PLN_DIVIDE_ID
			  LEFT JOIN PLN_SALEORD T2
			    ON T2.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
			  LEFT JOIN CRAFT_ORD_DESIGN M
			    ON M.ORD_LN_PK = T2.ORD_LN_PK
			   AND M.CRAFT_SEQ = T.CRAFT_SEQ
			  LEFT JOIN CRAFT_ORD_DESIGN_MSC_PL_PRC M1
			    ON M1.DESGIN_KEY = M.DESGIN_KEY
			   AND M1.MSC_PLINE = T.INDEX_SEQ
			   AND M1.PROCESS_CODE = 'D'
			 WHERE T.PRO_ORDER_NO = ?
		]]>
	</query>
	
	
	<query id="CorePlnGxOrdM.selectPlnGxJgxM" desc="查找加工工序订单">
		<![CDATA[
			SELECT T.PRO_PLAN_ID
			  FROM PLN_GX_JGX_M T, PLN_SALEORD T1
			 WHERE T1.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
			   AND T.IFBUYPLAN != '1'
			   AND T.ISENDGX != '1'
			   AND T1.ORD_LN_PK = ?
			   AND T.CRAFT_SEQ = ?
			   AND T.PRO_MONTH = ?
			   AND T.VERSION_NO = ?
			   AND T.ORDER_SOURCE <> '备料需求'
		]]>
	</query>
	
	<query id="CorePlnGxOrdM.selectPlnGxRclM" desc="查找热处理工序订单">
		<![CDATA[
			SELECT T.PRO_PLAN_ID
			  FROM PLN_GX_RCL_M T, PLN_SALEORD T1
			 WHERE T1.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
			   AND T.IFBUYPLAN != '1'
			   AND T.ISENDGX != '1'
			   AND T1.ORD_LN_PK = ?
			   AND T.CRAFT_SEQ = ?
			   AND T.PRO_MONTH = ?
			   AND T.VERSION_NO = ?
			   AND T.ORDER_SOURCE <> '备料需求'
		]]>
	</query>
	
	<query id="CorePlnGxOrdM.selectPlnGxDbkM" desc="查找镦拔扩工序订单">
		<![CDATA[
			SELECT T.PRO_PLAN_ID
			  FROM PLN_GX_DBK_M T, PLN_SALEORD T1
			 WHERE T1.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
			   AND T.IFBUYPLAN != '1'
			   AND T.ISENDGX != '1'
			   AND T1.ORD_LN_PK = ?
			   AND T.CRAFT_SEQ = ?
			   AND T.PRO_MONTH = ?
			   AND T.VERSION_NO = ?
			   AND T.ORDER_SOURCE <> '备料需求'
		]]>
	</query>
	
	<query id="CorePlnGxOrdM.selectPlnGxZgM" desc="查找轧管工序订单">
		<![CDATA[
			SELECT T.PRO_PLAN_ID
			  FROM PLN_GX_ZG_M T, PLN_SALEORD T1
			 WHERE T1.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
			   AND T.IFBUYPLAN != '1'
			   AND T.ISENDGX != '1'
			   AND T1.ORD_LN_PK = ?
			   AND T.CRAFT_SEQ = ?
			   AND T.PRO_MONTH = ?
			   AND T.VERSION_NO = ?
			   AND T.ORDER_SOURCE <> '备料需求'
		]]>
	</query>
	
	<query id="CorePlnGxOrdM.getPlnGxJgxMPlanId" desc="工序订单编号">
		<![CDATA[
			SELECT NVL(MAX(TO_NUMBER(SUBSTR(T.PRO_PLAN_ID, 10)) + 1), 0) AS PLAN_ID
			  FROM PLN_GX_JGX_M T
			 WHERE SUBSTR(T.PRO_PLAN_ID, 4, 6) = TO_CHAR(SYSDATE, 'YYYYMM')
		]]>
	</query>
	
	<query id="CorePlnGxOrdM.getPlnGxRclMPlanId" desc="工序订单编号">
		<![CDATA[
			SELECT NVL(MAX(TO_NUMBER(SUBSTR(T.PRO_PLAN_ID, 10)) + 1), 0) AS PLAN_ID
			  FROM PLN_GX_RCL_M T
			 WHERE SUBSTR(T.PRO_PLAN_ID, 4, 6) = TO_CHAR(SYSDATE, 'YYYYMM')
		]]>
	</query>
	
	<query id="CorePlnGxOrdM.getPlnGxDbkMPlanId" desc="工序订单编号">
		<![CDATA[
			SELECT NVL(MAX(TO_NUMBER(SUBSTR(T.PRO_PLAN_ID, 10)) + 1), 0) AS PLAN_ID
			  FROM PLN_GX_DBK_M T
			 WHERE SUBSTR(T.PRO_PLAN_ID, 4, 6) = TO_CHAR(SYSDATE, 'YYYYMM')
		]]>
	</query>
	
	<query id="CorePlnGxOrdM.getPlnGxZgMPlanId" desc="工序订单编号">
		<![CDATA[
			SELECT NVL(MAX(TO_NUMBER(SUBSTR(T.PRO_PLAN_ID, 10)) + 1), 0) AS PLAN_ID
			  FROM PLN_GX_ZG_M T
			 WHERE SUBSTR(T.PRO_PLAN_ID, 4, 6) = TO_CHAR(SYSDATE, 'YYYYMM')
		]]>
	</query>
	
	<query id="CorePlnGxOrdM.addPlnGxJgxM" desc="新增加工工序订单">
		<![CDATA[
			INSERT INTO PLN_GX_JGX_M
				  (PRO_PLAN_ID,
				   PRO_ORDER_NO,
				   ORDER_SOURCE,
				   ORD_LN_DLY_PK,
				   PLN_DIVIDE_ID,
				   ORDER_NO,
				   ORDER_SEQ,
				   DELIVERY_NO,
				   PLAN_GROUP_ID,
				   REQ_BL_ID,
				   GROUP_JGX,
				   STEELCODE,
				   STEELNAME,
				   OUTDIAMETER,
				   WALLTHICK,
				   AIMWALLTHICK,
				   LENGTHMAX,
				   LENGTHMIN,
				   LENGTHDISC,
				   AIMLENGTH,
				   SHRT_LEN_RATO,
				   SHORTEST,
				   LONG_LEN_RATO,
				   LONGEST,
				   SHRT_STOVE,
				   AVG_LEN_MIN,
				   DIFRNC_LEN_MAX,
				   SIGL_LEN,
				   ENDLEN_SPECSTD,
				   MODEL_CODE,
				   MODEL_DESC,
				   GETRATE,
				   LENGTHMAX_IN,
				   LENGTHMIN_IN,
				   INWL_ID,
				   INWL_DESC,
				   OUTWL_ID,
				   OUTWL_DESC,
				   PLANWEIGHT,
				   PLANNUM,
				   MATCH_WEIGHT,
				   MATCH_NUM,
				   REQ_PROD_WEIGHT,
				   IN_WEIGHT,
				   IN_NUM,
				   ISENDGX,
				   PREVIOUS_GX,
				   PREV_GXPLAN_ID,
				   IF_MONITOR_JGX,
				   PRDCR_NO,
				   MONITOR_POINT,
				   CRAFT_FILE_NO,
				   CRAFT_FILE_MAN,
				   CRAFT_SEQ,
				   PRO_MONTH,
				   PLANSTATUS,
				   CREATE_NAME,
				   CREATE_TIME,
				   PREVIOUS_GX_CODE,
				   PLINE_CODE,
				   PLINE_NAME,
				   PLAN_WT_MIN,
				   PLAN_WT_MAX,
				   VERSION_NO)
				  SELECT '#PRO_PLAN_ID#',
				         T.PRO_ORDER_NO,
				         T.ORDER_SOURCE,
				         T.ORD_LN_DLY_PK,
				         T.PLN_DIVIDE_ID,
				         T1.ORDER_NO,
				         T1.ORDER_SEQ,
				         T1.DELIVERY_NO,
				         T.PLAN_GROUP_ID,
				         T.REQ_BL_ID,
				         T.GROUP_JGX,
				         T.STEELCODE,
				         T.STEELNAME,
				         T.OUTDIAMETER,
				         T.WALLTHICK,
				         T.AIMWALLTHICK,
				         T.LENGTHMAX,
				         T.LENGTHMIN,
				         T.LENGTHDISC,
				         T.AIMLENGTH,
				         T1.SHRT_LEN_RATO,
				         T1.SHORTEST,
				         T1.LONG_LEN_RATO,
				         T1.LONGEST,
				         T1.SHRT_STOVE,
				         T1.AVG_LEN_MIN,
				         T1.DIFRNC_LEN_MAX,
				         T1.SIGL_LEN,
				         T1.ENDLEN_SPECSTD,
				         T.MODEL_CODE,
				         T.MODEL_DESC,
				         T.GETRATE,
				         T.LENGTHMAX_IN,
				         T.LENGTHMIN_IN,
				         T.INWL_ID,
				         K.IN_MATERIAL_DESC,
				         T.OUTWL_ID,
				         K.OUT_MATERIAL_DESC,
				         T.ORDERWEIGHT,
				         T.ORDERNUM,
				         NULL,
				         NULL,
				         NULL,
				         T.IN_WEIGHT,
				         T.IN_NUM,
				         T.ISENDGX,
				         T.PREVIOUS_GX,
				         '#PREV_GXPLAN_ID#',
				         T.IF_MONITOR_JGX,
				         T.PRDCR_NO,
				         '#MONITOR_POINT#',
				         T.CRAFT_FILE_NO,
				         T.CRAFT_FILE_MAN,
				         T.CRAFT_SEQ,
				         T2.ROLL_MONTH,
				         '0',
				         '#CREATE_NAME#',
				         SYSDATE,
				         T.PREVIOUS_GX_CODE,
				         T.PLINE_CODE,
				         T.PLINE_NAME,
				         '#PLAN_WT_MIN#',
				         '#PLAN_WT_MAX#',
				         '#VERSION_NO#'
				    FROM PLN_ORDER_JGX T
				    LEFT JOIN SLM_BASE_MATERIAL_K K
				      ON K.IN_MATERIAL_NO = T.INWL_ID
				     AND K.OUT_MATERIAL_NO = T.OUTWL_ID, PLN_SALEORD T1,
				   PLN_SALEORD_PROC T2
				   WHERE T1.ORD_LN_DLY_PK = T2.ORD_LN_DLY_PK
				     AND T.ORD_LN_DLY_PK = T2.ORD_LN_DLY_PK
				     AND T.PLN_DIVIDE_ID = T2.PLN_DIVIDE_ID
				     AND T.PRO_ORDER_NO = ?
		]]>
	</query>
	
	<query id="CorePlnGxOrdM.updatePlnGxJgxM" desc="更新加工工序订单">
		<![CDATA[
			UPDATE PLN_GX_JGX_M T
			   SET T.PLANWEIGHT  = NVL(T.PLANWEIGHT, 0) + NVL('#PLANWEIGHT#', 0),
			       T.PLANNUM     = NVL(T.PLANNUM, 0) + NVL('#PLANNUM#', 0),
			       T.IN_WEIGHT   = NVL(T.IN_WEIGHT, 0) + NVL('#IN_WEIGHT#', 0),
			       T.IN_NUM      = NVL(T.IN_NUM, 0) + NVL('#IN_NUM#', 0),
			       T.PLAN_WT_MIN = NVL(T.PLAN_WT_MIN, 0) + NVL('#PLAN_WT_MIN#', 0),
			       T.PLAN_WT_MAX = NVL(T.PLAN_WT_MAX, 0) + NVL('#PLAN_WT_MAX#', 0),
			       T.UPDATE_NAME = '#UPDATE_NAME#',
			       T.UPDATE_TIME = SYSDATE,
			       T.VERSION_NO	 = '#VERSION_NO#'
			 WHERE T.PRO_PLAN_ID = '#PRO_PLAN_ID#'
		]]>
	</query>
	
	<query id="CorePlnGxOrdM.addPlnGxRclM" desc="新增加工工序订单">
		<![CDATA[
			INSERT INTO PLN_GX_RCL_M
				  (PRO_PLAN_ID,
				   PRO_ORDER_NO,
				   ORDER_SOURCE,
				   ORD_LN_DLY_PK,
				   PLN_DIVIDE_ID,
				   ORDER_NO,
				   ORDER_SEQ,
				   DELIVERY_NO,
				   PLAN_GROUP_ID,
				   REQ_BL_ID,
				   GROUP_RCL,
				   PLINE_CODE,
				   PLINE_NAME,
				   STEELCODE,
				   STEELNAME,
				   OUTDIAMETER,
				   WALLTHICK,
				   AIMWALLTHICK,
				   LENGTHMAX,
				   LENGTHMIN,
				   AIMLENGTH,
				   GETRATE,
				   LENGTHMAX_IN,
				   LENGTHMIN_IN,
				   INWL_ID,
				   INWL_DESC,
				   OUTWL_ID,
				   OUTWL_DESC,
				   PLANWEIGHT,
				   PLANNUM,
				   MATCH_WEIGHT,
				   MATCH_NUM,
				   REQ_PROD_WEIGHT,
				   IN_WEIGHT,
				   IN_NUM,
				   ISENDGX,
				   PREVIOUS_GX,
				   PREV_GXPLAN_ID,
				   IF_MONITOR_RCL,
				   PRDCR_NO,
				   MONITOR_POINT,
				   CRAFT_FILE_NO,
				   CRAFT_FILE_MAN,
				   CRAFT_SEQ,
				   PRO_MONTH,
				   PLANSTATUS,
				   CREATE_NAME,
				   CREATE_TIME,
				   PREVIOUS_GX_CODE,
				   PLAN_WT_MIN,
				   PLAN_WT_MAX,
				   VERSION_NO)
				  SELECT '#PRO_PLAN_ID#',
				         T.PRO_ORDER_NO,
				         T.ORDER_SOURCE,
				         T.ORD_LN_DLY_PK,
				         T.PLN_DIVIDE_ID,
				         T.ORDER_NO,
				         T.ORDER_SEQ,
				         T.DELIVERY_NO,
				         T.PLAN_GROUP_ID,
				         T.REQ_BL_ID,
				         T.GROUP_RCL,
				         T.PLINE_CODE,
				         T.PLINE_NAME,
				         T.STEELCODE,
				         T.STEELNAME,
				         T.OUTDIAMETER,
				         T.WALLTHICK,
				         T.AIMWALLTHICK,
				         T.LENGTHMAX,
				         T.LENGTHMIN,
				         T.AIMLENGTH,
				         T.GETRATE,
				         (T.LENGTHMAX + NVL((L.INSPECTION_VALUE / 1000), 0)),
				         (T.LENGTHMIN + NVL((L.INSPECTION_VALUE / 1000), 0)),
				         T.INWL_ID,
				         K.IN_MATERIAL_DESC,
				         T.OUTWL_ID,
				         K.OUT_MATERIAL_DESC,
				         T.ORDERWEIGHT,
				         T.ORDERNUM,
				         NULL,
				         NULL,
				         NULL,
				         T.IN_WEIGHT,
				         T.IN_NUM,
				         T.ISENDGX,
				         T.PREVIOUS_GX,
				         '#PREV_GXPLAN_ID#',
				         T.IF_MONITOR_RCL,
				         T.PRDCR_NO,
				         '#MONITOR_POINT#',
				         T.CRAFT_FILE_NO,
				         T.CRAFT_FILE_MAN,
				         T.CRAFT_SEQ,
				         T2.ROLL_MONTH,
				         '0',
				         '#CREATE_NAME#',
				         SYSDATE,
				         T.PREVIOUS_GX_CODE,
				         '#PLAN_WT_MIN#',
				         '#PLAN_WT_MAX#',
				         '#VERSION_NO#'
				    FROM PLN_ORDER_RCL T
				    LEFT JOIN SLM_BASE_MATERIAL_F K
				      ON K.IN_MATERIAL_NO = T.INWL_ID
				     AND K.OUT_MATERIAL_NO = T.OUTWL_ID, PLN_SALEORD T1
				    LEFT JOIN SLM_ORDER_LINE L
				      ON L.ORD_LN_PK = T1.ORD_LN_PK
				     AND L.VALIDFLAG = '1', PLN_SALEORD_PROC T2
				   WHERE T1.ORD_LN_DLY_PK = T2.ORD_LN_DLY_PK
				     AND T.ORD_LN_DLY_PK = T2.ORD_LN_DLY_PK
				     AND T.PLN_DIVIDE_ID = T2.PLN_DIVIDE_ID
				     AND T.PRO_ORDER_NO = ?
		]]>
	</query>
	
	<query id="CorePlnGxOrdM.updatePlnGxRclM" desc="更新热处理工序订单">
		<![CDATA[
			UPDATE PLN_GX_RCL_M T
			   SET T.PLANWEIGHT  = NVL(T.PLANWEIGHT, 0) + NVL('#PLANWEIGHT#', 0),
			       T.PLANNUM     = NVL(T.PLANNUM, 0) + NVL('#PLANNUM#', 0),
			       T.IN_WEIGHT   = NVL(T.IN_WEIGHT, 0) + NVL('#IN_WEIGHT#', 0),
			       T.IN_NUM      = NVL(T.IN_NUM, 0) + NVL('#IN_NUM#', 0),
			       T.PLAN_WT_MIN = NVL(T.PLAN_WT_MIN, 0) + NVL('#PLAN_WT_MIN#', 0),
			       T.PLAN_WT_MAX = NVL(T.PLAN_WT_MAX, 0) + NVL('#PLAN_WT_MAX#', 0),
			       T.UPDATE_NAME = '#UPDATE_NAME#',
			       T.UPDATE_TIME = SYSDATE,
			       T.VERSION_NO	 = '#VERSION_NO#'
			 WHERE T.PRO_PLAN_ID = '#PRO_PLAN_ID#'
		]]>
	</query>
	
	<query id="CorePlnGxOrdM.addPlnGxDbkM" desc="新增镦拔扩工序订单">
		<![CDATA[
			INSERT INTO PLN_GX_DBK_M
				  (PRO_PLAN_ID,
				   PRO_ORDER_NO,
				   ORDER_SOURCE,
				   ORD_LN_DLY_PK,
				   PLN_DIVIDE_ID,
				   ORDER_NO,
				   ORDER_SEQ,
				   DELIVERY_NO,
				   PLAN_GROUP_ID,
				   REQ_BL_ID,
				   PLINE_CODE,
				   PLINE_NAME,
				   STEELCODE,
				   STEELNAME,
				   GRADECODE,
				   GRADENAME,
				   OUTDIAMETER,
				   WALLTHICK,
				   AIMWALLTHICK,
				   LENGTHMAX,
				   LENGTHMIN,
				   AIMLENGTH,
				   OUTWL_ID,
				   OUTWL_DESC,
				   GETRATE,
				   OUTDIAMETER_IN,
				   WALLTHICK_IN,
				   LENGTHMAX_IN,
				   LENGTHMIN_IN,
				   INWL_ID,
				   INWL_DESC,
				   PLANWEIGHT,
				   PLANNUM,
				   MATCH_WEIGHT,
				   MATCH_NUM,
				   REQ_PROD_WEIGHT,
				   IN_WEIGHT,
				   IN_NUM,
				   ISENDGX,
				   PREVIOUS_GX,
				   PREV_GXPLAN_ID,
				   IF_MONITOR_DBK,
				   PRDCR_NO,
				   MONITOR_POINT,
				   CRAFT_FILE_NO,
				   CRAFT_FILE_MAN,
				   CRAFT_SEQ,
				   PRO_MONTH,
				   PLANSTATUS,
				   CREATE_NAME,
				   CREATE_TIME,
				   PREVIOUS_GX_CODE,
				   PLAN_WT_MIN,
				   PLAN_WT_MAX,
				   VERSION_NO)
				  SELECT '#PRO_PLAN_ID#',
				         T.PRO_ORDER_NO,
				         T.ORDER_SOURCE,
				         T.ORD_LN_DLY_PK,
				         T.PLN_DIVIDE_ID,
				         T.ORDER_NO,
				         T.ORDER_SEQ,
				         T.DELIVERY_NO,
				         T.PLAN_GROUP_ID,
				         T.REQ_BL_ID,
				         T.PLINE_CODE,
				         T.PLINE_NAME,
				         T.STEELCODE,
				         T.STEELNAME,
				         B.GRADECODE,
				         B.GRADENAME,
				         T.OUTDIAMETER,
				         T.WALLTHICK,
				         T.AIMWALLTHICK,
				         T.LENGTHMAX,
				         T.LENGTHMIN,
				         T.AIMLENGTH,
				         T.OUTWL_ID,
				         K.OUT_MATERIAL_DESC,
				         T.GETRATE,
				         T.OUTDIAMETER_IN,
				         T.WALLTHICK_IN,
				         T.LENGTHMAX_IN,
				         T.LENGTHMIN_IN,
				         T.INWL_ID,
				         K.IN_MATERIAL_DESC,
				         T.ORDERWEIGHT,
				         T.ORDERNUM,
				         NULL,
				         NULL,
				         NULL,
				         T.IN_WEIGHT,
				         T.IN_NUM,
				         T.ISENDGX,
				         T.PREVIOUS_GX,
				         '#PREV_GXPLAN_ID#',
				         T.IF_MONITOR_BJ,
				         T.PRDCR_NO,
				         '#MONITOR_POINT#',
				         T.CRAFT_FILE_NO,
				         T.CRAFT_FILE_MAN,
				         T.CRAFT_SEQ,
				         T2.ROLL_MONTH,
				         '0',
				         '#CREATE_NAME#',
				         SYSDATE,
				         T.PREVIOUS_GX_CODE,
				         '#PLAN_WT_MIN#',
				         '#PLAN_WT_MAX#',
				         '#VERSION_NO#'
				    FROM PLN_ORDER_DBK T
				    LEFT JOIN SLM_BASE_MATERIAL_E K
				      ON K.IN_MATERIAL_NO = T.INWL_ID
				     AND K.OUT_MATERIAL_NO = T.OUTWL_ID, PLN_SALEORD T1,
				   PLN_SALEORD_PROC T2
				    LEFT JOIN COM_BASE_GRADE B
				      ON B.GRADECODE = T2.GRADECODE
				   WHERE T1.ORD_LN_DLY_PK = T2.ORD_LN_DLY_PK
				     AND T.ORD_LN_DLY_PK = T2.ORD_LN_DLY_PK
				     AND T.PLN_DIVIDE_ID = T2.PLN_DIVIDE_ID
				     AND T.PRO_ORDER_NO = ?
		]]>
	</query>
	
	<query id="CorePlnGxOrdM.updatePlnGxDbkM" desc="更新镦拔扩工序订单">
		<![CDATA[
			UPDATE PLN_GX_DBK_M T
			   SET T.PLANWEIGHT  = NVL(T.PLANWEIGHT, 0) + NVL('#PLANWEIGHT#', 0),
			       T.PLANNUM     = NVL(T.PLANNUM, 0) + NVL('#PLANNUM#', 0),
			       T.IN_WEIGHT   = NVL(T.IN_WEIGHT, 0) + NVL('#IN_WEIGHT#', 0),
			       T.IN_NUM      = NVL(T.IN_NUM, 0) + NVL('#IN_NUM#', 0),
			       T.PLAN_WT_MIN = NVL(T.PLAN_WT_MIN, 0) + NVL('#PLAN_WT_MIN#', 0),
			       T.PLAN_WT_MAX = NVL(T.PLAN_WT_MAX, 0) + NVL('#PLAN_WT_MAX#', 0),
			       T.UPDATE_NAME = '#UPDATE_NAME#',
			       T.UPDATE_TIME = SYSDATE,
			       T.VERSION_NO	 = '#VERSION_NO#'
			 WHERE T.PRO_PLAN_ID = '#PRO_PLAN_ID#'
		]]>
	</query>
	
	
	<query id="CorePlnGxOrdM.addPlnGxZgM" desc="新增轧管工序订单">
		<![CDATA[
			INSERT INTO PLN_GX_ZG_M
				  (PRO_PLAN_ID,
				   PRO_ORDER_NO,
				   ORDER_SOURCE,
				   ORD_LN_DLY_PK,
				   PLN_DIVIDE_ID,
				   ORDER_NO,
				   ORDER_SEQ,
				   DELIVERY_NO,
				   PLAN_GROUP_ID,
				   REQ_BL_ID,
				   PLINE_CODE,
				   PLINE_NAME,
				   STEELCODE,
				   STEELNAME,
				   GRADECODE,
				   GRADENAME,
				   OUTDIAMETER,
				   WALLTHICK,
				   AIMWALLTHICK,
				   LENGTHMAX,
				   LENGTHMIN,
				   AIMLENGTH,
				   OUTWL_ID,
				   OUTWL_DESC,
				   ROLL_LENGTH,
				   OUTNUM_SINGLE,
				   DIAMETER_MANDREL,
				   DIAMETER_GP,
				   LENGTH_GP,
				   INWL_GP,
				   INWL_DESC,
				   WEIGHT_GP_ONE,
				   GETRATE,
				   PLAN_WT,
				   PLAN_NUM,
				   MATCH_WEIGHT,
				   MATCH_NUM,
				   IFBUYPLAN,
				   BUYPLANID,
				   BUYPLANWEIGHT,
				   REQ_PROD_WEIGHT,
				   IN_WT,
				   IN_NUM,
				   ISENDGX,
				   PLANSTATUS,
				   IF_MONITOR_ZG,
				   PRDCR_NO,
				   MONITOR_POINT,
				   CRAFT_FILE_NO,
				   CRAFT_FILE_MAN,
				   CRAFT_SEQ,
				   PRO_MONTH,
				   CREATE_NAME,
				   CREATE_TIME,
				   PLAN_WT_MIN,
				   PLAN_WT_MAX,
				   VERSION_NO)
				  SELECT '#PRO_PLAN_ID#',
				         T.PRO_ORDER_NO,
				         T.ORDER_SOURCE,
				         T.ORD_LN_DLY_PK,
				         T.PLN_DIVIDE_ID,
				         T.ORDER_NO,
				         T.ORDER_SEQ,
				         T.DELIVERY_NO,
				         T.PLAN_GROUP_ID,
				         T.REQ_BL_ID,
				         T.PLINE_CODE,
				         T.PLINE_NAME,
				         T.STEELCODE,
				         T.STEELNAME,
				         B.GRADECODE,
				         B.GRADENAME,
				         T.OUTDIAMETER,
				         T.WALLTHICK,
				         T.AIMWALLTHICK,
				         T.LENGTHMAX,
				         T.LENGTHMIN,
				         T.AIMLENGTH,
				         T.OUTWL_ID,
				         K.OUT_MATERIAL_DESC,
				         T.ROLL_LENGTH,
				         T.OUTNUM_SINGLE,
				         '#DIAMETER_MANDREL#',
				         T.DIAMETER_GP,
				         T.LENGTH_GP,
				         T.INWL_GP,
				         K.IN_MATERIAL_DESC,
				         T.WEIGHT_GP_ONE,
				         T.GETRATE,
				         T.ORDERWEIGHT,
				         T.ORDERNUM,
				         NULL,
				         NULL,
				         '#IFBUYPLAN#',
				         NULL,
				         NULL,
				         NULL,
				         T.IN_WT,
				         T.IN_NUM,
				         T.ISENDGX,
				         '0',
				         T.IF_MONITOR_ZG,
				         T.PRDCR_NO,
				         '#MONITOR_POINT#',
				         T.CRAFT_FILE_NO,
				         T.CRAFT_FILE_MAN,
				         T.CRAFT_SEQ,
				         T2.ROLL_MONTH,
				         '#CREATE_NAME#',
				         SYSDATE,
				         '#PLAN_WT_MIN#',
				         '#PLAN_WT_MAX#',
				         '#VERSION_NO#'
				    FROM PLN_ORDER_ZG T
				    LEFT JOIN SLM_BASE_MATERIAL_D K
				      ON K.IN_MATERIAL_NO = T.INWL_GP
				     AND K.OUT_MATERIAL_NO = T.OUTWL_ID, PLN_SALEORD T1,
				   PLN_SALEORD_PROC T2
				    LEFT JOIN COM_BASE_GRADE B
				      ON B.GRADECODE = T2.GRADECODE
				   WHERE T1.ORD_LN_DLY_PK = T2.ORD_LN_DLY_PK
				     AND T.ORD_LN_DLY_PK = T2.ORD_LN_DLY_PK
				     AND T.PLN_DIVIDE_ID = T2.PLN_DIVIDE_ID
				     AND T.PRO_ORDER_NO = ?
		]]>
	</query>
	
	<query id="CorePlnGxOrdM.updatePlnGxZgM" desc="更新轧管工序订单">
		<![CDATA[
			UPDATE PLN_GX_ZG_M T
			   SET T.PLAN_WT     = NVL(T.PLAN_WT, 0) + NVL('#PLAN_WT#', 0),
			       T.PLAN_NUM    = NVL(T.PLAN_NUM, 0) + NVL('#PLAN_NUM#', 0),
			       T.IN_WT       = NVL(T.IN_WT, 0) + NVL('#IN_WT#', 0),
			       T.IN_NUM      = NVL(T.IN_NUM, 0) + NVL('#IN_NUM#', 0),
			       T.PLAN_WT_MIN = NVL(T.PLAN_WT_MIN, 0) + NVL('#PLAN_WT_MIN#', 0),
			       T.PLAN_WT_MAX = NVL(T.PLAN_WT_MAX, 0) + NVL('#PLAN_WT_MAX#', 0),
			       T.UPDATE_NAME = '#UPDATE_NAME#',
			       T.UPDATE_TIME = SYSDATE,
			       T.VERSION_NO	 = '#VERSION_NO#'
			 WHERE T.PRO_PLAN_ID = '#PRO_PLAN_ID#'
		]]>
	</query>
	
	
	<query id = "CorePlnGxOrdM.selectCountJgxGxM" desc = "查询加工订单向下的工序合同数">
		<![CDATA[
			SELECT T.PRO_PLAN_ID,
			       T.ORDERWEIGHT,
			       T.ORDERNUM,
			       T.GETRATE,
			       T.IN_WEIGHT,
			       T.IN_NUM,
			       ABS(DECODE(T2.DELVRY_RANGE_TPE,
			                  '绝对值',
			                  T2.DELVRY_RANGE_MAX * 100 / T2.ORDER_QTY,
			                  T2.DELVRY_RANGE_MAX)) DELVRY_RANGE_MAX,
			       ABS(DECODE(T2.DELVRY_RANGE_TPE,
			                  '绝对值',
			                  T2.DELVRY_RANGE_MIN * 100 / T2.ORDER_QTY,
			                  T2.DELVRY_RANGE_MIN)) DELVRY_RANGE_MIN
			  FROM PLN_ORDER_JGX T
			  LEFT JOIN PLN_ORDER_JGX T1
			    ON T1.PRO_PLAN_ID = T.PRO_PLAN_ID
			  LEFT JOIN PLN_SALEORD T2
			    ON T2.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
			 WHERE T.PRO_ORDER_NO = ?
		]]>
	</query>
	
	<query id = "CorePlnGxOrdM.deleteGxJgxM" desc = "删除加工线订单">
		<![CDATA[
			DELETE FROM PLN_GX_JGX_M T WHERE T.PRO_PLAN_ID = ?
		]]>
	</query>
	
	<query id = "CorePlnGxOrdM.selectCountRclGxM" desc = "查询热处理订单向下的工序合同数">
		<![CDATA[
			SELECT T.PRO_PLAN_ID,
			       T.ORDERWEIGHT,
			       T.ORDERNUM,
			       T.GETRATE,
			       T.IN_WEIGHT,
			       T.IN_NUM,
			       ABS(DECODE(T2.DELVRY_RANGE_TPE,
			                  '绝对值',
			                  T2.DELVRY_RANGE_MAX * 100 / T2.ORDER_QTY,
			                  T2.DELVRY_RANGE_MAX)) DELVRY_RANGE_MAX,
			       ABS(DECODE(T2.DELVRY_RANGE_TPE,
			                  '绝对值',
			                  T2.DELVRY_RANGE_MIN * 100 / T2.ORDER_QTY,
			                  T2.DELVRY_RANGE_MIN)) DELVRY_RANGE_MIN
			  FROM PLN_ORDER_RCL T
			  LEFT JOIN PLN_ORDER_RCL T1
			    ON T1.PRO_PLAN_ID = T.PRO_PLAN_ID
			  LEFT JOIN PLN_SALEORD T2
			    ON T2.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
			 WHERE T.PRO_ORDER_NO = ?
		]]>
	</query>
	
	<query id = "CorePlnGxOrdM.deleteGxRclM" desc = "删除热处理工序订单">
		<![CDATA[
			DELETE FROM PLN_GX_RCL_M T WHERE T.PRO_PLAN_ID = ?
		]]>
	</query>
	
	<query id = "CorePlnGxOrdM.selectCountDbkGxM" desc = "查询镦拔扩订单向下的工序合同数">
		<![CDATA[
			SELECT T.PRO_PLAN_ID,
			       T.ORDERWEIGHT,
			       T.ORDERNUM,
			       T.GETRATE,
			       T.IN_WEIGHT,
			       T.IN_NUM,
			       ABS(DECODE(T2.DELVRY_RANGE_TPE,
			                  '绝对值',
			                  T2.DELVRY_RANGE_MAX * 100 / T2.ORDER_QTY,
			                  T2.DELVRY_RANGE_MAX)) DELVRY_RANGE_MAX,
			       ABS(DECODE(T2.DELVRY_RANGE_TPE,
			                  '绝对值',
			                  T2.DELVRY_RANGE_MIN * 100 / T2.ORDER_QTY,
			                  T2.DELVRY_RANGE_MIN)) DELVRY_RANGE_MIN
			  FROM PLN_ORDER_DBK T
			  LEFT JOIN PLN_ORDER_DBK T1
			    ON T1.PRO_PLAN_ID = T.PRO_PLAN_ID
			  LEFT JOIN PLN_SALEORD T2
			    ON T2.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
			 WHERE T.PRO_ORDER_NO = ?
		]]>
	</query>
	
	<query id = "CorePlnGxOrdM.deleteGxDbkM" desc = "删除热处理工序订单">
		<![CDATA[
			DELETE FROM PLN_GX_DBK_M T WHERE T.PRO_PLAN_ID = ?
		]]>
	</query>
	
	
	
	<query id = "CorePlnGxOrdM.selectCountZgGxM" desc = "查询轧管订单向下的工序合同数">
		<![CDATA[
			SELECT T.PRO_PLAN_ID,
			       T.ORDERWEIGHT,
			       T.ORDERNUM,
			       T.GETRATE,
			       T.IN_WT,
			       T.IN_NUM,
			       ABS(DECODE(T2.DELVRY_RANGE_TPE,
			                  '绝对值',
			                  T2.DELVRY_RANGE_MAX * 100 / T2.ORDER_QTY,
			                  T2.DELVRY_RANGE_MAX)) DELVRY_RANGE_MAX,
			       ABS(DECODE(T2.DELVRY_RANGE_TPE,
			                  '绝对值',
			                  T2.DELVRY_RANGE_MIN * 100 / T2.ORDER_QTY,
			                  T2.DELVRY_RANGE_MIN)) DELVRY_RANGE_MIN
			  FROM PLN_ORDER_ZG T
			  LEFT JOIN PLN_ORDER_ZG T1
			    ON T1.PRO_PLAN_ID = T.PRO_PLAN_ID
			  LEFT JOIN PLN_SALEORD T2
			    ON T2.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
			 WHERE T.PRO_ORDER_NO = ?
		]]>
	</query>
	
	<query id = "CorePlnGxOrdM.deleteGxZgM" desc = "删除轧管工序订单">
		<![CDATA[
			DELETE FROM PLN_GX_ZG_M T WHERE T.PRO_PLAN_ID = ?
		]]>
	</query>
	
	
</queryMap>