<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="接箍订单利接箍料，炉次作业计划">

	<query id="CoreJgMPlnZy.getJgPine" desc="查询接箍产线">
		<![CDATA[
			SELECT T.PLINE_CODE, T.PLINE_NAME
			  FROM COM_BASE_PLINE T
			 WHERE T.VALIDFLAG = '1'
			   AND T.PROCESS_CODE = 'H'
		]]>
	</query>
	
	<query id="CoreJgMPlnZy.queryJgGxMNo" desc="查询工序订单订单号">
		<![CDATA[
			SELECT T.PRO_PLAN_ID FROM PLN_GX_JG_M T WHERE T.PLANSTATUS = '0'
		]]>
	</query>

	<query id="CoreJgMPlnZy.getPlnGxJgMStatus" desc="查询接箍工序订单">
		<![CDATA[
			SELECT T.CODE_JG,
			       T.PLINE_CODE,
			       T.CODE_JG_BL,
			       T.PLANSTATUS,
			       T.AIMLENGTH,
			       TO_NUMBER(M.LENGTH_JG) LENGTH_JG,
			       T1.GROUP_STATUS,
			       T1.GROUP_NUM,
			       T1.DEMAND_DETECTION,
			       T1.DEMAND_BONDERIZING,
			       T1.DEMAND_COPPER,
			       T1.DEMAND_BLAST,
			       T1.MATCHWT_BL,
			       T1.MATCHNUM_BL,
			       T1.BATCHED_WT,
			       T1.BATCHED_NUM,
			       NVL(T1.MATCHNUM_JG, 0) MATCHNUM_JG
			  FROM PLN_GX_JG_M T
			  LEFT JOIN COM_MSC_JG M
			    ON M.CODE_JG = T.CODE_JG, PLN_GX_JG_PROP T1
			 WHERE T1.PRO_PLAN_ID = T.PRO_PLAN_ID
			   AND T.PRO_PLAN_ID = ?
			   AND T1.JG_GROUP_ID = ?
		]]>
	</query>

	<query id="CoreJgMPlnZy.getPlnJgMBlCode" desc="查询接箍码对应备料码">
		<![CDATA[
			SELECT T.PSC_BL, T.KEY_JG
			  FROM COM_MSC_JG_R_BL T
			 WHERE T.CODE_JG = ?
			   AND T.CUST_ALPHA_NO = ?
			   AND T.ALPHA_CODE = ?
			   AND T.VALIDFLAG = '1'
		]]>
	</query>

	<query id="CoreJgMPlnZy.getPlnJgMPine" desc="查询接箍订单产线">
		<![CDATA[
			SELECT T.PLINE_CODE, T.PLINE_NAME
			  FROM SLM_BASE_MATERIAL_H_PL T
			 WHERE (T.DISABLE_FL != '1' OR T.DISABLE_FL IS NULL)
			   AND T.IN_MATERIAL_NO = ?
			   AND T.OUT_MATERIAL_NO = ?
		]]>
	</query>

	<query id="CoreJgMPlnZy.queryGxJgM" desc="查询接箍订单信息">
		<![CDATA[
			SELECT T.PRO_PLAN_ID,
			       T.PLINE_CODE,
			       T.PLINE_NAME,
			       T.PLAN_SEQ_NO,
			       T.MONITORDEMAND,
			       DECODE(T.IF_MONITOR_JG, '1', '是', '否') 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,
			       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = T.STYLE_JG) STYLE_JG,
			       H.BASENAME STYLE_JG_DESC,
			       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.ALPHA_NAME,
			       A.STD_NAME,
			       A.STD_STYLE_DESC,
			       (SELECT REPLACE(WM_CONCAT(A.STEELCODE_JG_DESC), ',', ';')
			          FROM COM_MSC_JG_R_STEEL N
			         WHERE N.STEELCODE = A.STEELCODE_JG) REP_STEELNAME,
			       A.MIN_D_JG,
			       A.MAX_D_JG,
			       A.PRODUCCODE_JG,
			       C.BASENAME PRODUCCODE_JG_DESC,
			       A.STEELCODE_JG,
			       D.STEELNAME STEELCODE_JG_DESC,
			       A.PRODUCCODE,
			       G.PRODUCNAME,
			       A.DIAMETER_JG,
			       A.LENGTH_JG,
			       A.HEIGHT_JG,
			       A.WEIGHT_JG,
			       A.MIN_H_CP,
			       A.MAX_H_CP,
			       A.MIN_D_CP,
			       A.MAX_D_CP,
			       A.ALPHA,
			       T.PLAN_NUM,
			       T.BL_NUM,
			       T.BL_WEIGHT,
			       T.ZYPLAN_NUM,
			       T.PRODUCED_NUM,
			       T.CUST_ALPHA_NO,
			       T.ORDER_SPECIAL_DESC,
			       T.ALPHA_CODE,
			       DECODE(T.PLANSTATUS,
			              '0',
			              '计划',
			              '1',
			              '下发',
			              '2',
			              '生产中',
			              '3',
			              '生产完成',
			              '4',
			              '取消') 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,
			       NVL(T.MATCHNUM, 0) MATCHNUM,
			       DECODE(T.IFBUYPLAN, '1', '是', '否') IFBUYPLAN,
			       T.BUYPLANID,
			       NVL(T.BUYPLANNUM, 0) BUYPLANNUM,
			       NVL(T.JGWT_BLREQ, 0) JGWT_BLREQ
			  FROM PLN_GX_JG_M T
			  LEFT JOIN COM_MSC_JG A
			    ON T.CODE_JG = A.CODE_JG
			  LEFT JOIN COM_BASE_INFO C
			    ON C.BASECODE = A.PRODUCCODE_JG
			  LEFT JOIN COM_BASE_STEEL D
			    ON D.STEELCODE = A.STEELCODE_JG
			  LEFT JOIN COM_BASE_PRODUCT G
			    ON G.PRODUCCODE = A.PRODUCCODE
			  LEFT JOIN COM_BASE_INFO H
			    ON H.BASECODE = A.STYLE_JG
			 WHERE T.PRO_PLAN_ID LIKE '%' || NLS_UPPER(?) || '%'
			   AND NVL(T.PLINE_CODE, '1') = NVL(?, NVL(T.PLINE_CODE, '1'))
			   AND NVL(A.SPEC_JG_DESC, '1') LIKE
			       '%' || NVL(?, NVL(A.SPEC_JG_DESC, '1')) || '%'
			   AND NVL(A.PRODUCCODE_JG_DESC, '1') LIKE
			       '%' || NVL(?, NVL(A.PRODUCCODE_JG_DESC, '1')) || '%'
			   AND NVL(A.STEELCODE_JG_DESC, '1') LIKE
			       '%' || NVL(?, NVL(A.STEELCODE_JG_DESC, '1')) || '%'
			   AND NVL(A.MODEL_DESC, '1') LIKE
			       '%' || NVL(?, NVL(A.MODEL_DESC, '1')) || '%'
			   AND T.PLANSTATUS < '3'
		]]>
	</query>
	
	<query id="CoreJgMPlnZy.queryPlnZyJg" desc="查询接箍作业炉次计划">
		<![CDATA[
			SELECT T.HEAT_PLAN_NO,
			       T.PRO_PLAN_ID,
			       T.JG_GROUP_ID,
			       T.JUDGE_STOVE_NO,
			       T.BATCH_NO,
			       T.BATCH_GROUD_NO,
			       T.PLINE_CODE,
			       T.PLINE_NAME,
			       T.CODE_JG_BL,
			       T.BL_WL_ID,
			       T.BL_WL_DESC,
			       T.STEELCODE,
			       T.STEELNAME,
			       T.GRADECODE,
			       T.GRADENAME,
			       T.MIN_D,
			       T.MIN_H,
			       T.AIMLENGTH_BL,
			       T.AIM_CUT_LEN,
			       T.LENGTH_MIN,
			       T.LENGTH_MAX,
			       T.TAPER,
			       T.CODE_JG,
			       T.MODEL_CODE,
			       T.MODEL_DESC,
			       T.OUTDIAMETER,
			       T.WALLTHICK,
			       T.SPEC_JG,
			       T.SPEC_JG_DESC,
			       T.STYLE_JG,
			       T.DIAMETER,
			       T.CHECK_J_VAL,
			       T.AIMLENGTH,
			       T.SINGLEWEIGHT,
			       T.COAT_TYPE,
			       T.PLAN_JG_NUM,
			       T.PLAN_BL_NUM,
			       T.PLAN_BL_WT,
			       T.USE_BL_NUM,
			       T.USE_BL_WT,
			       T.MONITORDEMAND,
			       DECODE(T.IF_MONITOR_JG, '1', '是', '否') IF_MONITOR_JG,
			       T.PRDCR_NO,
			       T.CUT_MACH_GRP_NO,
			       T.CUT_MACH_GRP_NM,
			       T.PLAN_CUT_NUM,
			       T.CUT_OK_NUM,
			       T.CUT_FAIL_NUM,
			       DECODE(T.IF_NEED_CJG, '1', '是', '否') IF_NEED_CJG,
			       T.CJG_DEPT,
			       T.PLAN_CJG_NUM,
			       T.CJG_OK_NUM,
			       T.DEMAND_COPPER,
			       DECODE(T.IF_IMPRESS, '1', '是', '否') IF_IMPRESS,
			       T.IMPRESS_DEPT,
			       T.PLAN_IMPRESS_NUM,
			       T.IMPRESS_OK_NUM,
			       T.LATHE_GRP_NO,
			       T.LATHE_GRP_NM,
			       T.PLAN_LATHE_NUM,
			       T.PLAN_LTH_USETIME,
			       T.LATHE_OK_NUM,
			       T.LATHE_FAIL_NUM,
			       T.THREAD_CHK_OK_NUM,
			       T.THREAD_CHK_FAIL_NUM,
			       T.DEMAND_DETECTION,
			       T.DETECT_DEPT,
			       T.PLAN_DETECT_NUM,
			       T.DETECT_OK_NUM,
			       T.DETECT_FAIL_NUM,
			       DECODE(T.IF_BLAST, '1', '是', '否') IF_BLAST,
			       T.DEMAND_BLAST,
			       T.BLAST_DEPT,
			       T.PLAN_BLAST_NUM,
			       T.BLAST_OK_NUM,
			       T.SPOT_CHK_OK_NUM,
			       T.SPOT_CHK_FAIL_NUM,
			       T.DEMAND_BONDERIZING,
			       DECODE(T.IF_PLATE_CU, '1', '是', '否') IF_PLATE_CU,
			       T.PLT_CU_DEPT,
			       T.PLAN_PLTCU_NUM,
			       T.PLT_CU_OK_NUM,
			       DECODE(T.IF_PHOSPHATING, '1', '是', '否') IF_PHOSPHATING,
			       T.PHOS_DEPT,
			       T.PLAN_PHOS_NUM,
			       T.PHOS_OK_NUM,
			       DECODE(T.IF_COPPER, '1', '是', '否') IF_COPPER,
			       T.COPPER_DEPT,
			       T.PLAN_COPPER_NUM,
			       T.COPPER_OK_NUM,
			       T.JUDGE_OK_NUM,
			       T.JUDGE_FAIL_NUM,
			       T.JUDGE_STATUS,
			       T.INSTORE_NUM,
			       T.INSTORE_STATUS,
			       DECODE(T.ZY_PLAN_STATUS,
			              '0',
			              '计划',
			              '1',
			              '下发',
			              '2',
			              '生产中',
			              '3',
			              '生产完成',
			              '4',
			              '交库完成',
			              '5',
			              '取消') ZY_PLAN_STATUS,
			       T.MEMO,
			       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.CUST_ALPHA_NO,
			       T.ORDER_SPECIAL_DESC,
			       T.ALPHA_CODE
			  FROM PLN_ZY_JG T
			 WHERE T.PRO_PLAN_ID = ?
			   AND T.JG_GROUP_ID = ?
			 
		]]>
	</query>
	
	<query id="CoreJgMPlnZy.updateJgMBlPl" desc="更新接箍订单备料产线">
		<![CDATA[
			UPDATE PLN_GX_JG_M T
			   SET T.CODE_JG_BL = ?,
			       T.BL_WL_ID   = ?,
			       T.BL_WL_DESC = ?,
			       T.PLINE_CODE = ?,
			       T.PLINE_NAME = ?
			 WHERE T.PRO_PLAN_ID = ?
		]]>
	</query>
	
	
	<query id="CoreJgMPlnZy.getJgMBlReq" desc="获取接箍订单备料需求号">
		<![CDATA[
			SELECT T.REQ_BL_ID, T.CODE_JG_BL
			  FROM PLN_JG_AND_BL T
			 WHERE T.PRO_PLAN_ID = ?
		]]>
	</query>
	
	<query id="CoreJgMPlnZy.queryBaseSort" desc="查询基础信息维护表">
		<![CDATA[
			SELECT T.BASECODE, T.BASENAME
			  FROM COM_BASE_INFO T
			 WHERE T.SORTCODE = ?
			   AND T.VALIDFLAG = '1'
		]]>
	</query>
	
	<query id="CoreJgMPlnZy.queryPlnPropLenSum" desc="查询订单分组已经出库的长度">
		<![CDATA[
			SELECT SUM(DECODE(T.ACT_LEN,
			                  NULL,
			                  (T.ACT_LEN_MIN + T.ACT_LEN_MAX) / 2,
			                  0,
			                  (T.ACT_LEN_MIN + T.ACT_LEN_MAX) / 2,
			                  T.ACT_LEN)) PROP_LEN_SUM
			  FROM MAT_ZC_M T
			 WHERE T.PRO_ORDER_ID = ?
			   AND T.GX_PLAN_NO = ?
		]]>
	</query>
	
	<query id="CoreJgMPlnZy.selectJgMStoverBatch" desc="查询接箍订单接箍料炉批">
		<![CDATA[
			SELECT T.JUDGE_STOVE_NO,
			       T.BATCH_NO,
			       T.BATCH_GROUD_NO,
			       COUNT(*) MAT_NUM,
			       0 CHECKED_NUM,
			       MAX(T.MATERIAL_NAME) MATERIAL_NAME,
			       MAX(T.PRODUCNAME) PRODUCNAME,
			       MAX(T.STEELNAME) STEELNAME,
			       MAX(T.GRADENAME) GRADENAME,
			       MAX(T.SPEC_NAME) SPEC_NAME,
			       MAX(T.MODEL_DESC) MODEL_DESC,
			       MAX(T.STD_NAME) STD_NAME,
			       MAX(T.STD_STYLE_DESC) STD_STYLE_DESC,
			       MAX(DECODE(T.ACT_LEN,
			                  NULL,
			                  (T.ACT_LEN_MIN + T.ACT_LEN_MAX) / 2,
			                  0,
			                  (T.ACT_LEN_MIN + T.ACT_LEN_MAX) / 2,
			                  T.ACT_LEN)) ACT_LEN,
			       MAX(T.ACT_LEN_MIN) ACT_LEN_MIN,
			       MAX(T.ACT_LEN_MAX) ACT_LEN_MAX,
			       MAX(T.ACT_WEIGHT) ACT_WEIGHT
			  FROM MAT_ZC_M        T,
			       YDM_ZC_BUTTRESS T1,
			       YDM_BS_STORAGE  T2,
			       PLN_GX_JG_M     M,
			       COM_BASE_PLINE  P,
			       COM_MSC_JG      J
			 WHERE T1.MAT_NO = T.MAT_NO
			   AND T.PRODUCT_FLAG = '801401'
			   AND T.MAT_STATUS = '80150102'
			   AND T2.STORAGE_ATTR = '800302'
			   AND T2.STORAGE_TYPE_NO = '800202'
			   AND T1.STORAGE_NO = T2.STORAGE_NO
			   AND T2.MANAGEMENT_NO = P.DEPARTMENT_CODE
			   AND P.PLINE_CODE = M.PLINE_CODE
			   AND P.VALIDFLAG = '1'
			   AND J.CODE_JG = M.CODE_JG
			   AND J.VALIDFLAG = '1'
			   AND M.PRO_PLAN_ID = ?
			   AND (T.JUDGE_STOVE_NO || T.BATCH_NO || T.BATCH_GROUD_NO) NOT IN
				       (SELECT (Z.JUDGE_STOVE_NO || Z.BATCH_NO || Z.BATCH_GROUD_NO)
				          FROM PLN_ZY_JG Z
				         WHERE Z.PRO_PLAN_ID = M.PRO_PLAN_ID
				           AND Z.JG_GROUP_ID = ?)
		]]>
	</query>
	
	<query id="CoreJgMPlnZy.selectMatZcM" desc="查询钢管生产物料主表">
		<![CDATA[
			SELECT T.MAT_NO,
			       T.PRODUCT_FLAG,
			       T.MAT_STATUS,
			       T.LOT_NO,
			       T.STOVE_NO,
			       T.JUDGE_STOVE_NO,
			       T.BATCH_NO,
			       T.BATCH_GROUD_NO,
			       T.MAT_SQE_NO,
			       T.SAMPLE_FLAG,
			       T.CUTTING_FLAG,
			       T.ORIGIN_MAT_NO,
			       T.MATERIAL_NO,
			       T.MATERIAL_NAME,
			       T.INPUT_MATERIAL_NAME,
			       T.INPUT_MATERIAL_NO,
			       T.INPUT_ORIGIN_CODE,
			       T.PRODUCCODE,
			       T.PRODUCNAME,
			       T.STEELCODE,
			       T.STEELNAME,
			       T.GRADECODE,
			       T.GRADENAME,
			       T.SPEC_CODE,
			       T.SPEC_NAME,
			       T.MODEL_CODE,
			       T.MODEL_DESC,
			       T.STD_CODE,
			       T.STD_NAME,
			       T.STD_STYLE,
			       T.STD_STYLE_DESC,
			       T.PRO_ORDER_ID,
			       T.MAT_ORIGIN_CODE,
			       T.MAT_ORIGIN_NAME,
			       T.DIMATER,
			       T.HEIGHT,
			       T.LEN_NO,
			       T.LEN_DESC,
			       T.LEN_UNIT,
			       T.LEN_MIN,
			       T.LEN_MAX,
			       T.TARG_DIMATER,
			       T.TARG_HEIGHT,
			       T.TARG_LEN_MIN,
			       T.TARG_LEN_MAX,
			       T.ACT_DIMATER,
			       T.ACT_HEIGHT,
			       DECODE(T.ACT_LEN,
			              NULL,
			              (T.ACT_LEN_MIN + T.ACT_LEN_MAX) / 2,
			              0,
			              (T.ACT_LEN_MIN + T.ACT_LEN_MAX) / 2,
			              T.ACT_LEN) ACT_LEN,
			       T.ACT_LEN_MIN,
			       T.ACT_LEN_MAX,
			       T.ACT_COUNT,
			       T.ACT_WEIGHT,
			       T.ACT_THEORY_WEIGHT,
			       DECODE(T.MEASURE_FLAG, '0', '未委托', '1', '委托') MEASURE_FLAG,
			       T.BELONG_CODE,
			       T.BELONG_NAME,
			       DECODE(T.PACK_FLAG, '1', '包装', '0', '未打包') PACK_FLAG,
			       T.PACK_TYPE_CODE,
			       T.PACK_TYPE_NAME,
			       T.PACK_NO,
			       TO_CHAR(T.PACK_TIME, 'YYYY-MM-DD HH24:MI:SS') PACK_TIME,
			       T.PACK_MAT_WT,
			       T.MAT_GROSS_WT,
			       T.MAT_GOWHERE_CODE,
			       T.MAT_GOWHERE_NAME,
			       T.CREATE_NAME,
			       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
			       T.UPDATE_NAME,
			       TO_CHAR(T.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
			       T.REQ_BL_ID,
			       T.IF_BATCHED_JG,
			       T.COUPCUT_BATCH_ID,
			       T1.STORAGE_NO,
			       T1.LOCATION_NO,
			       T1.LARY_NO,
			       T1.LOC_NO,
			       T2.STORAGE_ATTR,
			       T2.STORAGE_ATTR_NAME,
			       T2.STORAGE_TYPE_NO,
			       T2.STORAGE_TYPE_NAME,
			       T1.MANAGEMENT_NO,
			       T1.MANAGEMENT_NAME
			  FROM MAT_ZC_M        T,
			       YDM_ZC_BUTTRESS T1,
			       YDM_BS_STORAGE  T2,
			       PLN_GX_JG_M     M,
			       COM_BASE_PLINE  P,
			       COM_MSC_JG      J
			 WHERE T1.MAT_NO = T.MAT_NO
			   AND T.PRODUCT_FLAG = '801401'
			   AND T.MAT_STATUS = '80150102'
			   AND T2.STORAGE_ATTR = '800302'
			   AND T2.STORAGE_TYPE_NO = '800202'
			   AND T1.STORAGE_NO = T2.STORAGE_NO
			   AND T2.MANAGEMENT_NO = P.DEPARTMENT_CODE
			   AND P.PLINE_CODE = M.PLINE_CODE
			   AND P.VALIDFLAG = '1'
			   AND J.CODE_JG = M.CODE_JG
			   AND J.VALIDFLAG = '1'
			   AND M.PRO_PLAN_ID = ?
			   AND (T.JUDGE_STOVE_NO || T.BATCH_NO || T.BATCH_GROUD_NO) NOT IN
				       (SELECT (Z.JUDGE_STOVE_NO || Z.BATCH_NO || Z.BATCH_GROUD_NO)
				          FROM PLN_ZY_JG Z
				         WHERE Z.PRO_PLAN_ID = M.PRO_PLAN_ID
				           AND Z.JG_GROUP_ID = ?)
		]]>
	</query>
	
	
	<query id="CoreJgMPlnZy.selectJgMBatchGroupModify" desc="查询炉次计划的材料炉批组详细">
		<![CDATA[
			SELECT T.JUDGE_STOVE_NO,
			       T.BATCH_NO,
			       T.BATCH_GROUD_NO,
			       COUNT(*) MAT_NUM,
			       0 CHECKED_NUM,
			       MAX(T.MATERIAL_NAME) MATERIAL_NAME,
			       MAX(T.PRODUCNAME) PRODUCNAME,
			       MAX(T.STEELNAME) STEELNAME,
			       MAX(T.GRADENAME) GRADENAME,
			       MAX(T.SPEC_NAME) SPEC_NAME,
			       MAX(T.MODEL_DESC) MODEL_DESC,
			       MAX(T.STD_NAME) STD_NAME,
			       MAX(T.STD_STYLE_DESC) STD_STYLE_DESC,
			       MAX(DECODE(T.ACT_LEN,
			                  NULL,
			                  (T.ACT_LEN_MIN + T.ACT_LEN_MAX) / 2,
			                  0,
			                  (T.ACT_LEN_MIN + T.ACT_LEN_MAX) / 2,
			                  T.ACT_LEN)) ACT_LEN,
			       MAX(T.ACT_LEN_MIN) ACT_LEN_MIN,
			       MAX(T.ACT_LEN_MAX) ACT_LEN_MAX,
			       MAX(T.ACT_WEIGHT) ACT_WEIGHT
			  FROM MAT_ZC_M        T,
			       YDM_ZC_BUTTRESS T1,
			       YDM_BS_STORAGE  T2,
			       PLN_GX_JG_M     M,
			       COM_BASE_PLINE  P,
			       COM_MSC_JG      J,
			       PLN_ZY_JG       Z
			 WHERE T1.MAT_NO = T.MAT_NO
			   AND ((T.PRODUCT_FLAG = '801401' AND T.MAT_STATUS = '80150102') OR
			       T.COUPCUT_BATCH_ID = Z.ZY_PLAN_ID)
			   AND T2.STORAGE_ATTR = '800302'
			   AND T2.STORAGE_TYPE_NO = '800202'
			   AND T1.STORAGE_NO = T2.STORAGE_NO
			   AND T2.MANAGEMENT_NO = P.DEPARTMENT_CODE
			   AND P.PLINE_CODE = M.PLINE_CODE
			   AND P.VALIDFLAG = '1'
			   AND J.CODE_JG = M.CODE_JG
			   AND J.VALIDFLAG = '1'
			   AND M.PRO_PLAN_ID = Z.PRO_PLAN_ID
			   AND T.JUDGE_STOVE_NO = Z.JUDGE_STOVE_NO
			   AND T.BATCH_NO = Z.BATCH_NO
			   AND T.BATCH_GROUD_NO = Z.BATCH_GROUD_NO
			   AND Z.ZY_PLAN_ID = ?
		]]>
	</query>
	
	
	
	<query id="CoreJgMPlnZy.selectMatZcMStatus" desc="查询材料表">
		<![CDATA[
			SELECT T.JUDGE_STOVE_NO,
			       T.BATCH_NO,
			       T.BATCH_GROUD_NO,
			       T.MAT_NO,
			       T.PRODUCT_FLAG,
			       T.MAT_STATUS,
			       T.ACT_WEIGHT,
			       T.ACT_COUNT,
			       T.ACT_WEIGHT,
			       T.ACT_DIMATER,
			       T.ACT_HEIGHT,
			       T.ACT_LEN_MIN,
			       T.ACT_LEN_MAX,
			       DECODE(T.ACT_LEN,
			              NULL,
			              (T.ACT_LEN_MIN + T.ACT_LEN_MAX) / 2,
			              0,
			              (T.ACT_LEN_MIN + T.ACT_LEN_MAX) / 2,
			              T.ACT_LEN) ACT_LEN,
			       T2.STORAGE_ATTR,
			       T2.STORAGE_TYPE_NO
			  FROM MAT_ZC_M T, YDM_ZC_BUTTRESS T1, YDM_BS_STORAGE T2
			 WHERE T.MAT_NO = T1.MAT_NO
			   AND T1.STORAGE_NO = T2.STORAGE_NO
			   AND T.MAT_NO = ?
		]]>
	</query>
	
	<query id="CoreJgMPlnZy.getZyJgPlanId" desc="生成接箍炉作业批次号">
		<![CDATA[
			SELECT ('ZYJG' || TO_CHAR(SYSDATE, 'YYMM') ||
			       LPAD(NVL(MAX(TO_NUMBER(SUBSTR(T.ZY_PLAN_ID, 9)) + 1), 1), 5, '0')) ZY_PLAN_ID
			  FROM PLN_ZY_JG T
			 WHERE SUBSTR(T.ZY_PLAN_ID, 0, 8) = 'ZYJG' || TO_CHAR(SYSDATE, 'YYMM')
		]]>
	</query>
	
	<query id="CoreJgMPlnZy.updateMatZgM" desc="更新材料表出库">
		<![CDATA[
			UPDATE MAT_ZC_M T
			   SET T.MAT_STATUS       = '#MAT_STATUS#',
			       T.PRO_ORDER_ID     = '#PRO_ORDER_ID#',
			       T.GX_PLAN_NO       = '#GX_PLAN_NO#',
			       T.IF_BATCHED_JG    = '#IF_BATCHED_JG#',
			       T.COUPCUT_BATCH_ID = '#COUPCUT_BATCH_ID#'
			 WHERE T.MAT_NO = '#MAT_NO#'
		]]>
	</query>
	
	<query id="CoreJgMPlnZy.addPlnZyJg" desc="新增接箍炉作业批次">
		<![CDATA[
			INSERT INTO PLN_ZY_JG
				  (ZY_PLAN_ID,
				   PRO_PLAN_ID,
				   JG_GROUP_ID,
				   JUDGE_STOVE_NO,
				   BATCH_NO,
				   BATCH_GROUD_NO,
				   PLINE_CODE,
				   PLINE_NAME,
				   CODE_JG_BL,
				   BL_WL_ID,
				   BL_WL_DESC,
				   STEELCODE,
				   STEELNAME,
				   GRADECODE,
				   GRADENAME,
				   MIN_D,
				   MIN_H,
				   AIMLENGTH_BL,
				   AIM_CUT_LEN,
				   LENGTH_MIN,
				   LENGTH_MAX,
				   TAPER,
				   CODE_JG,
				   MODEL_CODE,
				   MODEL_DESC,
				   OUTDIAMETER,
				   WALLTHICK,
				   SPEC_JG,
				   SPEC_JG_DESC,
				   STYLE_JG,
				   DIAMETER,
				   CHECK_J_VAL,
				   AIMLENGTH,
				   SINGLEWEIGHT,
				   COAT_TYPE,
				   PLAN_JG_NUM,
				   PLAN_BL_NUM,
				   PLAN_BL_WT,
				   MONITORDEMAND,
				   IF_MONITOR_JG,
				   PRDCR_NO,
				   PLAN_CUT_NUM,
				   IF_NEED_CJG,
				   PLAN_CJG_NUM,
				   DEMAND_COPPER,
				   IF_IMPRESS,
				   PLAN_IMPRESS_NUM,
				   PLAN_LATHE_NUM,
				   DEMAND_DETECTION,
				   PLAN_DETECT_NUM,
				   IF_BLAST,
				   DEMAND_BLAST,
				   PLAN_BLAST_NUM,
				   DEMAND_BONDERIZING,
				   IF_PLATE_CU,
				   PLAN_PLTCU_NUM,
				   IF_PHOSPHATING,
				   PLAN_PHOS_NUM,
				   IF_COPPER,
				   PLAN_COPPER_NUM,
				   ZY_PLAN_STATUS,
				   CREATE_NAME,
				   CREATE_TIME,
				   CUST_ALPHA_NO,
				   ORDER_SPECIAL_DESC,
				   ALPHA_CODE)
				  SELECT '#ZY_PLAN_ID#',
				         P.PRO_PLAN_ID,
				         P.JG_GROUP_ID,
				         '#JUDGE_STOVE_NO#',
				         '#BATCH_NO#',
				         '#BATCH_GROUD_NO#',
				         M.PLINE_CODE,
				         M.PLINE_NAME,
				         (SELECT B.CODE_JG_BL
				            FROM PLN_PORDER_BL_REQ B
				           WHERE B.REQ_BL_ID = Z.REQ_BL_ID),
				         Z.MATERIAL_NO,
				         Z.MATERIAL_NAME,
				         Z.STEELCODE,
				         Z.STEELNAME,
				         Z.GRADECODE,
				         Z.GRADENAME,
				         Z.ACT_DIMATER,
				         Z.ACT_HEIGHT,
				         DECODE(Z.ACT_LEN,
				                NULL,
				                (Z.ACT_LEN_MIN + Z.ACT_LEN_MAX) / 2,
				                0,
				                (Z.ACT_LEN_MIN + Z.ACT_LEN_MAX) / 2,
				                Z.ACT_LEN),
				         P.AIM_CUT_LEN,
				         M.LENGTH_MIN,
				         M.LENGTH_MAX,
				         M.TAPER,
				         M.CODE_JG,
				         M.MODEL_CODE,
				         M.MODEL_DESC,
				         M.OUTDIAMETER,
				         M.WALLTHICK,
				         M.SPEC_JG,
				         M.SPEC_JG_DESC,
				         M.STYLE_JG,
				         M.DIAMETER,
				         M.CHECK_J_VAL,
				         M.AIMLENGTH,
				         M.SINGLEWEIGHT,
				         '#COAT_TYPE#',
				         '#PLAN_JG_NUM#',
				         '#PLAN_BL_NUM#',
				         '#PLAN_BL_WT#',
				         M.MONITORDEMAND,
				         M.IF_MONITOR_JG,
				         M.PRDCR_NO,
				         '#PLAN_CUT_NUM#',
				         '#IF_NEED_CJG#',
				         '#PLAN_CJG_NUM#',
				         '#DEMAND_COPPER#',
				         '#IF_IMPRESS#',
				         '#PLAN_IMPRESS_NUM#',
				         '#PLAN_LATHE_NUM#',
				         '#DEMAND_DETECTION#',
				         '#PLAN_DETECT_NUM#',
				         '#IF_BLAST#',
				         '#DEMAND_BLAST#',
				         '#PLAN_BLAST_NUM#',
				         '#DEMAND_BONDERIZING#',
				         '#IF_PLATE_CU#',
				         '#PLAN_PLTCU_NUM#',
				         '#IF_PHOSPHATING#',
				         '#PLAN_PHOS_NUM#',
				         '#IF_COPPER#',
				         '#PLAN_COPPER_NUM#',
				         '0',
				         '#CREATE_NAME#',
				         SYSDATE,
				         M.CUST_ALPHA_NO,
				         M.ORDER_SPECIAL_DESC,
				         M.ALPHA_CODE
				    FROM PLN_GX_JG_M M, PLN_GX_JG_PROP P, MAT_ZC_M Z
				   WHERE M.PRO_PLAN_ID = P.PRO_PLAN_ID
				     AND Z.MAT_NO = ?
				     AND P.PRO_PLAN_ID = ?
				     AND P.JG_GROUP_ID = ?
		]]>
	</query>
	
	<query id="CoreJgMPlnZy.udpdateGxJgPropBatch" desc="更新接箍订单分组出库">
		<![CDATA[
			UPDATE PLN_GX_JG_PROP T
			   SET T.MATCHWT_BL  = ?,
			       T.MATCHNUM_BL = ?,
			       T.BATCHED_WT  = ?,
			       T.BATCHED_NUM = ?
			 WHERE T.PRO_PLAN_ID = ?
			   AND T.JG_GROUP_ID = ?
		]]>
	</query>
	
	<query id="CoreJgMPlnZy.selectJgZyStatus" desc="查询作业工单状态">
		<![CDATA[
			SELECT T.ZY_PLAN_ID,
			       T.PRO_PLAN_ID,
			       T.JG_GROUP_ID,
			       T.JUDGE_STOVE_NO,
			       T.BATCH_NO,
			       T.BATCH_GROUD_NO,
			       T.ZY_PLAN_STATUS,
			       T.PLAN_BL_NUM
			  FROM PLN_ZY_JG T
			 WHERE T.ZY_PLAN_ID = ?
		]]>
	</query>
	
	<query id="CoreJgMPlnZy.selectJgZyMat" desc="查询作业工单材料来源">
		<![CDATA[
			SELECT T.ACT_WEIGHT, T.ACT_COUNT, T.MAT_NO, T.REQ_BL_ID
			  FROM MAT_ZC_M T
			 WHERE T.COUPCUT_BATCH_ID = ?
			   AND T.PRO_ORDER_ID = ?
			   AND T.GX_PLAN_NO = ?
		]]>
	</query>
	
	<query id="CoreJgMPlnZy.deleteZyJg" desc="删除作业工单">
		<![CDATA[
			DELETE FROM PLN_ZY_JG T WHERE T.ZY_PLAN_ID = ?
		]]>
	</query>
	
	<query id="CoreJgMPlnZy.selectGroupMatZcM" desc="查询作业分组材料">
		<![CDATA[
			SELECT T.JUDGE_STOVE_NO,
			       T.BATCH_NO,
			       T.BATCH_GROUD_NO,
			       T.MAT_NO,
			       T.PRODUCT_FLAG,
			       T.MAT_STATUS,
			       T.ACT_WEIGHT,
			       T.ACT_COUNT,
			       T.ACT_WEIGHT,
			       T.ACT_DIMATER,
			       T.ACT_HEIGHT,
			       T.ACT_LEN_MIN,
			       T.ACT_LEN_MAX,
			       DECODE(T.ACT_LEN,
			              NULL,
			              (T.ACT_LEN_MIN + T.ACT_LEN_MAX) / 2,
			              0,
			              (T.ACT_LEN_MIN + T.ACT_LEN_MAX) / 2,
			              T.ACT_LEN) ACT_LEN
			  FROM MAT_ZC_M        T,
			       YDM_ZC_BUTTRESS T1,
			       YDM_BS_STORAGE  T2,
			       PLN_GX_JG_M     M,
			       COM_BASE_PLINE  P,
			       COM_MSC_JG      J
			 WHERE T1.MAT_NO = T.MAT_NO
			   AND T.PRODUCT_FLAG = '801401'
			   AND T.MAT_STATUS = '80150102'
			   AND T2.STORAGE_ATTR = '800302'
			   AND T2.STORAGE_TYPE_NO = '800202'
			   AND T1.STORAGE_NO = T2.STORAGE_NO
			   AND T2.MANAGEMENT_NO = P.DEPARTMENT_CODE
			   AND P.PLINE_CODE = M.PLINE_CODE
			   AND P.VALIDFLAG = '1'
			   AND J.CODE_JG = M.CODE_JG
			   AND J.VALIDFLAG = '1'
			   AND M.PRO_PLAN_ID = ?
			   AND T.JUDGE_STOVE_NO = ?
			   AND T.BATCH_NO = ?
			   AND T.BATCH_GROUD_NO = ?
		]]>
	</query>
	
	<query id="CoreJgMPlnZy.addPlnZyJgReady" desc="新增接箍炉计划预排表">
		<![CDATA[
			INSERT INTO PLN_ZY_JG_READY
				  (PRO_PLAN_ID,
				   JG_GROUP_ID,
				   READY_PLAN_NO,
				   JUDGE_STOVE_NO,
				   BATCH_NO,
				   BATCH_GROUD_NO,
				   PLINE_CODE,
				   PLINE_NAME,
				   REQ_BL_ID,
				   CODE_JG_BL,
				   STEELCODE,
				   STEELNAME,
				   GRADECODE,
				   GRADENAME,
				   ACT_DIMATER,
				   ACT_HEIGHT,
				   ACT_LEN,
				   ALLOT_NUM,
				   ALLOT_WT,
				   IF_MATCH_ODD,
				   IF_DO_HEAT_PLAN,
				   CREATE_TIME)
				  SELECT P.PRO_PLAN_ID,
				         P.JG_GROUP_ID,
				         (SELECT LPAD(NVL(MAX(TO_NUMBER(R.READY_PLAN_NO) + 1), 1), 3, '0')
				            FROM PLN_ZY_JG_READY R
				           WHERE R.PRO_PLAN_ID = P.PRO_PLAN_ID
				             AND R.JG_GROUP_ID = P.JG_GROUP_ID) READY_PLAN_NO,
				         '#JUDGE_STOVE_NO#',
				         '#BATCH_NO#',
				         '#BATCH_GROUD_NO#',
				         M.PLINE_CODE,
				         M.PLINE_NAME,
				         '#REQ_BL_ID#',
				         M.CODE_JG_BL,
				         Z.STEELCODE,
				         Z.STEELNAME,
				         Z.GRADECODE,
				         Z.GRADENAME,
				         Z.ACT_DIMATER,
				         Z.ACT_HEIGHT,
				         DECODE(Z.ACT_LEN,
				                NULL,
				                (Z.ACT_LEN_MIN + Z.ACT_LEN_MAX) / 2,
				                0,
				                (Z.ACT_LEN_MIN + Z.ACT_LEN_MAX) / 2,
				                Z.ACT_LEN),
				         '#ALLOT_NUM#',
				         '#ALLOT_WT#',
				         '#IF_MATCH_ODD#',
				         '#IF_DO_HEAT_PLAN#',
				         SYSDATE
				    FROM PLN_GX_JG_M M, PLN_GX_JG_PROP P, MAT_ZC_M Z
				   WHERE M.PRO_PLAN_ID = P.PRO_PLAN_ID
				     AND Z.MAT_NO = ?
				     AND P.PRO_PLAN_ID = ?
				     AND P.JG_GROUP_ID = ?
		]]>
	</query>
	
	<query id="CoreJgMPlnZy.updatePlnZyJg" desc="查询作业分组材料">
		<![CDATA[
			UPDATE PLN_ZY_JG T
			   SET T.PLAN_JG_NUM      = '#PLAN_JG_NUM#',
			       T.PLAN_BL_NUM      = '#PLAN_BL_NUM#',
			       T.PLAN_BL_WT       = '#PLAN_BL_WT#',
			       T.PLAN_CUT_NUM     = '#PLAN_JG_NUM#',
			       T.PLAN_IMPRESS_NUM = DECODE(T.PLAN_IMPRESS_NUM,
			                                   0,
			                                   0,
			                                   NULL,
			                                   0,
			                                   '#PLAN_JG_NUM#'),
			       T.PLAN_LATHE_NUM   = '#PLAN_JG_NUM#',
			       T.PLAN_BLAST_NUM   = DECODE(T.PLAN_BLAST_NUM,
			                                   0,
			                                   0,
			                                   NULL,
			                                   0,
			                                   '#PLAN_JG_NUM#'),
			       T.PLAN_PLTCU_NUM   = DECODE(T.PLAN_PLTCU_NUM,
			                                   0,
			                                   0,
			                                   NULL,
			                                   0,
			                                   '#PLAN_JG_NUM#'),
			       T.PLAN_PHOS_NUM    = DECODE(T.PLAN_PHOS_NUM,
			                                   0,
			                                   0,
			                                   NULL,
			                                   0,
			                                   '#PLAN_JG_NUM#'),
			       T.PLAN_COPPER_NUM  = DECODE(T.PLAN_COPPER_NUM,
			                                   0,
			                                   0,
			                                   NULL,
			                                   0,
			                                   '#PLAN_JG_NUM#'),
			       T.UPDATE_NAME      = '#UPDATE_NAME#',
			       T.UPDATE_TIME      = SYSDATE
			 WHERE T.ZY_PLAN_ID = '#ZY_PLAN_ID#'
		]]>
	</query>
	
	<query id="CoreJgMPlnZy.deleteZyJgReady" desc="删除接箍炉计划预排表">
		<![CDATA[
			DELETE FROM PLN_ZY_JG_READY T
			 WHERE T.JUDGE_STOVE_NO = ?
			   AND T.BATCH_NO = ?
			   AND T.BATCH_GROUD_NO = ?
		]]>
	</query>
	
	<query id="CoreJgMPlnZy.updatePlnZyJgReady" desc="更新接箍炉计划预排表支数">
		<![CDATA[
			UPDATE PLN_ZY_JG_READY T
			   SET T.ALLOT_NUM = ?, T.ALLOT_WT = ?
			 WHERE T.JUDGE_STOVE_NO = ?
			   AND T.BATCH_NO = ?
			   AND T.BATCH_GROUD_NO = ?
		]]>
	</query>
	
	
</queryMap>