<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="离线管理">
	<query id="FrmHttDownLineManage.doQueryOffLine" desc="查询离线实绩">
	  <![CDATA[
	 SELECT T.ORDER_NO || '/' || T.ORDER_SEQ  PROCESS_ORDER,
       T.ORDER_NO,
       T.ORDER_SEQ,
       T.DELIVERY_NO,
       T.ORD_LN_DLY_PK,
       T.RESULT_NO,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.STATION_CODE,
       T.STATION_DESC,
       T.HEAT_PLAN_NO,
       T.ZY_BATCH_ID,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.BATCH_GROUD_NO,
       T.PRODUCCODE,
       T.PRODUCNAME,
       T.STEELCODE,
       T.STEELNAME,
       T.GRADECODE,
       T.GRADENAME,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.PROCESS_SEQ,
       T.STD_CODE,
       T.STD_NAME,
       T.STD_STYLE,
       T.STD_STYLE_DESC,
       T.ACT_DIMATER,
       T.ACT_HEIGHT,
       NVL(T.ACT_LEN, 0) ACT_LEN,
       T.ACT_LEN_MIN,
       T.ACT_LEN_MAX,
       T.ZP_JUDGE_STOVE_NO,
       T.ZP_BATCH_NO,
       T.MEMO,
       NVL(T.OFFLINE_NUM, 0) OFFLINE_NUM,
       NVL(T.OFFLINE_WT, 0) OFFLINE_WT,
       NVL(T.RE_NUM, 0) RE_NUM,
       NVL(T.RE_WT, 0) RE_WT,
       NVL(T.GROUP_NUM, 0) GROUP_NUM,
       NVL(T.GROUP_WT, 0) GROUP_WT,
       NVL(T.SUBCONTRACT_NUM, 0) SUBCONTRACT_NUM,
       NVL(T.SUBCONTRACTCOMPLETE_NUM, 0) SUBCONTRACTCOMPLETE_NUM,
       NVL(T.SUBCONTRACTCOMPLETE_WT, 0) SUBCONTRACTCOMPLETE_WT,
       T.SUBCONTRACT_NO,
       T.SUBCONTRACT_NO_SEQ,
       TO_CHAR(TO_DATE(T.PRO_YEAR_MONTH_DAY, 'YYYY-MM-DD'), 'YYYY-MM-DD') PRO_YEAR_MONTH_DAY,
       T.PRO_USER,
       T.ZY_BATCH_ID1,
       T.FLAG_STOVE_NO,
       DECODE(T.PRO_SHIFT, '1', '早', '2', '中', '3', '夜','0','白') PRO_SHIFT,
       DECODE(T.PRO_GROUP, '1', '甲', '2', '乙', '3', '丙', '4', '丁') PRO_GROUP,
       TO_CHAR(T.PRO_TIME, 'YYYY-MM-DD HH24:MI:SS') PRO_TIME,
       DECODE(T.GROUP_LOG, '1', '已组炉', '0', '未组炉') GROUP_LOG,
       (TO_NUMBER(NVL(T.OFFLINE_NUM, 0)) - TO_NUMBER(NVL(T.GROUP_NUM, 0)) -
       TO_NUMBER(NVL(T.RE_NUM, 0)) - TO_NUMBER(NVL(T.SUBCONTRACT_NUM, 0)) +
       TO_NUMBER(NVL(T.SUBCONTRACTCOMPLETE_NUM, 0))) OFFLINE_BRANCH,
       (TO_NUMBER(NVL(T.OFFLINE_NUM, 0)) - TO_NUMBER(NVL(T.GROUP_NUM, 0)) -
       TO_NUMBER(NVL(T.RE_NUM, 0)) - TO_NUMBER(NVL(T.SUBCONTRACT_NUM, 0)) +
       TO_NUMBER(NVL(T.SUBCONTRACTCOMPLETE_NUM, 0))) TOTALCOUNT
  FROM HTT_OFFLINE_RESULT T,PLN_ZY_RCL_M T1
 WHERE T.HEAT_PLAN_NO = T1.HEAT_PLAN_NO(+)
 AND (TO_NUMBER(NVL(T.OFFLINE_NUM, 0)) - TO_NUMBER(NVL(T.GROUP_NUM, 0)) -
       TO_NUMBER(NVL(T.RE_NUM, 0)) - TO_NUMBER(NVL(T.SUBCONTRACT_NUM, 0)) +
       TO_NUMBER(NVL(T.SUBCONTRACTCOMPLETE_NUM, 0))) <>0
	  ]]>
	</query>


	<query id="FrmHttDownLineManage.doQueryOffLine2" desc="查询离线实绩">
		<![CDATA[SELECT
	 T.*,
       (TO_NUMBER(NVL(T.OFFLINE_NUM, 0)) - TO_NUMBER(NVL(T.GROUP_NUM, 0)) -
       TO_NUMBER(NVL(T.RE_NUM, 0)) - TO_NUMBER(NVL(T.SUBCONTRACT_NUM, 0)) +
       TO_NUMBER(NVL(T.SUBCONTRACTCOMPLETE_NUM, 0))) TOTALCOUNT
  FROM HTT_OFFLINE_RESULT T
 WHERE 1=1
 AND RESULT_NO=?
 AND (TO_NUMBER(NVL(T.OFFLINE_NUM, 0)) - TO_NUMBER(NVL(T.GROUP_NUM, 0)) -
       TO_NUMBER(NVL(T.RE_NUM, 0)) - TO_NUMBER(NVL(T.SUBCONTRACT_NUM, 0)) +
       TO_NUMBER(NVL(T.SUBCONTRACTCOMPLETE_NUM, 0))) <>0
	  ]]>
	</query>

	<query id="FrmHttDownLineManage.doQueryOffLineGroup" desc="查询组炉实绩">
	  <![CDATA[
	 SELECT T.ORDER_NO || '/' || T.ORDER_SEQ || '/' || T.DELIVERY_NO PROCESS_ORDER,
       T.ORDER_NO,
       T.ORDER_SEQ,
       T.DELIVERY_NO,
       T.ORD_LN_DLY_PK,
       T.RESULT_NO,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.STATION_CODE,
       T.STATION_DESC,
       T.HEAT_PLAN_NO,
       T.ZY_BATCH_ID,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.PRODUCCODE,
       T.PRODUCNAME,
       T.STEELCODE,
       T.STEELNAME,
       T.GRADECODE,
       T.GRADENAME,
       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,
       NVL(T.ACT_LEN, 0) ACT_LEN,
       T.ACT_LEN_MIN,
       T.ACT_LEN_MAX,
       T.ZP_JUDGE_STOVE_NO,
       T.ZP_BATCH_NO,
       NVL(T.OFFLINE_NUM, 0) OFFLINE_NUM,
       NVL(T.OFFLINE_WT, 0) OFFLINE_WT,
       NVL(T.RE_NUM, 0) RE_NUM,
       NVL(T.RE_WT, 0) RE_WT,
       NVL(T.GROUP_NUM, 0) GROUP_NUM,
       NVL(T.GROUP_WT, 0) GROUP_WT,
       NVL(T.SUBCONTRACT_NUM, 0) SUBCONTRACT_NUM,
       NVL(T.SUBCONTRACTCOMPLETE_NUM, 0) SUBCONTRACTCOMPLETE_NUM,
       NVL(T.SUBCONTRACTCOMPLETE_WT, 0) SUBCONTRACTCOMPLETE_WT,
       T.SUBCONTRACT_NO,
       T.SUBCONTRACT_NO_SEQ,
       TO_CHAR(TO_DATE(T.PRO_YEAR_MONTH_DAY, 'YYYY-MM-DD'), 'YYYY-MM-DD') PRO_YEAR_MONTH_DAY,
       T.PRO_USER,
       T.ZY_BATCH_ID1,
       T.PROCESS_SEQ,
       DECODE(T.PRO_SHIFT, '1', '早', '2', '中', '3', '夜','0','白') PRO_SHIFT,
       DECODE(T.PRO_GROUP, '1', '甲', '2', '乙', '3', '丙', '4', '丁') PRO_GROUP,
       TO_CHAR(T.PRO_TIME, 'YYYY-MM-DD HH24:MI:SS') PRO_TIME,
       DECODE(T.GROUP_LOG, '1', '已组炉', '0', '未组炉') GROUP_LOG,
       (TO_NUMBER(NVL(T.OFFLINE_NUM, 0)) - TO_NUMBER(NVL(T.GROUP_NUM, 0)) -
       TO_NUMBER(NVL(T.RE_NUM, 0)) - TO_NUMBER(NVL(T.SUBCONTRACT_NUM, 0)) +
       TO_NUMBER(NVL(T.SUBCONTRACTCOMPLETE_NUM, 0))) OFFLINE_BRANCH,
       (TO_NUMBER(NVL(T.OFFLINE_NUM, 0)) - TO_NUMBER(NVL(T.GROUP_NUM, 0)) -
       TO_NUMBER(NVL(T.RE_NUM, 0)) - TO_NUMBER(NVL(T.SUBCONTRACT_NUM, 0)) +
       TO_NUMBER(NVL(T.SUBCONTRACTCOMPLETE_NUM, 0))) TOTALCOUNT,
       T.GROUP_ID
  FROM HTT_OFFLINE_RESULT T
 WHERE 1=1
	 AND T.GROUP_LOG='1'
	  ]]>
	</query>
	
		<query id="FrmHttDownLineManage.deleteOfflineD" desc="返线后删除离线记录">
        <![CDATA[
	 DELETE HTT_OFFLINE_RESULT_D 
	 WHERE RESULT_NO = ? AND HEAT_PLAN_NO = ? AND PLINE_CODE = ?
        ]]>
	</query>
	<query id="FrmHttDownLineManage.doQueryReturnLine" desc="查询返线实绩">
	  <![CDATA[
	 SELECT T.ORDER_NO || '/' || T.ORDER_SEQ || '/' || T.DELIVERY_NO PROCESS_ORDER,
       T.ORDER_NO,
       T.ORDER_SEQ,
       T.DELIVERY_NO,
       T.ORD_LN_DLY_PK,
       T.RESULT_NO,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.STATION_CODE,
       T.STATION_DESC,
       T.HEAT_PLAN_NO,
       T.ZY_BATCH_ID,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.PRODUCCODE,
       T.PRODUCNAME,
       T.STEELCODE,
       T.STEELNAME,
       T.GRADECODE,
       T.GRADENAME,
       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.RE_NAME,
       T.RE_TIME,
       NVL(T.ACT_LEN, 0) ACT_LEN,
       T.ACT_LEN_MIN,
       T.ACT_LEN_MAX,
       T.ZP_JUDGE_STOVE_NO,
       T.ZP_BATCH_NO,
       NVL(T.OFFLINE_NUM, 0) OFFLINE_NUM,
       NVL(T.OFFLINE_WT, 0) OFFLINE_WT,
       NVL(T.RE_NUM, 0) RE_NUM,
       NVL(T.RE_WT, 0) RE_WT,
       NVL(T.GROUP_NUM, 0) GROUP_NUM,
       NVL(T.GROUP_WT, 0) GROUP_WT,
       NVL(T.SUBCONTRACT_NUM, 0) SUBCONTRACT_NUM,
       NVL(T.SUBCONTRACTCOMPLETE_NUM, 0) SUBCONTRACTCOMPLETE_NUM,
       NVL(T.SUBCONTRACTCOMPLETE_WT, 0) SUBCONTRACTCOMPLETE_WT,
       T.SUBCONTRACT_NO,
       T.SUBCONTRACT_NO_SEQ,
       TO_CHAR(TO_DATE(T.PRO_YEAR_MONTH_DAY, 'YYYY-MM-DD'), 'YYYY-MM-DD') PRO_YEAR_MONTH_DAY,
       T.PRO_USER,
       T.ZY_BATCH_ID1,
       DECODE(T.PRO_SHIFT, '1', '早', '2', '中', '3', '夜','0','白') PRO_SHIFT,
       DECODE(T.PRO_GROUP, '1', '甲', '2', '乙', '3', '丙', '4', '丁') PRO_GROUP,
       TO_CHAR(T.PRO_TIME, 'YYYY-MM-DD HH24:MI:SS') PRO_TIME,
       DECODE(T.GROUP_LOG, '1', '已组炉', '0', '未组炉') GROUP_LOG,
       (TO_NUMBER(NVL(T.OFFLINE_NUM, 0)) - TO_NUMBER(NVL(T.GROUP_NUM, 0)) -
       TO_NUMBER(NVL(T.RE_NUM, 0)) - TO_NUMBER(NVL(T.SUBCONTRACT_NUM, 0)) +
       TO_NUMBER(NVL(T.SUBCONTRACTCOMPLETE_NUM, 0))) OFFLINE_BRANCH,
       (TO_NUMBER(NVL(T.OFFLINE_NUM, 0)) - TO_NUMBER(NVL(T.GROUP_NUM, 0)) -
       TO_NUMBER(NVL(T.RE_NUM, 0)) - TO_NUMBER(NVL(T.SUBCONTRACT_NUM, 0)) +
       TO_NUMBER(NVL(T.SUBCONTRACTCOMPLETE_NUM, 0))) TOTALCOUNT,
       T.GROUP_ID,
       T.RETURN_PROCESS,
       (SELECT BASENAME FROM  COM_BASE_INFO WHERE BASECODE = T.RETURN_PROCESS)  RETURN_PROCESS_DES,
       T.PROCESS_SEQ
  FROM HTT_OFFLINE_RESULT T
 WHERE 1=1
 AND TO_NUMBER(NVL(T.RE_NUM, 0)) <>0
	  ]]>
	</query>
	<query id="FrmHttDownLineManage.getOrder" desc="查询合同信息">
