<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="合同综合信息">
	<query id="CoreOrdCraftInfo.getSaleOrderStatus" desc="查询合同状态">
		<![CDATA[
			SELECT T.ORD_PK,
			       T.ORD_LN_PK,
			       T.ORD_LN_DLY_PK,
			       T1.INDEX_SEQ,
			       T.STEELCODE,
			       T.STEELNAME,
			       T.PRODUCCODE,
			       T.PRODUCNAME,
			       T.OUTDIAMETER,
			       T.WALLTHICK,
			       T.MODEL_CODE,
			       T.MODEL_DESC,
			       T.LENGTHDISC,
			       T1.GRADECODE_ALL,
			       T1.GRADECODE,
			       T1.BJ_TYPE,
			       T.ENDGXNAME,
			       T1.HEIGHT_NK_MIN,
			       T1.HEIGHT_NK_MAX,
			       T.MONITORDEMAND
			  FROM PLN_SALEORD T, PLN_SALEORD_PROC T1
			 WHERE T1.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
			   AND T1.PLN_DIVIDE_ID = 
			       (SELECT MIN(B.PLN_DIVIDE_ID)
			          FROM PLN_SALEORD_PROC B
			         WHERE B.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
			           AND B.ORDER_SOURCE = '销售合同')
			   AND T.ORDER_NO = ?
			   AND T.ORDER_SEQ = ?
			   AND T.PORDERSTATUS != '0'
		]]>
	</query>
	
	<query id="CoreOrdCraftInfo.getOrderCraftpath" desc="查询合同工艺路线">
		<![CDATA[
		 	SELECT T1.PROCESS_CODE_C, T1.PROCESS_DESC_C, T1.PROCESS_CODE
			  FROM CRAFT_ORD_DESIGN_MSC_PL_PRC T1, CRAFT_ORD_DESIGN T
			 WHERE T1.DESGIN_KEY = T.DESGIN_KEY
			   AND T.CRAFT_SEQ = (SELECT MAX(CRAFT_SEQ)
			                        FROM CRAFT_ORD_DESIGN B
			                       WHERE B.VALIDFLAG != '0'
			                         AND B.ORD_LN_PK = ?)
			   AND T.ORD_LN_PK = ?
			   AND T1.MSC_PLINE = ?
		]]>
	</query>
	
	<query id="CoreOrdCraftInfo.getCraftFileByOrdLnPk"
		desc="查询工艺文件">
		<![CDATA[	
			SELECT T.ORDER_SEQ
			  FROM PLN_ORD_CRAFT_FILE T
			 WHERE T.ORDER_NO = ?
			   AND T.ORDER_SEQ = ?
			   AND T.CRAFT_FILE_NO = ?
		]]>
	</query>
	
	<query id="CoreOrdCraftInfo.addCraftFile"
		desc="新增工艺文件">
		<![CDATA[	
			INSERT INTO PLN_ORD_CRAFT_FILE T
		        (T.PRODUC_JX,
		         T.ORDER_NO,
		         T.ORDER_SEQ,
		         T.CRAFT_FILE_NO,
		         T.CRAFT_FILE_MAN,
		         T.STD_LG_NO,
		         T.STD_ZG_NO,
		         T.STD_GJG_NO,
		         T.STEELCODE,
		         T.STEELNAME,
		         T.GRADECODE,
		         T.OUTDIAMETER,
		         T.WALLTHICK,
		         T.MODEL_CODE,
		         T.MODEL_DESC,
		         T.BJ_TYPE,
		         T.S_DIV_D,
		         T.HEIGHT_NK_MAX,
		         T.HEIGHT_NK_MIN,
		         T.LENGTH_EXTENT,
		         T.CRAFT_PATH,
		         T.RCL_INFO,
		         T.PAYDOWN_DPT,
		         T.MONITOR_INFO,
		         T.HOLE_MODAL_INFO,
		         T.VERSION_NO,
		         T.VERSION_DESC,
		         T.CRAFT_FILE_TYPE_CODE,
		         T.CRAFT_FILE_TYPE_NM,
		         T.CRAFT_FILE_PATH,
		         T.CRAFT_FILE_FLAG_CODE,
		         T.CRAFT_FILE_FLAG_NM,
		         T.CRAFT_FILE_UPTIME,
		         T.CREATE_NAME,
		         T.CREATE_TIME)
		      VALUES
		        ('#PRODUC_JX#',
		         '#ORDER_NO#',
		         '#ORDER_SEQ#',
		         '#CRAFT_FILE_NO#',
		         '#CRAFT_FILE_MAN#',
		         '#STD_LG_NO#',
		         '#STD_ZG_NO#',
		         '#STD_GJG_NO#',
		         '#STEELCODE#',
		         '#STEELNAME#',
		         '#GRADECODE#',
		         '#OUTDIAMETER#',
		         '#WALLTHICK#',
		         '#MODEL_CODE#',
		         '#MODEL_DESC#',
		         '#BJ_TYPE#',
		         '#S_DIV_D#',
		         '#HEIGHT_NK_MAX#',
		         '#HEIGHT_NK_MIN#',
		         '#LENGTH_EXTENT#',
		         '#CRAFT_PATH#',
		         '#RCL_INFO#',
		         '#PAYDOWN_DPT#',
		         '#MONITOR_INFO#',
		         '#HOLE_MODAL_INFO#',
		         (SELECT LPAD(TO_CHAR(COUNT(T.CRAFT_FILE_NO) + 1), 3, '0')
				  FROM PLN_ORD_CRAFT_FILE T
				 WHERE T.ORDER_NO = '#ORDER_NO#'
				   AND T.ORDER_SEQ = '#ORDER_SEQ#'),
		         '#VERSION_DESC#',
		         '#CRAFT_FILE_TYPE_CODE#',
		         '#CRAFT_FILE_TYPE_NM#',
		         '#CRAFT_FILE_PATH#',
		         '#CRAFT_FILE_FLAG_CODE#',
		         '#CRAFT_FILE_FLAG_NM#',
		         SYSDATE,
		         '#CREATE_NAME#',
		         SYSDATE)
		]]>
	</query>
	
	<query id="CoreOrdCraftInfo.updateCraftFile"
		desc="修改工艺文件">
		<![CDATA[	
			UPDATE PLN_ORD_CRAFT_FILE T
			   SET T.PRODUC_JX            = '#PRODUC_JX#',
			       T.CRAFT_FILE_MAN       = '#CRAFT_FILE_MAN#',
			       T.STD_LG_NO            = '#STD_LG_NO#',
			       T.STD_ZG_NO            = '#STD_ZG_NO#',
			       T.STD_GJG_NO           = '#STD_GJG_NO#',
			       T.STEELCODE            = '#STEELCODE#',
			       T.STEELNAME            = '#STEELNAME#',
			       T.GRADECODE            = '#GRADECODE#',
			       T.OUTDIAMETER          = '#OUTDIAMETER#',
			       T.WALLTHICK            = '#WALLTHICK#',
			       T.MODEL_CODE           = '#MODEL_CODE#',
			       T.MODEL_DESC           = '#MODEL_DESC#',
			       T.BJ_TYPE              = '#BJ_TYPE#',
			       T.S_DIV_D              = '#S_DIV_D#',
			       T.HEIGHT_NK_MAX        = '#HEIGHT_NK_MAX#',
			       T.HEIGHT_NK_MIN        = '#HEIGHT_NK_MIN#',
			       T.LENGTH_EXTENT        = '#LENGTH_EXTENT#',
			       T.CRAFT_PATH           = '#CRAFT_PATH#',
			       T.RCL_INFO             = '#RCL_INFO#',
			       T.PAYDOWN_DPT          = '#PAYDOWN_DPT#',
			       T.MONITOR_INFO         = '#MONITOR_INFO#',
			       T.HOLE_MODAL_INFO      = '#HOLE_MODAL_INFO#',
		           T.VERSION_DESC		  = '#VERSION_DESC#',
			       T.CRAFT_FILE_TYPE_CODE = '#CRAFT_FILE_TYPE_CODE#',
			       T.CRAFT_FILE_TYPE_NM   = '#CRAFT_FILE_TYPE_NM#',
			       T.CRAFT_FILE_PATH      = '#CRAFT_FILE_PATH#',
			       T.CRAFT_FILE_FLAG_CODE = '#CRAFT_FILE_FLAG_CODE#',
			       T.CRAFT_FILE_FLAG_NM   = '#CRAFT_FILE_FLAG_NM#',
			       T.CRAFT_FILE_UPTIME    = SYSDATE,
			       T.UPDATE_NAME          = '#UPDATE_NAME#',
			       T.UPDATE_TIME          = SYSDATE
			 WHERE T.ORDER_NO = '#ORDER_NO#'
			   AND T.ORDER_SEQ = '#ORDER_SEQ#'
			   AND T.CRAFT_FILE_NO = '#CRAFT_FILE_NO#'
		]]>
	</query>
	
	<query id="CoreOrdCraftInfo.updateCraftFileChange"
		desc="修改工艺文件，版本变动">
		<![CDATA[	
			UPDATE PLN_ORD_CRAFT_FILE T
			   SET T.PRODUC_JX            = '#PRODUC_JX#',
			       T.CRAFT_FILE_NO        = '#CRAFT_FILE_NO#',
			       T.CRAFT_FILE_MAN       = '#CRAFT_FILE_MAN#',
			       T.STD_LG_NO            = '#STD_LG_NO#',
			       T.STD_ZG_NO            = '#STD_ZG_NO#',
			       T.STD_GJG_NO           = '#STD_GJG_NO#',
			       T.STEELCODE            = '#STEELCODE#',
			       T.STEELNAME            = '#STEELNAME#',
			       T.GRADECODE            = '#GRADECODE#',
			       T.OUTDIAMETER          = '#OUTDIAMETER#',
			       T.WALLTHICK            = '#WALLTHICK#',
			       T.MODEL_CODE           = '#MODEL_CODE#',
			       T.MODEL_DESC           = '#MODEL_DESC#',
			       T.BJ_TYPE              = '#BJ_TYPE#',
			       T.S_DIV_D              = '#S_DIV_D#',
			       T.HEIGHT_NK_MAX        = '#HEIGHT_NK_MAX#',
			       T.HEIGHT_NK_MIN        = '#HEIGHT_NK_MIN#',
			       T.LENGTH_EXTENT        = '#LENGTH_EXTENT#',
			       T.CRAFT_PATH           = '#CRAFT_PATH#',
			       T.RCL_INFO             = '#RCL_INFO#',
			       T.PAYDOWN_DPT          = '#PAYDOWN_DPT#',
			       T.MONITOR_INFO         = '#MONITOR_INFO#',
			       T.HOLE_MODAL_INFO      = '#HOLE_MODAL_INFO#',
			       T.VERSION_NO			  = (SELECT LPAD(NVL(MAX(T1.VERSION_NO + 1), '001'),
					                                   3,
					                                   '0')
					                         FROM PLN_ORD_CRAFT_FILE T1
											 WHERE T1.ORDER_NO = '#ORDER_NO#'
											   AND T1.ORDER_SEQ = '#ORDER_SEQ#'),
		           T.VERSION_DESC		  = '#VERSION_DESC#',
			       T.CRAFT_FILE_TYPE_CODE = '#CRAFT_FILE_TYPE_CODE#',
			       T.CRAFT_FILE_TYPE_NM   = '#CRAFT_FILE_TYPE_NM#',
			       T.CRAFT_FILE_PATH      = '#CRAFT_FILE_PATH#',
			       T.CRAFT_FILE_FLAG_CODE = '#CRAFT_FILE_FLAG_CODE#',
			       T.CRAFT_FILE_FLAG_NM   = '#CRAFT_FILE_FLAG_NM#',
			       T.CRAFT_FILE_UPTIME    = SYSDATE,
			       T.UPDATE_NAME          = '#UPDATE_NAME#',
			       T.UPDATE_TIME          = SYSDATE
			 WHERE T.ORDER_NO = '#ORDER_NO#'
			   AND T.ORDER_SEQ = '#ORDER_SEQ#'
		]]>
	</query>
	
	<query id="CoreOrdCraftInfo.matchCraftfileToPln"
		desc="匹配工艺文件到销售合同提报表">
		<![CDATA[
			UPDATE PLN_SALEORD T
			   SET T.CRAFT_FILE_NO_IN = ?, T.CRAFT_FILE_MAN_IN = ?
			 WHERE T.ORDER_NO = ?
			   AND T.ORDER_SEQ = ?
		]]>
	</query>
	
	
	<query id="CoreOrdCraftInfo.queryExportOutImport" desc="查询外部导入系统的合同">
		<![CDATA[
			SELECT DECODE(T2.ORDER_SOURCE,
			              '补量需求',
			              R.ACCEPT_NO,
			              T.ACCEPT_NO) ACCEPT_NO,
			       M.DESGIN_KEY,
			       (SELECT A.PLINE_NAME
			          FROM COM_BASE_PLINE A
			         WHERE A.PLINE_CODE = T2.GROUP_ROLL
			           AND A.VALIDFLAG = '1') GROUP_ROLL,
			       (SELECT A.PRODUC_JX
			          FROM COM_BASE_PRODUCT A
			         WHERE A.PRODUCCODE = T.PRODUCCODE) PRODUC_JX,
			       (DECODE(T.STD_STYLE_DESC || ' ', ' ', '', T.STD_STYLE_DESC || ' ') ||
			       T.STEELNAME) STEELNAME,
			       T.OUTDIAMETER,
			       T.WALLTHICK,
			       T.LENGTHDISC,
			       T.MODEL_DESC,
			       T2.PLAN_P_MAIN ORDERWEIGHT,
			       DECODE(T.TOTLENGTH, 0, '', NULL, '', T2.PLAN_TOT_LEN_D) 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,
			       L.ORDER_ADD_DESC,
			       (SELECT A.BASENAME
			          FROM COM_BASE_INFO A
			         WHERE A.BASECODE = 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 || ' ') ||
			       T.STATION_NM) STATION_NM,
			       (SELECT A.BASENAME FROM COM_BASE_INFO A WHERE A.BASECODE = T.PRD_CLS) PRD_CLS,
			       TO_CHAR(TO_DATE(T2.ROLL_MONTH, 'YYYY-MM'), 'YYYYMM') ROLL_MONTH,
			       (SELECT A.BASENAME
			          FROM COM_BASE_INFO A
			         WHERE A.BASECODE = NVL(TRIM(T.OUTS_BILLET_FL), '121802')) OUTS_BILLET_FL,
			       T.SPEC_NAME,
			       (SELECT A.BASENAME
			          FROM COM_BASE_INFO A
			         WHERE A.BASECODE = T.MONITORDEMAND) MONITORDEMAND,
			       T2.PRDCRPRO,
			       T.PRDCR_NO,
			       (TO_CHAR(T.LENGTHMIN, 'FM99990.00') || '-' ||
			       TO_CHAR(T.LENGTHMAX, 'FM99990.00') || 'M') TECHNICALLEN,
			       T.ORDER_SPECIAL_DESC,
			       T2.ORDER_QTY_D ORDER_QTY,
			       T2.ORDER_UNIT,
			       T2.PLAN_WT_D,
			       T2.BJ_TYPE,
			       DECODE(T2.ORDER_SOURCE, '补量需求', NULL, T.PAYDOWNWEIGHT) PAYDOWNWEIGHT,
			       DECODE(T2.ORDER_SOURCE, '补量需求', NULL, T.PAYDOWN_NUM) PAYDOWN_NUM,
			       DECODE(T.ORDER_UNIT,
			              '米',
			              '吨',
			              '英尺',
			              '吨',
			              '英磅',
			              '吨',
			              T.ORDER_UNIT) DW,
			       DECODE(T.ORDER_UNIT,
			              '米',
			              '吨',
			              '英尺',
			              '吨',
			              '英磅',
			              '吨',
			              T.ORDER_UNIT) DW2,
			       T.SHRT_STOVE,
			       T.SIGL_LEN,
			       DECODE(T.ORDER_SPECIAL_DESC, NULL, '普通', '特殊') ORDER_TYPE,
			       T.ENDLEN_SPECSTD,
			       T2.STUFF_PROPERTY,
			       T2.GRADECODE_ALL,
			       (SELECT MAX(D.CRAFT_NO)
			          FROM CRAFT_ORD_DESIGN D
			         WHERE D.ORD_LN_PK = T.ORD_LN_PK
			           AND D.VALIDFLAG = '1') CRAFT_FILE_NO_NEW,
			       T2.CRAFT_FILE_NO,
			       (SELECT M1.CRAFT_NAME
			          FROM CRAFT_ORD_DESIGN_APPOINT M1
			         WHERE M1.ORD_LN_PK = M.ORD_LN_PK) CRAFT_FILE_MAN,
			       T2.HEIGHT_NK_MIN / 100 HEIGHT_NK_MIN,
			       T2.HEIGHT_NK_MAX / 100 HEIGHT_NK_MAX,
			       (SELECT MAX(T1.PROCESS_DESC_C)
			          FROM CRAFT_ORD_DESIGN_MSC_PL_PRC T1
			         WHERE T1.PROCESS_CODE = 'D'
			           AND T1.DESGIN_KEY = M.DESGIN_KEY
			           AND T1.MSC_PLINE = T2.INDEX_SEQ) CRAFT_PATH,
			       (SELECT MAX(T1.PROCESS_DESC_C)
			          FROM CRAFT_ORD_DESIGN_MSC_PL_PRC T1
			         WHERE T1.PROCESS_CODE = 'F'
			           AND T1.DESGIN_KEY = M.DESGIN_KEY
			           AND T1.MSC_PLINE = T2.INDEX_SEQ) RCL_INFO,
			       T2.CRAFT_NO_V VERSION_NO,
			       T2.ORDER_SOURCE ORDERCONTRACT,
			       DECODE(T2.PLANSTATUS,
			              '1',
			              '已接收',
			              '2',
			              '已下发',
			              '3',
			              '生产中',
			              '4',
			              '生产完成',
			              '5',
			              '缴库完成') PORDERSTATUS,
			       T.DELIVERY_NO,
			       (SELECT A.BASENAME
			          FROM COM_BASE_INFO A
			         WHERE A.BASECODE = T2.GROUP_RCL) GROUP_RCL,
			       (SELECT A.BASENAME
			          FROM COM_BASE_INFO A
			         WHERE A.BASECODE = T2.GROUP_JGX) GROUP_JGX,
			       (SELECT A.BASENAME FROM COM_BASE_INFO A WHERE A.BASECODE = T2.PRIORITY) PRIORITY,
			       T2.PRIORITY_MEMO,
			       DECODE(T.JGORD_IS_OK, '0', '否', '1', '是', '2', '/') JGORD_IS_OK,
			       DECODE(T.DJBL_REQ_IS_OK, '0', '否', '1', '是', '2', '/') DJBL_REQ_IS_OK,
			       (T2.ORD_LN_DLY_PK || '-' || T2.PLN_DIVIDE_ID) ORD_LN_DLY_PK,
			       T2.ABC,
			       T2.IF_EXPORT,
			       L.AW,
			       T2.LEN_ROLL_MAX LEN_TOEND_MAX,
			       T2.LEN_ROLL_MIN LEN_TOEND_MIN,
			       T2.DIMATER_YLG,
			       T2.HEIGHT_YLG,
			       Z1.Z_ORDERWEIGHT,
			       Z1.Z_ORDERNUM,
			       (T.STD_NAME ||'，'|| T.USE_DESC) USE_STAND,
			       (SELECT P.WHOLE_BACKLOG_DESC
			          FROM CRAFT_ORD_DESIGN_MSC_PL P
			         WHERE P.DESGIN_KEY = M.DESGIN_KEY
			           AND P.MSC_PLINE = T2.INDEX_SEQ) WHOLE_BACKLOG_DESC,
			             (CASE
         WHEN T2.PROCESS_SEQ LIKE '%G%' THEN
          'G'
         WHEN T2.PROCESS_SEQ LIKE '%F%' THEN
          'F'
         WHEN T2.PROCESS_SEQ LIKE '%E%' THEN
          'E'
         WHEN T2.PROCESS_SEQ LIKE '%D%' THEN
          'D'
         ELSE
          ''
       END) ISENDGX,
       DECODE((CASE
                WHEN T2.PROCESS_SEQ LIKE '%G%' THEN
                 (SELECT MIN(S.EXE_STATUS)
                    FROM PLN_ORDER_JGX_S S
                   WHERE S.ORD_LN_DLY_PK = T2.ORD_LN_DLY_PK
                     AND S.PLN_DIVIDE_ID = T2.PLN_DIVIDE_ID)
                WHEN T2.PROCESS_SEQ LIKE '%F%' THEN
                 (SELECT MIN(S.EXE_STATUS)
                    FROM PLN_ORDER_RCL_S S
                   WHERE S.ORD_LN_DLY_PK = T2.ORD_LN_DLY_PK
                     AND S.PLN_DIVIDE_ID = T2.PLN_DIVIDE_ID)
                WHEN T2.PROCESS_SEQ LIKE '%E%' THEN
                 (SELECT MIN(S.EXE_STATUS)
                    FROM PLN_ORDER_DBK_S S
                   WHERE S.ORD_LN_DLY_PK = T2.ORD_LN_DLY_PK
                     AND S.PLN_DIVIDE_ID = T2.PLN_DIVIDE_ID)
                WHEN T2.PROCESS_SEQ LIKE '%D%' THEN
                 (SELECT MIN(S.EXE_STATUS)
                    FROM PLN_ORDER_ZG_S S
                   WHERE S.ORD_LN_DLY_PK = T2.ORD_LN_DLY_PK
                     AND S.PLN_DIVIDE_ID = T2.PLN_DIVIDE_ID)
                ELSE
                 ''
              END),
              '0',
              '计划',
              '1',
              '生产中',
              '2',
              '已生产',
              '3',
              '关闭A') AFTER_STATE
			  FROM PLN_SALEORD T
			  LEFT JOIN SLM_ORDER_LINE L
			    ON L.ORD_LN_PK = T.ORD_LN_PK
			   AND L.VALIDFLAG = '1', PLN_SALEORD_PROC T2
			  LEFT JOIN (SELECT Z.ORD_LN_DLY_PK,
			                    Z.PLN_DIVIDE_ID,
			                    SUM(Z.ORDERWEIGHT) Z_ORDERWEIGHT,
			                    SUM(Z.ORDERNUM) Z_ORDERNUM
			               FROM PLN_ORDER_ZG Z
			              GROUP BY Z.ORD_LN_DLY_PK, Z.PLN_DIVIDE_ID) Z1
			    ON Z1.ORD_LN_DLY_PK = T2.ORD_LN_DLY_PK
			   AND Z1.PLN_DIVIDE_ID = T2.PLN_DIVIDE_ID
			  LEFT JOIN PLN_SALEORD E2 
			  	ON E2.ORD_LN_DLY_PK = T2.ORD_LN_DLY_PK
			  LEFT JOIN CRAFT_ORD_DESIGN M
			    ON M.CRAFT_SEQ = T2.CRAFT_SEQ
			   AND M.ORD_LN_PK = E2.ORD_LN_PK
			  LEFT JOIN PLN_SALEORDER_R_NUM R
			    ON R.R_NUM_ID = T2.R_NUM_ID
			  LEFT JOIN SLM_ORDER_LINE_DELIVERY D
			  	ON D.ORD_LN_DLY_PK = T2.ORD_LN_DLY_PK
			 WHERE T2.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
			   AND (DECODE(T2.ORDER_SOURCE,
			               '补量需求',
			               R.ACCEPT_NO,
			               T.ACCEPT_NO) LIKE '%' || NLS_UPPER(?) || '%' OR
			       DECODE(T2.ORDER_SOURCE,
			               '补量需求',
			               R.ACCEPT_NO,
			               T.ACCEPT_NO) IS NULL)
			   AND (T2.ORDER_NO || '/' || T2.ORDER_SEQ) LIKE '%' || NLS_UPPER(?) || '%'
			   AND NVL(T2.ROLL_MONTH, '1') LIKE '%' || NVL(?, NVL(T2.ROLL_MONTH, '1')) || '%'
			   AND T2.PLANSTATUS LIKE '%' || ? || '%'
		]]>
	</query>

</queryMap>