<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="销售合同下发工序">
	<query id="CorePlnProcessOrd.querySaleProcStatus" desc="查询状态">
		<![CDATA[
			SELECT (SELECT DESGIN_KEY
          FROM CRAFT_ORD_DESIGN T1
         WHERE T1.ORD_LN_PK = B.ORD_LN_PK
           AND T1.CRAFT_SEQ = T.CRAFT_SEQ) DESGIN_KEY,
       T.MSC,
       T.INDEX_SEQ,
       T.CRAFT_FILE_NO,
       T.CRAFT_SEQ,
       T.PROCESS_SEQ,
       T.BOM,
       T.GROUP_ROLL,
       T.GROUP_ROLL_NAME,
       T.PLAN_WT_D,
       T.PLAN_P_MAIN,
       T.PLAN_NUM_D,
       T.ORDER_UNIT,
       T.WEIGHT_PER_M,
       T.AIM_LEN_ROLL,
       T.AIM_LEN_END,
       T.LEN_ROLL_MAX,
       T.LEN_ROLL_MIN,
       T.GROUP_JGX,
       T.GROUP_RCL,
       B.PRDCR_NO,
       B.LENGTHMAX,
       B.LENGTHMIN,
       B.OUTDIAMETER,
       B.WALLTHICK,
       B.SHRT_STOVE,
       B.SIGL_LEN,
       (SELECT C.SHORTEST
                FROM SLM_ORDER_LINE C
               WHERE C.VALIDFLAG = '1'
                 AND C.ORD_LN_PK = B.ORD_LN_PK) SHORTEST,
       B.OUTS_STL_PIPE_FL,
       B.OUTS_BILLET_FL,
       T.OUT_MULT_D,
       (SELECT C.INSPECTION_VALUE
			          FROM SLM_ORDER_LINE C
			         WHERE C.VALIDFLAG = '1'
			           AND C.ORD_LN_PK = B.ORD_LN_PK) INSPECTION_VALUE,
       B.MODEL_DESC,
       (SELECT T1.CHECK_J_VAL
          FROM COM_MSC_JG T1
         WHERE T1.CODE_JG = B.CODE_JG) CHECK_J_VAL,
       NVL(B.AVG_LEN_MIN, 0) AVG_LEN_MIN,
       T.ORD_LN_DLY_PK,
       B.ORDER_UNIT,
       NVL(B.TOTLENGTH, 0) TOTLENGTH,
       NVL(B.TOTLENGTH_UNIT, B.LEN_UNIT) TOTLENGTH_UNIT,
       B.WEIGH_TYPE,
       T.ORDER_UNIT,
       T.PLAN_P_MAIN_MIN,
       B.ENDLEN_SPECSTD,
       B.PRD_CLS,
       B.PRODUCE_SORT,
       T.ROLL_MONTH,
       B.STD_NAME,
       B.USE_DESC,
       (SELECT C.OUTPUT_STD_NO
			          FROM SLM_ORDER_LINE C
			         WHERE C.VALIDFLAG = '1'
			           AND C.ORD_LN_PK = B.ORD_LN_PK) OUTPUT_STD_NO,
       T.ABC,
       T.ORDER_SOURCE,
       T.ORDER_NO,
       T.ORDER_SEQ,
       T.LEN_CUTHEAD_DBK,
       T.LEN_CUTEND_DBK,
       T.LEN_LONGER_DBK,
       T.RATIO_DBK,
       T.LEN_SCOPE,B.ORD_LN_PK,t.GRADECODE_ALL,T.GRADECODE,
        (SELECT G.GRADENAME
          FROM COM_BASE_GRADE G
         WHERE G.VALIDFLAG = '1'
           AND G.GRADECODE = T.GRADECODE) GRADENAME,
       B.SPEC_CODE,
       B.SPEC_NAME,B.SUPPLY_UNIT,B.SUPPLY_UNIT_CODE
  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 = ?
   AND T.PLN_DIVIDE_ID = ?
		]]>
	</query>

	<query id="CorePlnProcessOrd.querySaleStatus" desc="查询交货行">
		<![CDATA[
			SELECT T.PRDCR_NO,
			       T.LENGTHMAX,
			       T.LENGTHMIN,
			       T.LEN_TOEND_MAX,
			       T.LEN_TOEND_MIN,
			       T.OUTDIAMETER,
			       T.WALLTHICK,
			       T.SHRT_STOVE,
			       T.SIGL_LEN,
			       T.SHORTEST
			  FROM PLN_SALEORD T
			 WHERE T.ORD_LN_DLY_PK = ?
		]]>
	</query>

	<query id="CorePlnProcessOrd.queryMscplPrc" desc="销售合同查询制程工序">
		<![CDATA[
			SELECT T.DESGIN_KEY,
			       T.MSC_PLINE,
			       T.WHOLE_BACKLOG,
			       T.WHOLE_BACKLOG_DESC,
			       T.BACKLOG_SEQ,
			       T.PROCESS_CODE,
			       T.PROCESS_DESC,
			       T1.PROCESS_CODE PREVIOUS_GX_CODE,
			       T1.PROCESS_DESC PREVIOUS_GX,
			       T.PROCESS_SEQ,
			       T.PROCESS_CODE_C,
			       T.PROCESS_DESC_C,
			       T.PROCESS_SEQ,
			       T.SIC,
			       (SELECT LISTAGG(S.STATION_DESC, ',') WITHIN GROUP(ORDER BY S.STATION_CODE)
			          FROM CRAFT_ORD_DESIGN_MSC_PL_STI S
			         WHERE S.DESGIN_KEY = T.DESGIN_KEY
			           AND S.MSC_PLINE = T.MSC_PLINE
			           AND S.PROCESS_CODE = T.PROCESS_CODE) STATION_ROAD
			  FROM CRAFT_ORD_DESIGN_MSC_PL_PRC T
			  LEFT JOIN CRAFT_ORD_DESIGN_MSC_PL_PRC T1
			    ON T1.DESGIN_KEY = T.DESGIN_KEY
			   AND T1.MSC_PLINE = T.MSC_PLINE
			   AND T1.BACKLOG_SEQ = T.BACKLOG_SEQ - 1
			 WHERE T.DESGIN_KEY = ?
			   AND T.MSC_PLINE = ?
			 ORDER BY T.BACKLOG_SEQ DESC
		]]>
	</query>

	<query id="CorePlnProcessOrd.queryMscplPrcSeq" 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,
			       PROCESS_SEQ
			  FROM CRAFT_ORD_DESIGN_MSC_PL_PRC T
			 WHERE T.DESGIN_KEY = ?
			   AND T.MSC_PLINE = ?
			   AND T.BACKLOG_SEQ = ?
		]]>
	</query>

	<query id="CorePlnProcessOrd.queryMscplPrcProCode" 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,
			       PROCESS_SEQ
			  FROM CRAFT_ORD_DESIGN_MSC_PL_PRC T
			 WHERE T.DESGIN_KEY = ?
			   AND T.MSC_PLINE = ?
			   AND T.PROCESS_CODE = ?
		]]>
	</query>

	<query id="CorePlnProcessOrd.queryDesginMscpl" desc="销售合同查询制程">
		<![CDATA[
			SELECT DESGIN_KEY, MSC_PLINE, WHOLE_BACKLOG, WHOLE_BACKLOG_DESC
			  FROM CRAFT_ORD_DESIGN_MSC_PL T
			 WHERE T.DESGIN_KEY = ?
			   AND T.MSC_PLINE = ?
			   AND T.VALIDFLAG = '1'
		]]>
	</query>

	<query id="CorePlnProcessOrd.queryDesginBomI" desc="查询加工投入查出物料">
		<![CDATA[
			SELECT T.IN_MATERIAL_NO,
			       T.IN_MATERIAL_DESC,
			       T.OUT_MATERIAL_NO,
			       T.OUT_MATERIAL_DESC
			  FROM SLM_ORD_DESIGN_BOM_K T
			 WHERE T.BOM = ?
		]]>
	</query>

	<query id="CorePlnProcessOrd.queryDesginBom" desc="查询各工序投入查出物料">
		<![CDATA[
			SELECT T.MATERIAL_NO,
       T.BOM,
       T.MSC_PLINE,
       T.WHOLE_BACKLOG,
       T.WHOLE_BACKLOG_DESC,
       T.MSC,
       T.GRADECODE,
       T.GRADENAME,
       T.SPEC_CODE_C,
       T.SPEC_CODE_R,
       T.SPEC_CODE_D,
       T.SPEC_CODE_Z,
       T.A_IN_MATERIAL_NO,
       T.A_OUT_MATERIAL_NO,
       T.B_IN_MATERIAL_NO,
       T.B_OUT_MATERIAL_NO,
       T.C_IN_MATERIAL_NO,
       T.C_OUT_MATERIAL_NO,
       T.D_IN_MATERIAL_NO,
       T.D_IN_MATERIAL_DESC,
       T.D_OUT_MATERIAL_NO,
       T.D_OUT_MATERIAL_DESC,
       T.E_IN_MATERIAL_NO,
       T.E_IN_MATERIAL_DESC,
       T.E_OUT_MATERIAL_NO,
       T.E_OUT_MATERIAL_DESC,
       T.F_IN_MATERIAL_NO,
       T.F_IN_MATERIAL_DESC,
       T.F_OUT_MATERIAL_NO,
       T.F_OUT_MATERIAL_DESC,
       (SELECT B.DIMATER
          FROM COM_BASE_SPEC B
         WHERE B.SPEC_CODE = T.SPEC_CODE_C) DIMATERDBK,
       (SELECT B.HEIGHT
          FROM COM_BASE_SPEC B
         WHERE B.SPEC_CODE = T.SPEC_CODE_C) HEIGHTDBK,
       (SELECT B.DIMATER
          FROM COM_BASE_SPEC B
         WHERE B.SPEC_CODE = T.SPEC_CODE_R) DIMATER,
       (SELECT B.HEIGHT
          FROM COM_BASE_SPEC B
         WHERE B.SPEC_CODE = T.SPEC_CODE_R) HEIGHT,
       (SELECT B.DIMATER
          FROM COM_BASE_SPEC B
         WHERE B.SPEC_CODE = NVL(T.SPEC_CODE_D, T.SPEC_CODE_Z)) SPEC_SECTION,
       (SELECT B.DIMATER
          FROM COM_BASE_SPEC B
         WHERE B.SPEC_CODE = T.SPEC_CODE_Z) SPEC_B_OUT
  FROM SLM_ORD_DESIGN_BOM T
			 WHERE T.BOM = ?
		]]>
	</query>

	<query id="CorePlnProcessOrd.queryBaseMaterialIPl" desc="查询加工投入产出-产线能力">
		<![CDATA[
			SELECT OUT_MATERIAL_NO,
			       PLINE_CODE,
			       PLINE_NAME,
			       HR_CAPCTY,
			       PRD_RATE,
			       WASTE_RATE
			  FROM SLM_BASE_MATERIAL_K_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, COM_BASE_PLINE B2
			         WHERE B.PROCESS_CODE = 'G'
			           AND B.VALIDFLAG = '1'
			           AND B.PLINE_CODE = B2.PLINE_CODE
			           AND B2.VALIDFLAG = '1'
			           AND B.DESGIN_KEY = ?
			           AND B.MSC_PLINE = ?
			           AND B2.GROUP_PLAN = ?)
			 --ORDER BY T.PLINE_LEVEL ASC, T.PRD_RATE DESC
			 ORDER BY T.HR_CAPCTY DESC, T.PLINE_CODE ASC
		]]>
	</query>

	<query id="CorePlnProcessOrd.queryBaseMaterialFPl" desc="查询热处理投入产出-产线能力">
		<![CDATA[
			SELECT IN_MATERIAL_NO,
			       OUT_MATERIAL_NO,
			       PLINE_CODE,
			       PLINE_NAME,
			       HR_CAPCTY,
			       PRD_RATE,
			       DISABLE_FL,
			       WASTE_RATE
			  FROM SLM_BASE_MATERIAL_F_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, COM_BASE_PLINE B2
			         WHERE B.PROCESS_CODE = 'F'
			           AND B.VALIDFLAG = '1'
			           AND B.PLINE_CODE = B2.PLINE_CODE
			           AND B2.VALIDFLAG = '1'
			           AND B.DESGIN_KEY = ?
			           AND B.MSC_PLINE = ?
			           AND B2.GROUP_PLAN = ?
			           --AND B2.SUPPLY_UNIT_CODE = ?
			           )
			 ORDER BY T.PLINE_LEVEL ASC, T.PRD_RATE DESC
		]]>
	</query>

	<query id="CorePlnProcessOrd.queryBaseMaterialEPl" desc="查询镦拔扩投入产出-产线能力">
		<![CDATA[
			SELECT IN_MATERIAL_NO,
			       OUT_MATERIAL_NO,
			       PLINE_CODE,
			       PLINE_NAME,
			       HR_CAPCTY,
			       PRD_RATE,
			       DISABLE_FL,
			       CROP_HEAD,
			       CROP_END,
			       WASTE_RATE,
			       AUDIT_FLAG, 
			       UPSETTING_LENGTH
			  FROM SLM_BASE_MATERIAL_E_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.AUDIT_FLAG != '0'
			   AND T.PLINE_CODE IN (SELECT B.PLINE_CODE
                                 FROM CRAFT_ORD_DESIGN_MSC_PL_GX_PRL B
                                WHERE B.PROCESS_CODE = 'E'
                                  AND B.DESGIN_KEY = ?
                                  AND B.MSC_PLINE = ?
                                  AND B.VALIDFLAG = '1')
			 ORDER BY T.PLINE_LEVEL ASC, T.PRD_RATE DESC,T.PLINE_CODE ASC
		]]>
	</query>