<![CDATA[
SELECT T.PRO_ORDER_NO,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       T.ORDER_SOURCE,
       T.ORD_LN_DLY_PK,
       T.PLN_DIVIDE_ID,
       T.ORDER_NO,
       T.ORDER_SEQ,
       T.DELIVERY_NO,
       T.PLINE_CODE,
       T.PLINE_NAME,
       DECODE(T.EXE_STATUS,
              '0',
              '计划',
              '1',
              '生产中',
              '2',
              '已生产',
              '3',
              '关闭A',
              '') EXE_STATUS,
       T.ORD_LN_DLY_PK,      
       T2.*,
       NVL(T2.DIMATER1, 0) DIMATER,
       NVL(T2.HEIGHT1, 0) HEIGHT
  FROM PLN_ORDER_RCL_S T,
       (SELECT Q1.PRODUCCODE,
               Q1.PRODUCNAME,
               Q1.STD_CODE,
               Q1.STD_NAME,
               Q1.STD_STYLE,
               Q1.STD_STYLE_DESC,
               Q1.ORDER_SPEC_CODE,
               Q1.ORDER_SPEC_DESC,
               Q1.SPEC_CODE,
               Q1.SPEC_NAME,
               Q2.ORD_LN_DLY_PK  ORD_LN_DLY_PK1, 
               Q2.ORD_LN_PK,
               Q1.STEELCODE,
               Q1.STEELNAME,
               Q1.DELVRY_RANGE_TPE,
               Q1.DELVRY_RANGE_MAX,
               Q1.DELVRY_RANGE_MIN,
               Q2.DELVRY_QTY,
               Q3.CRAFT_SEQ,
               Q3.CRAFT_NO,
               Q4.CRAFT_NAME,
               NVL(Q1.DIMATER, 0) DIMATER1,
               NVL(Q1.HEIGHT, 0) HEIGHT1,
               NVL(Q3.CRAFT_PATH,
                   (SELECT C1.CRAFT_PATH
                      FROM CRAFT_ORD_DESIGN C2, CRAFT_ORD_DESIGN_FILE C1
                     WHERE C1.CRAFT_NO = C2.CRAFT_NO
                       AND C1.CRAFT_NO_V = C2.CRAFT_NO_V
                       AND C1.VALIDFLAG = '1'
                       AND C2.VALIDFLAG = '1'
                       AND C2.ORD_LN_PK = Q1.ORD_LN_PK)) AS CRAFT_PATH,
               Q3.CRAFT_FILE_LV2_E
          FROM SLM_ORDER_LINE           Q1,
               SLM_ORDER_LINE_DELIVERY  Q2,
               CRAFT_ORD_DESIGN         Q3,
               CRAFT_ORD_DESIGN_APPOINT Q4
         WHERE Q1.ORD_LN_PK = Q2.ORD_LN_PK
           AND Q1.ORD_LN_PK = Q3.ORD_LN_PK(+)
           AND Q1.ORD_LN_PK = Q4.ORD_LN_PK(+)
           AND Q3.VALIDFLAG(+) = '1') T2
 WHERE T.ORD_LN_DLY_PK = T2.ORD_LN_DLY_PK1(+)
   AND T.EXE_STATUS IN ('0', '1')
   AND T.PLINE_CODE = ?
    AND (T.PRO_PLAN_ID NOT IN (?) OR
       T.GX_PLAN_NO NOT IN (?))
   AND T.ORDER_NO || '&' LIKE ('%' || ?|| '%')
   ORDER BY T.PRO_PLAN_ID ASC
   ]]>
	</query>
	<query id="FrmHttDownLineManage.QueryOffLineMaxResultNo" desc="查询最大离线实绩编号">
        <![CDATA[
	  SELECT ? ||
  LPAD(SUBSTR(NVL(MAX(T.RESULT_NO),'000000'),-6,6) + 1, 6, '0') AS RESULT_NO
  FROM HTT_OFFLINE_RESULT T
  WHERE TO_CHAR(T.PRO_TIME,'YYYY-MM-DD') = ?
  AND T.PLINE_CODE= ?
        ]]>
	</query>
	<query id="FrmHttDownLineManage.QueryGroupResult" desc="查询组操作Id">
        <![CDATA[
	SELECT ? ||
  LPAD(SUBSTR(NVL(MAX(T.GROUP_ID),'000000'),-6,6) + 1, 6, '0') AS GROUP_ID
  FROM HTT_GROUP_RESULT T
  WHERE TO_CHAR(T.PRO_TIME,'YYYY-MM-DD') = ?
        ]]>
	</query>
	<query id="FrmHttDownLineManage.QueryOffLineGroupStart" desc="查询是否组炉">
        <![CDATA[
SELECT T.GROUP_LOG,
       T.GROUP_ID,
       NVL(T.OFFLINE_NUM, 0) OFFLINE_NUM,
       NVL(T.GROUP_NUM, 0) GROUP_NUM,
       TO_NUMBER(NVL(T.OFFLINE_NUM, 0)) - TO_NUMBER(NVL(T.GROUP_NUM, 0)) COUNT_NUM,
       TO_NUMBER(NVL(T.OFFLINE_NUM, 0)) - TO_NUMBER(NVL(T.RE_NUM, 0)) RE_NUM,
       TO_NUMBER(NVL(T.OFFLINE_NUM, 0)) - TO_NUMBER(NVL(T.SUBCONTRACT_NUM, 0)) SUBCONTRACT_NUM,
       FLAG
  FROM HTT_OFFLINE_RESULT T
 WHERE T.JUDGE_STOVE_NO = ?
   AND NVL(T.BATCH_NO,'/') = NVL(?,'/')
   AND T.RESULT_NO = ?
   AND NVL(T.HEAT_PLAN_NO,'/') = NVL(?,'/')
        ]]>
	</query>
	<query id="FrmHttDownLineManage.QueryOffLineGroupId" desc="查询组炉信息">
        <![CDATA[
SELECT COUNT(1) COUNT
  FROM HTT_OFFLINE_RESULT T
 WHERE T.GROUP_LOG = '1'
   AND T.RESULT_NO = ?
   AND T.GROUP_ID = ?
        ]]>
	</query>
	<query id="FrmHttDownLineManage.AddOffLineResu" desc="新增组炉实绩">
        <![CDATA[
INSERT INTO HTT_OFFLINE_RESULT (RESULT_NO, PLINE_CODE, PLINE_NAME, STATION_CODE, 
STATION_DESC, HEAT_PLAN_NO, ZY_BATCH_ID, PRO_PLAN_ID, GX_PLAN_NO, 
JUDGE_STOVE_NO, BATCH_NO, PRODUCCODE, PRODUCNAME, STEELCODE, STEELNAME, 
GRADECODE, GRADENAME, MODEL_CODE, MODEL_DESC, STD_CODE, STD_NAME, STD_STYLE, 
STD_STYLE_DESC, ACT_DIMATER, ACT_HEIGHT, ACT_LEN, ACT_LEN_MIN, ACT_LEN_MAX, 
ZP_JUDGE_STOVE_NO, ZP_BATCH_NO, OFFLINE_NUM, OFFLINE_WT, PRO_USER, PRO_SHIFT, 
PRO_GROUP, PRO_TIME, GROUP_LOG, GROUP_ID, ORD_LN_DLY_PK, ORDER_NO, ORDER_SEQ, 
DELIVERY_NO,ZY_BATCH_ID1,BATCH_GROUD_NO,PROCESS_SEQ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 
TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), '1', ?, ?, ?, ?, ?,?,?,?)
        ]]>
	</query>


	<query id="FrmHttDownLineManage.queryHttM" desc="新增组炉实绩">
		<![CDATA[
               SELECT * FROM htt_group_result  WHERE ZP_JUDGE_STOVE_NO =?
        ]]>
	</query>

	<query id="FrmHttDownLineManage.UpdateOffLineResu" desc="修改离线组炉支，吨">
        <![CDATA[    
 DECLARE
BEGIN
  UPDATE HTT_OFFLINE_RESULT
     SET GROUP_NUM = TO_NUMBER(NVL(GROUP_NUM, 0)) + TO_NUMBER(?),
         GROUP_WT  = TO_NUMBER(NVL(GROUP_WT, 0)) + TO_NUMBER(?),
         UPDATE_TIME=TO_DATE(?,'YYYY-MM-DD HH24:MI:SS'),
         UPDATE_NAME=?
   WHERE RESULT_NO = ?;
  INSERT INTO HTT_GROUP_RESULT
    (GROUP_ID,
     GROUP_XH,
     ZP_JUDGE_STOVE_NO,
     ZP_BATCH_NO,
     JUDGE_STOVE_NO,
     BATCH_NO,
     GROUP_NUM,
     GROUP_WT,
     PRO_USER,
     PRO_SHIFT,
     PRO_GROUP,
     PRO_TIME,
     LX_RESULT_NO)
  VALUES
    (?,
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),?);
END;
        ]]>
	</query>
	<query id="FrmHttDownLineManage.UpdateOffLineComm" desc="修改离线表数据（改判）">
        <![CDATA[ 
        UPDATE HTT_OFFLINE_RESULT
   SET PRODUCCODE     = ?,
       PRODUCNAME     = ?,
       STEELCODE      = ?,
       STEELNAME      = ?,
       MODEL_CODE     = ?,
       MODEL_DESC     = ?,
       STD_CODE       = ?,
       STD_NAME       = ?,
       STD_STYLE      = ?,
       STD_STYLE_DESC = ?,
       ACT_DIMATER    = ?,
       ACT_HEIGHT     = ?,
       ACT_LEN        = ?,
       ORD_LN_DLY_PK  = ?,
       ORDER_NO       = ?,
       ORDER_SEQ      = ?,
       DELIVERY_NO    = ?,
       UPDATE_TIME    = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
       UPDATE_NAME    = ?,
       PRO_PLAN_ID    = ?,
       GX_PLAN_NO     = ?
 WHERE RESULT_NO = ?  
        ]]>
	</query>
	<query id="FrmHttDownLineManage.DaeleteGroupResu" desc="修改离线组炉支，吨,删除组炉履历表">
        <![CDATA[    
 DECLARE
BEGIN
  UPDATE HTT_OFFLINE_RESULT
     SET GROUP_NUM = TO_NUMBER(NVL(GROUP_NUM, 0)) - TO_NUMBER(?),
         GROUP_WT  = TO_NUMBER(NVL(GROUP_WT, 0)) - TO_NUMBER(?),
         UPDATE_TIME=TO_DATE(?,'YYYY-MM-DD HH24:MI:SS'),
         UPDATE_NAME=?
   WHERE RESULT_NO = ?;
  DELETE HTT_GROUP_RESULT
   WHERE GROUP_ID = ?
     AND GROUP_XH = ?;
END;
        ]]>
	</query>
	<query id="FrmHttDownLineManage.DeleteOffLineResu" desc="删除离线表组炉记录">
        <![CDATA[    
DELETE HTT_OFFLINE_RESULT
 WHERE RESULT_NO = ?
 AND GROUP_ID=?
        ]]>
	</query>

	<query id="FrmHttDownLineManage.checkReHtt" desc="检查是否能重新热处理">
		<![CDATA[
           SELECT *
             FROM QCM_ZC_CHECKCONSIGN
            WHERE JUDGE_STOVE_NO = ?
              AND BATCH_NO = ?
              AND PROCESS_CODE='F'
        ]]>
	</query>

	<query id="FrmHttDownLineManage.QueryGroupVrpResult" desc="查询组炉履历表信息">
        <![CDATA[    
SELECT GROUP_ID,
       GROUP_XH,
       ZP_JUDGE_STOVE_NO,
       ZP_BATCH_NO,
       JUDGE_STOVE_NO,
       BATCH_NO,
       GROUP_NUM,
       GROUP_WT,
       PRO_YEAR_MONTH_DAY,
       PRO_USER,
       PRO_SHIFT,
       PRO_GROUP,
       PRO_TIME,
       LX_RESULT_NO
  FROM HTT_GROUP_RESULT
 WHERE GROUP_ID = ?
        ]]>
	</query>


	<query id="FrmHttDownLineManage.QueryGroupHttResult" desc="查询组炉履历表信息">
		<![CDATA[
		SELECT T.*,B.* FROM HTT_GROUP_RESULT T
			LEFT JOIN (
				SELECT
					MAX( PRODUCNAME ) PRODUCNAME,
					MAX( STEELCODE ) STEELCODE,
					MAX( STEELNAME ) STEELNAME,
					MAX( STD_NAME ) STD_NAME,
					MAX( STD_STYLE ) STD_STYLE,
					MAX( ACT_DIMATER ) ACT_DIMATER,
					MAX( ACT_HEIGHT ) ACT_HEIGHT,
					MAX( ACT_LEN ) ACT_LEN,
					MAX( ACT_LEN_MIN ) ACT_LEN_MIN,
					MAX( ACT_LEN_MAX ) ACT_LEN_MAX,
					MAX( MODEL_CODE ) MODEL_CODE,
					MAX( MODEL_DESC ) MODEL_DESC,
					MAX( GRADENAME ) GRADENAME,
					JUDGE_STOVE_NO,
					BATCH_NO
				FROM
					HTT_OFFLINE_RESULT
				GROUP BY
					JUDGE_STOVE_NO,
					BATCH_NO
				) B ON T.JUDGE_STOVE_NO = B.JUDGE_STOVE_NO
				AND T.BATCH_NO = B.BATCH_NO
		WHERE 1=1
        ]]>
	</query>

	<query id="FrmHttDownLineManage.doQuery" desc="查询工序点">
        <![CDATA[    
SELECT T.BASECODE,T.BASENAME
  FROM COM_BASE_INFO T
 WHERE T.SORTCODE = ?
   AND T.VALIDFLAG = '1'
   AND T.BASECODE NOT IN ('600210', '600211')
        ]]>
	</query>
		<query id="FrmHttDownLineManage.doQueryGX" desc="查询工序点">
        <![CDATA[    
SELECT DISTINCT REGEXP_SUBSTR (STATION_NAMES,'[^;]+',1,LEVEL) as "STATION_NAMES"
FROM  (SELECT  STATION_NAMES  FROM  MCH_COM_SETPLINE where PLINE_CODE = ?)
CONNECT BY REGEXP_SUBSTR (STATION_NAMES,'[^;]+',1,LEVEL) IS NOT NULL
order by 
case 
  when STATION_NAMES='上料' then 1
    when STATION_NAMES = '高温炉' then 2
      when STATION_NAMES = '淬火' then 3
        when STATION_NAMES = '低温炉' then 4
          when STATION_NAMES = '定径' then 5
            when STATION_NAMES = '热矫' then 6
              when STATION_NAMES = '冷矫' then 7
                when STATION_NAMES = '外观检验' then 8
                 when STATION_NAMES = '表检' then 8
                  when STATION_NAMES = '探伤' then 9
                    when STATION_NAMES = '分批取样' then 10
                      when STATION_NAMES = '交库' then 11
                        end 
        ]]>
	</query>
		<query id="FrmHttDownLineManage.doQueryGXcount" desc="查询工序点数量">
        <![CDATA[    
SELECT COUNT(DISTINCT REGEXP_SUBSTR (STATION_NAMES,'[^;]+',1,LEVEL)) as "STATION_NAMES"
FROM   (SELECT  STATION_NAMES  FROM  MCH_COM_SETPLINE where PLINE_CODE = ?)
CONNECT BY REGEXP_SUBSTR (STATION_NAMES,'[^;]+',1,LEVEL) IS NOT NULL
order by 1       
        ]]>
	</query>
	
		<query id="FrmHttDownLineManage.queryheatsqe" desc="热处理上料行ID">
        <![CDATA[    
SELECT ? ||
       LPAD(SUBSTR(NVL(MAX(T.HEAT_PLAN_SQE), '00'), -2, 2) + 1, 2, '0') AS HEAT_PLAN_SQE
  FROM PLN_ZY_RCL_C T
 WHERE T.HEAT_PLAN_NO = ?
        ]]>
	</query>
	<query id="FrmHttDownLineManage.AddReturnResu" desc="新增热处理计划表">
        <![CDATA[    
DECLARE
BEGIN
  FOR MYROW IN (SELECT PRO_ORDER_NO,
                       PRO_PLAN_ID,
                       GX_PLAN_NO,
                       PLAN_GROUP_ID,
                       ORDER_SOURCE,
                       ORD_LN_DLY_PK,
                       PLN_DIVIDE_ID,
                       ORDER_NO,
                       ORDER_SEQ,
                       DELIVERY_NO,
                       REQ_BL_ID,
                       PLINE_CODE,
                       PLINE_NAME,
                       INWL_ID,
                       INWL_DESC,
                       OUTWL_ID,
                       OUTWL_DESC,
                       GRADECODE,
                       GRADENAME,
                       OUTDIAMETER,
                       WALLTHICK,
                       LENGTHDISC,
                       LENGTHMAX_IN,
                       LENGTHMIN_IN,
                       LENGTH_IN,
                       AIMLENGTH,
                       IN_WEIGHT_S,
                       IN_NUM_S,
                       WEIGTH_S,
                       NUM_S,
                       MATCH_WT_IN,
                       MATCH_NUM_IN,
                       IF_MONITOR_RCL,
                       PRDCR_NO,
                       MONITOR_POINT,
                       CRAFT_FILE_NO,
                       CRAFT_FILE_MAN,
                       CRAFT_SEQ,
                       STATION_ROAD,
                       GX_PRO_SEQ,
                       PLAN_USETIME,
                       PLAN_TIME_B,
                       PLAN_TIME_E,
                       BATCHED_WT,
                       BATCHED_NUM,
                       FINISHWEIGHT,
                       FINISHNUM,
                       EXE_STATUS,
                       IS_REPAIR_PLN,
                       REPAIR_TYPE,
                       ZY_BATCH_ID,
                       ADD_WT_IN,
                       ADD_NUM_IN,
                       ISENDGX,
                       CIC,
                       PIC,
                       SIC,
                       DIC,
                       WIC,
                       GIC,
                       IS_PLAN_OK,
                       STEELCODE,
                       STEELNAME,
                       PRO_MONTH,
                       PREVIOUS_GX,
                       PREV_GXPLAN_ID,
                       IF_EXPORT,
                       CREATE_TIME,
                       MEMO,
                       ISSUED_TIME,
                       ISSUED_MAN,
                       LAST_UNDOWN_TIME,
                       LAST_UNDOWN_MAN,
                       VERSION_NO,
                       PROCESSING_COST,
                       TOTAL_COST,
                       IF_STOVE_ISSUED,
                       STOVE_ISSUED_TIME,
                       STOVE_ISSUED_MAN,
                       IS_ONLOAD_LINE
                  FROM PLN_ORDER_RCL_S
                 WHERE PRO_PLAN_ID = ?
                   AND GX_PLAN_NO = ?) LOOP
    INSERT INTO PLN_ZY_RCL_M
      (HEAT_PLAN_NO,
       ZY_BATCH_ID,
       --PROD_INDEX,
       PRO_PLAN_ID,
       GX_PLAN_NO,
       --GX_NAME_LAST,
      -- LAST_HEAT_PLAN_NO,
       JUDGE_STOVE_NO,
       BATCH_NO,
       PLINE_CODE,
       PLINE_NAME,
       ISENDGX,
       ORDER_SOURCE,
       ORD_LN_DLY_PK,
       ORDER_NO,
       ORDER_SEQ,
       DELIVERY_NO,
       REQ_BL_ID,
       STEELCODE,
       STEELNAME,
       GRADECODE,
       GRADENAME,
       OUTDIAMETER,
       WALLTHICK,
      -- LENGTHDISC,
      -- CP_LENGTHMIN,
       --CP_LENGTHMAX,
       OUTDIAMETER_IN,
       WALLTHICK_IN,
       LENGTH_IN,
       LENGTHMAX_IN,
       LENGTHMIN_IN,
    --   LENGTH_OUT,
       INWL_ID,
       INWL_DESC,
      -- IN_WT,
      -- IN_NUM,
     --  IF_WL_MATCHED,
       OUTWL_ID,
       OUTWL_DESC,
     --  OUT_WT,
     --  OUT_NUM,
      -- IF_MONITOR_RCL,
       PRDCR_NO,
       MONITOR_POINT,
       CRAFT_FILE_NO,
       CRAFT_FILE_MAN,
       CRAFT_SEQ,
       STATION_ROAD,
       PLANSTATUS,
       CREATE_NAME,
       CREATE_TIME--,
      -- IN_WT_REAL,
      -- IN_NUM_REAL--,
      -- BATCH_GROUD_NO
       )
    VALUES
      (?,
       MYROW.ZY_BATCH_ID,
      -- '',
       MYROW.PRO_PLAN_ID,
       MYROW.GX_PLAN_NO,
      -- MYROW.PREVIOUS_GX,
     --  '', 
       ?,
       ?,
       MYROW.PLINE_CODE,
       MYROW.PLINE_NAME,
       MYROW.ISENDGX,
       MYROW.ORDER_SOURCE,
       MYROW.ORD_LN_DLY_PK,
       MYROW.ORDER_NO,
       MYROW.ORDER_SEQ,
       MYROW.DELIVERY_NO,
       MYROW.REQ_BL_ID,
       MYROW.STEELCODE,
       MYROW.STEELNAME,
       MYROW.GRADECODE,
       MYROW.GRADENAME,
       MYROW.OUTDIAMETER,
       MYROW.WALLTHICK,
       --MYROW.LENGTHDISC,
      -- '',
      -- '',
       ?,
       ?,
       MYROW.LENGTH_IN,
       MYROW.LENGTHMAX_IN,
       MYROW.LENGTHMIN_IN,
      -- MYROW.AIMLENGTH,
       MYROW.INWL_ID,
       MYROW.INWL_DESC,
      -- '',
       --'',
     --  '1',
       MYROW.OUTWL_ID,
       MYROW.OUTWL_DESC,
     --  '',
     --  '',
      -- MYROW.IF_MONITOR_RCL,
       MYROW.PRDCR_NO,
       MYROW.MONITOR_POINT,
       MYROW.CRAFT_FILE_NO,
       MYROW.CRAFT_FILE_MAN,
       MYROW.CRAFT_SEQ,
       MYROW.STATION_ROAD,
       ?,
       ?,
       TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')--,
      -- '',
      -- ''--,
      -- ''
       );
  END LOOP;
END;
        ]]>
	</query>
		<query id="FrmHttDownLineManage.AddReturnResuC" desc="新增热处理计划从表">
        <![CDATA[          
DECLARE
BEGIN
  FOR MYROW IN (SELECT PRO_ORDER_NO,
                       PRO_PLAN_ID,
                       GX_PLAN_NO,
                       PLAN_GROUP_ID,
                       ORDER_SOURCE,
                       ORD_LN_DLY_PK,
                       PLN_DIVIDE_ID,
                       ORDER_NO,
                       ORDER_SEQ,
                       DELIVERY_NO,
                       REQ_BL_ID,
                       PLINE_CODE,
                       PLINE_NAME,
                       INWL_ID,
                       INWL_DESC,
                       OUTWL_ID,
                       OUTWL_DESC,
                       GRADECODE,
                       GRADENAME,
                       OUTDIAMETER,
                       WALLTHICK,
                       LENGTHDISC,
                       LENGTHMAX_IN,
                       LENGTHMIN_IN,
                       LENGTH_IN,
                       AIMLENGTH,
                       IN_WEIGHT_S,
                       IN_NUM_S,
                       WEIGTH_S,
                       NUM_S,
                       MATCH_WT_IN,
                       MATCH_NUM_IN,
                       IF_MONITOR_RCL,
                       PRDCR_NO,
                       MONITOR_POINT,
                       CRAFT_FILE_NO,
                       CRAFT_FILE_MAN,
                       CRAFT_SEQ,
                       STATION_ROAD,
                       GX_PRO_SEQ,
                       PLAN_USETIME,
                       PLAN_TIME_B,
                       PLAN_TIME_E,
                       BATCHED_WT,
                       BATCHED_NUM,
                       FINISHWEIGHT,
                       FINISHNUM,
                       EXE_STATUS,
                       IS_REPAIR_PLN,
                       REPAIR_TYPE,
                       ZY_BATCH_ID,
                       ADD_WT_IN,
                       ADD_NUM_IN,
                       ISENDGX,
                       CIC,
                       PIC,
                       SIC,
                       DIC,
                       WIC,
                       GIC,
                       IS_PLAN_OK,
                       STEELCODE,
                       STEELNAME,
                       PRO_MONTH,
                       PREVIOUS_GX,
                       PREV_GXPLAN_ID,
                       IF_EXPORT,
                       CREATE_TIME,
                       MEMO,
                       ISSUED_TIME,
                       ISSUED_MAN,
                       LAST_UNDOWN_TIME,
                       LAST_UNDOWN_MAN,
                       VERSION_NO,
                       PROCESSING_COST,
                       TOTAL_COST,
                       IF_STOVE_ISSUED,
                       STOVE_ISSUED_TIME,
                       STOVE_ISSUED_MAN,
                       IS_ONLOAD_LINE
                  FROM PLN_ORDER_RCL_S
                 WHERE PRO_PLAN_ID = ?
                   AND GX_PLAN_NO = ?) LOOP
    INSERT INTO PLN_ZY_RCL_C
      (HEAT_PLAN_NO,
      HEAT_PLAN_SQE,
       ZY_BATCH_ID,
       PRO_PLAN_ID,
       GX_PLAN_NO,
       JUDGE_STOVE_NO,
       BATCH_NO,
       BATCH_GROUD_NO,      
       PLINE_CODE,
       PLINE_NAME,

     
       OUTDIAMETER_IN,
       WALLTHICK_IN,
       OUTNUM_CUT,
       LENGTH_IN,
       LENGTHMAX_IN,
       LENGTHMIN_IN,
       
       PLAN_INDOUBLE_NUM,
       PLAN_INDOUBLE_WT,
       REAL_INDOUBLE_NUM,
       REAL_INDOUBLE_WT
       )
    VALUES
      (?,
      ?,
      MYROW.ZY_BATCH_ID,
      MYROW.PRO_PLAN_ID,
      MYROW.GX_PLAN_NO,
      ?,
      ?,
      ?,
       MYROW.PLINE_CODE,
       MYROW.PLINE_NAME,
       '',
       '',
       '',
       MYROW.LENGTH_IN,
       MYROW.LENGTHMAX_IN,
       MYROW.LENGTHMIN_IN,
       ?,
       ?,
       ?,
       ?
       );
  END LOOP;
END;
         ]]>
	</query>
	<query id="FrmHttDownLineManage.UpdatePortVrpReturn" desc="修改管号队列表">
        <![CDATA[          
UPDATE PORT_HTT_BATCH_SAMPLE_RESULT T
   SET MAT_STATUS          = ?,
       LEVE_LOG            = ?,
       PRC_TECHNOLOGY_PATH = ?,
       RETURN_PROCESS      = ?,
       FLAG_STOVE_NO =?,
       INSTORE_FLAG = ?
 WHERE HEAT_PLAN_NO = ?
 AND PROCESS_SEQ = (SELECT real_process_seq FROM pln_zy_rcl_m WHERE heat_plan_no = t.heat_plan_no)
   AND MAT_NO = ?
         ]]>
	</query>

	<query id="FrmHttDownLineManage.RestBatchInfo" desc="修改管号队列表">
		<![CDATA[
 UPDATE PORT_HTT_BATCH_SAMPLE_RESULT T
    SET  PHY_BATCH_NO         = '',
        IS_BATCH             = '0',
        CHECK_NO             = '',
        BAR_CODE             = '',
        SAMPLE_PIPE_LEN_A    = '',
        SAMPLE_PIPE_LEN_B    = '',
        SAMPLE_PIPE_LEN_C    = '',
        SAMPLE_PIPE_LEN_D    = '',
        SAMPLE_PIPE_LEN_E    = '',
        SAMPLE_PIPE_LEN_F    = '',
        SAMPLE_PIPE_LEN_P    = '',
        SAMPLE_PIPE_LEN_Q    = '',
        PHY_CODE_GROUP       = '',
        PHY_CODE_GROUPB      = '',
        PHY_CODE_GROUPC      = '',
        PHY_CODE_GROUPD      = '',
        PHY_CODE_GROUPE      = '',
        PHY_CODE_GROUPF      = '',
        PHY_CODE_GROUPP      = '',
        PHY_CODE_GROUPQ      = '',
        GET_SAMPLE_SHIFT     = '',
        GET_SAMPLE_CLASS     = '',
        GET_SAMPLE_NAME      = '',
        GET_SAMPLE_TIME      = '',
        RE_CHECK_NO          = '',
        RESAMPLE_PIPE_LEN_A  = '',
        RESAMPLE_PIPE_LEN_B  = '',
        RESAMPLE_PIPE_LEN_C  = '',
        RESAMPLE_PIPE_LEN_D  = '',
        RESAMPLE_PIPE_LEN_E  = '',
        RESAMPLE_PIPE_LEN_F  = '',
        RESAMPLE_PIPE_LEN_P  = '',
        RESAMPLE_PIPE_LEN_Q  = '',
        RESAMPLE_PIPE_LEN_M  = '',
        RE_GET_SAMPLE_NAME   = '',
        RE_GET_SAMPLE_TIME   = '',
        RE_GET_SAMPLE_STATUS = '',
        CRAFT_SOURCE         = '0',
        is_sample_pipe ='0'
  WHERE HEAT_PLAN_NO = ?
    AND PROCESS_SEQ = (SELECT REAL_PROCESS_SEQ
                         FROM PLN_ZY_RCL_M
                        WHERE HEAT_PLAN_NO = T.HEAT_PLAN_NO)
    AND MAT_NO = ?
         ]]>
	</query>

	<query id="FrmHttDownLineManage.BackUpBatchInfo" desc="备份管号队列表取样信息">
		<![CDATA[

 INSERT INTO HTT_SAMPLE_RESULT_BACKUP
   (HEAT_PLAN_NO,
    MAT_NO,
    PHY_BATCH_NO,
    IS_BATCH,
    RESULT_NO,
    CHECK_NO,
    BAR_CODE,
    SAMPLE_PIPE_LEN_A,
    SAMPLE_PIPE_LEN_B,
    SAMPLE_PIPE_LEN_C,
    SAMPLE_PIPE_LEN_D,
    SAMPLE_PIPE_LEN_E,
    SAMPLE_PIPE_LEN_F,
    SAMPLE_PIPE_LEN_P,
    SAMPLE_PIPE_LEN_Q,
    PHY_CODE_GROUP,
    PHY_CODE_GROUPB,
    PHY_CODE_GROUPC,
    PHY_CODE_GROUPD,
    PHY_CODE_GROUPE,
    PHY_CODE_GROUPF,
    PHY_CODE_GROUPP,
    PHY_CODE_GROUPQ,
    GET_SAMPLE_SHIFT,
    GET_SAMPLE_CLASS,
    GET_SAMPLE_NAME,
    GET_SAMPLE_TIME,
    RE_CHECK_NO,
    RESAMPLE_PIPE_LEN_A,
    RESAMPLE_PIPE_LEN_B,
    RESAMPLE_PIPE_LEN_C,
    RESAMPLE_PIPE_LEN_D,
    RESAMPLE_PIPE_LEN_E,
    RESAMPLE_PIPE_LEN_F,
    RESAMPLE_PIPE_LEN_P,
    RESAMPLE_PIPE_LEN_Q,
    RESAMPLE_PIPE_LEN_M,
    RE_GET_SAMPLE_NAME,
    RE_GET_SAMPLE_TIME,
    RE_GET_SAMPLE_STATUS,
    CRAFT_SOURCE,
    IS_SAMPLE_PIPE)
   SELECT HEAT_PLAN_NO,
          MAT_NO,
          PHY_BATCH_NO,
          IS_BATCH,
          RESULT_NO,
          CHECK_NO,
          BAR_CODE,
          SAMPLE_PIPE_LEN_A,
          SAMPLE_PIPE_LEN_B,
          SAMPLE_PIPE_LEN_C,
          SAMPLE_PIPE_LEN_D,
          SAMPLE_PIPE_LEN_E,
          SAMPLE_PIPE_LEN_F,
          SAMPLE_PIPE_LEN_P,
          SAMPLE_PIPE_LEN_Q,
          PHY_CODE_GROUP,
          PHY_CODE_GROUPB,
          PHY_CODE_GROUPC,
          PHY_CODE_GROUPD,
          PHY_CODE_GROUPE,
          PHY_CODE_GROUPF,
          PHY_CODE_GROUPP,
          PHY_CODE_GROUPQ,
          GET_SAMPLE_SHIFT,
          GET_SAMPLE_CLASS,
          GET_SAMPLE_NAME,
          GET_SAMPLE_TIME,
          RE_CHECK_NO,
          RESAMPLE_PIPE_LEN_A,
          RESAMPLE_PIPE_LEN_B,
          RESAMPLE_PIPE_LEN_C,
          RESAMPLE_PIPE_LEN_D,
          RESAMPLE_PIPE_LEN_E,
          RESAMPLE_PIPE_LEN_F,
          RESAMPLE_PIPE_LEN_P,
          RESAMPLE_PIPE_LEN_Q,
          RESAMPLE_PIPE_LEN_M,
          RE_GET_SAMPLE_NAME,
          RE_GET_SAMPLE_TIME,
          RE_GET_SAMPLE_STATUS,
          CRAFT_SOURCE,
          IS_SAMPLE_PIPE
     FROM PORT_HTT_BATCH_SAMPLE_RESULT T
    WHERE T.HEAT_PLAN_NO = ?
      AND T.PROCESS_SEQ =
          (SELECT REAL_PROCESS_SEQ
             FROM PLN_ZY_RCL_M
            WHERE HEAT_PLAN_NO = T.HEAT_PLAN_NO)
      AND T.MAT_NO = ?
         ]]>
	</query>

	<query id="FrmHttDownLineManage.RecoverBatchInfo" desc="恢复管号队列表取样信息">
		<![CDATA[
UPDATE PORT_HTT_BATCH_SAMPLE_RESULT T
   SET (IS_SAMPLE_PIPE,
        PHY_BATCH_NO,
        IS_BATCH,
        RESULT_NO,
        CHECK_NO,
        BAR_CODE,
        SAMPLE_PIPE_LEN_A,
        SAMPLE_PIPE_LEN_B,
        SAMPLE_PIPE_LEN_C,
        SAMPLE_PIPE_LEN_D,
        SAMPLE_PIPE_LEN_E,
        SAMPLE_PIPE_LEN_F,
        SAMPLE_PIPE_LEN_P,
        SAMPLE_PIPE_LEN_Q,
        PHY_CODE_GROUP,
        PHY_CODE_GROUPB,
        PHY_CODE_GROUPC,
        PHY_CODE_GROUPD,
        PHY_CODE_GROUPE,
        PHY_CODE_GROUPF,
        PHY_CODE_GROUPP,
        PHY_CODE_GROUPQ,
        GET_SAMPLE_SHIFT,
        GET_SAMPLE_CLASS,
        GET_SAMPLE_NAME,
        GET_SAMPLE_TIME,
        RE_CHECK_NO,
        RESAMPLE_PIPE_LEN_A,
        RESAMPLE_PIPE_LEN_B,
        RESAMPLE_PIPE_LEN_C,
        RESAMPLE_PIPE_LEN_D,
        RESAMPLE_PIPE_LEN_E,
        RESAMPLE_PIPE_LEN_F,
        RESAMPLE_PIPE_LEN_P,
        RESAMPLE_PIPE_LEN_Q,
        RESAMPLE_PIPE_LEN_M,
        RE_GET_SAMPLE_NAME,
        RE_GET_SAMPLE_TIME,
        RE_GET_SAMPLE_STATUS,
        CRAFT_SOURCE) =
       (SELECT IS_SAMPLE_PIPE,
               PHY_BATCH_NO,
               IS_BATCH,
               RESULT_NO,
               CHECK_NO,
               BAR_CODE,
               SAMPLE_PIPE_LEN_A,
               SAMPLE_PIPE_LEN_B,
               SAMPLE_PIPE_LEN_C,
               SAMPLE_PIPE_LEN_D,
               SAMPLE_PIPE_LEN_E,
               SAMPLE_PIPE_LEN_F,
               SAMPLE_PIPE_LEN_P,
               SAMPLE_PIPE_LEN_Q,
               PHY_CODE_GROUP,
               PHY_CODE_GROUPB,
               PHY_CODE_GROUPC,
               PHY_CODE_GROUPD,
               PHY_CODE_GROUPE,
               PHY_CODE_GROUPF,
               PHY_CODE_GROUPP,
               PHY_CODE_GROUPQ,
               GET_SAMPLE_SHIFT,
               GET_SAMPLE_CLASS,
               GET_SAMPLE_NAME,
               GET_SAMPLE_TIME,
               RE_CHECK_NO,
               RESAMPLE_PIPE_LEN_A,
               RESAMPLE_PIPE_LEN_B,
               RESAMPLE_PIPE_LEN_C,
               RESAMPLE_PIPE_LEN_D,
               RESAMPLE_PIPE_LEN_E,
               RESAMPLE_PIPE_LEN_F,
               RESAMPLE_PIPE_LEN_P,
               RESAMPLE_PIPE_LEN_Q,
               RESAMPLE_PIPE_LEN_M,
               RE_GET_SAMPLE_NAME,
               RE_GET_SAMPLE_TIME,
               RE_GET_SAMPLE_STATUS,
               CRAFT_SOURCE
          FROM HTT_SAMPLE_RESULT_BACKUP
         WHERE HEAT_PLAN_NO = T.HEAT_PLAN_NO
           AND MAT_NO = T.MAT_NO
           AND PHY_BATCH_NO = ?)
 WHERE HEAT_PLAN_NO = ?
   AND PROCESS_SEQ = (SELECT REAL_PROCESS_SEQ
                        FROM PLN_ZY_RCL_M
                       WHERE HEAT_PLAN_NO = T.HEAT_PLAN_NO)
   AND MAT_NO = ?
   AND EXISTS (SELECT 1
          FROM HTT_SAMPLE_RESULT_BACKUP
         WHERE HEAT_PLAN_NO = T.HEAT_PLAN_NO
           AND MAT_NO = T.MAT_NO
           AND PHY_BATCH_NO = ?)
         ]]>
	</query>

	<query id="FrmHttDownLineManage.DeleteBackUpBatchInfo" desc="删除备份列表取样信息">
		<![CDATA[
          DELETE
          FROM HTT_SAMPLE_RESULT_BACKUP
         WHERE HEAT_PLAN_NO = ?
           AND MAT_NO = ?
           AND PHY_BATCH_NO = ?
         ]]>
	</query>

	<query id="FrmHttDownLineManage.QueryOffMatNo" desc="查询管号队列离线材料号">
        <![CDATA[  
        SELECT *
  FROM (SELECT T.MAT_NO,T.PHY_BATCH_NO,T.IS_SAMPLE_PIPE,T.ACT_COUNT
          FROM PORT_HTT_BATCH_SAMPLE_RESULT T
         WHERE T.MAT_STATUS = '20'
           AND T.HEAT_PLAN_NO = ?
           AND T.OP_PROCESS = ?
         ORDER BY T.MAT_NO ASC)
 WHERE ROWNUM < ?
          ]]>
	</query>
	<query id="FrmHttDownLineManage.QueryOffMatNo2" desc="查询管号队列离线材料号">
		<![CDATA[
         SELECT *
    FROM (SELECT T.*, DECODE(C.OUT_REPOSITORY, NULL, 1, 0) SEQ
            FROM PORT_HTT_BATCH_SAMPLE_RESULT T
            LEFT JOIN YDM_BC_BUTTRESS B
              ON T.MAT_NO = B.MAT_NO
            LEFT JOIN COM_BASE_PLINE C
              ON C.PLINE_CODE = B.PLINE_CODE
             AND C.OUT_REPOSITORY = B.STORAGE_NO
           WHERE T.MAT_STATUS = '20'
             AND T.RESULT_NO = ?)
   ORDER BY SEQ, MAT_NO
          ]]>
	</query>

	<query id="FrmHttDownLineManage.QueryOffMatNo3" desc="查询管号队列离线材料号">
		<![CDATA[
SELECT *
          FROM PORT_HTT_BATCH_SAMPLE_RESULT T
         WHERE T.MAT_STATUS = '20'
           AND T.RESULT_NO =?
         ORDER BY T.MAT_NO ASC
          ]]>
	</query>

	<query id="FrmHttDownLineManage.QueryOffMatNo4" desc="查询管号队列离线材料号">
		<![CDATA[
SELECT *
          FROM PORT_HTT_BATCH_SAMPLE_RESULT T
         WHERE T.MAT_STATUS IN  ('20','40')
           AND T.RESULT_NO =?
         ORDER BY T.MAT_NO ASC
          ]]>
	</query>

	<query id="FrmHttDownLineManage.QueryPortHttBathSample" desc="查询管号队列合格材料号">
		<![CDATA[
        SELECT *
          FROM PORT_HTT_BATCH_SAMPLE_RESULT T
         WHERE T.MAT_STATUS = '00'
           AND T.HEAT_PLAN_NO = ?
         ORDER BY T.MAT_NO ASC
          ]]>
	</query>

	<query id="FrmHttDownLineManage.QueryReturnMatNo" desc="查询管号队列返线的材料号">
        <![CDATA[  
      SELECT T.MAT_NO
          FROM PORT_HTT_BATCH_SAMPLE_RESULT T
         WHERE T.RESULT_NO = ?
           AND  nvl(T.PHY_BATCH_NO,'/') = ( CASE WHEN T.RETURN_PROCESS <= '600204'
           THEN '/'  ELSE  nvl(T.PHY_BATCH_NO,'/') END)
           AND INSTORE_FLAG ='0'
         ORDER BY T.MAT_NO ASC
          ]]>
	</query>

	<query id="FrmHttDownLineManage.QueryReturnMatNo1" desc="查询管号队列返线的材料号">
		<![CDATA[
        SELECT *
  FROM (SELECT T.*
          FROM PORT_HTT_BATCH_SAMPLE_RESULT T
         WHERE  T.HEAT_PLAN_NO = ?
         AND INSTORE_FLAG ='0'
         ORDER BY T.MAT_NO ASC
         )
 WHERE ROWNUM < ?
          ]]>
	</query>

	<query id="FrmHttDownLineManage.AddPortVrpReturn" desc="新增管号队列表">
        <![CDATA[          
 INSERT INTO PORT_HTT_BATCH_SAMPLE_RESULT
  (HEAT_PLAN_NO,
   MAT_NO,
   M_MAT_NO,
   M_M_MAT_NO,
   LOT_NO,
   LOT_NO_SQE,
   PLINE_CODE,
   PLINE_NAME,
   JUDGE_STOVE_NO,
   BATCH_NO,
   GROUP_NO,
   STOVE_NO,
   FLAG_STOVE_NO,
   ACT_DIMATER,
   ACT_HEIGHT,
   ACT_LEN,
   ACT_LEN_MIN,
   ACT_LEN_MAX,
   ACT_COUNT,
   ACT_WEIGHT,
   ACT_THEORY_WEIGHT,
   OP_PROCESS,
   LEVE_LOG,
   PRO_USER,
   PRO_SHIFT,
   PRO_GROUP,
   PRO_TIME,
   PRC_TECHNOLOGY_PATH,
   RETURN_PROCESS,
   MAT_STATUS,
   PHY_BATCH_NO,
   HEAT_PLAN_SQE,
   PROCESS_SEQ,
   FEED_HEAT_NO,
   INSTORE_FLAG,
   IS_FAIL_CHECK,
   BAL_YEAR_MONTH_FAIL,
   BAL_YEAR_MONTH)
VALUES
  (?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?)

         ]]>
	</query>
	<query id="FrmHttDownLineManage.UpdateMatReturn" desc="修改材料表">
        <![CDATA[         
UPDATE MAT_BC_M T
   SET T.MAT_STATUS     = ?,
       T.QCM_STAUS      = ?,
       T.PRODUCCODE     = ?,
       T.PRODUCNAME     = ?,
       T.STEELCODE      = ?,
       T.STEELNAME      = ?,
       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.ORD_LN_DLY_PK  = ?,
       T.ORDER_NO       = ?,
       T.ORDER_SEQ      = ?,
       T.ORDER_SEQ_NO   = ?,
       T.ORD_PK         = ?,
       T.ORD_LN_PK      = ?
 WHERE T.MAT_NO = ?
 
         ]]>
	</query>

	<query id="FrmHttDownLineManage.queryMatNoM" desc="自动生存材料号">
		<![CDATA[
	SELECT ? || ? ||
       LPAD(NVL(MAX(SUBSTR(T2.MAT_NO, LENGTH(T2.MAT_NO) - 3)), 0) + 1, 4, 0) MAT_NO
  FROM (SELECT MAX(T.MAT_NO) MAT_NO
          FROM MAT_BC_M T
         WHERE T.JUDGE_STOVE_NO = ?
           AND T.BATCH_NO = ?
        UNION ALL
        SELECT MAX(T1.MAT_NO) MAT_NO
          FROM YDM_BC_INLIST T1
         WHERE T1.JUDGE_STOVE_NO = ?
           AND T1.BATCH_NO = ?
        UNION ALL
        SELECT MAX(T3.MAT_NO) MAT_NO
          FROM MAT_ZC_BACKUP T3
         WHERE T3.JUDGE_STOVE_NO = ?
           AND T3.BATCH_NO = ?) T2
		]]>
	</query>
	<query id="FrmHttDownLineManage.AddMatReturn" desc="新增材料表">
        <![CDATA[   
     INSERT INTO MAT_BC_M
    (JUDGE_STOVE_NO,
     BATCH_NO,
     BATCH_GROUD_NO,
     ACT_COUNT,
     ACT_WEIGHT,
     CREATE_NAME,
     CREATE_TIME,
     MAT_NO,
     PRODUCT_FLAG,
     MAT_STATUS,
     PLINE_CODE,
     PLINE_NAME,
     QCM_STAUS,
     PRODUCCODE,
     PRODUCNAME,
     STEELCODE,
     STEELNAME,
     SPEC_CODE,
     SPEC_NAME,
     GRADECODE,
     GRADENAME,
     MODEL_CODE,
     MODEL_DESC,
     STD_CODE,
     STD_NAME,
     BELONG_CODE,
     BELONG_NAME,
     STD_STYLE,
     STD_STYLE_DESC,
     ACT_DIMATER,
     ACT_HEIGHT,ORD_LN_DLY_PK,ORDER_NO,ORDER_SEQ,ORDER_SEQ_NO,ORD_PK,ORD_LN_PK)
  VALUES
    (?,
     ?,
     ?,
     ?,
     ?,?,
     TO_DATE(?,'YYYY-MM-DD HH24:MI:SS'),
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,
     ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
         ]]>
	</query>
	<query id="FrmHttDownLineManage.QueryPlnOrig" desc="查询原计划">
        <![CDATA[   
        SELECT 
       T.PRO_ORDER_NO,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       T.PLAN_GROUP_ID,
       T.ORDER_SOURCE,
       T.ORD_LN_DLY_PK,
       T.PLN_DIVIDE_ID,
       T.ORDER_NO,
       T.ORDER_SEQ,
       T.DELIVERY_NO,
       T.REQ_BL_ID,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.INWL_ID,
       T.INWL_DESC,
       T.OUTWL_ID,
       T.OUTWL_DESC,
       T.WEIGTH_S,
       T.NUM_S,
       T.GX_PRO_SEQ,
       T.PLAN_USETIME,
       TO_CHAR(T.PLAN_TIME_B, 'YYYY-MM-DD HH24:MI:SS') PLAN_TIME_B,
       TO_CHAR(T.PLAN_TIME_E, 'YYYY-MM-DD HH24:MI:SS') PLAN_TIME_E,
       T.EXE_STATUS,
       T.IS_REPAIR_PLN,
       T.REPAIR_TYPE,
       T.OUTDIAMETER,
       T.WALLTHICK,
       T.LENGTHDISC,
       T.AIMOUTDIAMETER,
       T.AIMWALLTHICK,
       T.AIMLENGTH,
       T.OUTDIAMETER_IN,
       T.WALLTHICK_IN,
       T.LENGTH_IN,
       T.LEN_CUTHEAD,
       T.LEN_CUTEND,
       T.LENGTHMAX_IN,
       T.LENGTHMIN_IN,
       T.IN_WEIGHT_S,
       T.IN_NUM_S,
       T.ADD_WT_IN,
       T.ADD_NUM_IN,
       T.MATCH_WT_IN,
       T.MATCH_NUM_IN,
       T.ISENDGX,
       T.IF_MONITOR_DBK,
       T.PRDCR_NO,
       T.MONITOR_POINT,
       T.CIC,
       T.PIC,
       T.SIC,
       T.DIC,
       T.WIC,
       T.GIC,
       T.CRAFT_FILE_NO,
       T.CRAFT_FILE_MAN,
       T.CRAFT_SEQ,
       T.STATION_ROAD,
       T.BATCHED_WT,
       T.BATCHED_NUM,
       T.FINISHWEIGHT,
       T.FINISHNUM,
       T.IS_PLAN_OK,
       T.ZY_BATCH_ID,
       T.GRADECODE,
       T.GRADENAME,
       T.PRO_MONTH,
       T.PREVIOUS_GX,
       T.PREV_GXPLAN_ID,
       T.IF_EXPORT,
       TO_CHAR(T.ISSUED_TIME, 'YYYY-MM-DD HH24:MI:SS') ISSUED_TIME,
       T.ISSUED_MAN,
       TO_CHAR(T.LAST_UNDOWN_TIME, 'YYYY-MM-DD HH24:MI:SS') LAST_UNDOWN_TIME,
       T.LAST_UNDOWN_MAN,
       T.VERSION_NO,
       T.PROCESSING_COST,
       T.TOTAL_COST,
       T.MEMO,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T.IF_STOVE_ISSUED,
       TO_CHAR(T.STOVE_ISSUED_TIME, 'YYYY-MM-DD HH24:MI:SS') STOVE_ISSUED_TIME,
       T.STOVE_ISSUED_MAN,
       T.REAL_BATCH_WT,
       T.REAL_BATCH_NUM
 FROM PLN_ORDER_DBK_S T
 WHERE
T.PRO_PLAN_ID = ?
AND T.GX_PLAN_NO = ?
AND T.EXE_STATUS IN ('0','1')  
         ]]>
	</query>
	<query id="FrmHttDownLineManage.queryPlanMaxNo" desc="获取最大计划编号">
	<![CDATA[
     SELECT ? ||
       LPAD(SUBSTR(NVL(MAX(T.HEAT_PLAN_NO), '0000'), -4,4) + 1, 4, '0') AS HEAT_PLAN_NO
  FROM PLN_ZY_RCL_M T
 WHERE TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD') = ?
	]]>
	</query>
	<query id="FrmHttDownLineManage.UpdateOff" desc=" 修改离线表返线支数">
	<![CDATA[
UPDATE HTT_OFFLINE_RESULT
   SET RE_NUM      = ?,
       RE_WT       = ?,
       RE_TIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
       RE_NAME = ?,
       RETURN_PROCESS=?,
       HEAT_PLAN_NO=?
 WHERE RESULT_NO = ?
	]]>
	</query>
		<query id="FrmHttDownLineManage.UpdateStatus" desc="修改组炉返线状态30">
	<![CDATA[
   UPDATE PORT_HTT_BATCH_SAMPLE_RESULT T
   SET MAT_STATUS = '30',LEVE_LOG = '00', BAL_YEAR_MONTH_FAIL =TO_CHAR(SYSDATE , 'YYYYMM'),IS_FAIL_CHECK='1'
 WHERE  HEAT_PLAN_NO = ?
 AND PROCESS_SEQ = ?
   AND MAT_NO = ?
	]]>
	</query>





	<query id="FrmHttDownLineManage.UpdateStatus1" desc="修改组炉返线材料状态20">
	<![CDATA[
UPDATE PORT_HTT_BATCH_SAMPLE_RESULT T
   SET MAT_STATUS = DECODE(MAT_STATUS,'40','40','20'),LEVE_LOG = '10',BAL_YEAR_MONTH_FAIL ='',IS_FAIL_CHECK='0'
 WHERE  HEAT_PLAN_NO = ?
   AND  PROCESS_SEQ = ?
   AND  MAT_NO = ?
	]]>
	</query>
	<query id="FrmHttDownLineManage.queryStorageType" desc="查询库位信息">
	 <![CDATA[ 
SELECT T.STORAGE_ATTR,
       T.STORAGE_ATTR_NAME,
       T.STORAGE_TYPE_NO,
       T.STORAGE_TYPE_NAME,
       T.MANAGEMENT_NO,
       T.MANAGEMENT_NAME,
       T.DEPARTMENT_CODE,
       T.DEPARTMENT_DESC
  FROM YDM_BS_STORAGE T
 WHERE T.STORAGE_NO = ?
 AND T.VALIDFLAG='1'
	  ]]>
	</query>
	<query id="FrmHttDownLineManage.AddButtReturn" desc=" 新增位置表">
	<![CDATA[
INSERT INTO YDM_BC_BUTTRESS
  (MAT_NO,
   JUDGE_STOVE_NO,
   BATCH_NO,
   BATCH_GROUD_NO,
   STORAGE_NO,
   LOCATION_NO,
   STORAGE_ATTR,
   STORAGE_ATTR_NAME,
   STORAGE_TYPE_NO,
   STORAGE_TYPE_NAME,
   MANAGEMENT_NO,
   MANAGEMENT_NAME,
   CREATE_NAME,
   CREATE_TIME,
   DEPARTMENT_CODE,
   DEPARTMENT_DESC)
VALUES
  (?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
   ?,
   ?)
	]]>
	</query>
	<query id="FrmHttDownLineManage.DeletePortVrpReturn" desc="删除管号队列表">
	 <![CDATA[ 
DELETE PORT_HTT_BATCH_SAMPLE_RESULT
 WHERE HEAT_PLAN_NO = ?
   AND MAT_NO = ?
	  ]]>
	</query>
	<query id="FrmHttDownLineManage.DeleteReturnResu" desc="删除计划表">
	 <![CDATA[ 
DELETE PLN_ZY_RCL_M WHERE HEAT_PLAN_NO = ?
	  ]]>
	</query>
	<query id="FrmHttDownLineManage.DeleteReturnResuC" desc="删除计划从表">
	 <![CDATA[ 
DELETE PLN_ZY_RCL_C WHERE HEAT_PLAN_NO = ?
	  ]]>
	</query>
	<query id="FrmHttDownLineManage.DeleteMatReturn" desc="删除材料表">
	 <![CDATA[ 
DELETE MAT_BC_M WHERE MAT_NO = ?
	  ]]>
	</query>
	<query id="FrmHttDownLineManage.QueryComVrpRes" desc="查询返线后是否存在实绩">
	 <![CDATA[ 
SELECT NVL(SUM(PRO_NUM),0)  COUNT  FROM HTT_COM_INFO T WHERE T.HEAT_PLAN_NO = ?
	  ]]>
	</query>

	<query id="FrmHttDownLineManage.QueryComVrpRes1" desc="查询返线后是否存在实绩">
		<![CDATA[

SELECT COUNT(1) COUNT FROM  PORT_HTT_BATCH_SAMPLE_RESULT WHERE MAT_STATUS <> '00' AND HEAT_PLAN_NO = ?

	  ]]>
	</query>

	<query id="FrmHttDownLineManage.QueryButtMatNo" desc="查询材料表材料号">
	 <![CDATA[ 
SELECT   T1.MAT_NO  FROM (SELECT T.MAT_NO
               FROM MAT_BC_M T
              WHERE T.JUDGE_STOVE_NO = ?
                AND NVL(T.BATCH_NO, '/') = NVL(?, '/')
                AND T.PRODUCT_FLAG = '801401'
              ORDER BY T.MAT_NO) T1
 WHERE ROWNUM < ?
	  ]]>
	</query>
	<query id="FrmHttDownLineManage.QueryNewFurnMatNo" desc="查询管号队列另组炉材料号">
		<![CDATA[
       SELECT *
          FROM port_HTT_batch_sample_result T
         WHERE T.MAT_STATUS IN  ('30','40')
           AND T.RESULT_NO  = ?
             AND T.HEAT_PLAN_NO =  (SELECT HEAT_PLAN_NO FROM HTT_OFFLINE_RESULT WHERE RESULT_NO = ?)
         ORDER BY T.MAT_NO ASC
          ]]>
	</query>
	<query id="FrmHttDownLineManage.doQueryOutSourc" desc="委外实绩查询">
	 <![CDATA[ 
SELECT T.SUBCONTRACT_NO,
       T.SUBCONTRACT_NO_SEQ,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.STATION_CODE,
       T.STATION_DESC,
       T.HEAT_PLAN_NO,
       T.ZY_BATCH_ID,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.PRODUCCODE,
       T.PRODUCNAME,
       T.STEELCODE,
       T.STEELNAME,
       T.GRADECODE,
       T.GRADENAME,
       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.CRAFT_FILE_NO,
       T.SUBCONTRACT_NUM,
       T.SUBCONTRACT_WT,
       T.HB_COMPLETE_NUM,
       T.HB_COMPLETE_WT,
       T.SUBCONTRACT_USER,
       DECODE(T.SUBCONTRACT_SHIFT, '1', '早', '2', '中', '3', '夜') SUBCONTRACT_SHIFT,
       DECODE(T.SUBCONTRACT_GROUP,
              '1',
              '甲',
              '2',
              '乙',
              '3',
              '丙',
              '4',
              '丁') SUBCONTRACT_GROUP,
       TO_CHAR(T.SUBCONTRACT_TIME, 'YYYY-MM-DD HH24:MI:SS') SUBCONTRACT_TIME,
       T.SP_USER,
       TO_CHAR(T.SP_TIME, 'YYYY-MM-DD HH24:MI:SS') SP_TIME,
       DECODE(T.SUBCONTRACT_LOG,
              '00',
              '委外申请',
              '10',
              '审核通过',
              '20',
              '审核不通过',
              '30',
              '回报完毕') SUBCONTRACT_LOG,
       T.SUBCONTRACT_PLINE_CODE,
       T.SUBCONTRACT_PLINE_NAME,
       T.SUBCONTRACT_NOTE,
       T.HB_FP_NUM,
       T.HB_FP_WT,
       T.SP_NOTE,
       T.RESULT_NO
  FROM HTT_ENTRUSTED_BILL T
 WHERE 1=1
	  ]]>
	</query>
	<query id="FrmHttDownLineManage.AddOutSourc" desc="新增委外加工表">
	 <![CDATA[
	 INSERT INTO HTT_ENTRUSTED_BILL (SUBCONTRACT_NO, SUBCONTRACT_NO_SEQ, PLINE_CODE, 
PLINE_NAME, STATION_CODE, STATION_DESC, HEAT_PLAN_NO, ZY_BATCH_ID, PRO_PLAN_ID, 
GX_PLAN_NO, JUDGE_STOVE_NO, BATCH_NO, PRODUCCODE, PRODUCNAME, STEELCODE, 
STEELNAME, GRADECODE, GRADENAME, MODEL_CODE, MODEL_DESC, STD_CODE, STD_NAME, 
STD_STYLE, STD_STYLE_DESC, ACT_DIMATER, ACT_HEIGHT, ACT_LEN, ACT_LEN_MIN, 
ACT_LEN_MAX, CRAFT_FILE_NO, SUBCONTRACT_NUM, SUBCONTRACT_WT, SUBCONTRACT_USER, 
SUBCONTRACT_SHIFT, SUBCONTRACT_GROUP, SUBCONTRACT_TIME, SUBCONTRACT_LOG, 
SUBCONTRACT_NOTE,RESULT_NO) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 
TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?, ?,?)
	  ]]>
	</query>
	<query id="FrmHttDownLineManage.UpdateOffOutSourc" desc="修改离线表委外支数">
	 <![CDATA[
	UPDATE HTT_OFFLINE_RESULT
   SET SUBCONTRACT_NUM  = ?,
       SUBCONTRACT_WT   = ?,
       SUBCONTRACT_TIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
       SUBCONTRACT_NAME = ?
 WHERE RESULT_NO = ?

	  ]]>
	</query>
	<query id="FrmHttDownLineManage.deleteOutSourc" desc="删除委外加工表">
	 <![CDATA[
	DELETE HTT_ENTRUSTED_BILL
 WHERE SUBCONTRACT_NO = ?
   AND SUBCONTRACT_NO_SEQ = ?
	  ]]>
	</query>
	<query id="FrmHttDownLineManage.queryEntrustrMax" desc="获取最大委外单号">
	<![CDATA[
SELECT ? ||
       LPAD(SUBSTR(NVL(MAX(T.SUBCONTRACT_NO), '0000'), -4,4) + 1, 4, '0') AS SUBCONTRACT_NO
  FROM HTT_ENTRUSTED_BILL T
 WHERE TO_CHAR(T.SUBCONTRACT_TIME, 'YYYY-MM-DD') = ?
	]]>
	</query>
	<query id="FrmHttDownLineManage.QuerySubConStart" desc="查询委托状态">
	<![CDATA[
SELECT T.SUBCONTRACT_LOG
  FROM HTT_ENTRUSTED_BILL T
 WHERE T.SUBCONTRACT_NO = ?
   AND T.SUBCONTRACT_NO_SEQ = ?
	]]>
	</query>
	<query id="FrmHttDownLineManage.doQueryPlanStrat" desc="查询计划是否结炉">
	<![CDATA[
SELECT T.PLANSTATUS FROM PLN_ZY_RCL_M T WHERE T.HEAT_PLAN_NO = ?
	]]>
	</query>
	<query id="FrmHttDownLineManage.doQueryComInfo" desc="查询返线最大实绩">
	<![CDATA[
SELECT ? ||
       LPAD(SUBSTR(NVL(MAX(T.RESULT_NO), '000000'), -6, 6) + 1, 6, '0') AS RESULT_NO
  FROM VRP_COM_INFO T
 WHERE TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD') = ?
   AND T.PLINE_CODE = ?

	]]>
	</query>
	<query id="FrmHttDownLineManage.doUpdateFlagStoveNo" desc="修改离线标识炉号">
	<![CDATA[
	UPDATE HTT_OFFLINE_RESULT T
   SET T.FLAG_STOVE_NO = ?
 WHERE T.RESULT_NO = ?
	]]>
	</query>

	<query id="FrmHttDownLineManage.doUpdateFlagStoveNo1" desc="修改离线标识炉号">
		<![CDATA[
UPDATE MAT_BC_M
   SET FLAG_STOVE_NO_ZG = ?
 WHERE MAT_NO IN （  SELECT MAT_NO
          FROM PORT_HTT_BATCH_SAMPLE_RESULT
         WHERE HEAT_PLAN_NO = ?
           AND RESULT_NO = ?）
	]]>
	</query>

	<query id="FrmHttDownLineManage.UpdatePlanStatus" desc="全组炉返线, 关闭原计划">
		<![CDATA[
UPDATE PLN_ZY_RCL_M T
   SET PLANSTATUS = DECODE((SELECT COUNT(1)
                             FROM PORT_HTT_BATCH_SAMPLE_RESULT
                            WHERE HEAT_PLAN_NO = T.HEAT_PLAN_NO
                              AND MAT_STATUS <> '10'
                              AND MAT_STATUS <> '30'
                              AND MAT_STATUS <> '40'),
                           0,
                           '40',
                           '20')
 WHERE T.HEAT_PLAN_NO =?
	]]>
	</query>


	<query id="FrmHttDownLineManage.SelectRCLCount" desc="">
		<![CDATA[
       SELECT NVL(COUNT(1),0) COUNT FROM PLN_ZY_RCL_M WHERE PRO_PLAN_ID=? AND GX_PLAN_NO=?
	]]>
	</query>

	<query id="FrmHttDownLineManage.getPlineCapacityF" desc="">
		<![CDATA[
   SELECT T.HR_CAPCTY  FROM SLM_BASE_MATERIAL_F_PL T WHERE T.IN_MATERIAL_NO = ?  AND T.OUT_MATERIAL_NO = ? AND T.PLINE_CODE = ?
	]]>
	</query>

	<query id="FrmHttDownLineManage.getOrderMaxSeq" desc="">
		<![CDATA[
         SELECT MAX(TO_NUMBER(GX_PRO_SEQ))  GX_PRO_SEQ,
            TO_CHAR(MAX(PLAN_TIME_E), 'YYYY-MM-DD HH24:MI:SS')  PLAN_TIME_E
         FROM PLN_ORDER_RCL_S
        WHERE PLINE_CODE = ?
          AND EXE_STATUS = '0'
	]]>
	</query>

	<query id="FrmHttDownLineManage.updatePlanOrderF" desc="修改热处理排产">
		<![CDATA[
             UPDATE PLN_ORDER_RCL_S T
   SET T.PLINE_CODE       = '#PLINE_CODE#',
       T.PLINE_NAME       =（SELECT PLINE_NAME FROM COM_BASE_PLINE WHERE PLINE_CODE = '#PLINE_CODE#'),
       T.WEIGTH_S         = '#WEIGTH_S#',
       T.NUM_S            = '#NUM_S#',
       T.GX_PRO_SEQ       = '#GX_PRO_SEQ#',
       T.PLAN_USETIME     = '#PLAN_USETIME#',
       T.PLAN_TIME_B      = TO_DATE('#PLAN_TIME_B#', 'YYYY-MM-DD HH24:MI:SS'),
       T.PLAN_TIME_E      = TO_DATE('#PLAN_TIME_E#', 'YYYY-MM-DD HH24:MI:SS'),
       T.EXE_STATUS       = '#EXE_STATUS#',
       T.IS_REPAIR_PLN    = '#IS_REPAIR_PLN#',
       T.REPAIR_TYPE      = '#REPAIR_TYPE#',
       T.IS_PLAN_OK       = '#IS_PLAN_OK#',
       T.ISSUED_TIME      = TO_DATE('#ISSUED_TIME#', 'YYYY-MM-DD HH24:MI:SS'),
       T.ISSUED_MAN       = '#ISSUED_MAN#',
       T.LAST_UNDOWN_TIME = TO_DATE('#LAST_UNDOWN_TIME#',
                                    'YYYY-MM-DD HH24:MI:SS'),
       T.LAST_UNDOWN_MAN  = '#LAST_UNDOWN_MAN#',
       T.MEMO             = '#MEMO#',
        T.IN_WEIGHT_S      = '#IN_WEIGHT_S#',
       T.IN_NUM_S         = '#IN_NUM_S#',
       T.ADD_WT_IN        = '#ADD_WT_IN#',
       T.ADD_NUM_IN       = '#ADD_NUM_IN#',
       T.WEIGTH_S_MIN     ='#WEIGTH_S_MIN#'
 WHERE T.PRO_PLAN_ID = '#PRO_PLAN_ID#'
   AND T.GX_PLAN_NO = '#GX_PLAN_NO#'
               ]]>
	</query>


	<query id="FrmHttDownLineManage.updatePlanOrderF2" desc="修改热处理排产">
		<![CDATA[
UPDATE PLN_ORDER_RCL_S
   SET PLINE_CODE   = '#PLINE_CODE#',
       PLINE_NAME   = （SELECT PLINE_NAME FROM COM_BASE_PLINE WHERE PLINE_CODE = '#PLINE_CODE#'),
       PLAN_TIME_B      = TO_DATE('#PLAN_TIME_B#', 'YYYY-MM-DD HH24:MI:SS'),
       PLAN_TIME_E      = TO_DATE('#PLAN_TIME_E#', 'YYYY-MM-DD HH24:MI:SS'),
       PLAN_USETIME = '#PLAN_USETIME#',
       GX_PRO_SEQ   = '#GX_PRO_SEQ#',
       EXE_STATUS = '0'
 WHERE PRO_PLAN_ID = '#PRO_PLAN_ID#'
   AND GX_PLAN_NO = '#GX_PLAN_NO#'
               ]]>
	</query>

	<query id="FrmHttDownLineManage.updatePlanOrderF3" desc="修改热处理排产">
		<![CDATA[
UPDATE PLN_ORDER_RCL_S
   SET   EXE_STATUS = '1'
 WHERE PRO_PLAN_ID = '#PRO_PLAN_ID#'
   AND GX_PLAN_NO = '#GX_PLAN_NO#'
   AND GX_PRO_SEQ = '#GX_PRO_SEQ#'
               ]]>
	</query>

	<query id="FrmHttDownLineManage.updateRclMPlan" desc="修改热处理排产">
		<![CDATA[
UPDATE PLN_ZY_RCL_M
   SET PLINE_CODE_W   = DECODE(?,PLINE_CODE,'',?),
       PLINE_NAME_W   =   DECODE(?,PLINE_CODE,'',(SELECT PLINE_NAME FROM COM_BASE_PLINE WHERE PLINE_CODE =?))
 WHERE HEAT_PLAN_NO = ?
               ]]>
	</query>

	<query id="FrmHttDownLineManage.updateRclCPlan" desc="修改热处理排产">
		<![CDATA[
UPDATE PLN_ZY_RCL_C
 SET PLINE_CODE_W   = DECODE(?,PLINE_CODE,'',?),
       PLINE_NAME_W   =   DECODE(?,PLINE_CODE,'',(SELECT PLINE_NAME FROM COM_BASE_PLINE WHERE PLINE_CODE =?))
 WHERE HEAT_PLAN_NO =?
               ]]>
	</query>

	<query id="FrmHttDownLineManage.updateRclMPlanLotSqe" desc="修改热处理排产生产批炉内顺序">
		<![CDATA[
UPDATE PLN_ZY_RCL_M
   SET LOT_NO_SQE = LOT_NO_SQE - 1
 WHERE PRO_PLAN_ID = '#PRO_PLAN_ID#'
   AND GX_PLAN_NO = '#GX_PLAN_NO#'
   AND LOT_NO_SQE > #LOT_NO_SQE#
               ]]>
	</query>

	<query id="FrmHttDownLineManage.updateRclOffLine" desc="修改热处理排产">
		<![CDATA[
UPDATE HTT_OFFLINE_RESULT T
   SET PLINE_CODE   = ?,
       PLINE_NAME   = （SELECT PLINE_NAME FROM COM_BASE_PLINE WHERE PLINE_CODE = ?)
 WHERE HEAT_PLAN_NO = ?
 AND (TO_NUMBER(NVL(T.OFFLINE_NUM, 0)) - TO_NUMBER(NVL(T.GROUP_NUM, 0)) -
       TO_NUMBER(NVL(T.RE_NUM, 0)) - TO_NUMBER(NVL(T.SUBCONTRACT_NUM, 0)) +
       TO_NUMBER(NVL(T.SUBCONTRACTCOMPLETE_NUM, 0)))  > 0
               ]]>
	</query>

	<query id="FrmHttDownLineManage.updateRclPort" desc="修改热处理排产">
		<![CDATA[
UPDATE PORT_HTT_BATCH_SAMPLE_RESULT T
   SET PLINE_CODE   =?,
       PLINE_NAME   = （SELECT PLINE_NAME FROM COM_BASE_PLINE WHERE PLINE_CODE =?)
 WHERE HEAT_PLAN_NO = ?
 AND PROCESS_SEQ = (SELECT real_process_seq FROM pln_zy_rcl_m WHERE heat_plan_no = t.heat_plan_no)
 AND MAT_STATUS ='20'
               ]]>
	</query>

	<query id="FrmHttDownLineManage.addPlanOrderF" desc="新增热处理排产">
		<![CDATA[
            INSERT INTO PLN_ORDER_RCL_S
  (PRO_ORDER_NO,
   PRO_PLAN_ID,
   GX_PLAN_NO,
   PLAN_GROUP_ID,
   ORDER_SOURCE,
   ORD_LN_DLY_PK,
   PLN_DIVIDE_ID,
   ORDER_NO,
   ORDER_SEQ,
   DELIVERY_NO,
   REQ_BL_ID,
   PLINE_CODE,
   PLINE_NAME,
   INWL_ID,
   INWL_DESC,
   OUTWL_ID,
   OUTWL_DESC,
   GRADECODE,
   GRADENAME,
   OUTDIAMETER,
   WALLTHICK,
   LENGTHDISC,
   LENGTHMAX_IN,
   LENGTHMIN_IN,
   LENGTH_IN,
   AIMLENGTH,
   IN_WEIGHT_S,
   IN_NUM_S,
   WEIGTH_S,
   NUM_S,
   MATCH_WT_IN,
   MATCH_NUM_IN,
   IF_MONITOR_RCL,
   PRDCR_NO,
   MONITOR_POINT,
   CRAFT_FILE_NO,
   CRAFT_FILE_MAN,
   CRAFT_SEQ,
   STATION_ROAD,
   GX_PRO_SEQ,
   PLAN_USETIME,
   PLAN_TIME_B,
   PLAN_TIME_E,
   BATCHED_WT,
   BATCHED_NUM,
   FINISHWEIGHT,
   FINISHNUM,
   EXE_STATUS,
   IS_REPAIR_PLN,
   REPAIR_TYPE,
   ZY_BATCH_ID,
   ADD_WT_IN,
   ADD_NUM_IN,
   ISENDGX,
   CIC,
   PIC,
   SIC,
   DIC,
   WIC,
   GIC,
   IS_PLAN_OK,
   STEELCODE,
   STEELNAME,
   PRO_MONTH,
   PREVIOUS_GX,
   PREV_GXPLAN_ID,
   IF_EXPORT,
   CREATE_TIME,
   MEMO,
   ISSUED_TIME,
   ISSUED_MAN,
   LAST_UNDOWN_TIME,
   LAST_UNDOWN_MAN,
   VERSION_NO,
   PROCESSING_COST,
   TOTAL_COST,
   MSC,
   INDEX_SEQ,
   BOM,
   WHOLE_BACKLOG_DESC,
   WEIGTH_S_MIN,
   PRIORITY,
   PRIORITY_MEMO,PROCESS_CODE_C,PROCESS_DESC_C,DECISION,PRDCR_ADVC_DAY,GROUP_RCL)
  VALUES
  ('#PRO_ORDER_NO#',
         '#PRO_PLAN_ID#',
         '#GX_PLAN_NO#',
         '#PLAN_GROUP_ID#',
         '#ORDER_SOURCE#',
         '#ORD_LN_DLY_PK#',
         '#PLN_DIVIDE_ID#',
         '#ORDER_NO#',
         '#ORDER_SEQ#',
         '#DELIVERY_NO#',
         '#REQ_BL_ID#',
         '#PLINE_CODE#',
         （SELECT PLINE_NAME FROM COM_BASE_PLINE WHERE PLINE_CODE = '#PLINE_CODE#'),
         '#INWL_ID#',
         '#INWL_DESC#',
         '#OUTWL_ID#',
         '#OUTWL_DESC#',
         '#GRADECODE#',
         '#GRADENAME#',
         '#OUTDIAMETER#',
         '#WALLTHICK#',
         '#LENGTHDISC#',
         '#LENGTHMAX_IN#',
         '#LENGTHMIN_IN#',
         '#LENGTH_IN#',
         '#AIMLENGTH#',
         '#IN_WEIGHT_S#',
         '#IN_NUM_S#',
         '#WEIGTH_S#',
         '#NUM_S#',
         '#MATCH_WT_IN#',
         '#MATCH_NUM_IN#',
         '#IF_MONITOR_RCL#',
         '#PRDCR_NO#',
         '#MONITOR_POINT#',
         '#CRAFT_FILE_NO#',
         '#CRAFT_FILE_MAN#',
         '#CRAFT_SEQ#',
         '#STATION_ROAD#',
         '#GX_PRO_SEQ#',
         '#PLAN_USETIME#',
         TO_DATE('#PLAN_TIME_B#', 'YYYY-MM-DD HH24:MI:SS'),
         TO_DATE('#PLAN_TIME_E#', 'YYYY-MM-DD HH24:MI:SS'),
         '#BATCHED_WT#',
         '#BATCHED_NUM#',
         '#FINISHWEIGHT#',
         '#FINISHNUM#',
         '#EXE_STATUS#',
         '#IS_REPAIR_PLN#',
         '#REPAIR_TYPE#',
         '#ZY_BATCH_ID#',
         '#ADD_WT_IN#',
         '#ADD_NUM_IN#',
         '#ISENDGX#',
         '#CIC#',
         '#PIC#',
         '#SIC#',
         '#DIC#',
         '#WIC#',
         '#GIC#',
         '#IS_PLAN_OK#',
         '#STEELCODE#',
         '#STEELNAME#',
         '#PRO_MONTH#',
         '#PREVIOUS_GX#',
         '#PREV_GXPLAN_ID#',
         '#IF_EXPORT#',
         TO_DATE('#CREATE_TIME#', 'YYYY-MM-DD HH24:MI:SS'),
         '#MEMO#',
         TO_DATE('#ISSUED_TIME#', 'YYYY-MM-DD HH24:MI:SS'),
         '#ISSUED_MAN#',
         TO_DATE('#LAST_UNDOWN_TIME#', 'YYYY-MM-DD HH24:MI:SS'),
         '#LAST_UNDOWN_MAN#',
         '#VERSION_NO#',
         '#PROCESSING_COST#',
         '#TOTAL_COST#',
         '#MSC#',
         '#INDEX_SEQ#',
         '#BOM#',
         '#WHOLE_BACKLOG_DESC#',
         '#WEIGTH_S_MIN#',
         '#PRIORITY#',
         '#PRIORITY_MEMO#','#PROCESS_CODE_C#','#PROCESS_DESC_C#','#DECISION#','#PRDCR_ADVC_DAY#','#GROUP_RCL#')
               ]]>
	</query>
