<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="销售合同处理">
	<query id="CoreSaleOrderOP.queryBaseinfoAll" desc="查询基础维护数据">
		<![CDATA[
			SELECT T.BASECODE, T.BASENAME, T.SORTCODE
			  FROM COM_BASE_INFO T
			 WHERE T.SORTCODE = '1218'
			    OR T.SORTCODE = '1219'
			    OR T.SORTCODE = '2004'
			    OR T.SORTCODE = '2005'
			    OR T.SORTCODE = '1222'
			    OR T.SORTCODE = '2006'
			   AND T.VALIDFLAG = '1'
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.queryAsselFl" desc="查询是否Assel">
		<![CDATA[
			SELECT T.ASSEL_FL FROM SLM_ORDER_LINE T WHERE T.ORD_LN_PK = ?
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.queryBaseGrade" desc="查询钢种">
		<![CDATA[
			SELECT T.GRADECODE,T.GRADENAME FROM COM_BASE_GRADE T WHERE T.VALIDFLAG='1'
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.queryBaseinfo" desc="查询基础维护数据">
		<![CDATA[
			SELECT * FROM COM_BASE_INFO T WHERE T.BASECODE = ? AND T.VALIDFLAG = '1'
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.queryBasespec" desc="查询规格基础表">
		<![CDATA[
			SELECT T.SPEC_CODE, T.SPEC_NAME, T.DIMATER, T.HEIGHT, T.WEIGHT, T.MSC_STYLE
			  FROM COM_BASE_SPEC T
			 WHERE T.SPEC_CODE = ?
			   AND T.VALIDFLAG = '1'
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.queryPutRate" desc="查询投料原则，投料率">
		<![CDATA[
			SELECT * FROM PLN_MAT_PUT_MONTH T WHERE T.PUT_YEAR=? AND T.PUT_MONTH=?
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.queryLinePrdcr" desc="查询监制基础表">
		<![CDATA[
			SELECT T.PRDCR_NO,T.PRDCR_DESC,(SELECT A.BASENAME
                FROM COM_BASE_INFO A
               WHERE A.BASECODE = T.PRDCR_DESC) MONITORDEMAND
			  FROM SLM_ORDER_LINE_PRDCR T
			 WHERE T.PRDCR_NO = ?
			   AND T.MSC_PLINE = ?
			   AND T.CODE_JG IS NULL
			   AND T.CODE_BL IS NULL
			   AND T.VALIDFLAG = '1'
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.queryProducType" desc="查询品名基础表">
		<![CDATA[
			SELECT T.PRODUCCODE,
			       T.PRODUCNAME,
			       T.PRODUC_STYLE,
			       T.PRODUC_DESC,
			       T.PRODUC_JX,
			       T.PRODUC_ENG,
			       T.PRODUCCODE_OLD,
			       T.PRODUC_HEAD,
			       T.PRODUC_TYPE
			  FROM COM_BASE_PRODUCT T
			 WHERE T.PRODUCCODE = ?
			   AND T.VALIDFLAG = '1'
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.queryBaseinfoSort" desc="查询基础维护数据">
		<![CDATA[
			SELECT T.BASECODE, T.BASENAME, T.SORTCODE, T.COEFFICIENT
			  FROM COM_BASE_INFO T
			 WHERE T.SORTCODE = ?
			   AND T.VALIDFLAG = '1'
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.queryBaseAddAsk" desc="查询附加要求基础表">
		<![CDATA[
			SELECT T.ASK_ITEM_NO,
			       T.ASK_ITEM_DESC,
			       T.STATION_CODE,
			       T.STATION_DESC,
			       T.PIC,
			       T.ASK_P_ITEM_NO,
			       T.STDFLAG
			  FROM SLM_BASE_ADD_ASK T
			 WHERE T.ASK_ITEM_NO = ?
			   AND T.VALIDFLAG = '1'
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.queryAddAsk" desc="查询附加要求信息">
		<![CDATA[
			SELECT T.ASK_SUB_ITME_DESC || ':' || T.ASK_SUB_ITME_VAL_DESC || ';' ASKDESC,
			       T.ASK_ITME,
			       T.ADD_ASK_TYPE,
			       T.PIC
			  FROM SLM_ORDER_ADD_ASK T
			 WHERE T.ADD_ASK_NO = ?
			   AND T.VALIDFLAG = '1'
			 ORDER BY T.ASK_ITME ASC
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.queryWeighType" desc="查询计重方式">
		<![CDATA[
			SELECT ADD_ASK_NO,
			       ASK_ITME,
			       ASK_ITME_DESC,
			       ASK_SUB_ITME,
			       ASK_SUB_ITME_DESC,
			       ASK_SUB_ITME_VAL,
			       ASK_SUB_ITME_VAL_DESC,
			       PIC,
			       CUSTOMER_NO,
			       CUSTOMER_NM,
			       PSC,
			       PSC_DESC,
			       ADD_ASK_STATUS,
			       ADD_ASK_TYPE,
			       REVIEW_F_RS
			  FROM SLM_ORDER_ADD_ASK T
			 WHERE T.ADD_ASK_NO = ?
			   AND T.ASK_ITME = '121005'
			   AND T.VALIDFLAG = '1'
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.queryTransit" desc="查询交货到站">
		<![CDATA[
			SELECT T.STATION_NO,
			       (SELECT A.STATION_NM
			          FROM SLM_BASE_STATION A
			         WHERE A.STATION_NO = T.STATION_NO) STATION_NM
			  FROM SLM_ORDER_DELIVERY_TRANSIT T
			 WHERE T.ORD_LN_DLY_PK = ?
			   AND T.VALIDFLAG = '1'
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.queryTranType" desc="查询交货运输方案">
		<![CDATA[
			SELECT (SELECT A.BASENAME
			          FROM COM_BASE_INFO A
			         WHERE A.BASECODE = T.TRANSIT_TYP) TRANSIT_TYP
			  FROM SLM_ORDER_LINE_DELIVERY T
			 WHERE T.ORD_LN_DLY_PK = ?
			   AND T.VALIDFLAG = '1'
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.queryDjReqblid" desc="查询短节备料需求编号">
		<![CDATA[
			SELECT ('ZZBY-D' || TO_CHAR(SYSDATE, 'YY') || TO_CHAR(SYSDATE, 'MM') ||
			       TO_CHAR(SYSDATE, 'DD') || '/' ||
			       LPAD(DECODE(MAX(SUBSTR(T.REQ_BL_ID, 14) + 1),'','001',MAX(SUBSTR(T.REQ_BL_ID, 14) + 1)), 3, '0')) REQ_BL_ID
			  FROM PLN_PORDER_BL_REQ T WHERE T.REQ_BL_ID LIKE 'ZZBY-D'||'%'
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.queryJgReqblid" desc="查询接箍备料需求编号">
		<![CDATA[
			SELECT ('ZZBY-J' || TO_CHAR(SYSDATE, 'YY') || TO_CHAR(SYSDATE, 'MM') ||
			       TO_CHAR(SYSDATE, 'DD') || '/' ||
			       LPAD(DECODE(MAX(SUBSTR(T.REQ_BL_ID, 14) + 1),'','001',MAX(SUBSTR(T.REQ_BL_ID, 14) + 1)), 3, '0')) REQ_BL_ID
			  FROM PLN_PORDER_BL_REQ T WHERE T.REQ_BL_ID LIKE 'ZZBY-J'||'%'
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.queryPretreatNo" desc="查询预处理批次流水号">
		<![CDATA[
			SELECT MAX(TO_NUMBER(SUBSTR(T.ACCEPT_NO,10))+1) MAXACCEPT FROM PLN_SALEORDER T WHERE SUBSTR(T.ACCEPT_NO,1,9)=?
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.queryCancelPreNo" desc="查询撤消预处理流水号">
		<![CDATA[
			SELECT MAX(TO_NUMBER(SUBSTR(T.BACKLOG_ID, 9)) + 1) MAXBACKLOGT
			  FROM PLN_SALEORD_BACKLOG T
			 WHERE SUBSTR(T.BACKLOG_ID, 0, 8) = ?
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.queryBasePline" desc="查询产线基础表，获取机组信息">
		<![CDATA[
			SELECT * FROM COM_BASE_PLINE T WHERE T.PLINE_CODE=? AND T.VALIDFLAG='1'
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.queryZgPline" desc="查询备料轧管产线">
		<![CDATA[
			SELECT T.PLINE_CODE, T.PLINE_NAME
			  FROM COM_BASE_PLINE T
			 WHERE T.VALIDFLAG = '1'
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.queryPlanWeight" desc="查询热处理组各部门已排产量">
		<![CDATA[
			SELECT SUM(T.PLANWEIGHT) PLANWEIGHT,T.GROUP_RCL
			  FROM PLN_SALEORDER T
			 WHERE T.ROLL_MONTH = ? AND T.GROUP_RCL IS NOT NULL AND T.GROUP_RCL!='/'
			 GROUP BY T.GROUP_RCL
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.queryJgxPlanWeight" desc="查询加工组各部门已排产量">
		<![CDATA[
			SELECT SUM(T.PLANWEIGHT) PLANWEIGHT,T.GROUP_JGX
			  FROM PLN_SALEORDER T
			 WHERE T.ROLL_MONTH = ? AND T.GROUP_JGX IS NOT NULL AND T.GROUP_JGX!='/'
			 GROUP BY T.GROUP_JGX
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.queryRollPlanWeight" desc="查询轧管机组月排产量">
		<![CDATA[
			SELECT SUM(T.PLANWEIGHT) PLANWEIGHT,
		       T.GROUP_ROLL,
		       (SELECT A.PLINE_NAME
		          FROM COM_BASE_PLINE A
		         WHERE A.PLINE_CODE = T.GROUP_ROLL) PLINE_NAME
			  FROM PLN_SALEORDER T
			 WHERE T.ROLL_MONTH = ?
			   AND T.GROUP_ROLL IS NOT NULL
			 GROUP BY T.GROUP_ROLL
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.queryPlineDimaterIsc" desc="查询经过锻造时,经过轧管的坯料断面和产线">
		<![CDATA[
			SELECT T.DESGIN_KEY,
				   T.MSC_PLINE,
				   T.PLINE_CODE,
				   T.PLINE_NAME,
				   C.SPEC_CODE,
				   C.SPEC_NAME,
				   C.DIMATER,
				   C.WEIGHT,
				   C.MEMO  
			FROM SLM_ORD_DESIGN_MSC_GZ_GG_PL T,
			     SLM_ORD_DESIGN_MSC_BILT_PL  A,
			     SLM_ORD_DESIGN_MSC_BILT     B,
			     COM_BASE_SPEC               C 
			WHERE T.DESGIN_KEY = ? 
			AND T.MSC_PLINE = ? 
			AND B.DESGIN_KEY = T.DESGIN_KEY 
			AND B.MSC_PLINE = T.MSC_PLINE 
			AND B.SPEC_CODE = T.SPEC_CODE 
			AND A.DESGIN_KEY=T.DESGIN_KEY 
			AND A.MSC_PLINE = T.MSC_PLINE 
			AND B.B_SPEC_CODE = A.B_SPEC_CODE 
			AND C.SPEC_CODE = B.B_SPEC_CODE
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.queryPlineDimaterIsnotc" desc="查询不经过锻造时,经过轧管的坯料断面和产线">
		<![CDATA[
			SELECT T.DESGIN_KEY,
			       T.MSC_PLINE,
			       T.PLINE_CODE,
			       T.PLINE_NAME,
			       C.SPEC_CODE,
			       C.SPEC_NAME,
			       C.DIMATER,
			       C.WEIGHT,
				   C.MEMO  
			       FROM SLM_ORD_DESIGN_MSC_GZ_GG_PL  T,
			            SLM_ORD_DESIGN_MSC_BILT_C    A,
			            SLM_ORD_DESIGN_MSC_BILT_C_PL B,
			            COM_BASE_SPEC                C 
			       WHERE T.DESGIN_KEY = ? 
			       AND T.MSC_PLINE = ? 
			       AND A.DESGIN_KEY = T.DESGIN_KEY 
			       AND A.MSC_PLINE = T.MSC_PLINE 
			       AND A.SPEC_CODE = T.SPEC_CODE 
			       AND B.DESGIN_KEY = T.DESGIN_KEY 
			       AND B.MSC_PLINE = T.MSC_PLINE 
			       AND A.C_SPEC_CODE = B.C_SPEC_CODE 
			       AND C.SPEC_CODE = A.C_SPEC_CODE
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.updateOrdernum" desc="更新合同支数，成品长度和扎管控制壁厚">
		<![CDATA[
			UPDATE PLN_SALEORDER T
				   SET T.ORDERNUM = ?, T.AIMWALLTHICK_ZG = ?, T.AIMLENGTH = ?
				 WHERE T.ORD_PK = ?
				   AND T.ORD_LN_PK = ?
				   AND T.ORD_LN_DLY_PK = ?
		]]>
	</query>
		
	<query id="CoreSaleOrderOP.querydesginkey" desc="查询质量设计表得到DESGIN_KEY">
		<![CDATA[
			SELECT T.DESGIN_KEY FROM SLM_ORD_DESIGN_MSC T WHERE T.ORD_PK=? AND T.ORD_LN_PK=? AND T.VALIDFLAG='1'
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.querypsc" desc="查询产品码">
		<![CDATA[
			SELECT *
			  FROM COM_PSC T
			 WHERE T.PRODUCCODE = ?
			   AND T.STD_CODE = ?
			   AND T.STEELCODE = ?
			   AND DECODE(?, '', 1, T.STD_STYLE) = DECODE(?, '', 1, ?)
			   AND T.VALIDFLAG = '1'
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.querypscformsc" desc="根据产品码查找对应冶金规范码">
		<![CDATA[
			SELECT * FROM COM_PSC_R_MSC T WHERE T.PSC=?
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.queryMscIndex" desc="根据备料冶金规范查找制程号">
		<![CDATA[
			SELECT T.MSC,T.MSC_PLINE,T.WHOLE_BACKLOG,T.WHOLE_BACKLOG_DESC FROM COM_MSC_BACKLOG T WHERE T.MSC=?
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.queryMscTpco" desc="查询工艺单号和负责人">
		<![CDATA[
			SELECT * FROM PLN_ORD_CRAFT_FILE T WHERE T.ORDER_NO=? AND T.ORDER_SEQ=? 
          ORDER BY TO_NUMBER(T.VERSION_NO) DESC
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.queryDesginIndex" desc="根据质量设计查找制程号">
		<![CDATA[
			SELECT * FROM SLM_ORD_DESIGN_MSC_PL T 
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.queryjgcode" desc="根据DESGIN_KEY查询接箍码">
		<![CDATA[
			SELECT * FROM SLM_ORD_DESIGN_MSC_JG T WHERE T.DESGIN_KEY=?
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.queryBlGroup" desc="查询短节备料码组">
		<![CDATA[
			SELECT DISTINCT T.GROUP_NUM FROM SLM_ORD_DESIGN_MSC_BL T WHERE T.DESGIN_KEY=?
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.queryblcode" desc="根据DESGIN_KEY查询短节备料码">
		<![CDATA[
			SELECT * FROM SLM_ORD_DESIGN_MSC_BL T WHERE T.DESGIN_KEY=?
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.queryBlCodeByGp" desc="根据DESGIN_KEY与备料组查询短节备料码">
		<![CDATA[
			SELECT * FROM SLM_ORD_DESIGN_MSC_BL T WHERE T.DESGIN_KEY=? AND T.GROUP_NUM=?
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.queryMscplPrc" 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,
			       CIC,
			       PIC,
			       SIC,
			       DIC,
			       WIC,
			       GIC
			  FROM SLM_ORD_DESIGN_MSC_PL_PRC T
			 WHERE T.DESGIN_KEY = ?
			   AND T.MSC_PLINE = ?
			 ORDER BY T.BACKLOG_SEQ ASC
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.queryblprocess" desc="备料需求查询工序">
		<![CDATA[
			SELECT *
			  FROM COM_MSC_PROCESS T
			 WHERE T.MSC = ?
			   AND T.MSC_PLINE = ?
			   AND T.VALIDFLAG = '1'
			 ORDER BY T.BACKLOG_SEQ ASC
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.querysaleorder" desc="查询销售合同">
		<![CDATA[
			SELECT T1.DESGIN_KEY,
			       T.ORD_PK,
			       T.ORD_LN_PK,
			       T.ORD_LN_DLY_PK,
			       T.ORDER_NO,
			       T.ORDER_SEQ,
			       T.ORDER_NO || '/' || T.ORDER_SEQ ORDER_SEQNO,
			       T.DELIVERY_NO,
			       T.ACCEPT_NO,
			       (SELECT A.PRODUC_DESC
			          FROM COM_BASE_PRODUCT A
			         WHERE A.PRODUCCODE = T.PRODUCCODE
			           AND A.VALIDFLAG = '1') 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,
			       DECODE(T.ORDER_UNIT, '米', '吨', '英尺', '吨', T.ORDER_UNIT) ORDERWEIGHTUNIT,
			       DECODE(T.TOTLENGTH, 0, '', T.TOTLENGTH) TOTLENGTH,
			       T.TOTLENGTH_UNIT,
			       '(-' || TO_CHAR(ABS(T.DELVRY_RANGE_MIN)) ||
			       DECODE(T.DELVRY_RANGE_TPE, '%', '%', '') || ',' ||
			       TO_CHAR(T.DELVRY_RANGE_MAX) ||
			       DECODE(T.DELVRY_RANGE_TPE, '%', '%', '') || ')' DELVRY_RANGE,
			       T.DELVRY_RANGE_TPE,
			       T.DELVRY_RANGE_MIN,
			       T.DELVRY_RANGE_MAX,
			       T.BUYER_ID,
			       (SELECT A.ABRVITION
			          FROM SLM_BASE_CUSTOMER A
			         WHERE A.CUSTOMER_NO = T.BUYER_ID) BUYER_NAME,
			       T.CUST_ALPHA_NO,
			       T.ORDER_SPECIAL_DESC,
			       T.ADD_ASK_NO,
			       (SELECT B.ORDER_ADD_DESC FROM SLM_ORDER_LINE B WHERE B.ORD_LN_PK = T.ORD_LN_PK) ORDER_ADD_DESC,
			       (SELECT MAX(A.BASENAME)
			          FROM COM_BASE_INFO A
			         WHERE A.BASECODE = T.ORDERFROM
			            OR A.BASENAME = T.ORDERFROM) ORDERFROM,
			       (SELECT B.SALE_AREA_DESC
			          FROM SLM_ORDER_HEAD B
			         WHERE B.ORD_PK = T.ORD_PK) SALE_AREA_DESC,
			       T.FINAL_USER,
			       (SELECT A.ABRVITION
			          FROM SLM_BASE_CUSTOMER A
			         WHERE A.CUSTOMER_NO = T.FINAL_USER) FINAL_USER_DESC,
			       TO_CHAR(T.DELVRY_EDATE, 'YYYY-MM-DD') DELVRY_EDATE,
			       TO_CHAR(T.LATEST_PROD_DATE, 'YYYY-MM-DD') LATEST_PROD_DATE,
			       T.ORDERCONTACT,
			       (SELECT A.BASENAME
			          FROM COM_BASE_INFO A
			         WHERE A.BASECODE = T.MONITORDEMAND) MONITORDEMAND,
			       (SELECT LISTAGG(PROCESS_DESC, ',') WITHIN GROUP(ORDER BY PROCESS_CODE)
			          FROM (SELECT DISTINCT B.PROCESS_DESC, B.PRDCR_NO, B.PROCESS_CODE
			                  FROM SLM_ORDER_LINE_PRDCR_LST B
			                 WHERE B.PRDCR_PRC_FL = '1')
			         WHERE PRDCR_NO = T.PRDCR_NO) PRDCRPRO,
			       NVL(T.SPECSTANDARD,
			           (SELECT B.SIC
			              FROM SLM_ORD_DESIGN_STD B
			             WHERE B.DESGIN_KEY = T1.DESGIN_KEY)) SPECSTANDARD,
			       T.MEMO,
			       T.PRIORITY,
			       T.PRIORITY_MEMO,
			       DECODE(T.PORDERSTATUS,
			              '0',
			              '待接收',
			              '1',
			              '已接收',
			              '2',
			              '已下发',
			              '3',
			              '生产中',
			              '4',
			              '生产完成',
			              '5',
			              '缴库完成',
			              '6',
			              '发运完毕',
			              '7',
			              '结算完毕',
			              '8',
			              '合同关闭') PORDERSTATUS,
			       T.PSC,
			       T.MSC,
			       NVL(T.INDEX_SEQ,
			           (SELECT MIN(C.MSC_PLINE)
			              FROM SLM_ORD_DESIGN_MSC_PL C
			             WHERE C.DESGIN_KEY = T1.DESGIN_KEY)) 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,
			       DECODE(T.BL_GROUP_NUM,
			              NULL,
			              (SELECT MIN(A.GROUP_NUM)
			                 FROM SLM_ORD_DESIGN_MSC_BL A
			                WHERE A.DESGIN_KEY = T1.DESGIN_KEY),
			              T.BL_GROUP_NUM) BL_GROUP_NUM,
			       T.ROLL_MONTH,
			       NVL(T.ROLL_WELL_MONTH, T.ROLL_MONTH) ROLL_WELL_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.HEIGHT_ORD_MIN,
			       T.HEIGHT_ORD_MAX,
			       T.WEIGHT_PER_M,
			       T.PLAN_QTY,
			       T.PLAN_NUM,
			       T.ENDLEN_SPECSTD,
			       T.PRODUCE_SORT,
			       T.USE_CODE,
			       T.USE_DESC,
			       DECODE(T.TOTLENGTH_M, 0, '', T.TOTLENGTH_M) TOTLENGTH_M,
			       DECODE(TRIM(T.OUTS_BILLET_FL), NULL, '121802', T.OUTS_BILLET_FL) OUTS_BILLET_FL,
			       T.GROUP_ROLL_ALL,
			       T.GROUP_ROLL,
			       T.STUFF_PROPERTY,
			       T.PIPE_PROPERTY,
			       T.PROCESS_SEQ,
			       T.LEN_TOEND_MIN,
			       T.LEN_TOEND_MAX,
			       T.TEMP_HTCAST,
			       NVL(T.GRADECODE_ALL,
			           (SELECT LISTAGG(T3.GRADENAME, ',') WITHIN GROUP(ORDER BY T3.GRADENAME)
			              FROM (SELECT DISTINCT B.GRADENAME,
			                                    B.MSC_PLINE,
			                                    B.MSC,
			                                    B.MATERIAL_NO
			                      FROM SLM_ORD_DESIGN_BOM B) T3
			             WHERE T3.MSC_PLINE =
			                   NVL(T.INDEX_SEQ,
			                       (SELECT MIN(C.MSC_PLINE)
			                          FROM SLM_ORD_DESIGN_MSC_PL C
			                         WHERE C.DESGIN_KEY = T1.DESGIN_KEY))
			               AND T3.MSC = T.MSC
			               AND T3.MATERIAL_NO = T.MATERIAL_NO)) GRADECODE_ALL,
			       T.GRADECODE,
			       T.CRAFT_FILE_NO,
			       T.CRAFT_FILE_MAN,
			       T.LENGTH_JG,
			       T.LEN_UNIT,
			       T.SHRT_STOVE,
			       T.AVG_LEN_MIN,
			       T.DIFRNC_LEN_MAX,
			       T.WEIGH_TYPE,
			       T.TRANSIT_TYP,
			       (SELECT MAX(A.BASENAME)
			          FROM COM_BASE_INFO A
			         WHERE A.BASECODE = T.OUTS_STL_PIPE_FL
			            OR A.BASENAME = T.OUTS_STL_PIPE_FL) OUTS_STL_PIPE_FL,
			       DECODE(T.JGORD_IS_OK, '0', '否', '1', '是', '2', '/') JGORD_IS_OK,
			       DECODE(T.JGL_REQ_IS_OK, '0', '否', '1', '是', '2', '/') JGL_REQ_IS_OK,
			       DECODE(T.DJBL_REQ_IS_OK, '0', '否', '1', '是', '2', '/') DJBL_REQ_IS_OK,
			       T.STD_STYLE_DESC,
			       DECODE(T.IF_ALLOW_ISSUE, '0', '否', '1', '是') IF_ALLOW_ISSUE,
			       DECODE(T.GRADECODE_IS_OK, '0', '否', '1', '是') GRADECODE_IS_OK,
			       DECODE(T.D_IS_OK, '0', '否', '1', '是', '2', '/') D_IS_OK,
			       DECODE(T.E_IS_OK, '0', '否', '1', '是', '2', '/') E_IS_OK,
			       DECODE(T.F_IS_OK, '0', '否', '1', '是', '2', '/') F_IS_OK,
			       DECODE(T.G_IS_OK, '0', '否', '1', '是', '2', '/') G_IS_OK,
			       NVL(T.BOM,
			           (SELECT MIN(B.BOM)
			              FROM SLM_ORD_DESIGN_BOM B
			             WHERE B.MSC_PLINE =
			                   NVL(T.INDEX_SEQ,
			                       (SELECT MIN(C.MSC_PLINE)
			                          FROM SLM_ORD_DESIGN_MSC_PL C
			                         WHERE C.DESGIN_KEY = T1.DESGIN_KEY))
			               AND B.MSC = T.MSC
			               AND B.MATERIAL_NO = T.MATERIAL_NO)) BOM,
			       (SELECT SUM(B.REQWEIGHT)
			          FROM PLN_SALEORDER_R_NUM B
			         WHERE B.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK) REQ_QTYSUM,
			         (SELECT SUM(B.CONFIRM_WT)
			          FROM PLN_SALEORDER_R_NUM B
			         WHERE B.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK) CONFIRM_WT_SUM,
			       T.EXTRA_LEN_TOT_WT,
			       (SELECT B.AW FROM SLM_ORDER_LINE B WHERE B.ORD_LN_PK = T.ORD_LN_PK) AW
			  FROM PLN_SALEORDER T,
			       (SELECT T1.DESGIN_KEY, T1.ORD_LN_PK
			          FROM SLM_ORD_DESIGN_MSC T1
			         WHERE T1.VALIDFLAG = '1') T1
			 WHERE T1.ORD_LN_PK(+) = T.ORD_LN_PK
			   AND NVL(T.ROLL_MONTH, '1') LIKE '%' || NVL(?, '1') || '%'
			   AND NVL(T.ACCEPT_NO, '1') LIKE '%' || NVL(?, '1') || '%'
			   AND (T.ORDER_NO || '/' || T.ORDER_SEQ) LIKE '%' || ? || '%'
			   AND T.PORDERSTATUS LIKE '%' || ? || '%'
			   AND DECODE(?, '1', T.JGORD_IS_OK, 1) != DECODE(?, '1', '2', 2)
			   AND DECODE(?, '1', T.DJBL_REQ_IS_OK, 1) != DECODE(?, '1', '2', 2)
			   AND DECODE(?, '1', T.MERGETYPE, 1) = DECODE(?, '1', '3', 1)
			   AND T.PORDERSTATUS < '6'
			   AND DECODE(?, '', '1', T.D_IS_OK) != DECODE(?, '', '2', '2')
			   AND DECODE(?, '', '1', T.E_IS_OK) != DECODE(?, '', '2', '2')
			   AND DECODE(?, '', '1', T.F_IS_OK) != DECODE(?, '', '2', '2')
			   AND DECODE(?, '', '1', T.G_IS_OK) != DECODE(?, '', '2', '2')
			   AND DECODE(?, '', '1', T.JGL_REQ_IS_OK) != DECODE(?, '', '2', '2')
			   AND DECODE(?, '', '1', T.DJBL_REQ_IS_OK) != DECODE(?, '', '2', '2')
			   AND DECODE(?, '', '1', T.ORDERFROM) = NVL(?, '1')
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.queryBaseCustomer" desc="查询客户基础表">
		<![CDATA[
			SELECT * FROM SLM_BASE_CUSTOMER T WHERE T.CUSTOMER_NO = ?
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.queryExportSaleOrder" desc="查询导出销售合同">
		<![CDATA[
			SELECT T.ACCEPT_NO,
			       (SELECT A.PLINE_NAME
			          FROM COM_BASE_PLINE A
			         WHERE A.PLINE_CODE = T.GROUP_ROLL
			           AND A.VALIDFLAG = '1') GROUP_ROLL,
			       (SELECT A.PRODUC_JX
			          FROM COM_BASE_PRODUCT A
			         WHERE A.PRODUCCODE = T.PRODUCCODE) PRODUC_JX,
			       T.PROCESS_SEQ,
			       (DECODE(T.STD_STYLE_DESC || ' ', ' ', '', T.STD_STYLE_DESC || ' ') ||
			       T.STEELNAME) STEELNAME,
			       T.OUTDIAMETER,
			       T.WALLTHICK,
			       T.LENGTHDISC,
			       T.MODEL_DESC,
			       T.ORDERWEIGHT,
			       DECODE(T.TOTLENGTH_M, 0, '', T.TOTLENGTH_M) TOTLENGTH,
			       T.STD_NAME,
			       T.ORDER_NO || '/' || T.ORDER_SEQ ORDER_SEQNO,
			       NVL((SELECT A.ABRVITION
			             FROM SLM_BASE_CUSTOMER A
			            WHERE A.CUSTOMER_NO = DECODE(T.FINAL_USER,
			                                      NULL,
			                                      T.BUYER_ID,
			                                      '/',
			                                      T.BUYER_ID,
			                                      T.FINAL_USER)),
			           DECODE(T.FINAL_USER_DESC,
			                  NULL,
			                  T.BUYER_NAME,
			                  '/',
			                  T.BUYER_NAME,
			                  T.FINAL_USER_DESC)) FINAL_USER,
			       (SELECT B.ORDER_ADD_DESC FROM SLM_ORDER_LINE B WHERE B.ORD_LN_PK = T.ORD_LN_PK) ORDER_ADD_DESC,
			       (SELECT MAX(A.BASENAME)
			          FROM COM_BASE_INFO A
			         WHERE A.BASECODE = T.ORDERFROM
			            OR A.BASENAME = T.ORDERFROM) ORDERFROM,
			       T.PRODUCE_SORT,
			       (TO_CHAR(DECODE(T.DELVRY_RANGE_TPE,
			                       '绝对值',
			                       T.DELVRY_RANGE_MAX * 100 / T.ORDER_QTY,
			                       T.DELVRY_RANGE_MAX),
			                'FM9990.00') || '%') RANGE_MAX,
			       ('-' || TO_CHAR(ABS(DECODE(T.DELVRY_RANGE_TPE,
			                                  '绝对值',
			                                  T.DELVRY_RANGE_MIN * 100 / T.ORDER_QTY,
			                                  T.DELVRY_RANGE_MIN)),
			                       'FM9990.00') || '%') RANGE_MIN,
			       TO_CHAR(DECODE(T.DELVRY_RANGE_TPE,
			                      '绝对值',
			                      T.DELVRY_RANGE_MAX / T.ORDER_QTY,
			                      T.DELVRY_RANGE_MAX / 100),
			               'FM90.0000') DELVRY_RANGE_MAX,
			       ('-' || TO_CHAR(ABS(DECODE(T.DELVRY_RANGE_TPE,
			                                  '绝对值',
			                                  T.DELVRY_RANGE_MIN / T.ORDER_QTY,
			                                  T.DELVRY_RANGE_MIN / 100)),
			                       'FM90.0000')) DELVRY_RANGE_MIN,
			       TO_CHAR(T.DELVRY_EDATE, 'YYYY-MM-DD') DELVRY_EDATE,
			       T.ORDERCONTACT,
			       (DECODE(T.TRANSIT_TYP || ' ', ' ', '', T.TRANSIT_TYP || ' ') ||
			       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.PLAN_QTY,
			       (SELECT MAX(A.BASENAME)
			          FROM COM_BASE_INFO A
			         WHERE A.BASECODE = T.PRD_CLS
			            OR A.BASENAME = T.PRD_CLS) PRD_CLS,
			       T.ROLL_MONTH,
			       (SELECT MAX(A.BASENAME)
			          FROM COM_BASE_INFO A
			         WHERE A.BASECODE = DECODE(TRIM(T.OUTS_BILLET_FL),
			         NULL,'121802',T.OUTS_BILLET_FL)) OUTS_BILLET_FL,
			       T.SPEC_NAME,
			       T.PACKTYPE,
			       (SELECT A.BASENAME
			          FROM COM_BASE_INFO A
			         WHERE A.BASECODE = T.MONITORDEMAND) MONITORDEMAND,
			         (SELECT LISTAGG(PROCESS_DESC, ',') WITHIN GROUP(ORDER BY PROCESS_CODE) 
					  FROM (SELECT DISTINCT B.PROCESS_DESC,B.PRDCR_NO,B.PROCESS_CODE
					          FROM SLM_ORDER_LINE_PRDCR_LST B
					         WHERE B.PRDCR_PRC_FL = '1' )
					         WHERE PRDCR_NO = T.PRDCR_NO) PRDCRPRO,
			       (TO_CHAR(T.LENGTHMIN, 'FM9999999990.00') || '-' ||
       TO_CHAR(T.LENGTHMAX, 'FM9999999990.00') || 'M') TECHNICALLEN,
			       T.ORDER_SPECIAL_DESC,
			       T.ORDER_QTY,
			       T.ORDER_UNIT,
			       DECODE(T.ORDER_UNIT,
			              '个',
			              '支',
			              '米',
			              '吨',
			              '英尺',
			              '吨',
			              T.ORDER_UNIT) DW,
			       T.SHRT_STOVE,
			       T.SIGL_LEN,
			       DECODE(T.ORDER_SPECIAL_DESC, NULL, '普通', '特殊') ORDER_TYPE,
			       T.ENDLEN_SPECSTD,
             	   T.STUFF_PROPERTY,
             	   T.GRADECODE_ALL,
			       T1.CRAFT_FILE_NO,
			       T1.CRAFT_FILE_MAN,
			       T1.STD_LG_NO,
			       T1.STD_ZG_NO,
			       T1.STD_GJG_NO,
			       T1.HEIGHT_NK_MIN,
			       T1.HEIGHT_NK_MAX,
			       TO_CHAR(T.LEN_TOEND_MIN, 'FM99990.00') LEN_TOEND_MIN,
			       TO_CHAR(T.LEN_TOEND_MAX, 'FM99990.00') LEN_TOEND_MAX,
			       T1.CRAFT_PATH,
			       T1.RCL_INFO,
			       T1.VERSION_NO,
			       T1.VERSION_DESC,
			       '销售合同' ORDERCONTRACT,
			       DECODE(T.PORDERSTATUS,
			              '0',
			              '待接收',
			              '1',
			              '已接收',
			              '2',
			              '已下发',
			              '3',
			              '生产中',
			              '4',
			              '生产完成',
			              '5',
			              '缴库完成',
			              '6',
			              '发运完毕',
			              '7',
			              '结算完毕',
			              '8',
			              '合同关闭') PORDERSTATUS,
			       T.DELIVERY_NO,
			       DECODE(T.JGORD_IS_OK, '0', '否', '1', '是', '2', '/') JGORD_IS_OK,
			       DECODE(T.DJBL_REQ_IS_OK, '0', '否', '1', '是', '2', '/') DJBL_REQ_IS_OK,
			       T.ORD_PK,
			       T.ORD_LN_PK,
			       T.ORD_LN_DLY_PK,
		           (SELECT SUM(B.CONFIRM_WT)
			          FROM PLN_SALEORDER_R_NUM B
			         WHERE B.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK) CONFIRM_WT_SUM,
			       (SELECT B.AW FROM SLM_ORDER_LINE B WHERE B.ORD_LN_PK = T.ORD_LN_PK) AW 
			  FROM PLN_SALEORDER T,PLN_ORD_CRAFT_FILE T1
			 WHERE T1.ORDER_NO(+) = T.ORDER_NO
			   AND T1.ORDER_SEQ(+) = T.ORDER_SEQ
		       AND T1.CRAFT_FILE_NO(+) = T.CRAFT_FILE_NO
			   AND (T.PORDERSTATUS <> '5' or
			        TO_DATE(T.ROLL_MONTH, 'YYYY-MM') >=
			        TO_DATE(to_char(sysdate, 'yyyy-mm'), 'YYYY-MM'))
			   AND (T.ACCEPT_NO LIKE '%' || ? || '%')
			   AND (T.ORDER_NO || '/' || T.ORDER_SEQ) LIKE '%' || ? || '%'
			   AND TO_DATE(TO_CHAR(T.UPDATE_TIME, 'YYYY-MM-DD'), 'YYYY-MM-DD') BETWEEN
			       TO_DATE(?, 'YYYY/MM/DD') AND
			       TO_DATE(?, 'YYYY/MM/DD')
			   AND T.PORDERSTATUS LIKE '%' || ? || '%'
			   AND T.PORDERSTATUS != '0'
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.queryExportIsGSaleOrder" desc="查询管体导出销售合同">
		<![CDATA[
			SELECT T.ACCEPT_NO,
			       (SELECT A.PLINE_NAME
			          FROM COM_BASE_PLINE A
			         WHERE A.PLINE_CODE = T.GROUP_ROLL
			           AND A.VALIDFLAG = '1') GROUP_ROLL,
			       (SELECT A.PRODUC_JX
			          FROM COM_BASE_PRODUCT A
			         WHERE A.PRODUCCODE = T.PRODUCCODE) PRODUC_JX,
			       T.PROCESS_SEQ,
			       (DECODE(T.STD_STYLE_DESC || ' ', ' ', '', T.STD_STYLE_DESC || ' ') ||
			       T.STEELNAME) STEELNAME,
			       T.OUTDIAMETER,
			       T.WALLTHICK,
			       T.LENGTHDISC,
			       T.MODEL_DESC,
			       T.ORDERWEIGHT,
			       DECODE(T.TOTLENGTH_M, 0, '', T.TOTLENGTH_M) TOTLENGTH,
			       T.STD_NAME,
			       T.ORDER_NO || '/' || T.ORDER_SEQ ORDER_SEQNO,
			       NVL((SELECT A.ABRVITION
			             FROM SLM_BASE_CUSTOMER A
			            WHERE A.CUSTOMER_NO = DECODE(T.FINAL_USER,
			                                      NULL,
			                                      T.BUYER_ID,
			                                      '/',
			                                      T.BUYER_ID,
			                                      T.FINAL_USER)),
			           DECODE(T.FINAL_USER_DESC,
			                  NULL,
			                  T.BUYER_NAME,
			                  '/',
			                  T.BUYER_NAME,
			                  T.FINAL_USER_DESC)) FINAL_USER,
			       (SELECT B.ORDER_ADD_DESC FROM SLM_ORDER_LINE B WHERE B.ORD_LN_PK = T.ORD_LN_PK) ORDER_ADD_DESC,
			       (SELECT MAX(A.BASENAME)
			          FROM COM_BASE_INFO A
			         WHERE A.BASECODE = T.ORDERFROM
			            OR A.BASENAME = T.ORDERFROM) ORDERFROM,
			       T.PRODUCE_SORT,
			       (TO_CHAR(DECODE(T.DELVRY_RANGE_TPE,
			                       '绝对值',
			                       T.DELVRY_RANGE_MAX * 100 / T.ORDER_QTY,
			                       T.DELVRY_RANGE_MAX),
			                'FM9990.00') || '%') RANGE_MAX,
			       ('-' || TO_CHAR(ABS(DECODE(T.DELVRY_RANGE_TPE,
			                                  '绝对值',
			                                  T.DELVRY_RANGE_MIN * 100 / T.ORDER_QTY,
			                                  T.DELVRY_RANGE_MIN)),
			                       'FM9990.00') || '%') RANGE_MIN,
			       TO_CHAR(DECODE(T.DELVRY_RANGE_TPE,
			                      '绝对值',
			                      T.DELVRY_RANGE_MAX / T.ORDER_QTY,
			                      T.DELVRY_RANGE_MAX / 100),
			               'FM90.0000') DELVRY_RANGE_MAX,
			       ('-' || TO_CHAR(ABS(DECODE(T.DELVRY_RANGE_TPE,
			                                  '绝对值',
			                                  T.DELVRY_RANGE_MIN / T.ORDER_QTY,
			                                  T.DELVRY_RANGE_MIN / 100)),
			                       'FM90.0000')) DELVRY_RANGE_MIN,
			       TO_CHAR(T.DELVRY_EDATE, 'YYYY-MM-DD') DELVRY_EDATE,
			       T.ORDERCONTACT,
			       (DECODE(T.TRANSIT_TYP || ' ', ' ', '', T.TRANSIT_TYP || ' ') ||
			       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.PLAN_QTY,
			       (SELECT MAX(A.BASENAME)
			          FROM COM_BASE_INFO A
			         WHERE A.BASECODE = T.PRD_CLS
			            OR A.BASENAME = T.PRD_CLS) PRD_CLS,
			       T.ROLL_MONTH,
			       (SELECT MAX(A.BASENAME)
			          FROM COM_BASE_INFO A
			         WHERE A.BASECODE = DECODE(TRIM(T.OUTS_BILLET_FL),
			         NULL,'121802',T.OUTS_BILLET_FL)) OUTS_BILLET_FL,
			       T.SPEC_NAME,
			       T.PACKTYPE,
			       (SELECT A.BASENAME
			          FROM COM_BASE_INFO A
			         WHERE A.BASECODE = T.MONITORDEMAND) MONITORDEMAND,
			         (SELECT LISTAGG(PROCESS_DESC, ',') WITHIN GROUP(ORDER BY PROCESS_CODE) 
					  FROM (SELECT DISTINCT B.PROCESS_DESC,B.PRDCR_NO,B.PROCESS_CODE
					          FROM SLM_ORDER_LINE_PRDCR_LST B
					         WHERE B.PRDCR_PRC_FL = '1' )
					         WHERE PRDCR_NO = T.PRDCR_NO) PRDCRPRO,
			       (TO_CHAR(T.LENGTHMIN, 'FM9999999990.00') || '-' ||
       TO_CHAR(T.LENGTHMAX, 'FM9999999990.00') || 'M') TECHNICALLEN,
			       T.ORDER_SPECIAL_DESC,
			       T.ORDER_QTY,
			       T.ORDER_UNIT,
			       DECODE(T.ORDER_UNIT,
			              '个',
			              '支',
			              '米',
			              '吨',
			              '英尺',
			              '吨',
			              T.ORDER_UNIT) DW,
			       T.SHRT_STOVE,
			       T.SIGL_LEN,
			       DECODE(T.ORDER_SPECIAL_DESC, NULL, '普通', '特殊') ORDER_TYPE,
			       T.ENDLEN_SPECSTD,
             	   T.STUFF_PROPERTY,
             	   T.GRADECODE_ALL,
			       T1.CRAFT_FILE_NO,
			       T1.CRAFT_FILE_MAN,
			       T1.STD_LG_NO,
			       T1.STD_ZG_NO,
			       T1.STD_GJG_NO,
			       T1.HEIGHT_NK_MIN,
			       T1.HEIGHT_NK_MAX,
			       TO_CHAR(T.LEN_TOEND_MIN, 'FM99990.00') LEN_TOEND_MIN,
			       TO_CHAR(T.LEN_TOEND_MAX, 'FM99990.00') LEN_TOEND_MAX,
			       T1.CRAFT_PATH,
			       T1.RCL_INFO,
			       T1.VERSION_NO,
			       T1.VERSION_DESC,
			       '销售合同' ORDERCONTRACT,
			       DECODE(T.PORDERSTATUS,
			              '0',
			              '待接收',
			              '1',
			              '已接收',
			              '2',
			              '已下发',
			              '3',
			              '生产中',
			              '4',
			              '生产完成',
			              '5',
			              '缴库完成',
			              '6',
			              '发运完毕',
			              '7',
			              '结算完毕',
			              '8',
			              '合同关闭') PORDERSTATUS,
			       T.DELIVERY_NO,
			       DECODE(T.JGORD_IS_OK, '0', '否', '1', '是', '2', '/') JGORD_IS_OK,
			       DECODE(T.DJBL_REQ_IS_OK, '0', '否', '1', '是', '2', '/') DJBL_REQ_IS_OK,
			       T.ORD_PK,
			       T.ORD_LN_PK,
			       T.ORD_LN_DLY_PK,
		           (SELECT SUM(B.CONFIRM_WT)
			          FROM PLN_SALEORDER_R_NUM B
			         WHERE B.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK) CONFIRM_WT_SUM,
			       (SELECT B.AW FROM SLM_ORDER_LINE B WHERE B.ORD_LN_PK = T.ORD_LN_PK) AW 
			  FROM PLN_SALEORDER T,COM_BASE_PRODUCT A,PLN_ORD_CRAFT_FILE T1
			 WHERE T1.ORDER_NO(+) = T.ORDER_NO
			   AND T1.ORDER_SEQ(+) = T.ORDER_SEQ
		       AND T1.CRAFT_FILE_NO(+) = T.CRAFT_FILE_NO
			   AND A.PRODUCCODE = T.PRODUCCODE
			   and (T.PORDERSTATUS <> '5' or
			        TO_DATE(T.ROLL_MONTH, 'YYYY-MM') >=
			        TO_DATE(to_char(sysdate, 'yyyy-mm'), 'YYYY-MM'))
			   AND (A.PRODUC_TYPE = 'B' OR (A.PRODUC_TYPE = 'A' AND T.MERGETYPE = '0'))
			   AND (T.ACCEPT_NO LIKE '%' || ? || '%')
			   AND (T.ORDER_NO || '/' || T.ORDER_SEQ) LIKE '%' || ? || '%'
			   AND TO_DATE(TO_CHAR(T.UPDATE_TIME, 'YYYY-MM-DD'), 'YYYY-MM-DD') BETWEEN
			       TO_DATE(?, 'YYYY/MM/DD') AND
			       TO_DATE(?, 'YYYY/MM/DD')
			   AND T.PORDERSTATUS LIKE '%' || ? || '%'
			   AND T.PORDERSTATUS != '0'
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.queryExportNotGSaleOrder" desc="查询非管体导出销售合同">
		<![CDATA[
			SELECT T.ACCEPT_NO,
			       (SELECT A.PLINE_NAME
			          FROM COM_BASE_PLINE A
			         WHERE A.PLINE_CODE = T.GROUP_ROLL
			           AND A.VALIDFLAG = '1') GROUP_ROLL,
			       (SELECT A.PRODUC_JX
			          FROM COM_BASE_PRODUCT A
			         WHERE A.PRODUCCODE = T.PRODUCCODE) PRODUC_JX,
			       T.PROCESS_SEQ,
			       (DECODE(T.STD_STYLE_DESC || ' ', ' ', '', T.STD_STYLE_DESC || ' ') ||
			       T.STEELNAME) STEELNAME,
			       T.OUTDIAMETER,
			       T.WALLTHICK,
			       T.LENGTHDISC,
			       T.MODEL_DESC,
			       T.ORDERWEIGHT,
			       DECODE(T.TOTLENGTH_M, 0, '', T.TOTLENGTH_M) TOTLENGTH,
			       T.STD_NAME,
			       T.ORDER_NO || '/' || T.ORDER_SEQ ORDER_SEQNO,
			       NVL((SELECT A.ABRVITION
			             FROM SLM_BASE_CUSTOMER A
			            WHERE A.CUSTOMER_NO = DECODE(T.FINAL_USER,
			                                      NULL,
			                                      T.BUYER_ID,
			                                      '/',
			                                      T.BUYER_ID,
			                                      T.FINAL_USER)),
			           DECODE(T.FINAL_USER_DESC,
			                  NULL,
			                  T.BUYER_NAME,
			                  '/',
			                  T.BUYER_NAME,
			                  T.FINAL_USER_DESC)) FINAL_USER,
			       (SELECT B.ORDER_ADD_DESC FROM SLM_ORDER_LINE B WHERE B.ORD_LN_PK = T.ORD_LN_PK) ORDER_ADD_DESC,
			       (SELECT MAX(A.BASENAME)
			          FROM COM_BASE_INFO A
			         WHERE A.BASECODE = T.ORDERFROM
			            OR A.BASENAME = T.ORDERFROM) ORDERFROM,
			       T.PRODUCE_SORT,
			       (TO_CHAR(DECODE(T.DELVRY_RANGE_TPE,
			                       '绝对值',
			                       T.DELVRY_RANGE_MAX * 100 / T.ORDER_QTY,
			                       T.DELVRY_RANGE_MAX),
			                'FM9990.00') || '%') RANGE_MAX,
			       ('-' || TO_CHAR(ABS(DECODE(T.DELVRY_RANGE_TPE,
			                                  '绝对值',
			                                  T.DELVRY_RANGE_MIN * 100 / T.ORDER_QTY,
			                                  T.DELVRY_RANGE_MIN)),
			                       'FM9990.00') || '%') RANGE_MIN,
			       TO_CHAR(DECODE(T.DELVRY_RANGE_TPE,
			                      '绝对值',
			                      T.DELVRY_RANGE_MAX / T.ORDER_QTY,
			                      T.DELVRY_RANGE_MAX / 100),
			               'FM90.0000') DELVRY_RANGE_MAX,
			       ('-' || TO_CHAR(ABS(DECODE(T.DELVRY_RANGE_TPE,
			                                  '绝对值',
			                                  T.DELVRY_RANGE_MIN / T.ORDER_QTY,
			                                  T.DELVRY_RANGE_MIN / 100)),
			                       'FM90.0000')) DELVRY_RANGE_MIN,
			       TO_CHAR(T.DELVRY_EDATE, 'YYYY-MM-DD') DELVRY_EDATE,
			       T.ORDERCONTACT,
			       (DECODE(T.TRANSIT_TYP || ' ', ' ', '', T.TRANSIT_TYP || ' ') ||
			       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.PLAN_QTY,
			       (SELECT MAX(A.BASENAME)
			          FROM COM_BASE_INFO A
			         WHERE A.BASECODE = T.PRD_CLS
			            OR A.BASENAME = T.PRD_CLS) PRD_CLS,
			       T.ROLL_MONTH,
			       (SELECT MAX(A.BASENAME)
			          FROM COM_BASE_INFO A
			         WHERE A.BASECODE = DECODE(TRIM(T.OUTS_BILLET_FL),
			         NULL,'121802',T.OUTS_BILLET_FL)) OUTS_BILLET_FL,
			       T.SPEC_NAME,
			       T.PACKTYPE,
			       (SELECT A.BASENAME
			          FROM COM_BASE_INFO A
			         WHERE A.BASECODE = T.MONITORDEMAND) MONITORDEMAND,
			         (SELECT LISTAGG(PROCESS_DESC, ',') WITHIN GROUP(ORDER BY PROCESS_CODE) 
					  FROM (SELECT DISTINCT B.PROCESS_DESC,B.PRDCR_NO,B.PROCESS_CODE
					          FROM SLM_ORDER_LINE_PRDCR_LST B
					         WHERE B.PRDCR_PRC_FL = '1' )
					         WHERE PRDCR_NO = T.PRDCR_NO) PRDCRPRO,
			       (TO_CHAR(T.LENGTHMIN, 'FM9999999990.00') || '-' ||
       TO_CHAR(T.LENGTHMAX, 'FM9999999990.00') || 'M') TECHNICALLEN,
			       T.ORDER_SPECIAL_DESC,
			       T.ORDER_QTY,
			       T.ORDER_UNIT,
			       DECODE(T.ORDER_UNIT,
			              '个',
			              '支',
			              '米',
			              '吨',
			              '英尺',
			              '吨',
			              T.ORDER_UNIT) DW,
			       T.SHRT_STOVE,
			       T.SIGL_LEN,
			       DECODE(T.ORDER_SPECIAL_DESC, NULL, '普通', '特殊') ORDER_TYPE,
			       T.ENDLEN_SPECSTD,
             	   T.STUFF_PROPERTY,
             	   T.GRADECODE_ALL,
			       T1.CRAFT_FILE_NO,
			       T1.CRAFT_FILE_MAN,
			       T1.STD_LG_NO,
			       T1.STD_ZG_NO,
			       T1.STD_GJG_NO,
			       T1.HEIGHT_NK_MIN,
			       T1.HEIGHT_NK_MAX,
			       TO_CHAR(T.LEN_TOEND_MIN, 'FM99990.00') LEN_TOEND_MIN,
			       TO_CHAR(T.LEN_TOEND_MAX, 'FM99990.00') LEN_TOEND_MAX,
			       T1.CRAFT_PATH,
			       T1.RCL_INFO,
			       T1.VERSION_NO,
			       T1.VERSION_DESC,
			       '销售合同' ORDERCONTRACT,
			       DECODE(T.PORDERSTATUS,
			              '0',
			              '待接收',
			              '1',
			              '已接收',
			              '2',
			              '已下发',
			              '3',
			              '生产中',
			              '4',
			              '生产完成',
			              '5',
			              '缴库完成',
			              '6',
			              '发运完毕',
			              '7',
			              '结算完毕',
			              '8',
			              '合同关闭') PORDERSTATUS,
			       T.DELIVERY_NO,
			       DECODE(T.JGORD_IS_OK, '0', '否', '1', '是', '2', '/') JGORD_IS_OK,
			       DECODE(T.DJBL_REQ_IS_OK, '0', '否', '1', '是', '2', '/') DJBL_REQ_IS_OK,
			       T.ORD_PK,
			       T.ORD_LN_PK,
			       T.ORD_LN_DLY_PK,
		           (SELECT SUM(B.CONFIRM_WT)
			          FROM PLN_SALEORDER_R_NUM B
			         WHERE B.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK) CONFIRM_WT_SUM,
			       (SELECT B.AW FROM SLM_ORDER_LINE B WHERE B.ORD_LN_PK = T.ORD_LN_PK) AW 
			  FROM PLN_SALEORDER T,COM_BASE_PRODUCT A,PLN_ORD_CRAFT_FILE T1
			 WHERE T1.ORDER_NO(+) = T.ORDER_NO
			   AND T1.ORDER_SEQ(+) = T.ORDER_SEQ
		       AND T1.CRAFT_FILE_NO(+) = T.CRAFT_FILE_NO
			   AND A.PRODUCCODE = T.PRODUCCODE 
			   and (T.PORDERSTATUS <> '5' or
			        TO_DATE(T.ROLL_MONTH, 'YYYY-MM') >=
			        TO_DATE(to_char(sysdate, 'yyyy-mm'), 'YYYY-MM'))
			   AND (A.PRODUC_TYPE!='A' OR T.MERGETYPE='3')
			   AND A.PRODUC_TYPE != 'B'
			   AND (T.ACCEPT_NO LIKE '%' || ? || '%')
			   AND (T.ORDER_NO || '/' || T.ORDER_SEQ) LIKE '%' || ? || '%'
			   AND TO_DATE(TO_CHAR(T.UPDATE_TIME, 'YYYY-MM-DD'), 'YYYY-MM-DD') BETWEEN
			       TO_DATE(?, 'YYYY/MM/DD') AND
			       TO_DATE(?, 'YYYY/MM/DD')
			   AND T.PORDERSTATUS LIKE '%' || ? || '%'
			   AND T.PORDERSTATUS != '0'
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.queryExportOutImport" desc="查询外部导入系统的合同">
		<![CDATA[
			SELECT T.ACCEPT_NO,
		             (SELECT A.PLINE_NAME
		                FROM COM_BASE_PLINE A
		               WHERE A.PLINE_CODE = T.GROUP_ROLL
		                 AND A.VALIDFLAG = '1') GROUP_ROLL,
		             (SELECT A.PRODUC_JX
		                FROM COM_BASE_PRODUCT A
		               WHERE A.PRODUCCODE = T.PRODUCCODE) PRODUC_JX,
		             T.PROCESS_SEQ,
		             (DECODE(T.STD_STYLE_DESC || ' ', ' ', '', T.STD_STYLE_DESC || ' ') ||
		             T.STEELNAME) STEELNAME,
		             T.OUTDIAMETER,
		             T.WALLTHICK,
		             T.LENGTHDISC,
		             T.MODEL_DESC,
		             T.ORDERWEIGHT,
		             DECODE(T.TOTLENGTH_M, 0, '', T.TOTLENGTH_M) TOTLENGTH,
		             T.STD_NAME,
		             T.ORDER_NO || '/' || T.ORDER_SEQ ORDER_SEQNO,
		             NVL((SELECT A.ABRVITION
			             FROM SLM_BASE_CUSTOMER A
			            WHERE A.CUSTOMER_NO = DECODE(T.FINAL_USER,
			                                      NULL,
			                                      T.BUYER_ID,
			                                      '/',
			                                      T.BUYER_ID,
			                                      T.FINAL_USER)),
			           DECODE(T.FINAL_USER_DESC,
			                  NULL,
			                  T.BUYER_NAME,
			                  '/',
			                  T.BUYER_NAME,
			                  T.FINAL_USER_DESC)) FINAL_USER,
			       (SELECT B.ORDER_ADD_DESC FROM SLM_ORDER_LINE B WHERE B.ORD_LN_PK = T.ORD_LN_PK) ORDER_ADD_DESC,
		             (SELECT MAX(A.BASENAME)
		                FROM COM_BASE_INFO A
		               WHERE A.BASECODE = T.ORDERFROM
		                  OR A.BASENAME = T.ORDERFROM) ORDERFROM,
		             T.PRODUCE_SORT,
			       (TO_CHAR(DECODE(T.DELVRY_RANGE_TPE,
			                       '绝对值',
			                       T.DELVRY_RANGE_MAX * 100 / T.ORDER_QTY,
			                       T.DELVRY_RANGE_MAX),
			                'FM9990.00') || '%') RANGE_MAX,
			       ('-' || TO_CHAR(ABS(DECODE(T.DELVRY_RANGE_TPE,
			                                  '绝对值',
			                                  T.DELVRY_RANGE_MIN * 100 / T.ORDER_QTY,
			                                  T.DELVRY_RANGE_MIN)),
			                       'FM9990.00') || '%') RANGE_MIN,
			       TO_CHAR(DECODE(T.DELVRY_RANGE_TPE,
			                      '绝对值',
			                      T.DELVRY_RANGE_MAX / T.ORDER_QTY,
			                      T.DELVRY_RANGE_MAX / 100),
			               'FM90.0000') DELVRY_RANGE_MAX,
			       ('-' || TO_CHAR(ABS(DECODE(T.DELVRY_RANGE_TPE,
			                                  '绝对值',
			                                  T.DELVRY_RANGE_MIN / T.ORDER_QTY,
			                                  T.DELVRY_RANGE_MIN / 100)),
			                       'FM90.0000')) DELVRY_RANGE_MIN,
		             TO_CHAR(T.DELVRY_EDATE, 'YYYY-MM-DD') DELVRY_EDATE,
		             T.ORDERCONTACT,
		             (DECODE(T.TRANSIT_TYP || ' ', ' ', '', T.TRANSIT_TYP || ' ') ||
		             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.PLAN_QTY,
		             (SELECT MAX(A.BASENAME)
		                FROM COM_BASE_INFO A
		               WHERE A.BASECODE = T.PRD_CLS
		                  OR A.BASENAME = T.PRD_CLS) PRD_CLS,
		             T.ROLL_MONTH,
		             (SELECT MAX(A.BASENAME)
		                FROM COM_BASE_INFO A
		               WHERE A.BASECODE = DECODE(TRIM(T.OUTS_BILLET_FL),
		               NULL,'121802',T.OUTS_BILLET_FL)) OUTS_BILLET_FL,
		             T.SPEC_NAME,
		             T.PACKTYPE,
		             (SELECT A.BASENAME
		                FROM COM_BASE_INFO A
		               WHERE A.BASECODE = T.MONITORDEMAND) MONITORDEMAND,
			         (SELECT LISTAGG(PROCESS_DESC, ',') WITHIN GROUP(ORDER BY PROCESS_CODE) 
					  FROM (SELECT DISTINCT B.PROCESS_DESC,B.PRDCR_NO,B.PROCESS_CODE
					          FROM SLM_ORDER_LINE_PRDCR_LST B
					         WHERE B.PRDCR_PRC_FL = '1' )
					         WHERE PRDCR_NO = T.PRDCR_NO) PRDCRPRO,
		             (TO_CHAR(T.LENGTHMIN, 'FM9999999990.00') || '-' ||
		       TO_CHAR(T.LENGTHMAX, 'FM9999999990.00') || 'M') TECHNICALLEN,
		             T.ORDER_SPECIAL_DESC,
		             T.ORDER_QTY,
		             T.ORDER_UNIT,
		             DECODE(T.ORDER_UNIT,
		                    '个',
		                    '支',
		                    '米',
		                    '吨',
		                    '英尺',
		                    '吨',
		                    T.ORDER_UNIT) DW,
		             T.SHRT_STOVE,
		             T.SIGL_LEN,
		             DECODE(T.ORDER_SPECIAL_DESC, NULL, '普通', '特殊') ORDER_TYPE,
		             T.ENDLEN_SPECSTD,
		                  T.STUFF_PROPERTY,
		                  T.GRADECODE_ALL,
		             T1.CRAFT_FILE_NO,
		             T1.CRAFT_FILE_MAN,
		             T1.STD_LG_NO,
		             T1.STD_ZG_NO,
		             T1.STD_GJG_NO,
		             T1.HEIGHT_NK_MIN,
		             T1.HEIGHT_NK_MAX,
		             TO_CHAR(T.LEN_TOEND_MIN, 'FM99990.00') LEN_TOEND_MIN,
		             TO_CHAR(T.LEN_TOEND_MAX, 'FM99990.00') LEN_TOEND_MAX,
		             T1.CRAFT_PATH,
		             T1.RCL_INFO,
		             T1.VERSION_NO,
		             T1.VERSION_DESC,
		             '销售合同' ORDERCONTRACT,
			       DECODE(T.PORDERSTATUS,
			              '0',
			              '待接收',
			              '1',
			              '已接收',
			              '2',
			              '已下发',
			              '3',
			              '生产中',
			              '4',
			              '生产完成',
			              '5',
			              '缴库完成',
			              '6',
			              '发运完毕',
			              '7',
			              '结算完毕',
			              '8',
			              '合同关闭') PORDERSTATUS,
			         T.DELIVERY_NO,
		             T.ORD_PK,
		             T.ORD_LN_PK,
		             T.ORD_LN_DLY_PK,
		           (SELECT SUM(B.CONFIRM_WT)
			          FROM PLN_SALEORDER_R_NUM B
			         WHERE B.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK) CONFIRM_WT_SUM,
			       (SELECT B.AW FROM SLM_ORDER_LINE B WHERE B.ORD_LN_PK = T.ORD_LN_PK) AW 
		        FROM PLN_SALEORDER T,PLN_ORD_CRAFT_FILE T1
		       WHERE T1.ORDER_NO(+) = T.ORDER_NO
		         AND T1.ORDER_SEQ(+) = T.ORDER_SEQ
		         AND T1.CRAFT_FILE_NO(+) = T.CRAFT_FILE_NO
			     AND (T.PORDERSTATUS <> '5' or
			        TO_DATE(T.ROLL_MONTH, 'YYYY-MM') >=
			        TO_DATE(to_char(sysdate, 'yyyy-mm'), 'YYYY-MM'))
		         AND (T.ACCEPT_NO LIKE '%' || ? || '%' OR T.ACCEPT_NO IS NULL)
		         AND (T.ORDER_NO || '/' || T.ORDER_SEQ) LIKE '%' || ? || '%'
		         AND (TO_DATE(TO_CHAR(T.UPDATE_TIME, 'YYYY-MM-DD'), 'YYYY-MM-DD') BETWEEN
		             TO_DATE(?, 'YYYY/MM/DD') AND
		             TO_DATE(?, 'YYYY/MM/DD') OR T.UPDATE_TIME IS NULL)
			     AND T.PORDERSTATUS LIKE '%' || ? || '%'
		         AND T.PORDERSTATUS != '0'
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.queryJgbyOrderno" desc="通过接箍合同号查询接箍和同">
		<![CDATA[
			SELECT * FROM PLN_ORDER_JG T WHERE T.JG_ORDERNO=?
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.queryBLbyReqBlId" desc="通过备料需求编号查询备料需求">
		<![CDATA[
			SELECT * FROM PLN_PORDER_BL_REQ T WHERE T.REQ_BL_ID=?
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.queryjgorder" desc="查询接箍和同">
		<![CDATA[
			SELECT T.JG_ORDERNO,
			       T.ORDER_NO,
			       T.ORDER_SEQ,
			       T.DELIVERY_NO,
			       T.BUYER_ID,
			       T.BUYER_NAME,
			       TO_CHAR(T.DELVRY_BDATE,'YYYY-MM-DD') DELVRY_BDATE,
			       TO_CHAR(T.DELVRY_EDATE,'YYYY-MM-DD') DELVRY_EDATE,
			       T.ORDERCONTACT,
			       T.MONITORDEMAND,
			       T.PSC,
			       T.MSC,
			       T.INDEX_SEQ,
			       T.CODE_JG,
			       T.STEELCODE,
			       T.STEELNAME,
			       T.OUTDIAMETER,
			       T.WALLTHICK,
			       T.AIMWALLTHICK,
			       T.MODEL_CODE,
			       T.AIMLENGTH,
			       T.SINGLEWEIGHT,
			       T.ORDERWEIGHT,
			       T.ORDERNUM,
			       TO_CHAR(T.LATEST_PROD_DATE,'YYYY-MM-DD') LATEST_PROD_DATE,
			       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,
			       DECODE(T.JGORDERSTATUS,
			              '0',
			              '待处理',
			              '1',
			              '完成配料',
			              '2',
			              '已下发') JGORDERSTATUS,
			       T.MATCHWEIGHT,
			       T.MATCHNUM,
			       DECODE(T.IFBUYPLAN, '1', '有', '0', '无') IFBUYPLAN,
			       T.BUYPLANID,
			       T.BUYPLANWEIGHT,
			       T.BUYPLANNUM,
			       T.GROUP_JGX,
			       T.JGWT_BLREQ
			  FROM PLN_ORDER_JG T, PLN_SALEORDER T1
			 WHERE T.ORDER_NO = T1.ORDER_NO
			   AND T.ORDER_SEQ = T1.ORDER_SEQ
			   AND T.DELIVERY_NO = T1.DELIVERY_NO
			   AND NVL(T1.ROLL_MONTH, '1') LIKE '%' || NVL(?, '1') || '%'
			   AND NVL(T1.ACCEPT_NO, '1') LIKE '%' || NVL(?, '1') || '%'
			   AND (T.ORDER_NO || '/' || T.ORDER_SEQ) LIKE '%' || ? || '%'
			   AND T1.PORDERSTATUS LIKE '%' || ? || '%'
			   AND DECODE(?, '1', T1.JGORD_IS_OK, 1) != DECODE(?, '1', '2', 2)
			   AND DECODE(?, '1', T1.DJBL_REQ_IS_OK, 1) != DECODE(?, '1', '2', 2)
			   AND DECODE(?, '1', T1.MERGETYPE, 1) = DECODE(?, '1', '3', 1)
			   AND T1.PORDERSTATUS < '6'
			   AND DECODE(?, '', '1', T1.D_IS_OK) != DECODE(?, '', '2', '2')
			   AND DECODE(?, '', '1', T1.E_IS_OK) != DECODE(?, '', '2', '2')
			   AND DECODE(?, '', '1', T1.F_IS_OK) != DECODE(?, '', '2', '2')
			   AND DECODE(?, '', '1', T1.G_IS_OK) != DECODE(?, '', '2', '2')
			   AND DECODE(?, '', '1', T1.JGL_REQ_IS_OK) != DECODE(?, '', '2', '2')
			   AND DECODE(?, '', '1', T1.DJBL_REQ_IS_OK) != DECODE(?, '', '2', '2')
			   AND DECODE(?, '', '1', T1.ORDERFROM) = NVL(?, '1')
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.queryIssJgOrder" desc="查询已下发接箍和同">
		<![CDATA[
			SELECT T.JG_ORDERNO,
			       T.ORDER_NO,
			       T.ORDER_SEQ,
			       T.DELIVERY_NO,
			       T.BUYER_ID,
			       T.BUYER_NAME,
			       TO_CHAR(T.DELVRY_BDATE,'YYYY-MM-DD') DELVRY_BDATE,
			       TO_CHAR(T.DELVRY_EDATE,'YYYY-MM-DD') DELVRY_EDATE,
			       T.ORDERCONTACT,
			       T.MONITORDEMAND,
			       T.PSC,
			       T.MSC,
			       T.INDEX_SEQ,
			       T.CODE_JG,
			       T.STEELCODE,
			       T.STEELNAME,
			       T.OUTDIAMETER,
			       T.WALLTHICK,
			       T.AIMWALLTHICK,
			       T.MODEL_CODE,
			       T.AIMLENGTH,
			       T.SINGLEWEIGHT,
			       T.ORDERWEIGHT,
			       T.ORDERNUM,
			       TO_CHAR(T.LATEST_PROD_DATE,'YYYY-MM-DD') LATEST_PROD_DATE,
			       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,
			       DECODE(T.JGORDERSTATUS,
			              '0',
			              '待处理',
			              '1',
			              '完成配料',
			              '2',
			              '已下发') JGORDERSTATUS,
			       T.MATCHWEIGHT,
			       T.MATCHNUM,
			       DECODE(T.IFBUYPLAN, '1', '有', '0', '无') IFBUYPLAN,
			       T.BUYPLANID,
			       T.BUYPLANWEIGHT,
			       T.BUYPLANNUM,
			       T.GROUP_JGX,
			       T.JGWT_BLREQ
			  FROM PLN_ORDER_JG T
			 WHERE T.JGORDERSTATUS = '2'
			   AND T.ISSUED_TIME BETWEEN TO_DATE(?, 'YYYY/MM/DD') AND
			       TO_DATE(?, 'YYYY/MM/DD')
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.querySaleByPrimary" desc="通过合同号查询销售合同内容">
		<![CDATA[
			SELECT *
			  FROM PLN_SALEORDER T
			 WHERE T.ORDER_NO = ?
			   AND T.ORDER_SEQ = ?
			   AND T.DELIVERY_NO = ?
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.QueryJgDeal" desc="查询所有未处理完成接箍和同">
		<![CDATA[
			SELECT T.JG_ORDERNO,
			       T.ORDER_NO,
			       T.ORDER_SEQ,
			       T.DELIVERY_NO,
			       T.BUYER_ID,
			       T.BUYER_NAME,
			       TO_CHAR(T.DELVRY_BDATE,'YYYY-MM-DD') DELVRY_BDATE,
			       TO_CHAR(T.DELVRY_EDATE,'YYYY-MM-DD') DELVRY_EDATE,
			       T.ORDERCONTACT,
			       T.MONITORDEMAND,
			       T.PSC,
			       T.MSC,
			       T.INDEX_SEQ,
			       T.CODE_JG,
			       T.STEELCODE,
			       T.STEELNAME,
			       T.OUTDIAMETER,
			       T.WALLTHICK,
			       T.AIMWALLTHICK,
			       T.MODEL_CODE,
			       T.AIMLENGTH,
			       T.SINGLEWEIGHT,
			       T.ORDERWEIGHT,
			       T.ORDERNUM,
			       TO_CHAR(T.LATEST_PROD_DATE,'YYYY-MM-DD') LATEST_PROD_DATE,
			       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,
			       DECODE(T.JGORDERSTATUS,
			              '0',
			              '待处理',
			              '1',
			              '完成配料',
			              '2',
			              '已下发') JGORDERSTATUS,
			       T.MATCHWEIGHT,
			       T.MATCHNUM,
			       T.IFBUYPLAN,
			       T.BUYPLANID,
			       T.BUYPLANWEIGHT,
			       T.BUYPLANNUM,
			       T.GROUP_JGX,
			       T.JGWT_BLREQ
			  FROM PLN_ORDER_JG T
			 WHERE T.JGORDERSTATUS < '2'
			   AND T.IFBUYPLAN = '0'
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.queryJgDealedit" desc="查询接箍料编辑信息">
		<![CDATA[
			SELECT T.JG_ORDERNO,
			DECODE(T.JGORDERSTATUS,'0','未完成配料','1','完成配料') JGORDERSTATUS,
			       T.CODE_JG,
			       (SELECT MAX(B.DESGIN_KEY)
			          FROM PLN_SALEORDER A, SLM_ORD_DESIGN_MSC B
			         WHERE A.ORDER_NO = T.ORDER_NO
			           AND A.ORDER_SEQ = T.ORDER_SEQ
			           AND A.DELIVERY_NO = T.DELIVERY_NO
			           AND B.ORD_PK = A.ORD_PK
			           AND B.ORD_LN_PK = A.ORD_LN_PK
			           AND B.VALIDFLAG = '1') DESGIN_KEY,
			       (C.PSC_BL) CODE_JG_BL,
       			   (T.SINGLEWEIGHT) SINGLEWEIGHT_JG,
			       T.OUTDIAMETER,
			       T.AIMLENGTH,
			       T.WALLTHICK,
			       T.JGWT_BLREQ,
			       D.PRODUCCODE,
			       D.PRODUCNAME,
			       D.STD_CODE,
			       D.STD_NAME,
			       D.STEELCODE,
			       D.STEELNAME,
			       D.STD_STYLE,
			       D.STD_STYLE_DESC,
			       D.MODEL_CODE,
			       D.MODEL_DESC,
			       D.MIN_D,
			       D.MIN_H,
			       D.USE_CODE,
			       D.USE_DESC,
			       D.MIN_L,
			       D.MAX_L
			  FROM PLN_ORDER_JG T, SLM_ORD_DESIGN_MSC_JG_BL C, COM_MSC_BL D
			 WHERE C.DESGIN_KEY = (SELECT MAX(B.DESGIN_KEY)
			          FROM PLN_SALEORDER A, SLM_ORD_DESIGN_MSC B
			         WHERE A.ORDER_NO = T.ORDER_NO
			           AND A.ORDER_SEQ = T.ORDER_SEQ
			           AND A.DELIVERY_NO = T.DELIVERY_NO
			           AND B.ORD_PK = A.ORD_PK
			           AND B.ORD_LN_PK = A.ORD_LN_PK
			           AND B.VALIDFLAG = '1')
			   AND C.CODE_JG = T.CODE_JG
			   AND D.PSC_BL = C.PSC_BL
			   AND T.JGORDERSTATUS != '2'
			   AND T.IFBUYPLAN = '0'
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.queryDjBlNeed" 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,
			       T.GROUP_ROLL,
			       DECODE(T.D_IS_OK, '0', '否', '1', '是', '2', '/') D_IS_OK,
			       DECODE(T.E_IS_OK, '0', '否', '1', '是', '2', '/') E_IS_OK,
			       DECODE(T.F_IS_OK, '0', '否', '1', '是', '2', '/') F_IS_OK,
			       DECODE(T.IF_ALLOW_ISSUE, '0', '否', '1', '是') IF_ALLOW_ISSUE,
			       DECODE(T.SPEC_SAME_SALE, '1', '相同', '0', '不同') SPEC_SAME_SALE
			  FROM PLN_PORDER_BL_REQ T, PLN_SALEORDER T1
			 WHERE T.BLTYPE = '短节备料'
			   AND T.ORDER_NO = T1.ORDER_NO
			   AND T.ORDER_SEQ = T1.ORDER_SEQ
			   AND T.DELIVERY_NO = T1.DELIVERY_NO
			   AND NVL(T1.ROLL_MONTH, '1') LIKE '%' || NVL(?, '1') || '%'
			   AND NVL(T1.ACCEPT_NO, '1') LIKE '%' || NVL(?, '1') || '%'
			   AND (T.ORDER_NO || '/' || T.ORDER_SEQ) LIKE '%' || ? || '%'
			   AND T1.PORDERSTATUS LIKE '%' || ? || '%'
			   AND DECODE(?, '1', T1.JGORD_IS_OK, 1) != DECODE(?, '1', '2', 2)
			   AND DECODE(?, '1', T1.DJBL_REQ_IS_OK, 1) != DECODE(?, '1', '2', 2)
			   AND DECODE(?, '1', T1.MERGETYPE, 1) = DECODE(?, '1', '3', 1)
			   AND T1.PORDERSTATUS < '6'
			   AND DECODE(?, '', '1', T1.D_IS_OK) != DECODE(?, '', '2', '2')
			   AND DECODE(?, '', '1', T1.E_IS_OK) != DECODE(?, '', '2', '2')
			   AND DECODE(?, '', '1', T1.F_IS_OK) != DECODE(?, '', '2', '2')
			   AND DECODE(?, '', '1', T1.G_IS_OK) != DECODE(?, '', '2', '2')
			   AND DECODE(?, '', '1', T1.JGL_REQ_IS_OK) != DECODE(?, '', '2', '2')
			   AND DECODE(?, '', '1', T1.DJBL_REQ_IS_OK) != DECODE(?, '', '2', '2')
			   AND DECODE(?, '', '1', T1.ORDERFROM) = NVL(?, '1')
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.queryJgBlNeed" 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,
			       T.GROUP_ROLL,
			       DECODE(T.D_IS_OK, '0', '否', '1', '是', '2', '/') D_IS_OK,
			       DECODE(T.E_IS_OK, '0', '否', '1', '是', '2', '/') E_IS_OK,
			       DECODE(T.F_IS_OK, '0', '否', '1', '是', '2', '/') F_IS_OK,
			       DECODE(T.IF_ALLOW_ISSUE, '0', '否', '1', '是') IF_ALLOW_ISSUE
			  FROM PLN_PORDER_BL_REQ T
			 WHERE T.BLTYPE = '接箍料'
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.queryjgbase" desc="查询接箍基础信息">
		<![CDATA[
			SELECT * FROM COM_MSC_JG T WHERE T.CODE_JG = ?
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.querybllist" desc="查询备料清单表">
		<![CDATA[
			SELECT * FROM COM_MSC_BL T WHERE T.PSC_BL = ? AND T.VALIDFLAG='1'
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.queryjgbl" desc="查询接箍合同接箍料">
		<![CDATA[
			SELECT * FROM SLM_ORD_DESIGN_MSC_JG_BL T WHERE T.DESGIN_KEY=? AND T.CODE_JG=?
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.queryLine_bom" desc="查询合同行生产BOM">
		<![CDATA[
			SELECT * FROM SLM_ORD_LINE_BOM T WHERE T.DESGIN_KEY=?
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.queryMaterial" desc="查询物料基础表">
		<![CDATA[
			SELECT * FROM SLM_BASE_MATERIAL T WHERE T.MATERIAL_NO=?
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.SavePretreatJG" desc="保存销售合同预处理接箍部分信息">
		<![CDATA[
			INSERT INTO PLN_ORDER_JG T(
			T.JG_ORDERNO,T.ORDER_NO,T.ORDER_SEQ,
			T.DELIVERY_NO,T.BUYER_ID,T.BUYER_NAME,
			T.DELVRY_BDATE,T.DELVRY_EDATE,T.ORDERCONTACT,
			T.MONITORDEMAND,T.PSC,T.MSC,T.INDEX_SEQ,
			T.CODE_JG,T.STEELCODE,T.STEELNAME,
			T.OUTDIAMETER,T.WALLTHICK,T.AIMWALLTHICK,
			T.MODEL_CODE,T.AIMLENGTH,T.SINGLEWEIGHT,
			T.ORDERWEIGHT,T.ORDERNUM,
			T.LATEST_PROD_DATE,T.JGORDERSTATUS,T.CREATE_NAME,
			T.CREATE_TIME,T.MATCHWEIGHT,T.MATCHNUM,
			T.IFBUYPLAN,T.BUYPLANWEIGHT,
			T.BUYPLANNUM,T.JGWT_BLREQ
			)VALUES(
			?,?,?,?,?,?,
			TO_DATE(?,'YYYY/MM/DD HH24:MI:SS'),
			TO_DATE(?,'YYYY/MM/DD HH24:MI:SS'),
			?,?,?,?,?,?,
			?,?,?,?,?,?,
			?,?,?,?,
			TO_DATE(?,'YYYY/MM/DD HH24:MI:SS'),
			?,?,
			TO_DATE(?,'YYYY/MM/DD HH24:MI:SS'),
			?,?,?,?,?,?
			)
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.haveJgOrder" desc="撤销原来形成的接箍合同">
		<![CDATA[
			SELECT * FROM PLN_ORDER_JG T WHERE T.ORDER_NO=? AND T.ORDER_SEQ=? AND T.DELIVERY_NO=?
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.SavePretreatBL" desc="保存销售合同预处理短节备料部分信息">
		<![CDATA[
			INSERT INTO PLN_PORDER_BL_REQ T
				  (T.REQ_BL_ID,
				   T.BLTYPE,
				   T.ORDER_NO,
				   T.ORDER_SEQ,
				   T.DELIVERY_NO,
				   T.CODE_DJ_BL,
				   T.PLANSTATUS,
				   T.CREATE_NAME,
				   T.CREATE_TIME,
				   T.STEELCODE,
				   T.STEELNAME,
				   T.GRADECODE,
				   T.OUTDIAMETER,
				   T.WALLTHICK,
				   T.AIMWALLTHICK,
				   T.LENGTHMAX,
				   T.LENGTHMIN,
				   T.AIMLENGTH,
				   T.STD_CODE,
				   T.STD_NAME,
				   T.MSC,
				   T.SINGLEWEIGHT,
				   T.JGBL_REQ_WEIGHT,
				   T.JGBL_REQ_NUM,
				   T.SPEC_SAME_SALE)
				VALUES
				  ((SELECT ('ZZBY-D' || TO_CHAR(SYSDATE, 'YY') || TO_CHAR(SYSDATE, 'MM') ||
			       TO_CHAR(SYSDATE, 'DD') || '/' ||
			       LPAD(DECODE(MAX(SUBSTR(T.REQ_BL_ID, 14) + 1),'','001',MAX(SUBSTR(T.REQ_BL_ID, 14) + 1)), 3, '0'))
			  FROM PLN_PORDER_BL_REQ T WHERE T.REQ_BL_ID LIKE 'ZZBY-D'||'%'),
				   ?,
				   ?,
				   ?,
				   ?,
				   ?,
				   ?,
				   ?,
				   TO_DATE(?, 'YYYY/MM/DD HH24:MI:SS'),
				   ?,
				   ?,
				   ?,
				   ?,
				   ?,
				   ?,
				   ?,
				   ?,
				   ?,
				   ?,
				   ?,
				   ?,
				   ?,
				   ?,
				   ?,
				   ?)
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.RollbackDj" desc="撤销原来形成的短节需求">
		<![CDATA[
			DELETE FROM PLN_PORDER_BL_REQ T WHERE T.ORDER_NO=? AND T.ORDER_SEQ=? AND T.DELIVERY_NO=?
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.RollbackJg" desc="撤销原来形成的接箍合同">
		<![CDATA[
			DELETE FROM PLN_ORDER_JG T WHERE T.ORDER_NO=? AND T.ORDER_SEQ=? AND T.DELIVERY_NO=?
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.querySaleStatus" desc="查询销售合同状态">
		<![CDATA[
			SELECT *
			  FROM PLN_SALEORDER T
			 WHERE T.ORD_LN_DLY_PK = ?
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.updateDjSaleorder" desc="更新销售合同">
		<![CDATA[
			UPDATE PLN_SALEORDER T
			   SET T.DJBL_REQ_IS_OK = ?
			 WHERE T.ORD_LN_DLY_PK = ?
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.updateJgSaleorder" desc="更新销售合同">
		<![CDATA[
			UPDATE PLN_SALEORDER T
			   SET T.JGORD_IS_OK = ?,
       			   T.JGL_REQ_IS_OK = ?,
			       T.PLAN_QTY  = DECODE(T.PLANWEIGHT, 0, 0, T.PLANWEIGHT - ?)
			 WHERE T.ORD_LN_DLY_PK = ?
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.updateBlIndexChanged" desc="更新备料需求制程与工序信息">
		<![CDATA[
			UPDATE PLN_PORDER_BL_REQ T SET 
			T.INDEX_SEQ=?,
			T.BJ_TYPE=?,
			T.E_IN_MATERIAL_NO=?,
			T.E_IN_MATERIAL_DESC=?,
			T.DIMATER_YLG=?,T.HEIGHT_YLG=?  
			WHERE T.REQ_BL_ID=?
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.saveSaleOrderZg" desc="轧管确认">
		<![CDATA[
			UPDATE PLN_SALEORDER T
			   SET T.OUTS_BILLET_FL   = ?,
			       T.GROUP_ROLL       = ?,
			       T.ROLL_MONTH       = ?,
			       T.D_IS_OK          = ?,
			       T.LEN_TOEND_MAX    = ?,
			       T.LEN_TOEND_MIN    = ?,
			       T.EXTRA_LEN_TOT_WT = ?,
			       T.PLANWEIGHT       = ?,
			       T.PLAN_QTY         = DECODE(T.PLAN_QTY, 0, 0, T.PLAN_QTY + ?),
			       T.PRIORITY         = ?,
			       T.PRIORITY_MEMO    = ?
			 WHERE T.ORD_LN_DLY_PK = ?
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.saveSaleOrderGrade" desc="钢种坯料确认">
		<![CDATA[
			UPDATE PLN_SALEORDER T
			   SET T.GRADECODE = ?, T.STUFF_PROPERTY = ?, T.GRADECODE_IS_OK = ?
			 WHERE T.ORD_LN_DLY_PK = ?
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.saveSaleOrderBj" desc="镦拔扩确认">
		<![CDATA[
			UPDATE PLN_SALEORDER T
			   SET T.E_IN_MATERIAL_NO   = ?,
			       T.E_IN_MATERIAL_DESC = ?,
			       T.DIMATER_YLG        = ?,
			       T.HEIGHT_YLG         = ?,
			       T.E_IS_OK            = ?
			 WHERE T.ORD_LN_DLY_PK = ?
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.saveSaleOrderRcl" desc="热处理确认">
		<![CDATA[
			UPDATE PLN_SALEORDER T
			   SET T.GROUP_RCL = ?, T.F_IS_OK = ? 
			 WHERE T.ORD_LN_DLY_PK = ? 
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.saveSaleOrderGjg" desc="加工线确认">
		<![CDATA[
			UPDATE PLN_SALEORDER T
			   SET T.GROUP_JGX = ?, T.G_IS_OK = ? 
			 WHERE T.ORD_LN_DLY_PK = ? 
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.updatePretreat" desc="保存预处理信息">
		<![CDATA[
			UPDATE PLN_SALEORDER T
			   SET T.ACCEPT_NO          = ?,
			       T.PRD_CLS            = ?,
			       T.CODE_JG            = ?,
			       T.WEIGH_TYPE         = ?,
			       T.TRANSIT_TYP        = ?,
			       T.STATION_NO         = ?,
			       T.STATION_NM         = ?,
			       T.AIMLENGTH          = ?,
			       T.AIMWALLTHICK_ZG    = ?,
			       T.HEIGHT_NK_MIN      = ?,
			       T.HEIGHT_NK_MAX      = ?,
			       T.HEIGHT_ORD_MAX     = ?,
			       T.HEIGHT_ORD_MIN     = ?,
			       T.WEIGHT_PER_M       = ?,
			       T.PLAN_QTY           = ?,
			       T.PLANWEIGHT         = ?,
			       T.PLAN_NUM           = ?,
			       T.SHRT_STOVE         = ?,
			       T.TOTLENGTH_UNIT     = ?,
			       T.LENGTHDISC         = ?,
			       T.LEN_UNIT           = ?,
			       T.LENGTHMAX          = ?,
			       T.LENGTHMIN          = ?,
			       T.TOTLENGTH          = ?,
			       T.SHRT_LEN_RATO      = ?,
			       T.SHORTEST           = ?,
			       T.LONG_LEN_RATO      = ?,
			       T.LONGEST            = ?,
			       T.AVG_LEN_MIN        = ?,
			       T.DIFRNC_LEN_MAX     = ?,
			       T.SIGL_LEN           = ?,
			       T.ENDLEN_SPECSTD     = ?,
			       T.TOTLENGTH_M        = ?,
			       T.LENGTH_JG          = ?,
			       T.INDEX_SEQ          = ?,
			       T.BOM                = ?,
			       T.GROUP_JGX          = ?,
			       T.GROUP_RCL          = ?,
			       T.BJ_TYPE            = ?,
			       T.ENDGXNAME          = ?,
			       T.PROCESS_SEQ        = ?,
			       T.PRODUCE_SORT       = ?,
			       T.E_IN_MATERIAL_NO   = ?,
			       T.E_IN_MATERIAL_DESC = ?,
			       T.DIMATER_YLG        = ?,
			       T.HEIGHT_YLG         = ?,
			       T.GROUP_ROLL_ALL     = ?,
			       T.GROUP_ROLL         = ?,
			       T.GRADECODE_ALL      = ?,
			       T.GRADECODE          = ?,
			       T.STUFF_PROPERTY     = ?,
			       T.PIPE_PROPERTY      = ?,
			       T.PORDERSTATUS       = ?,
			       T.MERGETYPE          = ?,
			       T.MONITORDEMAND      = ?,
			       T.BL_GROUP_NUM       = ?,
			       T.SPECSTANDARD       = ?,
			       T.UPDATE_NAME        = ?,
			       T.UPDATE_TIME        = TO_DATE(?, 'YYYY/MM/DD HH24:MI:SS'),
			       T.JGORD_IS_OK        = ?,
			       T.JGL_REQ_IS_OK      = ?,
			       T.DJBL_REQ_IS_OK     = ?,
			       T.D_IS_OK            = ?,
			       T.E_IS_OK            = ?,
			       T.F_IS_OK            = ?,
			       T.G_IS_OK            = ?,
			       T.PRIORITY           = ?,
			       T.PRIORITY_MEMO      = ?,
			       T.CRAFT_FILE_NO      = ?,
			       T.CRAFT_FILE_MAN     = ?
			 WHERE T.ORD_LN_DLY_PK = ?
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.updateCancelPre" desc="取消预处理">
		<![CDATA[
			UPDATE PLN_SALEORDER T
			   SET T.PORDERSTATUS   = '0',
			       T.ACCEPT_NO      = '',
			       T.D_IS_OK        = '',
			       T.E_IS_OK        = '',
			       T.G_IS_OK        = ''
			 WHERE T.ORD_LN_DLY_PK = ?
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.queryCancelLog" desc="查询回退合同日志">
		<![CDATA[
			SELECT T.BACKLOG_ID,
			       T.ORD_PK,
			       T.ORD_LN_PK,
			       T.ORD_LN_DLY_PK,
			       T.ORDER_NO,
			       T.ORDER_SEQ,
			       T.DELIVERY_NO,
			       T.PRODUCNAME,
			       T.SPEC_NAME,
			       T.ORDER_UNIT,
			       T.ORDER_QTY,
			       T.BUYER_NAME,
			       T.FINAL_USER_DESC,
			       TO_CHAR(T.DELVRY_EDATE, 'YYYY-MM-DD') DELVRY_EDATE,
			       T.ROLL_MONTH,
			       T.BACK_REASON,
			       T.CREATE_NAME,
			       TO_CHAR(T.CREATE_TIME,'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
			       (T.ORDER_NO || '/' || T.ORDER_SEQ) ORDER_SEQNO
			  FROM PLN_SALEORD_BACKLOG T
			 WHERE ? <= TO_CHAR(T.CREATE_TIME, 'YYYY/MM/DD')
   				AND TO_CHAR(T.CREATE_TIME, 'YYYY/MM/DD') <= ?
			 	AND (T.ORDER_NO || '/' || T.ORDER_SEQ) LIKE '%' || ? || '%'
			   AND T.DELVRY_EDATE BETWEEN TO_DATE(?, 'YYYY/MM/DD') AND
			       TO_DATE(?, 'YYYY/MM/DD')
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.updateDeletelog" desc="删除回退合同日志">
		<![CDATA[
			DELETE FROM PLN_SALEORD_BACKLOG T WHERE T.BACKLOG_ID=?
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.insertCancelPreLog" desc="新建回退日志">
		<![CDATA[
			INSERT INTO PLN_SALEORD_BACKLOG T
				  (T.BACKLOG_ID,
				   T.ORD_PK,
				   T.ORD_LN_PK,
				   T.ORD_LN_DLY_PK,
				   T.ORDER_NO,
				   T.ORDER_SEQ,
				   T.DELIVERY_NO,
				   T.PRODUCNAME,
				   T.SPEC_NAME,
				   T.ORDER_UNIT,
				   T.ORDER_QTY,
				   T.BUYER_NAME,
				   T.FINAL_USER_DESC,
				   T.DELVRY_EDATE,
				   T.ROLL_MONTH,
				   T.BACK_REASON,
				   T.CREATE_NAME,
				   T.CREATE_TIME)
				VALUES
				  (?,
				   ?,
				   ?,
				   ?,
				   ?,
				   ?,
				   ?,
				   ?,
				   ?,
				   ?,
				   ?,
				   ?,
				   ?,
				   TO_DATE(?, 'YYYY/MM/DD'),
				   ?,
				   ?,
				   ?,
				   TO_DATE(?, 'YYYY/MM/DD HH24:MI:SS'))
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.updateDjBlGroup" desc="更新短节备料组">
		<![CDATA[
			UPDATE PLN_SALEORDER T SET 
			T.BL_GROUP_NUM=? 
			WHERE 
			T.ORD_PK=? AND T.ORD_LN_PK=? AND T.ORD_LN_DLY_PK=?
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.UpdateLkwgWeight" desc="更新接箍合同利库量和外购量">
		<![CDATA[
			UPDATE PLN_ORDER_JG T SET 
			T.MATCHWEIGHT=?,
			T.MATCHNUM=?,
			T.IFBUYPLAN=?,
			T.BUYPLANWEIGHT=?,
			T.BUYPLANNUM=?  
			WHERE T.JG_ORDERNO=?
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.queryrelation" desc="查询接箍及备料关系">
		<![CDATA[
			SELECT T.JG_ORDERNO,
			       T.REQ_BL_ID,
			       T.CODE_JG,
			       T.OUTDIAMETER,
			       T.AIMLENGTH,
			       T.WALLTHICK,
			       T.STEELCODE,
			       T.STEELNAME,
			       T.SINGLEWEIGHT,
			       T.CODE_JG_BL,
			       T.AIMLENGTH_BL,
			       T.SINGLEWEIGHT2,
			       T.JGBL_REQ_WEIGHT,
			       T.JGBL_REQ_NUM,
			       T.GETRATE,
			       T.WEIGHT_JG,
			       T.NUM_JG,
			       T.JGPLAN_NUM,
			       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
			  FROM PLN_JG_AND_BL T
			 WHERE T.REQ_BL_ID = ?
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.queryrelbyjg" desc="根据接箍合同查询接箍及备料关系">
		<![CDATA[
			SELECT T.JG_ORDERNO,
			       T.REQ_BL_ID,
			       T.CODE_JG,
			       T.OUTDIAMETER,
			       T.AIMLENGTH,
			       T.WALLTHICK,
			       T.STEELCODE,
			       T.STEELNAME,
			       T.SINGLEWEIGHT,
			       T.CODE_JG_BL,
			       T.AIMLENGTH_BL,
			       T.SINGLEWEIGHT2,
			       T.JGBL_REQ_WEIGHT,
			       T.JGBL_REQ_NUM,
			       T.GETRATE,
			       T.WEIGHT_JG,
			       T.NUM_JG,
			       T.JGPLAN_NUM,
			       DECODE(T.PLANSTATUS, '0', '待处理', '1', '已下发') PLANSTATUS,
			       T.CREATE_NAME,
			       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_JG_AND_BL T
			 WHERE T.JG_ORDERNO = ?
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.saverelation" desc="保存接箍与备料关系">
		<![CDATA[
			INSERT INTO PLN_JG_AND_BL T
			(T.JG_ORDERNO,T.REQ_BL_ID,T.CODE_JG,T.OUTDIAMETER,T.AIMLENGTH,
			T.WALLTHICK,T.STEELCODE,T.STEELNAME,T.SINGLEWEIGHT,
			T.CODE_JG_BL,T.AIMLENGTH_BL,T.SINGLEWEIGHT2,T.JGBL_REQ_WEIGHT,
			T.JGBL_REQ_NUM,T.GETRATE,T.WEIGHT_JG,T.NUM_JG,T.JGPLAN_NUM,
			T.PLANSTATUS,T.CREATE_NAME,T.CREATE_TIME
			)VALUES(
			?,?,?,?,?,
			?,?,?,?,?,
			?,?,?,?,?,
			?,?,?,?,?,
			TO_DATE(?,'YYYY/MM/DD HH24:MI:SS')
			)
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.savejglneed" desc="保存接箍料需求信息">
		<![CDATA[
			INSERT INTO PLN_PORDER_BL_REQ T
			(T.REQ_BL_ID,T.BLTYPE,T.STEELCODE,T.STEELNAME,T.GRADECODE,
			T.OUTDIAMETER,T.WALLTHICK,T.AIMWALLTHICK,T.LENGTHMAX,T.LENGTHMIN,
			T.AIMLENGTH,T.CODE_JG_BL,T.SINGLEWEIGHT,T.JGBL_REQ_WEIGHT,
			T.JGBL_REQ_NUM,T.PLANSTATUS,T.CREATE_NAME,T.CREATE_TIME,
			T.STD_CODE,T.STD_NAME,T.MSC
			)VALUES(
			?,?,?,?,?,
			?,?,?,?,?,
			?,?,?,?,?,?,?,
			TO_DATE(?,'YYYY/MM/DD HH24:MI:SS'),
			?,?,?
			)
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.updatejglneed" desc="更新接箍料需求信息">
		<![CDATA[
			UPDATE PLN_PORDER_BL_REQ T
		         SET T.JGBL_REQ_WEIGHT = T.JGBL_REQ_WEIGHT + ?,
		             T.JGBL_REQ_NUM    = T.JGBL_REQ_NUM + ?,
		             T.UPDATE_NAME     = ?,
		             T.UPDATE_TIME     = TO_DATE(?, 'YYYY/MM/DD HH24:MI/SS')
		       WHERE T.REQ_BL_ID = ?
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.updaterelation" desc="更新接箍与备料对应关系">
		<![CDATA[
			UPDATE PLN_JG_AND_BL T
			   SET T.JGBL_REQ_WEIGHT = ? +T.JGBL_REQ_WEIGHT,
			       T.JGBL_REQ_NUM    = ? +T.JGBL_REQ_NUM,
			       T.UPDATE_NAME     = ?,
			       T.UPDATE_TIME     = TO_DATE(?, 'YYYY/MM/DD HH24:MI/SS')
			 WHERE T.REQ_BL_ID = ?
			   AND T.JG_ORDERNO = ?
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.DeleteBlneed" desc="删除备料需求信息">
		<![CDATA[
			DELETE FROM PLN_PORDER_BL_REQ T WHERE T.REQ_BL_ID=?
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.DeleteRelation" desc="删除接箍与备料需求关系">
		<![CDATA[
			DELETE FROM PLN_JG_AND_BL T WHERE T.JG_ORDERNO=? AND T.REQ_BL_ID=?
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.DeleteJgReq" desc="删除接箍与备料需求关系">
		<![CDATA[
			DELETE FROM PLN_JG_AND_BL T WHERE T.JG_ORDERNO=?
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.issuedSaleOrder" desc="下发销售合同">
		<![CDATA[
			UPDATE PLN_SALEORDER T
			   SET T.PORDERSTATUS = '2',
			       T.ISSUED_TIME  = SYSDATE,
			       T.MEMO         = ?
			 WHERE T.ORD_LN_DLY_PK = ?
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.updatePocessOrder" desc="更新进程表">
		<![CDATA[
			UPDATE PROCESS_ORDER_M T
         SET T.PSS_NUM = T.PSS_NUM + NVL(?, 0),
             T.PSS_WGT = T.PSS_WGT + NVL(?, 0)
       WHERE T.ORD_LN_DLY_PK = ?
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.CancelSaleIssued" desc="取消下发销售合同">
		<![CDATA[
			UPDATE PLN_SALEORDER T
			   SET T.PORDERSTATUS = '1',
			       T.MEMO         = ?
			 WHERE T.ORD_LN_DLY_PK = ?
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.isFinishedJgOrder" desc="接箍合同是否需要配料">
		<![CDATA[
			UPDATE PLN_ORDER_JG T SET 
			T.JGORDERSTATUS=?
			WHERE T.JG_ORDERNO=?
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.issuedJgOrder" desc="下发接箍合同">
		<![CDATA[
			UPDATE PLN_ORDER_JG T SET 
			T.JGORDERSTATUS=?,
			T.ISSUED_TIME=TO_DATE(?,'YYYY/MM/DD') 
			WHERE T.JG_ORDERNO=?
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.cancelJgIssued" desc="取消下发接箍合同">
		<![CDATA[
			UPDATE PLN_ORDER_JG T SET 
				T.JGORDERSTATUS = '1'
			WHERE T.JG_ORDERNO = ?
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.IssuedJglNeed" desc="下发备料需求">
		<![CDATA[
			UPDATE PLN_PORDER_BL_REQ T
			   SET T.PLANSTATUS = '1', T.ISSUED_TIME = SYSDATE
			 WHERE T.REQ_BL_ID = ?
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.cancelBlIssued" desc="取消备料下发">
		<![CDATA[
			UPDATE PLN_PORDER_BL_REQ T 
			   SET T.PLANSTATUS = '0'
			 WHERE T.REQ_BL_ID=?
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.IssuedRelation" desc="下发接箍与备料关系">
		<![CDATA[
			UPDATE PLN_JG_AND_BL T SET T.PLANSTATUS='1' WHERE T.REQ_BL_ID=?
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.cancelBlrelIssued" desc="取消下发接箍与备料关系">
		<![CDATA[
			UPDATE PLN_JG_AND_BL T SET T.PLANSTATUS = '0' WHERE T.REQ_BL_ID=?
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.UpdateDjblRcl" desc="保存备料需求利库信息">
		<![CDATA[
			UPDATE PLN_PORDER_BL_REQ T
			   SET T.JGBL_REQ_WEIGHT = ?,
			       T.JGBL_REQ_NUM    = ?,
			       T.MATCHWEIGHT     = ?,
			       T.MATCHNUM        = ?,
			       T.GRADECODE       = ?
			 WHERE T.REQ_BL_ID = ?
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.UpdateBlreq" desc="更新已做备料需求的接箍量">
		<![CDATA[
			UPDATE PLN_ORDER_JG T
			   SET T.JGWT_BLREQ = ? +T.JGWT_BLREQ
			 WHERE T.JG_ORDERNO = ?
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.isFinishedJgl" desc="更新销售合同接箍料编制是否已完成">
		<![CDATA[
			UPDATE PLN_SALEORDER T
			   SET T.JGL_REQ_IS_OK = ?
			 WHERE T.ORDER_NO = ?
			   AND T.ORDER_SEQ = ?
			   AND T.DELIVERY_NO = ?
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.IfAllowIssue" desc="更新销售合同是否可以下发">
		<![CDATA[
			UPDATE PLN_SALEORDER T
			   SET T.IF_ALLOW_ISSUE = ?
			 WHERE T.ORD_LN_DLY_PK = ?
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.IfAllowBlIssue" desc="更新备料是否可以下发">
		<![CDATA[
			UPDATE PLN_PORDER_BL_REQ T SET T.IF_ALLOW_ISSUE = ? WHERE T.REQ_BL_ID = ?
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.queryOrderPrdcr" desc="查询合同信息_合同行_监制明细">
		<![CDATA[
			SELECT *
			  FROM SLM_ORDER_LINE_PRDCR_LST T
			 WHERE T.PRDCR_NO = ?
			 WHERE T.PRDCR_PRC_FL = '1'
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.confirmBlZg" desc="备料轧管确认">
		<![CDATA[
			UPDATE PLN_PORDER_BL_REQ T
			   SET T.D_IS_OK = ?, T.GROUP_ROLL = ?, T.DIMATER_YLG = ?, T.HEIGHT_YLG = ?
			 WHERE T.REQ_BL_ID = ?
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.confirmBlBj" desc="备料镦拔扩确认">
		<![CDATA[
			UPDATE PLN_PORDER_BL_REQ T
			   SET T.E_IS_OK            = ?,
			       T.E_IN_MATERIAL_NO   = ?,
			       T.E_IN_MATERIAL_DESC = ?, 
			       T.DIMATER_YLG = ?, 
			       T.HEIGHT_YLG = ?,
			       T.BJ_TYPE            = ?
			 WHERE T.REQ_BL_ID = ?
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.confirmBlRcl" desc="备料热处理确认">
		<![CDATA[
			UPDATE PLN_PORDER_BL_REQ T
			   SET T.F_IS_OK = ?, T.GROUP_RCL = ?
			 WHERE T.REQ_BL_ID = ?
		]]>
	</query>
	
	<query id="CoreSaleOrderOP.queryRollRupset" desc="查询镦拔扩与轧管规格关联">
		<![CDATA[
			SELECT T.MIN_D, T.MIN_H
			  FROM COM_MSC_ROLL_R_UPSET T
			 WHERE T.PLINE_NAME LIKE '%' || ? || '%'
			   AND T.MAX_D = ?
			   AND T.MAX_H = ?
			   AND T.VALIDFLAG = '1'
		]]>
	</query>
</queryMap>