<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="工序合同">

	<query id="CoreProcessOrdReq.getZgReqOrderNo" desc="获取轧管工序补量合同合同号">
		<![CDATA[
			SELECT 'ZG_' || TO_CHAR(SYSDATE, 'YYYYMMDD') ||
	                LPAD(NVL(MAX(TO_NUMBER(SUBSTR(T.PRO_ORDER_NO, 12)) + 1),
	                         '1'),
	                     4,
	                     '0') ORDER_NO
	           FROM PLN_ORDER_ZG T
	          WHERE SUBSTR(T.PRO_ORDER_NO, 4, 8) = TO_CHAR(SYSDATE, 'YYYYMMDD')
		]]>
	</query>
	
	<query id="CoreProcessOrdReq.getDbkReqOrderNo" desc="获取镦拔扩工序补量合同合同号">
		<![CDATA[
			SELECT 'DBK' || TO_CHAR(SYSDATE, 'YYYYMMDD') ||
		                         LPAD(NVL(MAX(TO_NUMBER(SUBSTR(T.PRO_ORDER_NO, 12)) + 1),
		                                  '1'),
		                              4,
		                              '0') ORDER_NO
		                    FROM PLN_ORDER_DBK T
		                   WHERE SUBSTR(T.PRO_ORDER_NO, 4, 8) = TO_CHAR(SYSDATE, 'YYYYMMDD')
		]]>
	</query>
	
	<query id="CoreProcessOrdReq.getRclReqOrderNo" desc="获取热处理工序补量合同合同号">
		<![CDATA[
			SELECT 'RCL' || TO_CHAR(SYSDATE, 'YYYYMMDD') ||
				                 LPAD(NVL(MAX(TO_NUMBER(SUBSTR(T.PRO_ORDER_NO, 12)) + 1),
				                          '1'),
				                      4,
				                      '0') ORDER_NO
				            FROM PLN_ORDER_RCL T
				           WHERE SUBSTR(T.PRO_ORDER_NO, 4, 8) = TO_CHAR(SYSDATE, 'YYYYMMDD')
		]]>
	</query>
	
	<query id="CoreProcessOrdReq.addZgReqOrder" desc="新增轧管工序补量合同">
		<![CDATA[
			INSERT INTO PLN_ORDER_ZG
				  (PRO_ORDER_NO,
				   PLAN_GROUP_ID,
				   ORDER_SOURCE,
				   ORD_LN_DLY_PK,
				   PLN_DIVIDE_ID,
				   ORDER_NO,
				   ORDER_SEQ,
				   DELIVERY_NO,
				   REQ_BL_ID,
				   INDEX_SEQ,
				   BOM,
				   BACKLOG_SEQ,
				   STEELCODE,
				   STEELNAME,
				   OUTDIAMETER,
				   WALLTHICK,
				   AIMWALLTHICK,
				   LENGTHMAX,
				   LENGTHMIN,
				   AIMLENGTH,
				   OUTWL_ID,
				   ROLL_LENGTH,
				   OUT_LENGTH,
				   OUTNUM_SINGLE,
				   DIAMETER_GP,
				   LENGTH_GP,
				   INWL_GP,
				   WEIGHT_GP_ONE,
				   GETRATE,
				   PLINE_CODE_MAY,
				   PLINE_NAME_MAY,
				   PLINE_CODE,
				   PLINE_NAME,
				   ORDERWEIGHT,
				   ORDERNUM,
				   IFBUYPLAN,
				   PROD_END_DATE,
				   ORDERSTATUS,
				   IS_PLANED,
				   PRO_PLAN_ID,
				   FINISHWEIGHT,
				   ISENDGX,
				   NEXT_GX,
				   IS_EXTRA_ORD,
				   IF_MONITOR_ZG,
				   PRDCR_NO,
				   CRAFT_FILE_NO,
				   CRAFT_FILE_MAN,
				   CREATE_NAME,
				   CREATE_TIME,
				   CRAFT_SEQ,
				   PASS_CODE,
				   PASS_NAME,
				   GO_TYPE,
				   PROCESS_CODE_C,
				   PROCESS_DESC_C,
				   STATION_ROAD,
				   CRAFT_NO_V,
				   BUYER_NAME,
				   FINAL_USER_DESC,
				   ORDER_ADD_DESC)
				  SELECT '#PRO_ORDER_NO#',
				         T.PLAN_GROUP_ID,
				         T.ORDER_SOURCE,
				         T.ORD_LN_DLY_PK,
				         T.PLN_DIVIDE_ID,
				         T.ORDER_NO,
				         T.ORDER_SEQ,
				         T.DELIVERY_NO,
				         T.REQ_BL_ID,
				         T.INDEX_SEQ,
				         T.BOM,
				         T.BACKLOG_SEQ,
				         T.STEELCODE,
				         T.STEELNAME,
				         T.OUTDIAMETER,
				         T.WALLTHICK,
				         T.AIMWALLTHICK,
				         T.LENGTHMAX,
				         T.LENGTHMIN,
				         T.AIMLENGTH,
				         T.OUTWL_ID,
				         T.ROLL_LENGTH,
				         T.OUT_LENGTH,
				         T.OUTNUM_SINGLE,
				         T.DIAMETER_GP,
				         T.LENGTH_GP,
				         T.INWL_GP,
				         T.WEIGHT_GP_ONE,
				         T.GETRATE,
				         T.PLINE_CODE_MAY,
				         T.PLINE_NAME_MAY,
				         T.PLINE_CODE,
				         T.PLINE_NAME,
				         '#ORDERWEIGHT#',
				         (T.ORDERNUM * '#ORDERWEIGHT#' / T.ORDERWEIGHT),
				         T.IFBUYPLAN,
				         T.PROD_END_DATE,
				         '1',
				         '0',
				         T.PRO_PLAN_ID,
				         '0',
				         T.ISENDGX,
				         T.NEXT_GX,
				         '1',
				         T.IF_MONITOR_ZG,
				         T.PRDCR_NO,
				         T.CRAFT_FILE_NO,
				         T.CRAFT_FILE_MAN,
				         '#CREATE_NAME#',
				         SYSDATE,
				         T.CRAFT_SEQ,
				         T.PASS_CODE,
				         T.PASS_NAME,
				         T.GO_TYPE,
				         T.PROCESS_CODE_C,
				         T.PROCESS_DESC_C,
				         T.STATION_ROAD,
				         T.CRAFT_NO_V,
				         T.BUYER_NAME,
				         T.FINAL_USER_DESC,
				         T.ORDER_ADD_DESC
				    FROM PLN_ORDER_ZG T
				   WHERE T.PLAN_GROUP_ID = '#PLAN_GROUP_ID#'
				     AND T.IS_EXTRA_ORD = '0'
				     AND ROWNUM = 1
		]]>
	</query>

	<query id="CoreProcessOrdReq.addDbkReqOrder" desc="新增热处理工序补量合同">
		<![CDATA[
			INSERT INTO PLN_ORDER_DBK
		          (PRO_ORDER_NO,
		           PLAN_GROUP_ID,
		           ORDER_SOURCE,
		           ORD_LN_DLY_PK,
		           PLN_DIVIDE_ID,
		           ORDER_NO,
		           ORDER_SEQ,
		           DELIVERY_NO,
		           REQ_BL_ID,
		           INDEX_SEQ,
		           BOM,
		           BACKLOG_SEQ,
		           STEELCODE,
		           STEELNAME,
		           OUTWL_ID,
		           OUTDIAMETER,
		           WALLTHICK,
		           AIMWALLTHICK,
		           LENGTHMAX,
		           LENGTHMIN,
		           AIMLENGTH,
		           INWL_ID,
		           OUTDIAMETER_IN,
		           WALLTHICK_IN,
		           LENGTHMAX_IN,
		           LENGTHMIN_IN,
		           GETRATE,
		           BJ_TYPE,
		           PLINE_CODE_MAY,
		           PLINE_NAME_MAY,
		           ORDERWEIGHT,
		           ORDERNUM,
		           IFBUYPLAN,
		           PROD_END_DATE,
		           ORDERSTATUS,
		           IS_PLANED,
		           PRO_PLAN_ID,
		           FINISHWEIGHT,
		           ISENDGX,
		           NEXT_GX,
		           IS_EXTRA_ORD,
		           IF_MONITOR_BJ,
		           PRDCR_NO,
		           CRAFT_FILE_NO,
		           CRAFT_FILE_MAN,
		           CREATE_NAME,
		           CREATE_TIME,
		           CRAFT_SEQ,
		           PLINE_CODE,
		           PLINE_NAME,
		           PROCESS_CODE_C,
		           PROCESS_DESC_C,
		           STATION_ROAD)
		          SELECT '#PRO_ORDER_NO#',
		                 T.PLAN_GROUP_ID,
		                 T.ORDER_SOURCE,
		                 T.ORD_LN_DLY_PK,
		                 T.PLN_DIVIDE_ID,
		                 T.ORDER_NO,
		                 T.ORDER_SEQ,
		                 T.DELIVERY_NO,
		                 T.REQ_BL_ID,
		                 T.INDEX_SEQ,
		                 T.BOM,
		                 T.BACKLOG_SEQ,
		                 T.STEELCODE,
		                 T.STEELNAME,
		                 T.OUTWL_ID,
		                 T.OUTDIAMETER,
		                 T.WALLTHICK,
		                 T.AIMWALLTHICK,
		                 T.LENGTHMAX,
		                 T.LENGTHMIN,
		                 T.AIMLENGTH,
		                 T.INWL_ID,
		                 T.OUTDIAMETER_IN,
		                 T.WALLTHICK_IN,
		                 T.LENGTHMAX_IN,
		                 T.LENGTHMIN_IN,
		                 T.GETRATE,
		                 T.BJ_TYPE,
		                 T.PLINE_CODE_MAY,
		                 T.PLINE_NAME_MAY,
		                 '#ORDERWEIGHT#',
		                 (T.ORDERNUM * '#ORDERWEIGHT#' / T.ORDERWEIGHT),
		                 T.IFBUYPLAN,
		                 T.PROD_END_DATE,
				         '1',
				         '0',
		                 T.PRO_PLAN_ID,
		                 0,
		                 T.ISENDGX,
		                 T.NEXT_GX,
		                 '1',
		                 T.IF_MONITOR_BJ,
		                 T.PRDCR_NO,
		                 T.CRAFT_FILE_NO,
		                 T.CRAFT_FILE_MAN,
		                 '#CREATE_NAME#',
		                 SYSDATE,
		                 T.CRAFT_SEQ,
		                 T.PLINE_CODE,
		                 T.PLINE_NAME,
		                 T.PROCESS_CODE_C,
		                 T.PROCESS_DESC_C,
		                 T.STATION_ROAD
		            FROM PLN_ORDER_DBK
		           WHERE T.PLAN_GROUP_ID = '#PLAN_GROUP_ID#'
		             AND T.IS_EXTRA_ORD = '0'
		             AND ROWNUM = 1
		]]>
	</query>
	
	<query id="CoreProcessOrdReq.addRclReqOrder" desc="新增热处理工序补量合同">
		<![CDATA[
			INSERT INTO PLN_ORDER_RCL
				  (PRO_ORDER_NO,
				   PLAN_GROUP_ID,
				   ORDER_SOURCE,
				   ORD_LN_DLY_PK,
				   PLN_DIVIDE_ID,
				   ORDER_NO,
				   ORDER_SEQ,
				   DELIVERY_NO,
				   REQ_BL_ID,
				   INDEX_SEQ,
				   BOM,
				   BACKLOG_SEQ,
				   STEELCODE,
				   STEELNAME,
				   OUTDIAMETER,
				   WALLTHICK,
				   AIMWALLTHICK,
				   LENGTHMAX,
				   LENGTHMIN,
				   AIMLENGTH,
				   GETRATE,
				   INWL_ID,
				   OUTWL_ID,
				   GROUP_RCL,
				   PLINE_CODE_MAY,
				   PLINE_NAME_MAY,
				   ORDERWEIGHT,
				   ORDERNUM,
				   IFBUYPLAN,
				   PROD_END_DATE,
				   ORDERSTATUS,
				   IS_PLANED,
				   PRO_PLAN_ID,
				   FINISHWEIGHT,
				   ISENDGX,
				   NEXT_GX,
				   IS_EXTRA_ORD,
				   IF_MONITOR_RCL,
				   PRDCR_NO,
				   CRAFT_FILE_NO,
				   CRAFT_FILE_MAN,
				   CREATE_NAME,
				   CREATE_TIME,
				   PLINE_CODE,
				   PLINE_NAME,
				   CRAFT_SEQ,
				   PROCESS_CODE_C,
				   PROCESS_DESC_C,
				   STATION_ROAD,
				   IF_SET_TIME)
				  SELECT '#PRO_ORDER_NO#',
				         T.PLAN_GROUP_ID,
				         T.ORDER_SOURCE,
				         T.ORD_LN_DLY_PK,
				         T.PLN_DIVIDE_ID,
				         T.ORDER_NO,
				         T.ORDER_SEQ,
				         T.DELIVERY_NO,
				         T.REQ_BL_ID,
				         T.INDEX_SEQ,
				         T.BOM,
				         T.BACKLOG_SEQ,
				         T.STEELCODE,
				         T.STEELNAME,
				         T.OUTDIAMETER,
				         T.WALLTHICK,
				         T.AIMWALLTHICK,
				         T.LENGTHMAX,
				         T.LENGTHMIN,
				         T.AIMLENGTH,
				         T.GETRATE,
				         T.INWL_ID,
				         T.OUTWL_ID,
				         T.GROUP_RCL,
				         T.PLINE_CODE_MAY,
				         T.PLINE_NAME_MAY,
				         '#ORDERWEIGHT#',
				         (T.ORDERNUM * '#ORDERWEIGHT#' / T.ORDERWEIGHT),
				         T.IFBUYPLAN,
				         T.PROD_END_DATE,
				         '1',
				         '0',
				         T.PRO_PLAN_ID,
				         0,
				         T.ISENDGX,
				         T.NEXT_GX,
				         '1',
				         T.IF_MONITOR_RCL,
				         T.PRDCR_NO,
				         T.CRAFT_FILE_NO,
				         T.CRAFT_FILE_MAN,
				         '#CREATE_NAME#',
				         SYSDATE,
				         T.PLINE_CODE,
				         T.PLINE_NAME,
				         T.CRAFT_SEQ,
				         T.PROCESS_CODE_C,
				         T.PROCESS_DESC_C,
				         T.STATION_ROAD,
				         T.IF_SET_TIME
				    FROM PLN_ORDER_RCL T
				   WHERE T.PLAN_GROUP_ID = '#PLAN_GROUP_ID#'
				     AND T.IS_EXTRA_ORD = '0'
				     AND ROWNUM = 1
		]]>
	</query>
	
	
	
</queryMap>