<query id = "FrmHttDownLineManage.insertVrpTakeReslut" desc = "插入脱单实绩表,脱单,回写PLN_ORDER_ZG_S">
<![CDATA[
DECLARE
  v_JUDGE_STOVE_NO HTT_OFFLINE_RESULT.JUDGE_STOVE_NO%TYPE := ?;
  v_STATION_CODE    HTT_OFFLINE_RESULT.STATION_CODE%TYPE := ?;
  v_PLINE_CODE     HTT_OFFLINE_RESULT.PLINE_CODE%TYPE :=?;

  v_ID           HTT_TAKE_RESULT.ID%TYPE := NULL;
  v_OFFLINE_PRO1 HTT_OFFLINE_RESULT.STATION_CODE%TYPE := NULL;
  v_NMB          HTT_TAKE_RESULT.ID%TYPE := NULL;
BEGIN
  --生成ID


  FOR MYROW IN (SELECT *
                  FROM HTT_OFFLINE_RESULT T
                 WHERE T.JUDGE_STOVE_NO = v_JUDGE_STOVE_NO
                   AND T.STATION_CODE = v_STATION_CODE
                   AND T.PLINE_CODE = v_PLINE_CODE) LOOP
                   
                   SELECT TO_CHAR(SYSDATE, 'YYMMDD') || v_PLINE_CODE ||
          LPAD(NVL(MAX(TO_NUMBER(SUBSTR(T.ID, LENGTH(T.ID) - 2))), 0) + 1,
               3,
               '0') ID  INTO v_ID
     FROM HTT_TAKE_RESULT T
    WHERE ID LIKE TO_CHAR(SYSDATE, 'YYMMDD') || v_PLINE_CODE || '___';
  
   insert into HTT_take_result
  (id,
   result_no,
   pline_code,
   pline_name,
   station_code,
   station_desc,
   heat_plan_no,
   zy_batch_id,
   pro_plan_id,
   gx_plan_no,
   judge_stove_no,
   batch_no,
   produccode,
   producname,
   steelcode,
   steelname,
   gradecode,
   gradename,
   model_code,
   model_desc,
   std_code,
   std_name,
   std_style,
   std_style_desc,
   act_dimater,
   act_height,
   act_len,
   act_len_min,
   act_len_max,
   zp_judge_stove_no,
   zp_batch_no,
   offline_num,
   offline_wt,
   re_num,
   re_wt,
   group_num,
   group_wt,
   subcontract_num,
   subcontractcomplete_num,
   subcontractcomplete_wt,
   subcontract_no,
   subcontract_no_seq,
   pro_year_month_day,
   pro_user,
   pro_shift,
   pro_group,
   pro_time,
   group_log,
   group_id,
   ord_ln_dly_pk,
   order_no,
   order_seq,
   delivery_no,
   update_time,
   update_name,
   return_process,
   subcontract_wt,
   re_time,
   re_name,
   subcontract_time,
   subcontract_name,
   subcontractcomplete_time,
   subcontractcomplete_name,
   hb_fp_num,
   hb_fp_wt,
   bal_year_month,
   zy_batch_id1,
   batch_groud_no,
   flag_stove_no,
   flag,
   take_time,
   take_user,
   take_num)
values
  (v_id,
   MYROW.result_no,
   MYROW.pline_code,
   MYROW.pline_name,
   MYROW.station_code,
   MYROW.station_desc,
   MYROW.heat_plan_no,
   MYROW.zy_batch_id,
   MYROW.pro_plan_id,
   MYROW.gx_plan_no,
   MYROW.judge_stove_no,
   MYROW.batch_no,
   MYROW.produccode,
   MYROW.producname,
   MYROW.steelcode,
   MYROW.steelname,
   MYROW.gradecode,
   MYROW.gradename,
   MYROW.model_code,
   MYROW.model_desc,
   MYROW.std_code,
   MYROW.std_name,
   MYROW.std_style,
   MYROW.std_style_desc,
   MYROW.act_dimater,
   MYROW.act_height,
   MYROW.act_len,
   MYROW.act_len_min,
   MYROW.act_len_max,
   MYROW.zp_judge_stove_no,
   MYROW.zp_batch_no,
   MYROW.offline_num,
   MYROW.offline_wt,
   MYROW.re_num,
   MYROW.re_wt,
   MYROW.group_num,
   MYROW.group_wt,
   MYROW.subcontract_num,
   MYROW.subcontractcomplete_num,
   MYROW.subcontractcomplete_wt,
   MYROW.subcontract_no,
   MYROW.subcontract_no_seq,
   MYROW.pro_year_month_day,
   MYROW.pro_user,
   MYROW.pro_shift,
   MYROW.pro_group,
   MYROW.pro_time,
   MYROW.group_log,
   MYROW.group_id,
   MYROW.ord_ln_dly_pk,
   MYROW.order_no,
   MYROW.order_seq,
   MYROW.delivery_no,
   MYROW.update_time,
   MYROW.update_name,
   MYROW.return_process,
   MYROW.subcontract_wt,
   MYROW.re_time,
   MYROW.re_name,
   MYROW.subcontract_time,
   MYROW.subcontract_name,
   MYROW.subcontractcomplete_time,
   MYROW.subcontractcomplete_name,
   MYROW.hb_fp_num,
   MYROW.hb_fp_wt,
   MYROW.bal_year_month,
   MYROW.zy_batch_id1,
   MYROW.batch_groud_no,
   MYROW.flag_stove_no,
   MYROW.flag,
   SYSDATE,
   ?,
   NVL(MYROW.OFFLINE_NUM, 0) - NVL(MYROW.GROUP_NUM, 0) -
   NVL(MYROW.RE_NUM, 0));

    UPDATE HTT_OFFLINE_RESULT T
       SET T.PRO_PLAN_ID = '', T.GX_PLAN_NO = '', T.Order_No = '',t.order_seq ='',t.DELIVERY_NO = ''
     WHERE T.JUDGE_STOVE_NO = v_JUDGE_STOVE_NO
       AND T.PLINE_CODE = v_PLINE_CODE
       AND T.STATION_CODE = v_STATION_CODE;
  END LOOP;
END;
]]>
</query>

