<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="销售合同接收下发">
	<query id="CoreSaleOrderReceive.querySaleOrder" desc="查询销售合同">
		<![CDATA[
			SELECT M.DESGIN_KEY,
			(SELECT COUNT(*)
          FROM CRAFT_ORD_DESIGN_MSC_PL T
         WHERE T.DESGIN_KEY = M.DESGIN_KEY
           AND T.VALIDFLAG = '1') WHOLE_BACKLOG_COUNT,
			       T.ORD_PK,
			       T.ORD_LN_PK,
			       T.ORDER_NO,
			       T.ORDER_SEQ,
			       T.DELIVERY_NO,
			       (T.ORDER_NO || '/' || T.ORDER_SEQ) ORDER_NO_SEQ,
			       (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.LEN_UNIT,
			       T.LENGTHMAX,
			       T.LENGTHMIN,
			       T.LENGTHDISC,
			       T.MODEL_CODE,
			       T.MODEL_DESC,
			       T.ORDERWEIGHT,
			       DECODE(T.ORDER_UNIT, '支', '支', '吨') ORDERWEIGHTUNIT,
			       DECODE(T.TOTLENGTH, 0, '', T.TOTLENGTH) TOTLENGTH,
			       T.TOTLENGTH_UNIT,
			       T.DELVRY_RANGE_TPE,
			       T.DELVRY_RANGE_MIN,
			       T.DELVRY_RANGE_MAX,
			       '(-' || 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.BUYER_ID,
			       (SELECT A.ABRVITION
			          FROM SLM_BASE_CUSTOMER A
			         WHERE A.CUSTOMER_NO = T.BUYER_ID) BUYER_NAME,
			       T.ORDER_SPECIAL_DESC,
			       T.ADD_ASK_NO,
			       L.ORDER_ADD_DESC,
			       (SELECT A.BASENAME
			          FROM COM_BASE_INFO A
			         WHERE A.BASECODE = T.ORDERFROM) ORDERFROM,
			       T.FINAL_USER,
			       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_DESC,
			       TO_CHAR(T.DELVRY_EDATE, 'YYYY-MM-DD') DELVRY_EDATE,
			       T.ORDERCONTACT,
			       (SELECT A.BASENAME
			          FROM COM_BASE_INFO A
			         WHERE A.BASECODE = T.MONITORDEMAND) MONITORDEMAND,
			       E.PRDCRPRO,
			       T.SPECSTANDARD,
			       T.PSC,
			       T.MSC,
			       T.CODE_JG,
			       T.CODE_DJ_BL,
			       T.PLANWEIGHT,
			       T.PAYDOWNWEIGHT,
			       DECODE(E.ORDER_SOURCE, '补量需求', R.REQ_NAME, T.CREATE_NAME) CREATE_NAME,
			       TO_CHAR(DECODE(E.ORDER_SOURCE, '补量需求', R.REQ_TIME, T.CREATE_TIME),
			       			'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
			       DECODE(E.ORDER_SOURCE, '补量需求', R.PLAN_DEAL_NAME, T.UPDATE_NAME) UPDATE_NAME,
			       TO_CHAR(DECODE(E.ORDER_SOURCE,
			                      '补量需求',
			                      R.PLAN_DEAL_TIME,
			                      T.UPDATE_TIME),
			               'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
			       T.ENDGXNAME,
			       T.MERGETYPE,
			       DECODE(T.JZ_FILE_IF_ALL, '1', '是', '0', '否') JZ_FILE_IF_ALL,
			       T.PRDCR_NO,
			       E.ROLL_MONTH,
			       T.MATERIAL_NO,
			       T.MATERIAL_DESC,
			       T.BL_GROUP_NUM,
			       T.SHRT_LEN_RATO,
			       T.SHORTEST,
			       T.LONG_LEN_RATO,
			       T.LONGEST,
			       T.SHRT_STOVE,
			       T.AVG_LEN_MIN,
			       T.DIFRNC_LEN_MAX,
			       T.SIGL_LEN,
			       T.ENDLEN_SPECSTD,
			       T.STATION_NO,
			       T.STATION_NM,
			       T.PRODUCE_SORT,
			       T.USE_CODE,
			       T.USE_DESC,
			       DECODE(T.TOTLENGTH_M, 0, '', T.TOTLENGTH_M) TOTLENGTH_M,
			       T.ORDERNUM,
			       T.OUTS_BILLET_FL,
			       T.PIPE_PROPERTY,
			       T.LEN_TOEND_MIN,
			       T.LEN_TOEND_MAX,
			       T.LENGTH_JG,
			       T.WEIGH_TYPE,
			       T.TRANSIT_TYP,
			       DECODE(E.ORDER_SOURCE,
			              '补量需求',
			              R.ACCEPT_NO,
			              T.ACCEPT_NO) ACCEPT_NO,
			       (SELECT A.BASENAME
			          FROM COM_BASE_INFO A
			         WHERE A.BASECODE = T.OUTS_STL_PIPE_FL) OUTS_STL_PIPE_FL,
			       H.SALE_AREA_DESC,
			       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,
			       DECODE(T.IF_SALE_FREEZE, '1', '是', '0', '否') IF_SALE_FREEZE,
			       T.ASK_TYPE_STATUS,
			       T.STD_STYLE_DESC,
			       NVL(T.ROLL_WELL_MONTH, T.ROLL_MONTH) ROLL_WELL_MONTH,
			       T.PAYDOWN_NUM,
			       T.HEIGHT_ORD_MIN,
			       T.HEIGHT_ORD_MAX,
			       L.AW,
			       E.PRIORITY_MEMO,
			       (SELECT A.BASENAME FROM COM_BASE_INFO A WHERE A.BASECODE = E.PRIORITY) PRIORITY,
			       E.ORDER_SOURCE,
			       E.ORD_LN_DLY_PK,
			       E.PLN_DIVIDE_ID,
			       E.R_NUM_ID,
			       E.CRAFT_SEQ,
			       E.CRAFT_FILE_NO,
			       E.CRAFT_NO_V,
			       (SELECT T1.CRAFT_NAME
			          FROM CRAFT_ORD_DESIGN_APPOINT T1
			         WHERE T1.ORD_LN_PK = T.ORD_LN_PK) CRAFT_FILE_MAN,
			       (SELECT MAX(T1.CRAFT_NO)
			          FROM CRAFT_ORD_DESIGN T1
			         WHERE T1.ORD_LN_PK = T.ORD_LN_PK
			           AND T1.VALIDFLAG = '1') CRAFT_NO_NEW,
			       (SELECT MAX(T1.CRAFT_NO_V)
			          FROM CRAFT_ORD_DESIGN T1
			         WHERE T1.ORD_LN_PK = T.ORD_LN_PK
			           AND T1.VALIDFLAG = '1') CRAFT_NO_V_NEW,
			       DECODE(E.CRAFT_SEQ,
			       		  NVL((SELECT MAX(T1.CRAFT_SEQ)
			       		  		 FROM CRAFT_ORD_DESIGN T1
			       		  		WHERE T1.ORD_LN_PK = T.ORD_LN_PK
			       		  		  AND T1.VALIDFLAG = '1'),
			       		  	  E.CRAFT_SEQ),
			       		  '无更新',
			       		  DECODE(E.PLANSTATUS, '4', '无更新', '5', '无更新', '待替换')) CRAFT_RENEW_ST,
			       E.INDEX_SEQ,
			       E.PROCESS_SEQ,
			       (SELECT P.WHOLE_BACKLOG_DESC
			          FROM CRAFT_ORD_DESIGN_MSC_PL P
			         WHERE P.DESGIN_KEY = M.DESGIN_KEY
			           AND P.MSC_PLINE = E.INDEX_SEQ) WHOLE_BACKLOG_DESC,
			       E.BOM,
			       E.GROUP_JGX,
			       E.GROUP_RCL,
			       (SELECT MAX(M1.PROCESS_DESC_C)
			          FROM CRAFT_ORD_DESIGN_MSC_PL_PRC M1
			         WHERE M1.PROCESS_CODE = 'F'
			           AND M1.DESGIN_KEY = M.DESGIN_KEY
			           AND M1.MSC_PLINE = E.INDEX_SEQ) RCL_INFO,
			       DECODE(E.PLANSTATUS,
			              '1',
			              '已接收',
			              '2',
			              '已下发',
			              '3',
			              '生产中',
			              '4',
			              '生产完成',
			              '5',
			              '缴库完毕') PLANSTATUS,
			       E.GRADECODE_ALL,
			       (SELECT A.GRADENAME
			          FROM COM_BASE_GRADE A
			         WHERE A.GRADECODE = E.GRADECODE) GRADECODE,
			       E.GROUP_ROLL_ALL,
			       (SELECT A.PLINE_NAME
			          FROM COM_BASE_PLINE A
			         WHERE A.PLINE_CODE = E.GROUP_ROLL) GROUP_ROLL,
			       E.BJ_TYPE,
			       E.E_IN_MATERIAL_NO,
			       E.E_IN_MATERIAL_DESC,
			       E.DIMATER_YLG,
			       E.HEIGHT_YLG,
			       E.STUFF_PROPERTY,
			       E.WEIGHT_PER_M,
			       E.PLAN_TOT_LEN_D,
			       E.ORDER_QTY_D,
			       E.ORDER_UNIT,
			       E.PLAN_WT_D,
			       E.PLAN_NUM_D,
			       E.FINISH_WT,
			       E.PLAN_WT_BEGIN,
			       E.PLAN_NUM_BEGIN,
			       E.HEIGHT_NK_MIN,
			       E.HEIGHT_NK_MAX,
			       E.AIM_LEN_END,
			       E.AIM_LEN_ROLL,
			       E.TOT_LEN_ONE_P,
			       E.CUT_NUM_P,
			       E.AIM_WALLTHICK,
			       E.ROLL_LENGTH,
			       E.PLAN_P_MAIN,
			       E.ISSUED_MAN,
			       E.IF_EXPORT,
			       E.LEN_ROLL_MAX,
			       E.LEN_ROLL_MIN,
			       Z1.Z_ORDERWEIGHT,
			       Z1.Z_ORDERNUM,
			       TO_CHAR(E.ISSUED_TIME, 'YYYY-MM-DD HH24:MI:SS') ISSUED_TIME,
			       DECODE(E.F_IS_OK, '0', '否', '1', '是', '2', '/') F_IS_OK,
			       DECODE(E.IF_ALLOW_ISSUE, '0', '否', '1', '是') IF_ALLOW_ISSUE,
			       DECODE(E.G_IS_OK, '0', '否', '1', '是', '2', '/') G_IS_OK,
			       DECODE(E.GRADECODE_IS_OK, '0', '否', '1', '是') GRADECODE_IS_OK,
			       DECODE(E.D_IS_OK, '0', '否', '1', '是', '2', '/') D_IS_OK,
			       DECODE(E.PLAN_IS_OK, '0', '否', '1', '是') PLAN_IS_OK,
			       DECODE(E.E_IS_OK, '0', '否', '1', '是', '2', '/') E_IS_OK,
			        E.AIM_OUTDIAMETER,
            E.FEED_RATE,E.COEFFICIENT,E.COEFFICIENT_MIN,E.PLAN_P_MAIN_MIN,E.AIM_WT_END,E.WEIGHT_KZ_M,
             NVL((SELECT T1.CHECK_J_VAL
             FROM COM_MSC_JG T1
            WHERE T1.CODE_JG = T.CODE_JG
              AND T1.VALIDFLAG = '1'),
           0)/1000 CHECK_J_VAL,
       NVL((SELECT T1.WEIGHT_JG
             FROM COM_MSC_JG T1
            WHERE T1.CODE_JG = T.CODE_JG
              AND T1.VALIDFLAG = '1'),
           0)/1000 WEIGHT_JG
			  FROM PLN_SALEORD T
			  LEFT JOIN SLM_ORDER_LINE L
			    ON L.ORD_LN_PK = T.ORD_LN_PK
			   AND L.VALIDFLAG = '1'
			  LEFT JOIN SLM_ORDER_HEAD H
			    ON H.ORD_PK = T.ORD_PK
			   AND H.VALIDFLAG = '1', PLN_SALEORD_PROC E
			  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 = E.ORD_LN_DLY_PK
			   AND Z1.PLN_DIVIDE_ID = E.PLN_DIVIDE_ID
			  LEFT JOIN PLN_SALEORD E2
			  	ON E.ORD_LN_DLY_PK = E2.ORD_LN_DLY_PK
			  LEFT JOIN CRAFT_ORD_DESIGN M
			    ON M.ORD_LN_PK = E2.ORD_LN_PK
			   AND M.CRAFT_SEQ = E.CRAFT_SEQ
			  LEFT JOIN PLN_SALEORDER_R_NUM R
			    ON R.R_NUM_ID = E.R_NUM_ID
			 WHERE T.ORD_LN_DLY_PK = E.ORD_LN_DLY_PK
			   AND NVL(E.ROLL_MONTH, '1') LIKE '%' || NVL(?, NVL(E.ROLL_MONTH, '1')) || '%'
			   AND (DECODE(E.ORDER_SOURCE,
			               '补量需求',
			               R.ACCEPT_NO,
			               NVL(T.ACCEPT_NO, '1')) LIKE
			       '%' || NVL(NLS_UPPER(?),
			                   DECODE(E.ORDER_SOURCE,
			                          '补量需求',
			                          R.ACCEPT_NO,
			                          NVL(T.ACCEPT_NO, '1'))) || '%')
			   AND (T.ORDER_NO || '/' || T.ORDER_SEQ) LIKE '%' || NLS_UPPER(?) || '%'
			   AND E.PLANSTATUS 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 E.ORDER_SOURCE LIKE '%' || ? || '%'
		]]>
	</query>

	<query id="CoreSaleOrderReceive.queryCraftMscPline" desc="销售合同查询适用工艺制程">
		<![CDATA[
			SELECT T.CRAFT_SEQ,
			       T.CRAFT_NO,
			       T.CRAFT_NO_V,
			       T.DESGIN_KEY,
			       DECODE(T.VALIDFLAG,
			              '1',
			              '生效',
			              '0',
			              '无效',
			              '2',
			              '制定中',
			              '3',
			              '待审核',
			              '4',
			              '审核',
			              '5',
			              '失败') VALIDFLAG,
			       DECODE(T.LOCK_FLAG, '1', '锁定', '0', '解锁') LOCK_FLAG,
			       DECODE(K.DESIGN_STS, 'W', '等待', 'S', '通过', 'F', '失败') DESIGN_STS,
			       A.CRAFT_NAME,
			       TO_CHAR(A.APPOINT_TIME, 'YYYY-MM-DD HH24:MI:SS') CRAFT_TIME,
			       T1.MSC_PLINE,
			       T1.WHOLE_BACKLOG,
			       T1.WHOLE_BACKLOG_DESC,
			       DECODE(T1.SET_FL, '0', '否', '1', '是') SET_FL,
			       T1.WARN_DESC
			  FROM CRAFT_ORD_DESIGN T
			  LEFT JOIN CRAFT_ORD_DESIGN_APPOINT A
			  ON A.ORD_LN_PK = T.ORD_LN_PK
			  LEFT JOIN CRAFT_ORD_DESIGN_STS_TKLG K
			    ON K.DESGIN_KEY = T.DESGIN_KEY
			   AND K.VALIDFLAG = '1'
			  LEFT JOIN CRAFT_ORD_DESIGN_MSC_PL T1
			    ON T1.DESGIN_KEY = T.DESGIN_KEY
			 WHERE T.VALIDFLAG = '1'
			   AND T.ORD_LN_PK = ?
		]]>
	</query>

<query id = "CoreSaleOrderReceive.queryPlnSorder" desc = "查询备料合同PK">
SELECT T.ORD_LN_PK FROM PLN_SALEORD T WHERE T.ORD_LN_DLY_PK = ?
</query>
	<query id="CoreSaleOrderReceive.queryCraftFilePath" desc="查询工艺文件上传路径">
		<![CDATA[
			SELECT M.CRAFT_PATH
			  FROM PLN_SALEORD_PROC T
			  LEFT JOIN PLN_SALEORD T1
			    ON T1.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
			  LEFT JOIN CRAFT_ORD_DESIGN M
			    ON M.ORD_LN_PK = T1.ORD_LN_PK
			   AND M.CRAFT_SEQ = T.CRAFT_SEQ
			 WHERE T.ORD_LN_DLY_PK = ?
			   AND T.PLN_DIVIDE_ID = ?
		]]>
	</query>

	<query id="CoreSaleOrderReceive.queryCraftLockFlag" desc="查询合同行工艺有无锁定">
		<![CDATA[
			SELECT COUNT(1)
			  FROM CRAFT_ORD_DESIGN T
			 WHERE T.ORD_LN_PK = ?
			   AND T.VALIDFLAG != '0'
			   AND T.LOCK_FLAG = '1'
		]]>
	</query>

	<query id="CoreSaleOrderReceive.queryLineLocked" desc="查询合同行有无锁定状态">
		<![CDATA[
			SELECT COUNT(1)
			  FROM PLN_SALEORD T
			 WHERE T.IF_SALE_FREEZE = '1'
			   AND T.ORD_LN_PK = ?
		]]>
	</query>

	<query id="CoreSaleOrderReceive.queryMscPlGz" desc="销售合同查询制程适用钢种">
		<![CDATA[
			SELECT DESGIN_KEY,
			       MSC_PLINE,
			       WHOLE_BACKLOG,
			       WHOLE_BACKLOG_DESC,
			       GRADECODE,
			       GRADENAME,
			       ASSORTMENT_CODE,
			       ASSORTMENT_NAME
			  FROM CRAFT_ORD_DESIGN_MSC_PL_GZ T
			 WHERE T.DESGIN_KEY = ?
			   AND T.MSC_PLINE = ?
		]]>
	</query>

	<query id="CoreSaleOrderReceive.queryPlStation" desc="销售合同查询制程工序点路径">
		<![CDATA[
			SELECT LISTAGG(T.STATION_DESC, '->') WITHIN GROUP(ORDER BY T.PROCESS_CODE, T.BACKLOG_SEQ) STATION_DESC
			  FROM CRAFT_ORD_DESIGN_MSC_PL_STI T
			 WHERE T.DESGIN_KEY = ?
			   AND T.MSC_PLINE = ?
		]]>
	</query>

	<query id="CoreSaleOrderReceive.querySaleProcStatus" desc="查询状态">
		<![CDATA[
			SELECT T.INDEX_SEQ,
			       T.PROCESS_SEQ,
			       T.CRAFT_NO_V,
			       T.CRAFT_FILE_NO,
			       T.CRAFT_SEQ,
			       (SELECT B.VALIDFLAG
			          FROM CRAFT_ORD_DESIGN B
			         WHERE B.ORD_LN_PK = T1.ORD_LN_PK
			           AND B.CRAFT_SEQ = T.CRAFT_SEQ) VALIDFLAG,
			       (SELECT B.DESGIN_KEY
			          FROM CRAFT_ORD_DESIGN B
			         WHERE B.ORD_LN_PK = T1.ORD_LN_PK
			           AND B.CRAFT_SEQ = T.CRAFT_SEQ) DESGIN_KEY,
			       T.BOM,
			       T.E_IN_MATERIAL_NO,
			       T.GROUP_ROLL,
			       T.BJ_TYPE,
			       T.E_IS_OK,
			       T.D_IS_OK,
			       T.PLAN_IS_OK,
			       T.GRADECODE_IS_OK,
			       T1.IF_SALE_FREEZE,
			       T.PLAN_WT_D,
			       T.PLAN_NUM_D,
			       T.ORDER_UNIT,
			       T.PLANSTATUS,
			       T.IF_ALLOW_ISSUE,
			       T1.CODE_JG,
			       T.ROLL_MONTH,
			       T1.MERGETYPE,
			       T1.JGORD_IS_OK,
			       T1.MSC,
			       (SELECT M.MSC_STYLE FROM COM_MSC M WHERE M.MSC = T1.MSC) MSC_STYLE,
			       T1.PSC,
			       T1.OUTDIAMETER,
			       T1.WALLTHICK,
			       T1.SPEC_CODE,
			       T1.SPEC_NAME,
			       T1.MODEL_CODE,
			       T1.MODEL_DESC,
			       T1.PRODUCCODE,
			       T1.PRODUCNAME,
			       T1.OUTS_BILLET_FL,
			       T1.OUTS_STL_PIPE_FL,
			       NVL(T1.FINAL_USER, T1.BUYER_ID) FINAL_USER,
			       T1.MATERIAL_NO,
			       T1.MATERIAL_DESC
			  FROM PLN_SALEORD_PROC T, PLN_SALEORD T1
			 WHERE T1.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
			   AND T.ORD_LN_DLY_PK = ?
			   AND T.PLN_DIVIDE_ID = ?
		]]>
	</query>

	<query id="CoreSaleOrderReceive.getCustomRpline" desc="查询最终用户认定产线">
		<![CDATA[
			SELECT R.PLINE_CODE, R.PLINE_NAME
			  FROM COM_BASE_CUSTOM_R_PLINE R
			 WHERE R.VALIDFLAG = '1'
			   AND R.CUSTOMER_NO = ?
			   AND R.PRODUCCODE = ?
		]]>
	</query>

	<query id="CoreSaleOrderReceive.getBomCustomRDpl" desc="轧管投入产出-产线能力经过最终用户认定">
		<![CDATA[
			SELECT T.IN_MATERIAL_NO,
			       T.OUT_MATERIAL_NO,
			       T.PLINE_CODE,
			       T.PLINE_NAME,
			       T.HR_CAPCTY,
			       T.PRD_RATE,
			       T.DBL_LEN_MAX,
			       T.ROL_LEN_MIN,
			       T.ROL_LEN_MAX,
			       T.CROP_END,
			       T.MANDREL_SIZE,
			       T.DISABLE_FL,
			       T.CROP_HEAD,
			       T.WASTE_RATE,
			       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.DELETE_NAME,
			       TO_CHAR(T.DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
			       T.PLINE_LEVEL
			  FROM SLM_BASE_MATERIAL_D_PL T
			 WHERE T.IN_MATERIAL_NO = ?
			   AND T.OUT_MATERIAL_NO = ?
			   AND (T.DISABLE_FL != '1' OR T.DISABLE_FL IS NULL)
			   AND T.PLINE_CODE IN (
			                        SELECT B.PLINE_CODE
			                          FROM CRAFT_ORD_DESIGN_MSC_PL_GX_PRL B
			                         WHERE B.PROCESS_CODE = 'D'
			                           AND B.DESGIN_KEY = ?
			                           AND B.MSC_PLINE = ?
			                           AND B.VALIDFLAG = '1'
			                        INTERSECT
			                        SELECT R.PLINE_CODE
			                          FROM COM_BASE_CUSTOM_R_PLINE R
			                         WHERE R.VALIDFLAG = '1'
			                           AND R.CUSTOMER_NO = ?
			                           AND R.PRODUCCODE = ?)
		]]>
	</query>

	<query id="CoreSaleOrderReceive.getBomMaterialDpl" desc="轧管投入产出-产线能力">
		<![CDATA[
			SELECT T.IN_MATERIAL_NO,
			       T.OUT_MATERIAL_NO,
			       T.PLINE_CODE,
			       T.PLINE_NAME,
			       T.HR_CAPCTY,
			       T.PRD_RATE,
			       T.DBL_LEN_MAX,
			       T.ROL_LEN_MIN,
			       T.ROL_LEN_MAX,
			       T.CROP_END,
			       T.MANDREL_SIZE,
			       T.DISABLE_FL,
			       T.CROP_HEAD,
			       T.WASTE_RATE,
			       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.DELETE_NAME,
			       TO_CHAR(T.DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
			       T.PLINE_LEVEL
			  FROM SLM_BASE_MATERIAL_D_PL T
			 WHERE T.IN_MATERIAL_NO = ?
			   AND T.OUT_MATERIAL_NO = ?
			   AND (T.DISABLE_FL != '1' OR T.DISABLE_FL IS NULL)
			   AND T.PLINE_CODE IN (SELECT B.PLINE_CODE
			                          FROM CRAFT_ORD_DESIGN_MSC_PL_GX_PRL B
			                         WHERE B.PROCESS_CODE = 'D'
			                           AND B.DESGIN_KEY = ?
			                           AND B.MSC_PLINE = ?
			                           AND B.VALIDFLAG = '1')
		]]>
	</query>

	<query id="CoreSaleOrderReceive.updateSaleordProc" desc="更改Bom和轧管产线">
		<![CDATA[
			UPDATE PLN_SALEORD_PROC T
			   SET T.BOM                = '#BOM#',
			       T.GRADECODE          = '#GRADECODE#',
			       T.GROUP_ROLL_ALL     = '#GROUP_ROLL_ALL#',
			       T.GROUP_ROLL         = '#GROUP_ROLL#',
			       T.GROUP_ROLL_NAME =
			       (SELECT B.PLINE_NAME
			          FROM COM_BASE_PLINE B
			         WHERE B.PLINE_CODE = '#GROUP_ROLL#'),
			       T.ABC                = '#ABC#',
			       T.E_IN_MATERIAL_NO   = '#E_IN_MATERIAL_NO#',
			       T.E_IN_MATERIAL_DESC = '#E_IN_MATERIAL_DESC#',
			       T.DIMATER_YLG        = '#DIMATER_YLG#',
			       T.HEIGHT_YLG         = '#HEIGHT_YLG#',
			       T.GROUP_JGX          = '#GROUP_JGX#',
			       T.GROUP_RCL          = '#GROUP_RCL#',
			       T.STUFF_PROPERTY     = '#STUFF_PROPERTY#',
			       T.E_IS_OK            = '#E_IS_OK#',
			       T.D_IS_OK            = '#D_IS_OK#',
			       T.GRADECODE_IS_OK    = '#GRADECODE_IS_OK#'
			 WHERE T.ORD_LN_DLY_PK = '#ORD_LN_DLY_PK#'
			   AND T.PLN_DIVIDE_ID = '#PLN_DIVIDE_ID#'
		]]>
	</query>

	<query id="CoreSaleOrderReceive.updateSaleordProcBomDp" desc="更改Bom和轧管产线">
		<![CDATA[
			UPDATE PLN_SALEORD_PROC T
			   SET T.BOM                = '#BOM#',
			       T.GRADECODE          = '#GRADECODE#',
			       T.GROUP_ROLL_ALL     = '#GROUP_ROLL_ALL#',
			       T.GROUP_ROLL         = '#GROUP_ROLL#',
			       T.GROUP_ROLL_NAME =
			       (SELECT B.PLINE_NAME
			          FROM COM_BASE_PLINE B
			         WHERE B.PLINE_CODE = '#GROUP_ROLL#'),
			       T.ABC                = '#ABC#',
			       T.E_IN_MATERIAL_NO   = '#E_IN_MATERIAL_NO#',
			       T.E_IN_MATERIAL_DESC = '#E_IN_MATERIAL_DESC#',
			       T.DIMATER_YLG        = '#DIMATER_YLG#',
			       T.HEIGHT_YLG         = '#HEIGHT_YLG#',
			       T.GROUP_JGX          = '#GROUP_JGX#',
			       T.GROUP_RCL          = '#GROUP_RCL#',
			       T.STUFF_PROPERTY     = '#STUFF_PROPERTY#',
			       T.E_IS_OK            = '#E_IS_OK#',
			       T.D_IS_OK            = '#D_IS_OK#',
			       T.GRADECODE_IS_OK    = '#GRADECODE_IS_OK#',
			       T.WEIGHT_PER_M       = '#WEIGHT_PER_M#',
			       T.PLAN_WT_D          = '#PLAN_WT_D#',
			       T.PLAN_NUM_D         = '#PLAN_NUM_D#',
			       T.AIM_LEN_END        = '#AIM_LEN_END#',
			       T.AIM_LEN_ROLL       = '#AIM_LEN_ROLL#',
			       T.PLAN_P_MAIN        = '#PLAN_P_MAIN#',
			       T.PLAN_TOT_LEN_D     = '#PLAN_TOT_LEN_D#',
			       T.TOT_LEN_ONE_P      = '#TOT_LEN_ONE_P#',
			       T.CUT_NUM_P          = '#CUT_NUM_P#',
			       T.AIM_WALLTHICK      = '#AIM_WALLTHICK#',
			       T.ROLL_LENGTH        = '#ROLL_LENGTH#',
			       T.AIM_OUTDIAMETER = '#AIM_OUTDIAMETER#',
                   T.FEED_RATE       = '#FEED_RATE#',
                   T.COEFFICIENT     = '#COEFFICIENT#',
			       T.PLAN_P_MAIN_MIN = '#PLAN_P_MAIN_MIN#',
			       T.AIM_WT_END      = '#AIM_WT_END#',
			       T.WEIGHT_KZ_M     = '#WEIGHT_KZ_M#'
			 WHERE T.ORD_LN_DLY_PK = '#ORD_LN_DLY_PK#'
			   AND T.PLN_DIVIDE_ID = '#PLN_DIVIDE_ID#'
		]]>
	</query>

	<query id="CoreSaleOrderReceive.saveSaleOrderRcl" desc="热处理确认">
		<![CDATA[
			UPDATE PLN_SALEORD_PROC T
			   SET T.GROUP_RCL = ?, T.F_IS_OK = ? 
			 WHERE T.ORD_LN_DLY_PK = ? 
			   AND T.PLN_DIVIDE_ID = ?
		]]>
	</query>

	<query id="CoreSaleOrderReceive.saveSaleOrderGjg" desc="加工线确认">
		<![CDATA[
			UPDATE PLN_SALEORD_PROC T
			   SET T.GROUP_JGX = ?, T.G_IS_OK = ? 
			 WHERE T.ORD_LN_DLY_PK = ? 
			   AND T.PLN_DIVIDE_ID = ?
		]]>
	</query>

	<query id="CoreSaleOrderReceive.queryIsNotAllowIssue" desc="更新销售合同是否可以下发">
		<![CDATA[
			SELECT T.INDEX_SEQ,
			       T.CRAFT_FILE_NO,
			       T.PROCESS_SEQ,
			       T.BOM,
			       T.D_IS_OK,
			       T.PLAN_IS_OK,
			       T.E_IS_OK,
			       T.GRADECODE_IS_OK,
			       T.PLN_DIVIDE_ID,
			       T.F_IS_OK,
			       T.G_IS_OK,
			       B.JGORD_IS_OK,
			       B.DJBL_REQ_IS_OK,
			       T.PLANSTATUS
			  FROM PLN_SALEORD_PROC T, PLN_SALEORD B
			 WHERE B.ORD_LN_DLY_PK(+) = T.ORD_LN_DLY_PK
			   AND T.ORD_LN_DLY_PK = ?
		]]>
	</query>

	<query id="CoreSaleOrderReceive.IfAllowIssue" desc="更新销售合同是否可以下发">
		<![CDATA[
			UPDATE PLN_SALEORD_PROC T
			   SET T.IF_ALLOW_ISSUE = ?
			 WHERE T.ORD_LN_DLY_PK = ?
			   AND T.PLN_DIVIDE_ID = ?
		]]>
	</query>

	<query id="CoreSaleOrderReceive.saveConfirmStatus" desc="默认物料确认">
		<![CDATA[
			UPDATE PLN_SALEORD_PROC T
			   SET T.GRADECODE_IS_OK = '#GRADECODE_IS_OK#',
			       T.D_IS_OK         = '#D_IS_OK#',
			       T.E_IS_OK         = '#E_IS_OK#'
			 WHERE T.ORD_LN_DLY_PK = '#ORD_LN_DLY_PK#'
			   AND T.PLN_DIVIDE_ID = '#PLN_DIVIDE_ID#'
		]]>
	</query>

	<query id="CoreSaleOrderReceive.updateSaleOrdProcStatus" desc="更新拆分合同状态">
		<![CDATA[
			UPDATE PLN_SALEORD_PROC T
			   SET T.CRAFT_FILE_NO =
			       (SELECT M.CRAFT_NO
			          FROM CRAFT_ORD_DESIGN M, PLN_SALEORD T1
			         WHERE M.ORD_LN_PK = T1.ORD_LN_PK
			           AND T1.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
			           AND M.CRAFT_SEQ = T.CRAFT_SEQ),
			       T.CRAFT_FILE_MAN =
			       (SELECT M.CRAFT_NAME
			          FROM CRAFT_ORD_DESIGN_APPOINT M, PLN_SALEORD T1
			         WHERE M.ORD_LN_PK = T1.ORD_LN_PK
			           AND T1.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK),
			       T.CRAFT_NO_V    =
			       (SELECT M.CRAFT_NO_V
			          FROM CRAFT_ORD_DESIGN M, PLN_SALEORD T1
			         WHERE M.ORD_LN_PK = T1.ORD_LN_PK
			           AND T1.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
			           AND M.CRAFT_SEQ = T.CRAFT_SEQ),
			       T.PLAN_WT_BEGIN  = T.PLAN_WT_D,
			       T.PLAN_NUM_BEGIN = T.PLAN_NUM_D,
			       T.PLANSTATUS     = ?,
			       T.ISSUED_MAN     = ?,
			       T.ISSUED_TIME    = SYSDATE
			 WHERE T.ORD_LN_DLY_PK = ?
			   AND T.PLN_DIVIDE_ID = ?
		]]>
	</query>

	<query id="CoreSaleOrderReceive.queryIsNotIussedOrd" desc="查询交货行有无下发">
		<![CDATA[
			SELECT COUNT(*) IUSSED_NUM
		           FROM PLN_SALEORD_PROC T
		          WHERE TO_NUMBER(T.PLANSTATUS) > 1
		            AND T.ORDER_SOURCE = '销售合同'
		            AND T.ORD_LN_DLY_PK = ?
		]]>
	</query>

	<query id="CoreSaleOrderReceive.updatePlnSaleStatus" desc="下发撤销下发更改交货行状态">
		<![CDATA[
			UPDATE PLN_SALEORD T
			   SET T.PORDERSTATUS = ?
			 WHERE T.ORD_LN_DLY_PK = ?
		]]>
	</query>

	<query id="CoreSaleOrderReceive.updateProcessOrderMt" desc="更新进程表">
		<![CDATA[
			UPDATE PROCESS_ORDER_M T
			   SET T.PSS_NUM = T.PSS_NUM + ?, T.PSS_WGT = T.PSS_WGT + ?
			 where t.ord_ln_dly_pk = ?
		]]>
	</query>

	<query id="CoreSaleOrderReceive.queryPlnOrderZg" desc="查询工序合同状态">
		<![CDATA[
			SELECT T.ORDERSTATUS, T.PRO_ORDER_NO
			  FROM PLN_ORDER_ZG T
			 WHERE T.ORD_LN_DLY_PK = ?
			   AND T.PLN_DIVIDE_ID = ?
		]]>
	</query>

	<query id="CoreSaleOrderReceive.queryPlnOrderDbk" desc="查询工序合同状态">
		<![CDATA[
			SELECT T.ORDERSTATUS, T.PRO_ORDER_NO
			  FROM PLN_ORDER_DBK T
			 WHERE T.ORD_LN_DLY_PK = ?
			   AND T.PLN_DIVIDE_ID = ?
		]]>
	</query>

	<query id="CoreSaleOrderReceive.queryPlnOrderRcl" desc="查询工序合同状态">
		<![CDATA[
			SELECT T.ORDERSTATUS, T.PRO_ORDER_NO
			  FROM PLN_ORDER_RCL T
			 WHERE T.ORD_LN_DLY_PK = ?
			   AND T.PLN_DIVIDE_ID = ?
		]]>
	</query>

	<query id="CoreSaleOrderReceive.queryPlnOrderJgx" desc="查询工序合同状态">
		<![CDATA[
			SELECT T.ORDERSTATUS, T.PRO_ORDER_NO
			  FROM PLN_ORDER_JGX T
			 WHERE T.ORD_LN_DLY_PK = ?
			   AND T.PLN_DIVIDE_ID = ?
		]]>
	</query>

	<query id="CoreSaleOrderReceive.deletePlnOrderZg" desc="删除工序合同">
		<![CDATA[
			DELETE FROM PLN_ORDER_ZG T WHERE T.ORD_LN_DLY_PK = ? AND T.PLN_DIVIDE_ID = ?
		]]>
	</query>

	<query id="CoreSaleOrderReceive.deletePlnOrderDbk" desc="删除工序合同">
		<![CDATA[
			DELETE FROM PLN_ORDER_DBK T WHERE T.ORD_LN_DLY_PK = ? AND T.PLN_DIVIDE_ID = ?
		]]>
	</query>

	<query id="CoreSaleOrderReceive.deletePlnOrderRcl" desc="删除工序合同">
		<![CDATA[
			DELETE FROM PLN_ORDER_RCL T WHERE T.ORD_LN_DLY_PK = ? AND T.PLN_DIVIDE_ID = ?
		]]>
	</query>

	<query id="CoreSaleOrderReceive.deletePlnOrderJgx" desc="删除工序合同">
		<![CDATA[
			DELETE FROM PLN_ORDER_JGX T WHERE T.ORD_LN_DLY_PK = ? AND T.PLN_DIVIDE_ID = ?
		]]>
	</query>

	<query id="CoreSaleOrderReceive.selectOrdProcBomDpline" desc="查询投入产出物料">
		<![CDATA[
			SELECT B.D_IN_MATERIAL_NO,
			       B.D_OUT_MATERIAL_NO,
			       B.E_IN_MATERIAL_NO,
			       B.E_OUT_MATERIAL_NO,
			       B.F_IN_MATERIAL_NO,
			       B.F_OUT_MATERIAL_NO,
			       B.I_IN_MATERIAL_NO,
			       B.I_OUT_MATERIAL_NO,
			       B.WHOLE_BACKLOG,
			       T.GROUP_ROLL,
			       T.BJ_TYPE
			  FROM PLN_SALEORD_PROC T
			  LEFT JOIN SLM_ORD_DESIGN_BOM B
			    ON B.BOM = T.BOM
			   AND B.MATERIAL_NO = T.MATERIAL_NO
			 WHERE T.ORD_LN_DLY_PK = ?
			   AND T.PLN_DIVIDE_ID = ?
		]]>
	</query>

</queryMap>