<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="接箍作业计划">
	<query id="CoreJgOperatPln.queryJglInform" desc="查询接箍备料需求">
		<![CDATA[
			SELECT * FROM PLN_PORDER_BL_REQ T WHERE T.PLANSTATUS='1' AND T.BLTYPE='接箍料'
		]]>
	</query>
	
	<query id="CoreJgOperatPln.queryBaseMaterial" desc="查询物料基础信息">
		<![CDATA[
			SELECT * FROM SLM_BASE_MATERIAL T
		]]>
	</query>
	
	<query id="CoreJgOperatPln.queryBaseSteel" desc="查询钢级 基础信息">
		<![CDATA[
			SELECT * FROM COM_BASE_STEEL T  WHERE T.VALIDFLAG='1'
		]]>
	</query>
	
	<query id="CoreJgOperatPln.queryBlRequire" desc="查询备料需求">
		<![CDATA[
			SELECT T.REQ_BL_ID,
			       T.BLTYPE,
			       T.JG_ORDERNO,
			       T.STEELCODE,
			       T.STEELNAME,
			       T.GRADECODE,
			       T.OUTDIAMETER,
			       T.WALLTHICK,
			       T.AIMWALLTHICK,
			       T.LENGTHMAX,
			       T.LENGTHMIN,
			       T.AIMLENGTH,
			       T.CODE_DJ_BL,
			       T.CODE_JG_BL,
			       T.INDEX_SEQ,
			       T.SINGLEWEIGHT,
			       T.JGBL_REQ_WEIGHT,
			       T.JGBL_REQ_NUM,
			       T.MATCHWEIGHT,
			       T.MATCHNUM,
			       DECODE(T.PLANSTATUS,
			              '0',
			              '待处理',
			              '1',
			              '已下发') PLANSTATUS,
			       T.CREATE_NAME,
			       TO_CHAR(T.CREATE_TIME,'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
			       T.UPDATE_NAME,
			       TO_CHAR(T.UPDATE_TIME,'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
			       T.STD_CODE,
			       T.STD_NAME,
			       T.MSC,
			       DECODE(T.IFNEED_RCL, '1', '是', '0', '否') IFNEED_RCL,
			       T.GROUP_RCL,
			       DECODE(T.IFNEED_BJ, '1', '是', '0', '否') IFNEED_BJ,
			       T.BJ_TYPE,
			       T.JGCUTPLAN_WT,
			       T.JGCUTPLAN_NUM
			  FROM PLN_PORDER_BL_REQ T
			 WHERE T.BLTYPE = '接箍料'
			   AND T.PLANSTATUS = '1' 
		]]>
	</query>
	
	<query id="CoreJgOperatPln.queryJgOrder" desc="根据接箍合同号查询接箍合同信息">
		<![CDATA[
			SELECT * FROM PLN_ORDER_JG T WHERE T.JG_ORDERNO = ?
		]]>
	</query>
	
	<query id="CoreJgOperatPln.queryMatzcm" desc="查询物料管库存信息">
		<![CDATA[
			SELECT T.MAT_NO,
			       T.PRODUCT_FLAG,
			       T.MAT_STATUS,
			       T.STOVE_NO,
			       T.JUDGE_STOVE_NO,
			       T.BATCH_NO,
			       T.BATCH_GROUD_NO,
			       T.MATERIAL_NO,
			       T.MATERIAL_NAME,
			       T.INPUT_MATERIAL_NAME,
			       T.INPUT_MATERIAL_NO,
			       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.ACT_DIMATER,
			       T.ACT_HEIGHT,
			       T.ACT_LEN,
			       T.ACT_LEN_MIN,
			       T.ACT_LEN_MAX,
			       T.ACT_COUNT,
			       T.ACT_WEIGHT,
			       T.ACT_THEORY_WEIGHT,
			       T.REQ_BL_ID,
			       DECODE(T.IF_BATCHED_JG, '1', '是', '0', '否') IF_BATCHED_JG,
			       T.COUPCUT_BATCH_ID,
			       T.CREATE_NAME,
			       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
			       T.MEMO
			  FROM MAT_ZC_M T
			 WHERE (T.COUPCUT_BATCH_ID = ? OR T.COUPCUT_BATCH_ID IS NULL) 
		 AND DECODE(?, NULL, '1', T.REQ_BL_ID) = DECODE(?, NULL, '1', ?)
         AND DECODE(?, NULL, '1', T.BATCH_NO) = DECODE(?, NULL, '1', ?)
         AND DECODE(?, NULL, '1', T.MATERIAL_NO) = DECODE(?, NULL, '1', ?)
         AND DECODE(?, NULL, '1', T.STOVE_NO) = DECODE(?, NULL, '1', ?)
         AND DECODE(?, NULL, '1', T.STEELCODE) = DECODE(?, NULL, '1', ?)
         AND DECODE(?, NULL, '1', T.ACT_DIMATER) = DECODE(?, NULL, '1', ?)
         AND DECODE(?, NULL, '1', T.ACT_HEIGHT) = DECODE(?, NULL, '1', ?)
		]]>
	</query>
	
	<query id="CoreJgOperatPln.queryrelation" desc="查询接箍及备料关系">
		<![CDATA[
			SELECT T.JG_ORDERNO,
			       T.REQ_BL_ID,
			       T.CODE_JG,
			       T.OUTDIAMETER,
			       T.AIMLENGTH,
			       T.WALLTHICK,
			       T.STEELCODE,
			       T.STEELNAME,
			       T.SINGLEWEIGHT,
			       T.CODE_JG_BL,
			       T.AIMLENGTH_BL,
			       T.SINGLEWEIGHT2,
			       T.JGBL_REQ_WEIGHT,
			       T.JGBL_REQ_NUM,
			       T.GETRATE,
			       T.WEIGHT_JG,
			       T.NUM_JG,
			       T.JGPLAN_NUM,
			       DECODE(T.PLANSTATUS,
			              '0',
			              '待处理',
			              '1',
			              '已下发') PLANSTATUS,
			       T.CREATE_NAME,
			       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
			       T.UPDATE_NAME,
			       TO_CHAR(T.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME
			  FROM PLN_JG_AND_BL T
			 WHERE T.REQ_BL_ID = ? 
		]]>
	</query>
	
	<query id="CoreJgOperatPln.queryJgCutByid" desc="通过作业批次号查询接箍切断计划">
		<![CDATA[
			SELECT T.COUPCUT_BATCH_ID,
             T.PLINE_CODE,
             T.PLINE_NAME,
             T.TASK_SEQ_NO,
             T.REQ_BL_ID,
             T.JUDGE_STOVE_NO,
             T.BATCH_NO,
             T.WL_ID_IN,
             T.CODE_JG_BL,
             T.STEELCODE,
             T.STEELNAME,
             T.OUTDIAMETER_BL,
             T.WALLTHICK_BL,
             T.JGBL_LENGTH,
             T.JG_LENGTH,
             T.CUT_NUM_EACH,
             T.JGBL_WEIGHT,
             T.JGBL_NUM,
             T.CUT_NUM_TOT,
             T.GROUP_CUT,
             TO_CHAR(T.PLAN_TIME,'YYYY-MM-DD HH24:MI') PLAN_TIME,
             T.PLAN_USETIME,
             T.PLANSTATUS,
             T.REAL_CUN_NUM_TOT,
             T.CREATE_NAME,
             TO_CHAR(T.CREATE_TIME,'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
             T.UPDATE_NAME,
             TO_CHAR(T.UPDATE_TIME,'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME
        FROM PLN_ZY_JG_CUT T
       WHERE T.COUPCUT_BATCH_ID = ?
		]]>
	</query>
	
	<query id="CoreJgOperatPln.queryJgCut" desc="查询接箍切断计划">
		<![CDATA[
			SELECT T.COUPCUT_BATCH_ID,
             T.PLINE_CODE,
             T.PLINE_NAME,
             T.TASK_SEQ_NO,
             T.REQ_BL_ID,
             T.JUDGE_STOVE_NO,
             T.BATCH_NO,
             T.WL_ID_IN,
             T.CODE_JG_BL,
             T.STEELCODE,
             T.STEELNAME,
             T.OUTDIAMETER_BL,
             T.WALLTHICK_BL,
             T.JGBL_LENGTH,
             T.JG_LENGTH,
             T.CUT_NUM_EACH,
             T.JGBL_WEIGHT,
             T.JGBL_NUM,
             T.CUT_NUM_TOT,
             T.GROUP_CUT,
             TO_CHAR(T.PLAN_TIME,'YYYY-MM-DD HH24:MI') PLAN_TIME,
             T.PLAN_USETIME,
             DECODE(T.PLANSTATUS,'0','计划','1','下发','2','执行','3','完成','4','取消') PLANSTATUS,
             T.REAL_CUN_NUM_TOT,
             T.CREATE_NAME,
             TO_CHAR(T.CREATE_TIME,'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
             T.UPDATE_NAME,
             TO_CHAR(T.UPDATE_TIME,'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME
        FROM PLN_ZY_JG_CUT T
       WHERE (T.REQ_BL_ID LIKE '%' || ? || '%' OR T.REQ_BL_ID IS NULL)
         AND T.PLANSTATUS LIKE '%' || ? || '%'
         AND ? <= TO_CHAR(T.PLAN_TIME,'YYYY-MM-DD')
         AND TO_CHAR(T.PLAN_TIME,'YYYY-MM-DD') <= ?
		]]>
	</query>
	
	<query id="CoreJgOperatPln.queryJgProcess" desc="查询接箍加工作业计划">
		<![CDATA[
			SELECT T.COUPCUT_BATCH_ID,
			       T.JG_ORDERNO,
			       T.TASK_SEQ_NO,
			       T.PLINE_CODE,
			       T.PLINE_NAME,
			       T.REQ_BL_ID,
			       T.HEAT_NO,
			       T.BATCH_NO,
			       T.GROUP_JGX,
			       T.CODE_JG,
			       T.OUTDIAMETER,
			       T.WALLTHICK,
			       T.AIMLENGTH,
			       (SELECT A.MODEL_DESC
			          FROM COM_BASE_MODEL A
			         WHERE A.MODEL_CODE = T.MODEL_CODE) MODEL_CODE,
			       DECODE(T.IF_MONITOR_JG,'0','否','1','是') IF_MONITOR_JG,
			       T.PRDCR_NO,
			       T.PLAN_PROC_NUM,
			       TO_CHAR(T.PLAN_TIME, 'YYYY-MM-DD HH24:MI') PLAN_TIME,
			       T.PLAN_USETIME,
			       DECODE(T.PLANSTATUS,'0','计划','1','下发','2','执行','3','完成','4','取消') PLANSTATUS,
			       T.FINISH_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
			  FROM PLN_ZY_JG_PROCESS T
			 WHERE T.COUPCUT_BATCH_ID = ?
		]]>
	</query>
	
	<query id="CoreJgOperatPln.querySerialNum" desc="查询接箍作业计划流水号">
		<![CDATA[
			SELECT (MAX(SUBSTR(T.COUPCUT_BATCH_ID, 12, 3)) + 1) MAXID
				  FROM PLN_ZY_JG_CUT T
				 WHERE SUBSTR(T.COUPCUT_BATCH_ID, 0, 11) = ?
		]]>
	</query>
	
	<query id="CoreJgOperatPln.addCutbatch" desc="新增一条接箍作业计划">
		<![CDATA[
			INSERT INTO PLN_ZY_JG_CUT T
			  (T.COUPCUT_BATCH_ID, T.PLAN_TIME, T.PLANSTATUS, T.CREATE_NAME, T.CREATE_TIME)
			VALUES
			  (?,
			   TO_DATE(?, 'YYYY-MM-DD HH24:MI'),
			   ?,
			   ?,
			   TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'))
		]]>
	</query>
	
	<query id="CoreJgOperatPln.addPlnZyJgPro" desc="新增一条接箍加工作业计划">
		<![CDATA[
			INSERT INTO PLN_ZY_JG_PROCESS
				  (COUPCUT_BATCH_ID,
				   JG_ORDERNO,
				   PLINE_CODE,
				   PLINE_NAME,
				   REQ_BL_ID,
				   HEAT_NO,
				   BATCH_NO,
				   CODE_JG,
				   OUTDIAMETER,
				   WALLTHICK,
				   AIMLENGTH,
				   MODEL_CODE,
				   PRDCR_NO,
				   IF_MONITOR_JG,
				   PLAN_PROC_NUM,
				   PLANSTATUS,
				   GROUP_JGX,
				   PLAN_TIME,
				   PLAN_USETIME,
				   CREATE_NAME,
				   CREATE_TIME,
				   UPDATE_NAME,
				   UPDATE_TIME)
				VALUES
				  (?,
				   ?,
				   ?,
				   ?,
				   ?,
				   ?,
				   ?,
				   ?,
				   ?,
				   ?,
				   ?,
				   ?,
				   ?,
				   ?,
				   ?,
				   ?,
				   ?,
				   TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
				   ?,
				   ?,
				   TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
				   ?,
				   TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'))
		]]>
	</query>
	
	<query id="CoreJgOperatPln.updateJgCutplan" desc="更新接箍切断作业计划表">
		<![CDATA[
			UPDATE PLN_ZY_JG_CUT
			   SET PLINE_CODE = ?,
			       PLINE_NAME = ?,
			       REQ_BL_ID = ?,
			       JUDGE_STOVE_NO = ?,
			       BATCH_NO = ?,
			       WL_ID_IN = ?,
			       CODE_JG_BL = ?,
			       STEELCODE = ?,
			       STEELNAME = ?,
			       OUTDIAMETER_BL = ?,
			       WALLTHICK_BL = ?,
			       JGBL_LENGTH = ?,
			       JG_LENGTH = ?,
			       CUT_NUM_EACH = ?,
			       JGBL_WEIGHT = ?,
			       JGBL_NUM = ?,
			       CUT_NUM_TOT = ?,
			       GROUP_CUT = ?,
			       PLAN_TIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
			       PLAN_USETIME = ?,
			       UPDATE_NAME = ?,
			       UPDATE_TIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')
			 WHERE COUPCUT_BATCH_ID = ?
		]]>
	</query>
	
	<query id="CoreJgOperatPln.updateJglPlanWt" desc="更新接箍料需求接箍切断计划量">
		<![CDATA[
			UPDATE PLN_PORDER_BL_REQ
			   SET JGCUTPLAN_WT = DECODE(JGCUTPLAN_WT,NULL,'0',JGCUTPLAN_WT) + ?,
			       JGCUTPLAN_NUM = DECODE(JGCUTPLAN_NUM,NULL,'0',JGCUTPLAN_NUM) + ?
			 WHERE REQ_BL_ID = ?
		]]>
	</query>
	
	<query id="CoreJgOperatPln.updateIfbatchedjg" desc="更新钢管生产物料主表已做接箍组批">
		<![CDATA[
			UPDATE MAT_ZC_M T
			   SET T.REQ_BL_ID = ?, T.IF_BATCHED_JG = ?, T.COUPCUT_BATCH_ID = ?
			 WHERE T.MAT_NO = ?
		]]>
	</query>
	
	<query id="CoreJgOperatPln.updateDeleIfBatchedJg" desc="删除接箍切断计划时，更新钢管生产物料主表已做接箍组批">
		<![CDATA[
			UPDATE MAT_ZC_M T
			   SET T.REQ_BL_ID = ?, T.IF_BATCHED_JG = ?, T.COUPCUT_BATCH_ID = ?
			 WHERE T.COUPCUT_BATCH_ID = ?
		]]>
	</query>
	
	<query id="CoreJgOperatPln.updateJglRelPlanNum" desc="更新接箍料明细接箍计划已排个数">
		<![CDATA[
			UPDATE PLN_JG_AND_BL
			   SET JGPLAN_NUM = DECODE(JGPLAN_NUM,NULL,'0',JGPLAN_NUM) + ?
			 WHERE JG_ORDERNO = ?
			   AND REQ_BL_ID = ?
		]]>
	</query>
	
	<query id="CoreJgOperatPln.issuedJgCutPln" desc="下发接箍切断作业计划">
		<![CDATA[
			UPDATE PLN_ZY_JG_CUT T SET T.PLANSTATUS = 1 WHERE T.COUPCUT_BATCH_ID = ?
		]]>
	</query>
	
	<query id="CoreJgOperatPln.CancelissuedPln" desc="取消下发接箍切断作业计划">
		<![CDATA[
			UPDATE PLN_ZY_JG_CUT T SET T.PLANSTATUS = 0 WHERE T.COUPCUT_BATCH_ID = ?
		]]>
	</query>
	
	<query id="CoreJgOperatPln.issuedPlnJgZyPro" desc="下发接箍加工作业计划">
		<![CDATA[
			UPDATE PLN_ZY_JG_PROCESS T SET T.PLANSTATUS = 1 WHERE T.COUPCUT_BATCH_ID = ?
		]]>
	</query>
	
	<query id="CoreJgOperatPln.CancelissuedPlnPro" desc="取消下发接箍加工作业计划">
		<![CDATA[
			UPDATE PLN_ZY_JG_PROCESS T SET T.PLANSTATUS = 0 WHERE T.COUPCUT_BATCH_ID = ?
		]]>
	</query>
	
	<query id="CoreJgOperatPln.deleteCutbatch" desc="删除接箍作业批次号">
		<![CDATA[
			DELETE FROM PLN_ZY_JG_CUT T WHERE T.COUPCUT_BATCH_ID=?
		]]>
	</query>
	
	<query id="CoreJgOperatPln.deletePlnJgZyPro" desc="删除接箍加工作业计划">
		<![CDATA[
			DELETE FROM PLN_ZY_JG_PROCESS T WHERE T.COUPCUT_BATCH_ID=?
		]]>
	</query>
	
</queryMap>