<query id = "FrmHttDownLineManage.doQueryTake" desc = "查询是否已脱单">
<![CDATA[
select count(1) ACOUNT
  from HTT_TAKE_RESulT t
 where t.judge_stove_no = ?
   and t.ZY_BATCH_ID = ?
   and t.STATION_CODE = ?
   AND NVL(T.PRO_PLAN_ID, '/') = NVL(?, '/')
   AND NVL(T.GX_PLAN_NO, '/') = NVL(?, '/')
]]>
</query>

	<query id = "FrmHttDownLineManage.UpdateHeatPlanID" desc = "更新组炉委托表里的炉计划ID">
		<![CDATA[
DECLARE
BEGIN
  FOR MYROW IN (SELECT T.* FROM  HTT_OFFLINE_RESULT T WHERE RESULT_NO =?) LOOP
    IF(MYROW.SUBCONTRACT_NO IS NOT NULL) THEN
    UPDATE HTT_ENTRUST SET HEAT_PLAN_NO = MYROW.HEAT_PLAN_NO WHERE SUBCONTRACT_NO = MYROW.SUBCONTRACT_NO AND SUBCONTRACT_NO_SEQ = MYROW.SUBCONTRACT_NO_SEQ;
    UPDATE HTT_ENTRUST_RESULT SET HEAT_PLAN_NO = MYROW.HEAT_PLAN_NO WHERE SUBCONTRACT_NO = MYROW.SUBCONTRACT_NO
     AND SUBCONTRACT_NO_SEQ = MYROW.SUBCONTRACT_NO_SEQ;

     UPDATE HTT_CRACK_DETECTION_ET
        SET HEAT_PLAN_NO = MYROW.HEAT_PLAN_NO
      WHERE RESULT_NO IN
            (SELECT RESULT_NO
               FROM HTT_ENTRUST_RESULT
              WHERE SUBCONTRACT_NO = MYROW.SUBCONTRACT_NO
                AND SUBCONTRACT_NO_SEQ = MYROW.SUBCONTRACT_NO_SEQ);

  UPDATE HTT_COM_INFO
        SET HEAT_PLAN_NO = MYROW.HEAT_PLAN_NO,
        JUDGE_STOVE_NO=MYROW.JUDGE_STOVE_NO
      WHERE RESULT_NO IN
            (SELECT RESULT_NO
               FROM HTT_ENTRUST_RESULT
              WHERE SUBCONTRACT_NO = MYROW.SUBCONTRACT_NO
                AND SUBCONTRACT_NO_SEQ = MYROW.SUBCONTRACT_NO_SEQ);

       END IF;
  END LOOP;
END;
]]>
	</query>

	<query id = "FrmHttDownLineManage.UpdateHeatPlanID2" desc = "更新组炉委托表里的炉计划ID">
		<![CDATA[
DECLARE
BEGIN
  FOR MYROW IN (SELECT T.* FROM  HTT_OFFLINE_RESULT T WHERE RESULT_NO =?) LOOP
    IF(MYROW.SUBCONTRACT_NO IS NOT NULL) THEN
    UPDATE HTT_ENTRUST SET HEAT_PLAN_NO = '' WHERE SUBCONTRACT_NO = MYROW.SUBCONTRACT_NO AND SUBCONTRACT_NO_SEQ = MYROW.SUBCONTRACT_NO_SEQ;
    UPDATE HTT_ENTRUST_RESULT SET HEAT_PLAN_NO = '' WHERE SUBCONTRACT_NO = MYROW.SUBCONTRACT_NO
     AND SUBCONTRACT_NO_SEQ = MYROW.SUBCONTRACT_NO_SEQ;

     UPDATE HTT_CRACK_DETECTION_ET
        SET HEAT_PLAN_NO = ''
      WHERE RESULT_NO IN
            (SELECT RESULT_NO
               FROM HTT_ENTRUST_RESULT
              WHERE SUBCONTRACT_NO = MYROW.SUBCONTRACT_NO
                AND SUBCONTRACT_NO_SEQ = MYROW.SUBCONTRACT_NO_SEQ);

  UPDATE HTT_COM_INFO
        SET HEAT_PLAN_NO = ''
      WHERE RESULT_NO IN
            (SELECT RESULT_NO
               FROM HTT_ENTRUST_RESULT
              WHERE SUBCONTRACT_NO = MYROW.SUBCONTRACT_NO
                AND SUBCONTRACT_NO_SEQ = MYROW.SUBCONTRACT_NO_SEQ);

       END IF;
  END LOOP;
END;
]]>
	</query>

	<query id = "FrmHttDownLineManage.UpdateOldPortStauts" desc = "还原原管号队列的另组炉改成委外废品">
		<![CDATA[

UPDATE PORT_HTT_BATCH_SAMPLE_RESULT T
   SET MAT_STATUS = '40'
 WHERE MAT_NO IN
       (SELECT W1.MAT_NO
          FROM MCH_WASTE_MAT_NO   W1,
               MCH_BUG_D          W2,
               HTT_ENTRUST        E,
               HTT_ENTRUST_RESULT R,
               HTT_OFFLINE_RESULT O
         WHERE  O.RESULT_NO = ?
             AND O.SUBCONTRACT_NO = E.SUBCONTRACT_NO
             AND O.RESULT_NO = E.RESULT_NO
           AND E.SUBCONTRACT_NO = R.SUBCONTRACT_NO
           AND E.SUBCONTRACT_NO_SEQ = R.SUBCONTRACT_NO_SEQ
           AND R.RESULT_NO = W2.RESULT_NO
           AND W2.FAIL_BILL = W1.FAIL_BILL
           AND W2.FAIL_BILL_SQE = W2.FAIL_BILL_SQE
           AND W2.FAIL_SORT = '10')
     AND MAT_STATUS  IN ('30')

]]>
	</query>
	
	<query id="FrmHttDownLineManage.updateMatFlagStoveNo" desc="修改离线数据标识炉号">
		<![CDATA[
 UPDATE MAT_BC_M T
    SET T.FLAG_STOVE_NO_ZG = ?
  WHERE T.JUDGE_STOVE_NO = ?
    AND T.BATCH_NO = ?
    AND T.QCM_STAUS = '11'
    AND T.PROCESS_CDOE = ?
    AND ROWNUM < NVL(?, 0) + 1
               ]]>
	</query>

</queryMap>