<query id="CorePlnProcessOrd.queryBaseMaterialBPl" desc="查询铸造投入产出-产线能力">
		<![CDATA[
			SELECT OUT_MATERIAL_NO,
       PLINE_CODE,
       PLINE_NAME
  FROM SLM_BASE_MATERIAL_B_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, COM_BASE_PLINE B2
         WHERE B.PROCESS_CODE = 'B'
           AND B.VALIDFLAG = '1'
           AND B.PLINE_CODE = B2.PLINE_CODE
           AND B2.VALIDFLAG = '1'
           AND B.DESGIN_KEY =?
           AND B.MSC_PLINE = ?)
 ORDER BY T.PLINE_LEVEL ASC, T.PRD_RATE DESC
		]]>
	</query>
	<query id="CorePlnProcessOrd.queryBaseMaterialDPl" desc="查询轧管投入产出-产线能力">
		<![CDATA[
			SELECT IN_MATERIAL_NO,
			       OUT_MATERIAL_NO,
			       PLINE_CODE,
			       PLINE_NAME,
			       NVL(HR_CAPCTY,0) HR_CAPCTY,
			       PRD_RATE,
			       ROL_LEN_MIN,
			       ROL_LEN_MAX,
			       CROP_END,
			       MANDREL_SIZE,
			       DISABLE_FL,
			       CROP_HEAD,
			       WASTE_RATE,
			       TUBE_END_RATIO,
			       NVL(DBL_LEN_MAX,0) DBL_LEN_MAX
			  FROM SLM_BASE_MATERIAL_D_PL T
			 WHERE T.IN_MATERIAL_NO = ?
			   AND T.OUT_MATERIAL_NO = ?
			   AND T.PLINE_CODE = ?
			   AND (T.DISABLE_FL != '1' OR T.DISABLE_FL IS NULL)
		]]>
	</query>

	<query id="CorePlnProcessOrd.queryBasePlineD" desc="查询轧管产线基础表">
		<![CDATA[
			SELECT PLINE_CODE,
			       PLINE_NAME,
			       DEPARTMENT_CODE,
			       DEPARTMENT_DESC,
			       PROCESS_CODE,
			       PROCESS_DESC,
			       LENGTH_MIN,
			       LENGTH_MAX,
			       LENGTH_COLDBED,
			       LENGTH_MAX_RING,
			       LENGTH_MIN_RING,
			       NVL(LENGTH_MIN_TUBE,0) LENGTH_MIN_TUBE,
			       NVL(LENGTH_MAX_TUBE,0) LENGTH_MAX_TUBE,
			       NVL(BURNOUT_RATE,0) BURNOUT_RATE,
			       NVL(TOLERANCE_ZONE,0) TOLERANCE_ZONE
			  FROM COM_BASE_PLINE T
			 WHERE T.VALIDFLAG = '1'
			   AND T.PLINE_CODE = ?
		]]>
	</query>

	<query id="CorePlnProcessOrd.queryBaseMaterialCPl" desc="查询锻造投入产出-产线能力">
		<![CDATA[
			SELECT IN_MATERIAL_NO,
	              OUT_MATERIAL_NO,
	              PLINE_CODE,
	              PLINE_NAME,
	              HR_CAPCTY,
	              PRD_RATE,
	              DISABLE_FL
	         FROM SLM_BASE_MATERIAL_C_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 = 'C'
	                                  AND B.DESGIN_KEY = ?
	                                  AND B.MSC_PLINE = ?
	                                  AND B.VALIDFLAG = '1')
		]]>
	</query>
	<query id="CorePlnProcessOrd.queryPorderBlReq" desc="查询备料类型">
		<![CDATA[
			SELECT T.BLTYPE FROM PLN_PORDER_BL_REQ T WHERE T.REQ_BL_ID=?
		]]>
	</query>
	<query id="CorePlnProcessOrd.queryOrderLinePrdcrLst" desc="查询管体监制工序">
		<![CDATA[
			SELECT TO_CHAR(WM_CONCAT(X.PROCESS_CODE)) PRDCR_PRC
			          FROM (SELECT B.PROCESS_CODE, B.PRDCR_NO, P.MSC_PLINE
			                  FROM SLM_ORDER_LINE_PRDCR_LST B, SLM_ORDER_LINE_PRDCR P
			                 WHERE P.PRDCR_NO = B.PRDCR_NO
			                   AND P.PRDCR_INDEX = B.PRDCR_INDEX
			                   AND P.CODE_JG IS NULL
			                   AND P.CODE_BL IS NULL
			                   AND B.PRDCR_PRC_FL = '1'
			                 GROUP BY B.PROCESS_CODE, B.PRDCR_NO, P.MSC_PLINE
			                HAVING COUNT(*) >= 1
			                 ORDER BY B.PROCESS_CODE) X
			         WHERE X.PRDCR_NO = ?
			           AND X.MSC_PLINE = ?
		]]>
	</query>
	<query id="CorePlnProcessOrd.queryOrderLinePrdcrLst1" desc="查询接箍料监制工序">
		<![CDATA[
			SELECT TO_CHAR(WM_CONCAT(X.PROCESS_CODE)) PRDCR_PRC
			          FROM (SELECT B.PROCESS_CODE, B.PRDCR_NO, P.MSC_PLINE
			                  FROM SLM_ORDER_LINE_PRDCR_LST B, SLM_ORDER_LINE_PRDCR P
			                 WHERE P.PRDCR_NO = B.PRDCR_NO
			                   AND P.PRDCR_INDEX = B.PRDCR_INDEX
			                   AND P.CODE_JG IS NOT NULL
			                   AND P.CODE_BL IS NOT NULL
			                   AND B.PRDCR_PRC_FL = '1'
			                 GROUP BY B.PROCESS_CODE, B.PRDCR_NO, P.MSC_PLINE
			                HAVING COUNT(*) >= 1
			                 ORDER BY B.PROCESS_CODE) X
			         WHERE X.PRDCR_NO = ?
			           AND X.MSC_PLINE = ?
		]]>
	</query>
	<query id="CorePlnProcessOrd.queryOrderLinePrdcrLst2" desc="查询短节备料监制工序">
		<![CDATA[
			SELECT TO_CHAR(WM_CONCAT(X.PROCESS_CODE)) PRDCR_PRC
			          FROM (SELECT B.PROCESS_CODE, B.PRDCR_NO, P.MSC_PLINE
			                  FROM SLM_ORDER_LINE_PRDCR_LST B, SLM_ORDER_LINE_PRDCR P
			                 WHERE P.PRDCR_NO = B.PRDCR_NO
			                   AND P.PRDCR_INDEX = B.PRDCR_INDEX
			                   AND P.CODE_JG IS NOT NULL
			                   AND P.CODE_BL IS NULL
			                   AND B.PRDCR_PRC_FL = '1'
			                 GROUP BY B.PROCESS_CODE, B.PRDCR_NO, P.MSC_PLINE
			                HAVING COUNT(*) >= 1
			                 ORDER BY B.PROCESS_CODE) X
			         WHERE X.PRDCR_NO = ?
			           AND X.MSC_PLINE = ?
		]]>
	</query>
	<query id="CorePlnProcessOrd.addPlnOrderJgx" desc="新增管加工工序">
		<![CDATA[
			INSERT INTO PLN_ORDER_JGX
				  ( VERSION_NO,
				  PRO_ORDER_NO,
				   PLAN_GROUP_ID,
				   ORDER_SOURCE,
				   ORD_LN_DLY_PK,
				   PLN_DIVIDE_ID,
				   ORDER_NO,
				   ORDER_SEQ,
				   DELIVERY_NO,
				   REQ_BL_ID,
				   INDEX_SEQ,
				   BOM,
				   BACKLOG_SEQ,
				   STEELCODE,
				   STEELNAME,
				   OUTDIAMETER,
				   WALLTHICK,
				   AIMWALLTHICK,
				   LENGTHMAX,
				   LENGTHMIN,
				   LENGTHDISC,
				   AIMLENGTH,
				   MODEL_CODE,
				   MODEL_DESC,
				   GETRATE,
				   LENGTHMAX_IN,
				   LENGTHMIN_IN,
				   INWL_ID,
				   OUTWL_ID,
				   GROUP_JGX,
				   PLINE_CODE_MAY,
				   PLINE_NAME_MAY,
				   ORDERWEIGHT,
				   ORDERNUM,
				   MATCH_WT,
				   MATCH_NUM,
				   REQ_PROD_WT,
				   REQ_PROD_NUM,
				   PROD_END_DATE,
				   ORDERSTATUS,
				   PRO_PLAN_ID,
				   ISENDGX,
				   IF_MONITOR_JGX,
				   PRDCR_NO,
				   CRAFT_FILE_NO,
				   CRAFT_FILE_MAN,
				   CREATE_NAME,
				   CREATE_TIME,
				   PLINE_CODE,
				   PLINE_NAME,
				   CRAFT_SEQ,
				   PROCESS_CODE_C,
				   PROCESS_DESC_C,
				   STATION_ROAD,
				   PREVIOUS_GX,
				   PREVIOUS_GX_CODE,
				   IN_WEIGHT,
				   IN_NUM,
				   ADD_WT_IN,
				   ADD_NUM_IN)
				  SELECT '#VERSION_NO#', '#PRO_ORDER_NO#',
				         (A.ORDER_NO || '/' || A.ORDER_SEQ || '/' || A.DELIVERY_NO || '/' ||
				         B.PLN_DIVIDE_ID || '/' || '01'),
				         B.ORDER_SOURCE,
				         B.ORD_LN_DLY_PK,
				         B.PLN_DIVIDE_ID,
				         A.ORDER_NO,
				         A.ORDER_SEQ,
				         A.DELIVERY_NO,
				         NULL,
				         B.INDEX_SEQ,
				         B.BOM,
				         '#BACKLOG_SEQ#',
				         A.STEELCODE,
				         A.STEELNAME,
				         A.OUTDIAMETER,
				         A.WALLTHICK,
				         B.AIM_WALLTHICK,
				         A.LENGTHMAX,
				         A.LENGTHMIN,
				         A.LENGTHDISC,
				         B.AIM_LEN_END,
				         A.MODEL_CODE,
				         A.MODEL_DESC,
				         '#GETRATE#',
				         (A.LENGTHMAX - NVL((J.LENGTH_JG / 1000), 0)),
				         (A.LENGTHMIN - NVL((J.LENGTH_JG / 1000), 0)),
				         '#INWL_ID#',
				         '#OUTWL_ID#',
				         B.GROUP_JGX,
				         NULL,
				         NULL,
				         '#ORDERWEIGHT#',
				         '#ORDERNUM#',
				         NULL,
				         NULL,
				         NULL,
				         NULL,
				         NULL,
				         '1',
				         NULL,
				         '#ISENDGX#',
				         '#IF_MONITOR_JGX#',
				         A.PRDCR_NO,
				         B.CRAFT_FILE_NO,
				         B.CRAFT_FILE_MAN,
				         '#CREATE_NAME#',
				         SYSDATE,
				         '#PLINE_CODE#',
				         '#PLINE_NAME#',
				         B.CRAFT_SEQ,
				         '#PROCESS_CODE_C#',
				         '#PROCESS_DESC_C#',
				         '#STATION_ROAD#',
				         '#PREVIOUS_GX#',
				         '#PREVIOUS_GX_CODE#',
				         '#IN_WEIGHT#',
				         '#IN_NUM#',
				         '#ADD_WT_IN#',
				         '#ADD_NUM_IN#'
				    FROM PLN_SALEORD A
				    LEFT JOIN COM_MSC_JG J
				      ON J.CODE_JG = A.CODE_JG
				     AND J.VALIDFLAG = '1', PLN_SALEORD_PROC B
				   WHERE A.ORD_LN_DLY_PK = B.ORD_LN_DLY_PK
				     AND B.ORD_LN_DLY_PK = '#ORD_LN_DLY_PK#'
				     AND B.PLN_DIVIDE_ID = '#PLN_DIVIDE_ID#'
		]]>
	</query>

	<query id="CorePlnProcessOrd.addPlnOrderRcl" desc="新增热处理工序">
		<![CDATA[
			INSERT INTO PLN_ORDER_RCL
				  (VERSION_NO,
				  PRO_ORDER_NO,
				   PLAN_GROUP_ID,
				   ORDER_SOURCE,
				   ORD_LN_DLY_PK,
				   PLN_DIVIDE_ID,
				   ORDER_NO,
				   ORDER_SEQ,
				   DELIVERY_NO,
				   INDEX_SEQ,
				   BOM,
				   BACKLOG_SEQ,
				   STEELCODE,
				   STEELNAME,
				   OUTDIAMETER,
				   WALLTHICK,
				   AIMWALLTHICK,
				   LENGTHMAX,
				   LENGTHMIN,
				   AIMLENGTH,
				   GETRATE,
				   INWL_ID,
				   OUTWL_ID,
				   GROUP_RCL,
				   ORDERWEIGHT,
				   ORDERNUM,
				   MATCH_WT,
				   MATCH_NUM,
				   REQ_PROD_WT,
				   REQ_PROD_NUM,
				   PROD_END_DATE,
				   ORDERSTATUS,
				   PRO_PLAN_ID,
				   ISENDGX,
				   NEXT_GX,
				   IF_MONITOR_RCL,
				   PRDCR_NO,
				   CRAFT_FILE_NO,
				   CRAFT_FILE_MAN,
				   CREATE_NAME,
				   CREATE_TIME,
				   PLINE_CODE,
				   PLINE_NAME,
				   CRAFT_SEQ,
				   PROCESS_CODE_C,
				   PROCESS_DESC_C,
				   STATION_ROAD,
				   PREVIOUS_GX,
				   PREVIOUS_GX_CODE,
				   IN_WEIGHT,
				   IN_NUM,ADD_WT_IN,ADD_NUM_IN)
				  SELECT '#VERSION_NO#','#PRO_ORDER_NO#',
				         (A.ORDER_NO || '/' || A.ORDER_SEQ || '/' || A.DELIVERY_NO || '/' ||
				         B.PLN_DIVIDE_ID || '/' || '01'),
				         B.ORDER_SOURCE,
				         B.ORD_LN_DLY_PK,
				         B.PLN_DIVIDE_ID,
				         A.ORDER_NO,
				         A.ORDER_SEQ,
				         A.DELIVERY_NO,
				         B.INDEX_SEQ,
				         B.BOM,
				         '#BACKLOG_SEQ#',
				         A.STEELCODE,
				         A.STEELNAME,
				         A.OUTDIAMETER,
				         A.WALLTHICK,
				         B.AIM_WALLTHICK,
				         (A.LENGTHMAX - NVL((J.LENGTH_JG / 1000), 0)),
				         (A.LENGTHMIN - NVL((J.LENGTH_JG / 1000), 0)),
				         (B.AIM_LEN_END - NVL((J.LENGTH_JG / 1000), 0)),
				         '#GETRATE#',
				         '#INWL_ID#',
				         '#OUTWL_ID#',
				         B.GROUP_RCL,
				         '#ORDERWEIGHT#',
				         '#ORDERNUM#',
				         NULL,
				         NULL,
				         NULL,
				         NULL,
				         NULL,
				         '1',
				         NULL,
				         '#ISENDGX#',
				         '#NEXT_GX#',
				         '#IF_MONITOR_RCL#',
				         A.PRDCR_NO,
				         B.CRAFT_FILE_NO,
				         B.CRAFT_FILE_MAN,
				         '#CREATE_NAME#',
				         SYSDATE,
				         '#PLINE_CODE#',
				         '#PLINE_NAME#',
				         B.CRAFT_SEQ,
				         '#PROCESS_CODE_C#',
				         '#PROCESS_DESC_C#',
				         '#STATION_ROAD#',
				         '#PREVIOUS_GX#',
				         '#PREVIOUS_GX_CODE#',
				         '#IN_WEIGHT#',
				         '#IN_NUM#','#ADD_WT_IN#','#ADD_NUM_IN#'
				    FROM PLN_SALEORD A
				    LEFT JOIN COM_MSC_JG J
				      ON J.CODE_JG = A.CODE_JG
				     AND J.VALIDFLAG = '1', PLN_SALEORD_PROC B
				   WHERE A.ORD_LN_DLY_PK = B.ORD_LN_DLY_PK
				     AND B.ORD_LN_DLY_PK = '#ORD_LN_DLY_PK#'
				     AND B.PLN_DIVIDE_ID = '#PLN_DIVIDE_ID#'
		]]>
	</query>

	<query id="CorePlnProcessOrd.addPlnOrderDbk" desc="新增镦拔扩工序">
		<![CDATA[
			INSERT INTO PLN_ORDER_DBK
				  (VERSION_NO,PRO_ORDER_NO,
				   PLAN_GROUP_ID,
				   ORDER_SOURCE,
				   ORD_LN_DLY_PK,
				   PLN_DIVIDE_ID,
				   ORDER_NO,
				   ORDER_SEQ,
				   DELIVERY_NO,
				   INDEX_SEQ,
				   BOM,
				   BACKLOG_SEQ,
				   STEELCODE,
				   STEELNAME,
				   OUTWL_ID,
				   OUTDIAMETER,
				   WALLTHICK,
				   AIMWALLTHICK,
				   LENGTHMAX,
				   LENGTHMIN,
				   AIMLENGTH,
				   INWL_ID,
				   OUTDIAMETER_IN,
				   WALLTHICK_IN,
				   LENGTHMAX_IN,
				   LENGTHMIN_IN,
				   GETRATE,
				   BJ_TYPE,
				   ORDERWEIGHT,
				   ORDERNUM,
				   MATCH_WT,
				   MATCH_NUM,
				   REQ_PROD_WT,
				   REQ_PROD_NUM,
				   PROD_END_DATE,
				   ORDERSTATUS,
				   ISENDGX,
				   NEXT_GX,
				   IF_MONITOR_BJ,
				   PRDCR_NO,
				   CRAFT_FILE_NO,
				   CRAFT_FILE_MAN,
				   CREATE_NAME,
				   CREATE_TIME,
				   CRAFT_SEQ,
				   PLINE_CODE,
				   PLINE_NAME,
				   PROCESS_CODE_C,
				   PROCESS_DESC_C,
				   STATION_ROAD,
				   ROLL_MONTH,
				   INWL_DESC,
				   OUTWL_DESC,
				   MONITOR_POINT,
				   PREVIOUS_GX,
				   PREVIOUS_GX_CODE,
				   IN_WEIGHT,
				   IN_NUM,ADD_WT_IN,ADD_NUM_IN)
				  SELECT '#VERSION_NO#','#PRO_ORDER_NO#',
				         (A.ORDER_NO || '/' || A.ORDER_SEQ || '/' || A.DELIVERY_NO || '/' ||
				         B.PLN_DIVIDE_ID || '/' || '01'),
				         B.ORDER_SOURCE,
				         B.ORD_LN_DLY_PK,
				         B.PLN_DIVIDE_ID,
				         A.ORDER_NO,
				         A.ORDER_SEQ,
				         A.DELIVERY_NO,
				         B.INDEX_SEQ,
				         B.BOM,
				         '#BACKLOG_SEQ#',
				         A.STEELCODE,
				         A.STEELNAME,
				         '#OUTWL_ID#',
				         A.OUTDIAMETER,
				         A.WALLTHICK,
				         B.AIM_WALLTHICK,
				         (A.LENGTHMAX - NVL((J.LENGTH_JG / 1000), 0) +
				         NVL((L.INSPECTION_VALUE / 1000), 0)),
				         (A.LENGTHMIN - NVL((J.LENGTH_JG / 1000), 0) +
				         NVL((L.INSPECTION_VALUE / 1000), 0)),
				         (B.AIM_LEN_END - NVL((J.LENGTH_JG / 1000), 0) +
				         NVL((L.INSPECTION_VALUE / 1000), 0)),
				         '#INWL_ID#',
				         '#OUTDIAMETER_IN#',
				         '#WALLTHICK_IN#',
				         '#LENGTHMAX_IN#',
				         '#LENGTHMIN_IN#',
				         '#GETRATE#',
				         B.BJ_TYPE,
				         '#ORDERWEIGHT#',
				         '#ORDERNUM#',
				         NULL,
				         NULL,
				         NULL,
				         NULL,
				         NULL,
				         '1',
				         '#ISENDGX#',
				         '#NEXT_GX#',
				         '#IF_MONITOR_BJ#',
				         A.PRDCR_NO,
				         B.CRAFT_FILE_NO,
				         B.CRAFT_FILE_MAN,
				         '#CREATE_NAME#',
				         SYSDATE,
				         B.CRAFT_SEQ,
				         '#PLINE_CODE#',
				         '#PLINE_NAME#',
				         '#PROCESS_CODE_C#',
				         '#PROCESS_DESC_C#',
				         '#STATION_ROAD#',
				         B.ROLL_MONTH,
				         '#INWL_DESC#',
				         '#OUTWL_DESC#',
				         '#MONITOR_POINT#',
				         '#PREVIOUS_GX#',
				         '#PREVIOUS_GX_CODE#',
				         '#IN_WEIGHT#',
				         '#IN_NUM#','#ADD_WT_IN#','#ADD_NUM_IN#'
				    FROM PLN_SALEORD A
				    LEFT JOIN SLM_ORDER_LINE L
				      ON L.ORD_LN_PK = A.ORD_LN_PK
				     AND L.VALIDFLAG = '1'
				    LEFT JOIN COM_MSC_JG J
				      ON J.CODE_JG = A.CODE_JG
				     AND J.VALIDFLAG = '1', PLN_SALEORD_PROC B
				   WHERE A.ORD_LN_DLY_PK = B.ORD_LN_DLY_PK
				     AND B.ORD_LN_DLY_PK = '#ORD_LN_DLY_PK#'
				     AND B.PLN_DIVIDE_ID = '#PLN_DIVIDE_ID#'
		]]>
	</query>

	<query id="CorePlnProcessOrd.addPlnOrderZg" desc="新增轧管工序">
		<![CDATA[
			INSERT INTO PLN_ORDER_ZG
				  (VERSION_NO,PRO_ORDER_NO,
				   PLAN_GROUP_ID,
				   ORDER_SOURCE,
				   ORD_LN_DLY_PK,
				   PLN_DIVIDE_ID,
				   ORDER_NO,
				   ORDER_SEQ,
				   DELIVERY_NO,
				   INDEX_SEQ,
				   BOM,
				   BACKLOG_SEQ,
				   STEELCODE,
				   STEELNAME,
				   OUTDIAMETER,
				   WALLTHICK,
				   AIMWALLTHICK,
				   LENGTHMAX,
				   LENGTHMIN,
				   AIMLENGTH,
				   OUTWL_ID,
				   ROLL_LENGTH,
				   LENGTH_GP,
				   DIAMETER_GP,
				   INWL_GP,
				   GETRATE,
				   PLINE_CODE,
				   PLINE_NAME,
				   ORDERWEIGHT,
				   ORDERNUM,
				   MATCH_WT,
				   MATCH_NUM,
				   IFBUYPLAN,
				   REQ_PROD_WT,
				   REQ_PROD_NUM,
				   PROD_END_DATE,
				   ORDERSTATUS,
				   ISENDGX,
				   NEXT_GX,
				   IF_MONITOR_ZG,
				   PRDCR_NO,
				   CRAFT_FILE_NO,
				   CRAFT_FILE_MAN,
				   CREATE_NAME,
				   CREATE_TIME,
				   CRAFT_SEQ,
				   GO_TYPE,
				   PROCESS_CODE_C,
				   PROCESS_DESC_C,
				   STATION_ROAD,
				   CRAFT_NO_V,
				   BUYER_NAME,
				   FINAL_USER_DESC,
				   ORDER_ADD_DESC,
				   PASS_CODE,
				   PASS_NAME,
				   IN_WT,
				   IN_NUM,ADD_WT_IN,ADD_NUM_IN,OUTNUM_SINGLE,WEIGHT_GP_ONE,OUT_LENGTH)
				  SELECT '#VERSION_NO#','#PRO_ORDER_NO#',
				         (A.ORDER_NO || '/' || A.ORDER_SEQ || '/' || A.DELIVERY_NO || '/' ||
				         B.PLN_DIVIDE_ID || '/' || '01'),
				         B.ORDER_SOURCE,
				         B.ORD_LN_DLY_PK,
				         B.PLN_DIVIDE_ID,
				         A.ORDER_NO,
				         A.ORDER_SEQ,
				         A.DELIVERY_NO,
				         B.INDEX_SEQ,
				         B.BOM,
				         '#BACKLOG_SEQ#',
				         A.STEELCODE,
				         A.STEELNAME,
				         '#OUTDIAMETER#',
				         '#WALLTHICK#',
				         '#AIMWALLTHICK#',
				         '#LENGTHMAX#',
				         '#LENGTHMIN#',
				         '#AIMLENGTH#',
				         '#OUTWL_ID#',
				         '#ROLL_LENGTH#',
				         '#LENGTH_GP#',
				         '#DIAMETER_GP#',
				         '#INWL_GP#',
				         '#GETRATE#',
				         '#PLINE_CODE#',
				         '#PLINE_NAME#',
				         '#ORDERWEIGHT#',
				         '#ORDERNUM#',
				         NULL,
				         NULL,
				         '#IFBUYPLAN#',
				         NULL,
				         NULL,
				         NULL,
				         '1',
				         '#ISENDGX#',
				         '#NEXT_GX#',
				         '#IF_MONITOR_ZG#',
				         A.PRDCR_NO,
				         B.CRAFT_FILE_NO,
				         B.CRAFT_FILE_MAN,
				         '#CREATE_NAME#',
				         SYSDATE,
				         B.CRAFT_SEQ,
				         B.ABC,
				         '#PROCESS_CODE_C#',
				         '#PROCESS_DESC_C#',
				         '#STATION_ROAD#',
				         B.CRAFT_NO_V,
				         A.BUYER_NAME,
				         A.FINAL_USER_DESC,
				         '#ORDER_ADD_DESC#',
				         '#PASS_CODE#',
				         '#PASS_NAME#',
				         '#IN_WT#',
				         '#IN_NUM#','#ADD_WT_IN#','#ADD_NUM_IN#','#OUTNUM_SINGLE#'
				         ,'#WEIGHT_GP_ONE#','#OUT_LENGTH#'
				    FROM PLN_SALEORD A, PLN_SALEORD_PROC B
				   WHERE A.ORD_LN_DLY_PK = B.ORD_LN_DLY_PK
				     AND B.ORD_LN_DLY_PK = '#ORD_LN_DLY_PK#'
				     AND B.PLN_DIVIDE_ID = '#PLN_DIVIDE_ID#'
		]]>
	</query>


	<query id="CorePlnProcessOrd.queryPlnPassCode" desc="查询孔型">
		<![CDATA[
			SELECT T.PASS_CODE, T.PASS_NAME
			  FROM COM_MSC_PLINE_R_SPEC T
			 WHERE VALIDFLAG='1' and ? BETWEEN T.MIN_D AND T.MAX_D
			   AND ? BETWEEN T.MIN_H AND T.MAX_H
			   AND T.PLINE_CODE = ?
			   and to_number(t.SPEC_NAME) = ?
		]]>
	</query>

	<query id="CorePlnProcessOrd.queryJudgePassCode" desc="验证孔型计划">
		<![CDATA[
			SELECT  t.PASSM_PLAN_ID,t.PRO_MONTH,t.PLINE_CODE,T.PLINE_NAME,T.PASS_CODE,T.PASS_NAME
            from PLN_PASSMODEL t where T.PLINE_CODE= ? and T.PASS_CODE=? 
            and T.PRO_MONTH=(select ROLL_MONTH FROM PLN_SALEORD_PROC p WHERE P.ORD_LN_DLY_PK=? AND P.PLN_DIVIDE_ID=?) 
		]]>
	</query>

	<query id="CorePlnProcessOrd.queryProcOrdStationDesc" 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 = ?
			   AND T.PROCESS_CODE = ?
		]]>
	</query>

	<query id="CorePlnProcessOrd.queryProcOrdLineAddAsk" desc="查询附加要求">
		<![CDATA[
			SELECT REPLACE(TO_CHAR(WM_CONCAT(T.ASK_SUB_ITME_DESC || ':' ||
			                                 T.ASK_SUB_ITME_VAL_DESC)),
			               ',',
			               CHR(10)) ADD_ASK
			  FROM SLM_ORDER_ADD_ASK T
			WHERE T.ADD_ASK_NO = ?
		]]>
	</query>

	<query id="CorePlnProcessOrd.getZgReqOrderNo" desc="获取轧管工序补量合同合同号">
		<![CDATA[
			SELECT 'ZG_' || TO_CHAR(SYSDATE, 'YYYYMMDD') ||
	                LPAD(NVL(MAX(TO_NUMBER(SUBSTR(T.PRO_ORDER_NO, 12)) + 1),
	                         '1'),
	                     4,
	                     '0') ORDER_NO
	           FROM PLN_ORDER_ZG T
	          WHERE SUBSTR(T.PRO_ORDER_NO, 4, 8) = TO_CHAR(SYSDATE, 'YYYYMMDD')
		]]>
	</query>

	<query id="CorePlnProcessOrd.getDbkReqOrderNo" desc="获取镦拔扩工序补量合同合同号">
		<![CDATA[
			SELECT 'DBK' || TO_CHAR(SYSDATE, 'YYYYMMDD') ||
		                         LPAD(NVL(MAX(TO_NUMBER(SUBSTR(T.PRO_ORDER_NO, 12)) + 1),
		                                  '1'),
		                              4,
		                              '0') ORDER_NO
		                    FROM PLN_ORDER_DBK T
		                   WHERE SUBSTR(T.PRO_ORDER_NO, 4, 8) = TO_CHAR(SYSDATE, 'YYYYMMDD')
		]]>
	</query>

	<query id="CorePlnProcessOrd.getRclReqOrderNo" desc="获取热处理工序补量合同合同号">
		<![CDATA[
			SELECT 'RCL' || TO_CHAR(SYSDATE, 'YYYYMMDD') ||
				                 LPAD(NVL(MAX(TO_NUMBER(SUBSTR(T.PRO_ORDER_NO, 12)) + 1),
				                          '1'),
				                      4,
				                      '0') ORDER_NO
				            FROM PLN_ORDER_RCL T
				           WHERE SUBSTR(T.PRO_ORDER_NO, 4, 8) = TO_CHAR(SYSDATE, 'YYYYMMDD')
		]]>
	</query>

	<query id="CorePlnProcessOrd.getJgxReqOrderNo" desc="获取热处理工序补量合同合同号">
		<![CDATA[
			SELECT 'JGX' || TO_CHAR(SYSDATE, 'YYYYMMDD') ||
		                         LPAD(NVL(MAX(TO_NUMBER(SUBSTR(T.PRO_ORDER_NO, 12)) + 1),
		                                  '1'),
		                              4,
		                              '0') ORDER_NO
		                    FROM PLN_ORDER_JGX T
		                   WHERE SUBSTR(T.PRO_ORDER_NO, 4, 8) = TO_CHAR(SYSDATE, 'YYYYMMDD')
		]]>
	</query>

	<query id="CorePlnProcessOrd.updateJgxOrdGxMNo" desc="更新工序合同订单编号">
		<![CDATA[
			UPDATE PLN_ORDER_JGX T SET T.PRO_PLAN_ID = ? WHERE T.PRO_ORDER_NO = ?
		]]>
	</query>

	<query id="CorePlnProcessOrd.selectJgxDlyDividePro" desc="查询排产记录的 加工工序合同">
		<![CDATA[
			SELECT T.PRO_ORDER_NO FROM PLN_ORDER_JGX T WHERE T.ORD_LN_DLY_PK = ? AND T.PLN_DIVIDE_ID = ?
		]]>
	</query>

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


	<query id="CorePlnProcessOrd.updateRclOrdGxMNo" desc="更新工序合同订单编号">
		<![CDATA[
			UPDATE PLN_ORDER_RCL T SET T.PRO_PLAN_ID = ? WHERE T.PRO_ORDER_NO = ?
		]]>
	</query>

	<query id="CorePlnProcessOrd.selectRclDlyDividePro" desc="查询排产记录的 热处理工序合同">
		<![CDATA[
			SELECT T.PRO_ORDER_NO FROM PLN_ORDER_RCL T WHERE T.ORD_LN_DLY_PK = ? AND T.PLN_DIVIDE_ID = ?
		]]>
	</query>

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


	<query id="CorePlnProcessOrd.updateDbkOrdGxMNo" desc="更新工序合同订单编号">
		<![CDATA[
			UPDATE PLN_ORDER_DBK T SET T.PRO_PLAN_ID = ? WHERE T.PRO_ORDER_NO = ?
		]]>
	</query>

	<query id="CorePlnProcessOrd.selectDbkDlyDividePro" desc="查询排产记录的 镦拔扩工序合同">
		<![CDATA[
			SELECT T.PRO_ORDER_NO FROM PLN_ORDER_DBK T WHERE T.ORD_LN_DLY_PK = ? AND T.PLN_DIVIDE_ID = ?
		]]>
	</query>

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


	<query id="CorePlnProcessOrd.updateZgOrdGxMNo" desc="更新工序合同订单编号">
		<![CDATA[
			UPDATE PLN_ORDER_ZG T SET T.PRO_PLAN_ID = ? WHERE T.PRO_ORDER_NO = ?
		]]>
	</query>

	<query id="CorePlnProcessOrd.selectZgDlyDividePro" desc="查询排产记录的 镦拔扩工序合同">
		<![CDATA[
			SELECT T.PRO_ORDER_NO
 			FROM PLN_ORDER_ZG T WHERE T.ORD_LN_DLY_PK = ? AND T.PLN_DIVIDE_ID = ?
		]]>
	</query>

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


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

	<query id="CorePlnProcessOrd.deletePlnOrderZg1" desc="删除工序合同">
		<![CDATA[
			DELETE FROM PLN_ORDER_ZG T WHERE T.PRO_PLAN_ID = ? and GX_PLAN_NO = ?
		]]>
	</query>

	<query id="CorePlnProcessOrd.getPlnSaleordEntityById" desc="查询工序合同">
		<![CDATA[
			 SELECT 
       T.ORD_LN_DLY_PK,
       T.PLN_DIVIDE_ID,
       T.ORDER_SOURCE,
       T.ORDER_NO,
       T.ORDER_SEQ,
       T.DELIVERY_NO,
       T.R_NUM_ID,
       T.PSC,
       T.CRAFT_FILE_NO,
       T.CRAFT_FILE_MAN,
       T.MSC,
       T.INDEX_SEQ,
       T.PROCESS_SEQ,
       T.BOM,
       T.GRADECODE_ALL,
       T.GRADECODE,
       T.G_IS_OK,
       T.GROUP_JGX,
       T.F_IS_OK,
       T.GROUP_RCL,
       T.GROUP_ROLL_ALL,
       T.GROUP_ROLL,
       T.BJ_TYPE,
       T.E_IN_MATERIAL_NO,
       T.E_IN_MATERIAL_DESC,
       T.DIMATER_YLG,
       T.HEIGHT_YLG,
       T.MATERIAL_NO,
       T.MATERIAL_DESC,
       T.STUFF_PROPERTY,
       T.GRADECODE_IS_OK,
       T.D_IS_OK,
       T.E_IS_OK,
       T.WEIGHT_PER_M,
       T.PLAN_WT_D,
       T.PLAN_NUM_D,
       T.PLAN_TOT_LEN_D,
       T.FINISH_WT,
       T.IF_CHANGE,
       T.PLAN_WT_BEGIN,
       T.PLAN_NUM_BEGIN,
       T.PLANSTATUS,
       T.IF_ALLOW_ISSUE,
       TO_CHAR(T.ISSUED_TIME, 'YYYY-MM-DD HH24:MI:SS') ISSUED_TIME,
       T.ISSUED_MAN,
       T.HEIGHT_NK_MIN,
       T.HEIGHT_NK_MAX,
       T.ORDER_QTY_D,
       T.ORDER_UNIT,
       T.AIM_LEN_ROLL,
       T.AIM_LEN_END,
       T.PLAN_P_MAIN,
       T.TOT_LEN_ONE_P,
       T.CUT_NUM_P,
       T.CRAFT_SEQ,
       T.CRAFT_NO_V,
       T.AIM_WALLTHICK,
       T.ROLL_LENGTH,
       T.CRAFT_RENEW_ST,
       T.CRAFT_NO_NEW,
       T.CRAFT_NO_V_NEW,
       T.GROUP_ROLL_NAME,
       T.PLAN_IS_OK,
       T.ABC,
       T.ROLL_MONTH,
       T.PRIORITY,
       T.PRIORITY_MEMO,
       T.PRDCRPRO,
       T.LEN_ROLL_MAX,
       T.LEN_ROLL_MIN,
       T.IF_EXPORT,
       T.VERSION_NO,
       TO_CHAR(T.LAST_UNDOWN_TIME, 'YYYY-MM-DD HH24:MI:SS') LAST_UNDOWN_TIME,
       T.LAST_UNDOWN_MAN,
       (select ROLL_WELL_MONTH from PLN_SALEORD where ORD_LN_DLY_PK =T.ORD_LN_DLY_PK) ROLL_WELL_MONTH,
       (select ACCEPT_NO from PLN_SALEORD where ORD_LN_DLY_PK =T.ORD_LN_DLY_PK) ACCEPT_NO,
       decode(T.D_IS_OK,'0','1','1','1','0') IF_PASS_ZG,
       decode(T.G_IS_OK,'0','1','1','1','0') IF_PASS_JGX
 FROM PLN_SALEORD_PROC T
 WHERE
T.ORD_LN_DLY_PK = ?
AND T.PLN_DIVIDE_ID = ?
		]]>
	</query>

	<query id="CorePlnProcessOrd.getPlnSaleOrdByPk" desc="查询销售合同接收处理表">
		<![CDATA[
SELECT T.ORD_PK,
       T.ORD_LN_PK,
       T.ORD_LN_DLY_PK,
       T.ORDER_NO,
       T.ORDER_SEQ,
       T.DELIVERY_NO,
       T.PRD_CLS,
       T.PRODUCCODE,
       T.PRODUCNAME,
       T.STD_CODE,
       T.STD_NAME,
       T.STEELCODE,
       T.STEELNAME,
       T.SPEC_CODE,
       T.SPEC_NAME,
       T.OUTDIAMETER,
       T.WALLTHICK,
       T.LEN_NO,
       T.LEN_UNIT,
       T.LENGTHMAX,
       T.LENGTHMIN,
       T.LENGTHDISC,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.ORDER_UNIT,
       T.ORDER_QTY,
       T.ORDERWEIGHT,
       T.ORDERNUM,
       T.TOTLENGTH,
       T.TOTLENGTH_UNIT,
       T.DELVRY_RANGE_TPE,
       T.DELVRY_RANGE_MIN,
       T.DELVRY_RANGE_MAX,
       T.BUYER_ID,
       T.BUYER_NAME,
       T.ORDER_SPECIAL_DESC,
       T.ADD_ASK_NO,
       T.ORDER_ADD_DESC,
       T.ASK_TYPE_STATUS,
       T.ORDERFROM,
       T.FINAL_USER,
       T.FINAL_USER_DESC,
       TO_CHAR(T.DELVRY_EDATE, 'YYYY-MM-DD HH24:MI:SS') DELVRY_EDATE,
       T.ORDERCONTACT,
       T.MONITORDEMAND,
       T.SPECSTANDARD,
       T.MEMO,
       T.PRIORITY,
       T.PRIORITY_MEMO,
       T.PORDERSTATUS,
       T.PSC,
       T.MSC,
       T.CODE_JG,
       T.CODE_DJ_BL,
       T.PLANWEIGHT,
       T.PAYDOWNWEIGHT,
       T.PAYDOWN_NUM,
       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,
       T.MERGETYPE,
       T.JZ_FILE_IF_ALL,
       T.PRDCR_NO,
       T.ROLL_MONTH,
       T.ROLL_WELL_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,
       T.WEIGHT_PER_M,
       T.TOTLENGTH_M,
       T.OUTS_BILLET_FL,
       T.OUTS_STL_PIPE_FL,
       T.PIPE_PROPERTY,
       T.LEN_TOEND_MIN,
       T.LEN_TOEND_MAX,
       T.TEMP_HTCAST,
       T.CRAFT_FILE_NO,
       T.CRAFT_FILE_MAN,
       T.LENGTH_JG,
       T.WEIGH_TYPE,
       T.TRANSIT_TYP,
       T.ACCEPT_NO,
       T.JGORD_IS_OK,
       T.JGL_REQ_IS_OK,
       T.DJBL_REQ_IS_OK,
       T.STD_STYLE_DESC,
       T.HEIGHT_ORD_MIN,
       T.HEIGHT_ORD_MAX,
       T.DELVRY_QTY,
       T.CHARGE_NUM,
       T.CHARGE_WGT,
       T.CHARGE_LEN,
       T.ELIM_NUM,
       T.ELIM_WGT,
       T.ELIM_LEN,
       T.PAYDOWN_WT_MIN,
       T.PAYDOWN_WT_MAX,
       T.CRAFT_FILE_NO_IN,
       T.CRAFT_FILE_MAN_IN,
       T.CRAFT_SEQ,
       T.IF_SALE_FREEZE,
       T.CRAFT_NO_V,
       T.IS_END_DLY,
       T.IS_BACKORD,
       T.ORDER_TYPE
  FROM PLN_SALEORD T
 WHERE T.ORD_LN_DLY_PK = ?
		]]>
	</query>


	<query id="CorePlnProcessOrd.getPlnOrderJG" 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 HH24:MI:SS') DELVRY_BDATE,
       TO_CHAR(T.DELVRY_EDATE, 'YYYY-MM-DD HH24:MI:SS') DELVRY_EDATE,
       T.ORDERCONTACT,
       T.MONITORDEMAND,
       T.IF_MONITOR_JG,
       T.PRDCR_NO,
       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 HH24:MI:SS') LATEST_PROD_DATE,
       T.MATCHWEIGHT,
       T.MATCHNUM,
       T.IFBUYPLAN,
       T.BUYPLANID,
       T.BUYPLANWEIGHT,
       T.BUYPLANNUM,
       T.JGORDERSTATUS,
       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.GROUP_JGX,
       T.JGWT_BLREQ,
       TO_CHAR(T.ISSUED_TIME, 'YYYY-MM-DD HH24:MI:SS') ISSUED_TIME,
       T.SPEC_JG,
       T.SPEC_JG_DESC,
       T.MODEL_DESC,
       T.STYLE_JG,
       T.DIAMETER,
       T.CHECK_J_VAL,
       T.ORD_LN_DLY_PK,
       T.DEMAND_DETECTION,
       T.DEMAND_BONDERIZING,
       T.DEMAND_COPPER,
       T.DEMAND_BLAST,
       T.PRO_PLAN_ID,
       T.KEY_JG,
       T.JG_GROUP_ID
 FROM PLN_ORDER_JG T
 WHERE
