<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="工序合同">
	<query id="CoreProcessOrder.queryIssSaleOrder" desc="查询已下发销售合同">
		<![CDATA[
			SELECT T.ORD_PK,
			       T.ORD_LN_PK,
			       T.ORD_LN_DLY_PK,
			       T.ORDER_NO,
			       T.ORDER_SEQ,
			       T.DELIVERY_NO,
			       T.PRD_CLS,
			       T.PRODUCCODE,
			       T.PRODUCNAME,
			       T.STD_CODE,
			       T.STD_NAME,
			       T.STEELCODE,
			       T.STEELNAME,
			       T.SPEC_CODE,
			       T.SPEC_NAME,
			       T.OUTDIAMETER,
			       T.WALLTHICK,
			       T.LENGTHMAX,
			       T.LENGTHMIN,
			       T.LENGTHDISC,
			       T.MODEL_CODE,
			       T.MODEL_DESC,
			       T.ORDER_UNIT,
			       T.ORDER_QTY,
			       T.ORDERWEIGHT,
			       T.ORDERNUM,
			       DECODE(T.TOTLENGTH,0,'',T.TOTLENGTH) TOTLENGTH,
			       ('-' || T.DELVRY_RANGE_MIN ||
			       DECODE(T.DELVRY_RANGE_TPE, '绝对值', '', DELVRY_RANGE_TPE) || ',+' ||
			       T.DELVRY_RANGE_MAX ||
			       DECODE(T.DELVRY_RANGE_TPE, '绝对值', '', DELVRY_RANGE_TPE)) DELVRY_RANGE,
			       T.DELVRY_RANGE_TPE,
			       T.DELVRY_RANGE_MIN,
			       T.DELVRY_RANGE_MAX,
			       T.BUYER_ID,
			       T.BUYER_NAME,
			       T.CUST_ALPHA_NO,
			       T.ORDER_SPECIAL_DESC,
			       T.ADD_ASK_NO,
			       T.ORDER_ADD_DESC,
			       T.ORDERFROM,
			       T.FINAL_USER,
			       T.FINAL_USER_DESC,
			       T.UPPERLIMIT,
			       T.LOWERLIMT,
			       TO_CHAR(T.DELVRY_BDATE,'YYYY-MM-DD') DELVRY_BDATE,
			       TO_CHAR(T.DELVRY_EDATE,'YYYY-MM-DD') DELVRY_EDATE,
			       TO_CHAR(T.LATEST_PROD_DATE,'YYYY-MM-DD') LATEST_PROD_DATE,
			       T.ORDERCONTACT,
			       T.MONITORDEMAND,
			       T.SPECSTANDARD,
			       T.PACKTYPE,
			       T.MEMO,
			       T.PRIORITY,
			       DECODE(T.PORDERSTATUS,
			              '0',
			              '待接收',
			              '1',
			              '已接收',
			              '2',
			              '已下发',
			              '3',
			              '生产中',
			              '4',
			              '生产完成',
			              '5',
			              '缴库完成',
			              '6',
			              '发运完毕',
			              '7',
			              '结算完毕',
			              '8',
			              '合同关闭') PORDERSTATUS,
			       T.PSC,
			       T.MSC,
			       T.INDEX_SEQ,
			       T.CODE_JG,
			       T.CODE_DJ_BL,
			       T.PLANWEIGHT,
			       T.PAYDOWNWEIGHT,
			       T.CREATE_NAME,
			       TO_CHAR(T.CREATE_TIME,'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
			       T.UPDATE_NAME,
			       TO_CHAR(T.UPDATE_TIME,'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
			       T.ENDGXNAME,
			       DECODE(T.MERGETYPE,
			              '0',
			              '不需配箍',
			              '1',
			              '需配箍',
			              '2',
			              '需短节和配箍',
			              '3',
			              '管坯') MERGETYPE,
			       T.GROUP_JGX,
			       T.GROUP_RCL,
			       T.BJ_TYPE,
			       DECODE(T.JZ_FILE_IF_ALL, '1', '是', '0', '否') JZ_FILE_IF_ALL,
			       T.MATERIAL_NO,
			       T.MATERIAL_DESC,
			       T.E_IN_MATERIAL_NO,
			       T.E_IN_MATERIAL_DESC,
			       T.DIMATER_YLG,
			       T.HEIGHT_YLG,
			       T.BL_GROUP_NUM,
			       T.ROLL_MONTH,
			       T.PRDCR_NO,
			       T.SHRT_LEN_RATO,
			       T.SHORTEST,
			       T.LONG_LEN_RATO,
			       T.LONGEST,
			       T.SIGL_LEN,
			       T.AIMLENGTH,
			       T.AIMWALLTHICK_ZG,
			       T.STATION_NO,
			       DECODE(T.STATION_NM,
			              NULL,
			              (SELECT A.STATION_NM
			                 FROM SLM_BASE_STATION A
			                WHERE A.STATION_NO = T.STATION_NO),
			              T.STATION_NM) STATION_NM,
			       T.HEIGHT_NK_MIN,
			       T.HEIGHT_NK_MAX,
			       T.WEIGHT_PER_M,
			       T.PLAN_QTY,
			       T.PLAN_NUM,
			       T.OUTS_STL_PIPE_FL,
			       TO_CHAR(T.ISSUED_TIME,'YYYY-MM-DD HH24:MI:SS') ISSUED_TIME
			  FROM PLN_SALEORDER T
			 WHERE T.PORDERSTATUS > '1'
			   AND TO_DATE(TO_CHAR(T.ISSUED_TIME,'YYYY-MM-DD'),'YYYY-MM-DD') 
			   BETWEEN TO_DATE(?, 'YYYY/MM/DD') AND TO_DATE(?, 'YYYY/MM/DD')
		]]>
	</query>

	<query id="CoreProcessOrder.queryIssBlNeed" desc="查询已下发备料需求">
		<![CDATA[
			SELECT T.REQ_BL_ID,
			       T.BLTYPE,
			       T.ORDER_NO,
			       T.ORDER_SEQ,
			       T.DELIVERY_NO,
			       T.JG_ORDERNO,
			       T.STEELCODE,
			       T.STEELNAME,
			       T.GRADECODE,
			       T.OUTDIAMETER,
			       T.WALLTHICK,
			       T.AIMWALLTHICK,
			       T.LENGTHMAX,
			       T.LENGTHMIN,
			       T.AIMLENGTH,
			       T.CODE_DJ_BL,
			       T.CODE_JG_BL,
			       T.INDEX_SEQ,
			       T.SINGLEWEIGHT,
			       T.JGBL_REQ_WEIGHT,
			       T.JGBL_REQ_NUM,
			       T.MATCHWEIGHT,
			       T.MATCHNUM,
			       T.PLAN_WEIGHT,
			       DECODE(T.PLANSTATUS,
			              '0',
			              '待处理',
			              '1',
			              '已下发') PLANSTATUS,
			       T.CREATE_NAME,
			       TO_CHAR(T.CREATE_TIME,'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
			       T.UPDATE_NAME,
			       TO_CHAR(T.UPDATE_TIME,'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
			       T.STD_CODE,
			       T.STD_NAME,
			       T.MSC,
			       T.GROUP_RCL,
			       T.BJ_TYPE,
			       TO_CHAR(T.ISSUED_TIME,'YYYY-MM-DD HH24:MI:SS') ISSUED_TIME
			  FROM PLN_PORDER_BL_REQ T
			 WHERE T.PLANSTATUS > '0'
			   AND TO_DATE(TO_CHAR(T.ISSUED_TIME,'YYYY-MM-DD'),'YYYY-MM-DD')
			    BETWEEN TO_DATE(?, 'YYYY/MM/DD') AND TO_DATE(?, 'YYYY/MM/DD')
		]]>
	</query>

	<query id="CoreProcessOrder.queryZGbySale" desc="查询轧管工序合同来自销售合同">
		<![CDATA[
			SELECT T.PRO_ORDER_NO,T.ORDER_SOURCE,T.ORDER_NO,
			T.ORDER_SEQ,T.DELIVERY_NO,T.REQ_BL_ID,T.PROCESS_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.ORDERWEIGHT,T.ORDERNUM,
			TO_CHAR(T.PROD_END_DATE,'YYYY-MM-DD') PROD_END_DATE,
			T.ORDERSTATUS,T.PLANED_WEIGHT,T.FINISHWEIGHT,T.INDEX_SEQ,
			DECODE(T.ISENDGX,'0','否','1','是') ISENDGX,T.NEXT_GX,
			DECODE(T.IF_MONITOR_ZG,'0','否','1','是') IF_MONITOR_ZG,
			T.PRDCR_NO,
			T.CREATE_NAME,TO_CHAR(T.CREATE_TIME,'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
			T.UPDATE_NAME,TO_CHAR(T.UPDATE_TIME,'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME 
			FROM PLN_ORDER_ZG T 
			WHERE T.ORDER_SOURCE='销售合同' AND T.ORDER_NO=? 
      AND T.ORDER_SEQ=? AND T.DELIVERY_NO=?
		]]>
	</query>
	
	<query id="CoreProcessOrder.queryZGbyBL" desc="查询轧管工序合同来自备料需求">
		<![CDATA[
			SELECT T.PRO_ORDER_NO,T.ORDER_SOURCE,T.ORDER_NO,
			T.ORDER_SEQ,T.DELIVERY_NO,T.REQ_BL_ID,T.PROCESS_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.ORDERWEIGHT,T.ORDERNUM,
			TO_CHAR(T.PROD_END_DATE,'YYYY-MM-DD') PROD_END_DATE,
			T.ORDERSTATUS,T.PLANED_WEIGHT,T.FINISHWEIGHT,T.INDEX_SEQ,
			DECODE(T.ISENDGX,'0','否','1','是') ISENDGX,T.NEXT_GX,
			DECODE(T.IF_MONITOR_ZG,'0','否','1','是') IF_MONITOR_ZG,
			T.PRDCR_NO,
			T.CREATE_NAME,TO_CHAR(T.CREATE_TIME,'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
			T.UPDATE_NAME,TO_CHAR(T.UPDATE_TIME,'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME 
			FROM PLN_ORDER_ZG T 
			WHERE T.ORDER_SOURCE='备料需求' AND T.REQ_BL_ID=?
		]]>
	</query>
	
	<query id="CoreProcessOrder.queryBJbySale" desc="查询变径工序合同来自销售合同">
		<![CDATA[
			SELECT T.PRO_ORDER_NO,T.ORDER_SOURCE,T.ORDER_NO,
			T.ORDER_SEQ,T.DELIVERY_NO,T.REQ_BL_ID,T.PROCESS_SEQ,
			T.STEELCODE,T.STEELNAME,T.OUTDIAMETER,T.WALLTHICK,
			T.AIMWALLTHICK,T.LENGTHMAX,T.LENGTHMIN,T.AIMLENGTH,
			T.OUTWL_ID,T.OUTDIAMETER_IN,T.WALLTHICK_IN,T.LENGTHMAX_IN,
			T.LENGTHMIN_IN,T.INWL_ID,T.GETRATE,T.ORDERWEIGHT,T.ORDERNUM,
			TO_CHAR(T.PROD_END_DATE,'YYYY-MM-DD') PROD_END_DATE,
			T.ORDERSTATUS,T.PLANED_WEIGHT,T.FINISHWEIGHT,
			T.INDEX_SEQ,DECODE(T.ISBEGINGX,'0','否','1','是') ISBEGINGX,
			T.PREVIOUS_GX,T.PREV_GXORDERID,
			DECODE(T.ISENDGX,'0','否','1','是') ISENDGX,T.NEXT_GX,
			DECODE(T.IF_MONITOR_BJ,'0','否','1','是') IF_MONITOR_BJ,
			T.PRDCR_NO,
			T.CREATE_NAME,TO_CHAR(T.CREATE_TIME,'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
			T.UPDATE_NAME,TO_CHAR(T.UPDATE_TIME,'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME 
			FROM PLN_ORDER_BJ T 
			WHERE T.ORDER_SOURCE='销售合同' AND T.ORDER_NO=? 
      AND T.ORDER_SEQ=? AND T.DELIVERY_NO=?
		]]>
	</query>
	
	<query id="CoreProcessOrder.queryBJbyBL" desc="查询变径工序合同来自备料需求">
		<![CDATA[
			SELECT T.PRO_ORDER_NO,T.ORDER_SOURCE,T.ORDER_NO,
			T.ORDER_SEQ,T.DELIVERY_NO,T.REQ_BL_ID,T.PROCESS_SEQ,
			T.STEELCODE,T.STEELNAME,T.OUTDIAMETER,T.WALLTHICK,
			T.AIMWALLTHICK,T.LENGTHMAX,T.LENGTHMIN,T.AIMLENGTH,
			T.OUTWL_ID,T.OUTDIAMETER_IN,T.WALLTHICK_IN,T.LENGTHMAX_IN,
			T.LENGTHMIN_IN,T.INWL_ID,T.GETRATE,T.ORDERWEIGHT,T.ORDERNUM,
			TO_CHAR(T.PROD_END_DATE,'YYYY-MM-DD') PROD_END_DATE,
			T.ORDERSTATUS,T.PLANED_WEIGHT,T.FINISHWEIGHT,
			T.INDEX_SEQ,DECODE(T.ISBEGINGX,'0','否','1','是') ISBEGINGX,
			T.PREVIOUS_GX,T.PREV_GXORDERID,
			DECODE(T.ISENDGX,'0','否','1','是') ISENDGX,T.NEXT_GX,
			DECODE(T.IF_MONITOR_BJ,'0','否','1','是') IF_MONITOR_BJ,
			T.PRDCR_NO,
			T.CREATE_NAME,TO_CHAR(T.CREATE_TIME,'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
			T.UPDATE_NAME,TO_CHAR(T.UPDATE_TIME,'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME 
			FROM PLN_ORDER_BJ T 
			WHERE T.ORDER_SOURCE='备料需求' AND T.REQ_BL_ID=?
		]]>
	</query>
	
	<query id="CoreProcessOrder.queryRCLbySale" desc="查询热处理工序合同来自销售合同">
		<![CDATA[
			SELECT T.PRO_ORDER_NO,T.ORDER_SOURCE,T.ORDER_NO,
			T.ORDER_SEQ,T.DELIVERY_NO,T.REQ_BL_ID,T.PROCESS_SEQ,
			T.STEELCODE,T.STEELNAME,T.OUTDIAMETER,T.WALLTHICK,
			T.AIMWALLTHICK,T.LENGTHMAX,T.LENGTHMIN,T.AIMLENGTH,
			T.OUTWL_ID,T.INWL_ID,T.GETRATE,T.ORDERWEIGHT,
			T.ORDERNUM,TO_CHAR(T.PROD_END_DATE,'YYYY-MM-DD') PROD_END_DATE,
			T.ORDERSTATUS,T.PLANED_WEIGHT,
			T.FINISHWEIGHT,T.INDEX_SEQ,
			DECODE(T.ISBEGINGX,'0','否','1','是') ISBEGINGX,
			T.PREVIOUS_GX,T.PREV_GXORDERID,
			DECODE(T.ISENDGX,'0','否','1','是') ISENDGX,T.NEXT_GX,
			DECODE(T.IF_MONITOR_RCL,'0','否','1','是') IF_MONITOR_RCL,
			T.PRDCR_NO,
			T.CREATE_NAME,TO_CHAR(T.CREATE_TIME,'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
			T.UPDATE_NAME,TO_CHAR(T.UPDATE_TIME,'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME 
			FROM PLN_ORDER_RCL T 
			WHERE T.ORDER_SOURCE='销售合同' AND T.ORDER_NO=? 
      AND T.ORDER_SEQ=? AND T.DELIVERY_NO=?
		]]>
	</query>
	
	<query id="CoreProcessOrder.queryRCLbyBL" desc="查询热处理工序合同来自备料需求">
		<![CDATA[
			SELECT T.PRO_ORDER_NO,T.ORDER_SOURCE,T.ORDER_NO,
			T.ORDER_SEQ,T.DELIVERY_NO,T.REQ_BL_ID,T.PROCESS_SEQ,
			T.STEELCODE,T.STEELNAME,T.OUTDIAMETER,T.WALLTHICK,
			T.AIMWALLTHICK,T.LENGTHMAX,T.LENGTHMIN,T.AIMLENGTH,
			T.OUTWL_ID,T.INWL_ID,T.GETRATE,T.ORDERWEIGHT,
			T.ORDERNUM,TO_CHAR(T.PROD_END_DATE,'YYYY-MM-DD') PROD_END_DATE,
			T.ORDERSTATUS,T.PLANED_WEIGHT,
			T.FINISHWEIGHT,T.INDEX_SEQ,
			DECODE(T.ISBEGINGX,'0','否','1','是') ISBEGINGX,
			T.PREVIOUS_GX,T.PREV_GXORDERID,
			DECODE(T.ISENDGX,'0','否','1','是') ISENDGX,T.NEXT_GX,
			DECODE(T.IF_MONITOR_RCL,'0','否','1','是') IF_MONITOR_RCL,
			T.PRDCR_NO,
			T.CREATE_NAME,TO_CHAR(T.CREATE_TIME,'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
			T.UPDATE_NAME,TO_CHAR(T.UPDATE_TIME,'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME 
			FROM PLN_ORDER_RCL T 
			WHERE T.ORDER_SOURCE='备料需求' AND T.REQ_BL_ID=?
		]]>
	</query>
	
	<query id="CoreProcessOrder.queryJGXbySale" desc="查询加工线工序合同来自销售合同">
		<![CDATA[
			SELECT T.PRO_ORDER_NO,T.ORDER_SOURCE,T.ORDER_NO,
			T.ORDER_SEQ,T.DELIVERY_NO,T.PROCESS_SEQ,
			T.STEELCODE,T.STEELNAME,T.OUTDIAMETER,T.WALLTHICK,
			T.AIMWALLTHICK,T.LENGTHMAX,T.LENGTHMIN,T.LENGTHDISC,
			T.AIMLENGTH,T.MODEL_CODE,T.LENGTHMAX_IN,T.LENGTHMIN_IN,
			T.OUTWL_ID,T.INWL_ID,T.GETRATE,T.ORDERWEIGHT,
			T.ORDERNUM,TO_CHAR(T.PROD_END_DATE,'YYYY-MM-DD') PROD_END_DATE,
			T.ORDERSTATUS,T.PLANED_WEIGHT,
			T.FINISHWEIGHT,T.INDEX_SEQ,
			DECODE(T.ISBEGINGX,'0','否','1','是') ISBEGINGX,
			T.PREVIOUS_GX,T.PREV_GXORDERID,
			DECODE(T.ISENDGX,'0','否','1','是') ISENDGX,T.NEXT_GX,
			DECODE(T.IF_MONITOR_JGX,'0','否','1','是') IF_MONITOR_JGX,
			T.PRDCR_NO,
			T.CREATE_NAME,TO_CHAR(T.CREATE_TIME,'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
			T.UPDATE_NAME,TO_CHAR(T.UPDATE_TIME,'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME 
			FROM PLN_ORDER_JGX T 
			WHERE T.ORDER_SOURCE='销售合同' AND T.ORDER_NO=? 
      AND T.ORDER_SEQ=? AND T.DELIVERY_NO=?
		]]>
	</query>
	
	<query id="CoreProcessOrder.queryGpNeed" desc="查询管坯需求">
		<![CDATA[
			SELECT T.GPREQ_ID,
			DECODE(T.ISENDGX,'1','是','0','否') ISENDGX,
			T.PRO_ORDER_NO,T.ZG_DETAIL_SEQ,T.ORDER_SOURCE,T.ORDER_NO,
			T.ORDER_SEQ,T.DELIVERY_NO,T.REQ_BL_ID,T.BUYER_ID,
			T.BUYER_NAME,T.PSC,T.MSC,T.INDEX_SEQ,T.GPTYPE,
			T.CASTINGTYPE,T.STEELCODE,T.STEELNAME,T.GRADECODE,
			T.DIAMETER_GP,T.LENGTH_GP,T.MATERIAL_NO,T.MATERIAL_NAME,
			T.CRAFTCODE,T.CIC,T.STD_CODE_NK,T.STD_NAME_NK,
			DECODE(T.IF_MONITOR_LG,'1','是','0','否') IF_MONITOR_LG,
			T.PRDCR_NO,T.WEIGHT_GP_ONE,
			T.GP_WEIGHT,T.GP_NUM,T.MATCH_WEIGHT,T.MATCH_NUM,
			DECODE(T.IFBUYPLAN,'1','是','0','否') IFBUYPLAN,
			T.BUYPLANID,T.BUYPLANWEIGHT,T.PPC_LG_WEIGHT,
			T.PPC_LG_NUM,T.REQ_DONESTATUS,T.MEMO 
			FROM PLN_REQINF_GP T 
			WHERE T.ORDER_SOURCE='销售合同' AND T.ORDER_NO=? 
      AND T.ORDER_SEQ=? AND T.DELIVERY_NO=?
		]]>
	</query>
	
</queryMap>