T.ORD_LN_DLY_PK = ?
		]]>
	</query>

	<query id="CorePlnProcessOrd.getPlnGxJgM" desc="查询接箍工序订单主表">
		<![CDATA[
		 SELECT 
       T.PRO_PLAN_ID,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.PLAN_SEQ_NO,
       T.MONITORDEMAND,
       T.IF_MONITOR_JG,
       T.PRDCR_NO,
       T.CODE_JG,
       T.STEELCODE,
       T.STEELNAME,
       T.OUTDIAMETER,
       T.WALLTHICK,
       T.AIMLENGTH,
       T.SINGLEWEIGHT,
       T.SPEC_JG,
       T.SPEC_JG_DESC,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.STYLE_JG,
       T.DIAMETER,
       T.CHECK_J_VAL,
       T.ALL_CODE_BL,
       T.CODE_JG_BL,
       T.BL_WL_ID,
       T.BL_WL_DESC,
       T.MIN_D,
       T.MIN_H,
       T.BL_MIN_D_OUT,
       T.BL_MAX_D_IN,
       T.AIMLENGTH_BL,
       T.DIAMETER_PL,
       T.HEIGHT_PL,
       T.LENGTH_MIN,
       T.LENGTH_MAX,
       T.TAPER,
       T.PLAN_NUM,
       T.BL_NUM,
       T.BL_WEIGHT,
       T.ZYPLAN_NUM,
       T.PRODUCED_NUM,
       T.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.MATCHWEIGHT,
       T.MATCHNUM,
       T.IFBUYPLAN,
       T.BUYPLANID,
       T.BUYPLANWEIGHT,
       T.BUYPLANNUM,
       T.CUST_ALPHA_NO,
       T.ORDER_SPECIAL_DESC,
       T.ALPHA_CODE,
       T.JGWT_BLREQ,
       T.ALPHA_NAME
 FROM PLN_GX_JG_M T
 WHERE
T.PRO_PLAN_ID =?
		]]>
	</query>

	<query id="CorePlnProcessOrd.getPlnJgAndBlList" desc=" 查询接箍对应的备料">
		<![CDATA[
		 SELECT 
       T.JG_ORDERNO,
       T.PRO_PLAN_ID,
       T.REQ_BL_ID,
       T.CODE_JG,
       T.OUTDIAMETER,
       T.WALLTHICK,
       T.AIMLENGTH,
       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,
       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.SINGLE_ADDLEN
 FROM PLN_JG_AND_BL T
 WHERE
T.PRO_PLAN_ID = ?
		]]>
	</query>

	<query id="CorePlnProcessOrd.getBlReq" 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.OUTDIAMETER,
       T.WALLTHICK,
       T.AIMWALLTHICK,
       T.LENGTHMAX,
       T.LENGTHMIN,
       T.AIMLENGTH,
       T.CODE_DJ_BL,
       T.GETRATE_DJ,
       T.CODE_JG_BL,
       T.STD_CODE,
       T.STD_NAME,
       T.MSC,
       T.SINGLEWEIGHT,
       T.JGBL_REQ_WEIGHT,
       T.JGBL_REQ_NUM,
       T.MATCHWEIGHT,
       T.MATCHNUM,
       T.PLANSTATUS,
       T.JGCUTPLAN_WT,
       T.JGCUTPLAN_NUM,
       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.SPEC_SAME_SALE,
       T.PRDCR_NO,
       T.PRO_PLAN_ID,
       T.ORD_LN_DLY_PK,
       T.PSC
 FROM PLN_PORDER_BL_REQ T
 WHERE 1=1
		]]>
	</query>

	<query id="CorePlnProcessOrd.queryPlnMandrelIdSpec" desc="查询芯棒适用规格">
		<![CDATA[
SELECT DISTINCT T.DIAMETER_MANDREL,
       T.MANDREL_ID,
       T1.LEN_MANDREL,
       T1.SCREW_MODEL,
       T1.TAPER_MANDREL,
       T1.MASSY_OR_HOLLOW,
       NVL(T.LEN_SINGER_BILL, 0) LEN_SINGER_BILL
  FROM COM_BASE_MANDREL_SPEC T, COM_BASE_MANDREL T1
 WHERE T.MANDREL_ID = T1.MANDREL_ID
   AND T.PLINE_CODE = ?
   AND T.PASS_CODE = ?
   AND ? BETWEEN T.MIN_D AND T.MAX_D
   AND ? BETWEEN T.MIN_H AND T.MAX_H


			]]>
	</query>
	<query id="CorePlnProcessOrd.queryPlnMandrelId" desc="查询是否存在芯棒直径">
		<![CDATA[
		SELECT T.MANDREL_ID FROM COM_BASE_MANDREL T WHERE T.DIAMETER_MANDREL=?
			]]>
	</query>
	<query id="CorePlnProcessOrd.queryDesginPl" desc="查询质量设计制程">
		<![CDATA[ 
	SELECT
       (SELECT LISTAGG(C.GRADECODE, ',') WITHIN GROUP(ORDER BY C.PRIORITY ASC, C.GRADECODE)
          FROM (SELECT DISTINCT B.GRADENAME, B.GRADECODE, B.PRIORITY
                  FROM CRAFT_ORD_DESIGN_MSC_PL_GZ B,
                       CRAFT_ORD_DESIGN_MSC_PL    B1
                 WHERE B.DESGIN_KEY = B1.DESGIN_KEY
                   AND B.MSC_PLINE = B1.MSC_PLINE
                   AND B.PRIORITY >= 100
                   AND B1.DESGIN_KEY = ?
                 ORDER BY B.PRIORITY ASC, B.GRADECODE ASC) C) GRADECODE,
                 (SELECT LISTAGG(C.GRADENAME, ',') WITHIN GROUP(ORDER BY C.PRIORITY ASC, C.GRADECODE)
          FROM (SELECT DISTINCT B.GRADENAME, B.GRADECODE, B.PRIORITY
                  FROM CRAFT_ORD_DESIGN_MSC_PL_GZ B,
                       CRAFT_ORD_DESIGN_MSC_PL    B1
                 WHERE B.DESGIN_KEY = B1.DESGIN_KEY
                   AND B.MSC_PLINE = B1.MSC_PLINE
                   AND B.PRIORITY >=100
                   AND B1.DESGIN_KEY = ?
                 ORDER BY B.PRIORITY ASC, B.GRADECODE ASC) C) GRADENAME
  FROM CRAFT_ORD_DESIGN_MSC_PL T
 WHERE T.DESGIN_KEY = ?
   AND T.VALIDFLAG = '1'
		]]>
	</query>
	<query id="CorePlnProcessOrd.getGpReqinfId" desc="生成管坯需求ID">
		<![CDATA[
		  SELECT ? || TO_CHAR(SYSDATE, 'YYYYMM') ||
             LPAD(NVL(MAX(TO_NUMBER(SUBSTR(T.PRO_PLAN_ID, 11)) + 1), 1), 5, '0') PRO_PLAN_ID
        FROM PLN_GX_CAST_M T
       WHERE SUBSTR(T.GPREQ_ID, 5, 6) = TO_CHAR(SYSDATE, 'YYYYMM')
       AND T.IF_FALG='1'
		]]>
	</query>
	<query id="CorePlnProcessOrd.addPlnGxCastM" desc="新增铸造订单">
		<![CDATA[
			INSERT INTO PLN_GX_CAST_M
				  (PRO_PLAN_ID,
				   GPTYPE,
				   CASTINGTYPE,
				   PLINE_CODE_MAY,
				   PLINE_NAME_MAY,
				   GRADECODE,
				   GRADENAME,
				   DIAMETER_LZ,
				   LEN_GP_SINGLE,
				   CUT_NUM_GP,
				   CUT_LOSE_LEN,
				   LENGTH_LZ,
				   MATERIAL_NO,
				   MATERIAL_NAME,
				   CIC,
				   PIC,
				   SIC,
				   DIC,
				   WIC,
				   GIC,
				   IF_MONITOR_LG,
				   PRDCR_NO,
				   MONITOR_POINT,
				   WT_CAST_ONE,
				   PLAN_WT,
				   PLAN_NUM,
				   REQ_STATUS,
				   CREATE_NAME,
				   CREATE_TIME,PLINE_CODE,PLINE_NAME,IF_FALG)
				VALUES
				  ('#PRO_PLAN_ID#',
				   '#GPTYPE#',
				   '#CASTINGTYPE#',
				   '#PLINE_CODE_MAY#',
				   '#PLINE_NAME_MAY#',
				   '#GRADECODE#',
				   '#GRADENAME#',
				   '#DIAMETER_LZ#',
				   '#LEN_GP_SINGLE#',
				   '#CUT_NUM_GP#',
				   '#CUT_LOSE_LEN#',
				   '#LENGTH_LZ#',
				   '#MATERIAL_NO#',
				   '#MATERIAL_NAME#',
				   '#CIC#',
				   '#PIC#',
				   '#SIC#',
				   '#DIC#',
				   '#WIC#',
				   '#GIC#',
				   '#IF_MONITOR_LG#',
				   '#PRDCR_NO#',
				   '#MONITOR_POINT#',
				   '#WT_CAST_ONE#',
				   '#PLAN_WT#',
				   '#PLAN_NUM#',
				   '#REQ_STATUS#',
				   '#CREATE_NAME#',
				   SYSDATE,
				   '#PLINE_CODE#','#PLINE_NAME#','1')
		]]>
	</query>
	
	<query id="CorePlnProcessOrd.queryPlnGxCastCIC" desc="新增铸造订单">
		<![CDATA[
	SELECT T1.LENGTHDISC,
       B.GRADECODE,
       B.GRADENAME,
       CASE
         WHEN C1.CIC IS NOT NULL THEN
          C1.CIC
         WHEN (SELECT P.CIC
                 FROM CRAFT_ORD_DESIGN_MSC_PL_PRC P
                WHERE P.DESGIN_KEY = C.DESGIN_KEY
                  AND P.MSC_PLINE = T2.INDEX_SEQ
                  AND P.PROCESS_CODE = 'A') IS NULL THEN
          C1.CIC
         WHEN (SELECT P.CIC
                 FROM CRAFT_ORD_DESIGN_MSC_PL_PRC P
                WHERE P.DESGIN_KEY = C.DESGIN_KEY
                  AND P.MSC_PLINE = T2.INDEX_SEQ
                  AND P.PROCESS_CODE = 'A') IS NOT NULL THEN
          (SELECT P.CIC
             FROM CRAFT_ORD_DESIGN_MSC_PL_PRC P
            WHERE P.DESGIN_KEY = C.DESGIN_KEY
              AND P.MSC_PLINE = T2.INDEX_SEQ
              AND P.PROCESS_CODE = 'A')
       END CIC,
       C1.PIC,
       C1.SIC,
       C1.DIC,
       C1.WIC,
       C1.GIC,
       (SELECT LISTAGG(S.STATION_DESC, ',') WITHIN GROUP(ORDER BY S.STATION_CODE)
          FROM CRAFT_ORD_DESIGN_MSC_PL_STI S
         WHERE S.DESGIN_KEY = C1.DESGIN_KEY
           AND S.MSC_PLINE = C1.MSC_PLINE
           AND S.PROCESS_CODE = C1.PROCESS_CODE) STATION_ROAD
  FROM PLN_SALEORD T1
  LEFT JOIN PLN_SALEORD_PROC T2
    ON T2.ORD_LN_DLY_PK = T1.ORD_LN_DLY_PK
  LEFT JOIN COM_BASE_GRADE B
    ON B.GRADECODE = T2.GRADECODE
  LEFT JOIN CRAFT_ORD_DESIGN C
    ON C.ORD_LN_PK = T1.ORD_LN_PK
   AND C.CRAFT_SEQ = T2.CRAFT_SEQ
  LEFT JOIN CRAFT_ORD_DESIGN_MSC_PL_PRC C1
    ON C1.DESGIN_KEY = C.DESGIN_KEY
   AND C1.MSC_PLINE = T2.INDEX_SEQ
   AND C1.PROCESS_CODE = 'B'
 WHERE T1.Ord_Ln_Dly_Pk =?
 	]]>
	</query>
	<query id = "CorePlnProcessOrd.addLenZgRuleMax" desc = "查询轧管加长上限值">
		<![CDATA[
		SELECT T.LEN_LONGER_MAX
    FROM COM_BASE_MODEL_LEN T
    WHERE T.MODEL_DESC = '#MODEL_DESC#'
    AND T.JG_NUM = '#CUT_JG#'
    AND T.DIAMETER_MIN <= '#OUTDIAMETER#'
    AND T.DIAMETER_MAX >= '#OUTDIAMETER#'
    AND T.WALLTHICK_MIN <= '#WALLTHICK#'
    AND T.WALLTHICK_MAX >= '#WALLTHICK#'
    AND T.LEN_TOLERA_MIN <= (TO_NUMBER('#LENGTHMAX#') - TO_NUMBER('#LENGTHMIN#'))*1000
    AND T.LEN_TOLERA_MAX >= (TO_NUMBER('#LENGTHMAX#') - TO_NUMBER('#LENGTHMIN#'))*1000
]]>
	</query>
	<query id = "CorePlnProcessOrd.addLenZgRuleMin" desc = "查询轧管加长下限值">
		<![CDATA[
		SELECT T.LEN_LONGER_MIN
    FROM COM_BASE_MODEL_LEN T
    WHERE T.MODEL_DESC = '#MODEL_DESC#'
    AND T.JG_NUM = '#CUT_JG#'
    AND T.DIAMETER_MIN <= '#OUTDIAMETER#'
    AND T.DIAMETER_MAX >= '#OUTDIAMETER#'
    AND T.WALLTHICK_MIN <= '#WALLTHICK#'
    AND T.WALLTHICK_MAX >= '#WALLTHICK#'
    AND T.LEN_TOLERA_MIN <= (TO_NUMBER('#LENGTHMAX#') - TO_NUMBER('#LENGTHMIN#'))*1000
    AND T.LEN_TOLERA_MAX >= (TO_NUMBER('#LENGTHMAX#') - TO_NUMBER('#LENGTHMIN#'))*1000
]]>
	</query>
</queryMap>