<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="离线管理">
	<query id="FrmMchDownLineManage.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.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,
       T.OUTNUM_CUT,
       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.BATCH_GROUD_NO,
       T.FLAG_STOVE_NO,
       T.MEMO,
       DECODE(T.PRO_SHIFT, '1', '早', '2', '中', '3', '夜') 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,
        (select   DBMS_LOB.SUBSTR( WM_CONCAT(DISTINCT p.measuring_seq) , 4000)  from port_mch_batch_sample_result p where p.result_no = t.result_no) MAT_NO
  FROM MCH_OFFLINE_RESULT T
 WHERE 1=1
 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="FrmMchDownLineManage.doQueryOffLineGroup" 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.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.FLAG_STOVE_NO,
       DECODE(T.PRO_SHIFT, '1', '早', '2', '中', '3', '夜') 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.BAL_YEAR_MONTH,
       T.UPDATE_NAME,
       T.UPDATE_TIME
  FROM MCH_OFFLINE_RESULT T
 WHERE 1=1
 AND T.GROUP_LOG='1'
	  ]]>
	</query>
	
	<query id="FrmMchDownLineManage.QueryOffMatNo2" desc="查询管号队列离线材料号">
		<![CDATA[
          SELECT *
    FROM (SELECT T.*, DECODE(C.OUT_REPOSITORY, NULL, 1, 0) SEQ
            FROM PORT_MCH_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 = ?
             AND T.VALIDFLAG = '1')
   ORDER BY SEQ, MAT_NO

          ]]>
	</query>

	<query id="FrmMchDownLineManage.QueryOffMatNo3" desc="查询管号队列离线材料号">
		<![CDATA[
        SELECT *
  FROM (SELECT T.*
          FROM port_MCH_batch_sample_result T
         WHERE T.MAT_STATUS = '20'
           AND T.HEAT_PLAN_NO =?
             AND T.RESULT_NO = ?
             AND T.VALIDFLAG = '1'
         ORDER BY T.MAT_NO ASC)
 WHERE ROWNUM <= ?
          ]]>
	</query>


	<query id="FrmMchDownLineManage.QueryOffMatNo4" desc="查询管号队列离线材料号">
		<![CDATA[
          SELECT *
    FROM (SELECT T.*, DECODE(C.OUT_REPOSITORY, NULL, 1, 0) SEQ
            FROM PORT_MCH_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 IN  ('20','40')
             AND T.RESULT_NO = ?
             AND T.VALIDFLAG = '1')
   ORDER BY SEQ, MAT_NO

          ]]>
	</query>


	<query id="FrmMchDownLineManage.QueryGroupHttResult" desc="查询组炉履历表信息">
		<![CDATA[
			SELECT
				T.*,B.*
			FROM
				MCH_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
					MCH_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="FrmMchDownLineManage.deteleVrpPort" desc="删除管号队列新增数据">
	  <![CDATA[
	DELETE port_mch_batch_sample_result T where T.MAT_NO = ? AND t.HEAT_PLAN_NO = ?
	and t.OP_PROCESS = ?
	  ]]>
	</query>
	<query id="FrmMchDownLineManage.doQueryOffLineNum" desc="查询离线实绩">
	  <![CDATA[
	 SELECT 
       (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,
       abs((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 MCH_OFFLINE_RESULT T
 WHERE 1=1 and t.HEAT_PLAN_NO = ? AND T.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="FrmMchDownLineManage.doQueryReturnLine" 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.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.FLAG_STOVE_NO,
       DECODE(T.PRO_SHIFT, '1', '早', '2', '中', '3', '夜') 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,
        (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = T.RETURN_PROCESS) RETURN_PROCESS,
       T.RETURN_PROCESS RETURN_PROCESS_CODE,
       T.BAL_YEAR_MONTH,
       T.BATCH_GROUD_NO,
       T.RE_NAME,
       T.RE_TIME
  FROM MCH_OFFLINE_RESULT T
 WHERE 1=1
 AND TO_NUMBER(NVL(T.RE_NUM, 0)) <>0
	  ]]>
	</query>
	<query id="FrmMchDownLineManage.QueryNewFurnMatNo" desc="查询管号队列另组炉材料号">
		<![CDATA[
        SELECT *
          FROM port_Mch_batch_sample_result T
         WHERE T.MAT_STATUS = '30'
           AND T.RESULT_NO  = ?
         ORDER BY T.MAT_NO ASC
          ]]>
	</query>
	<query id="FrmMchDownLineManage.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))) 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 MCH_OFFLINE_RESULT T
 WHERE 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="FrmMchDownLineManage.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,    
       T2.*
  FROM PLN_ORDER_JGX_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) DIMATER,
               NVL(Q1.HEIGHT, 0) HEIGHT,
               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 ('%' || ?|| '%')

   ]]>
	</query>
	<query id="FrmMchDownLineManage.QueryOffLineMaxResultNo" desc="查询最大离线实绩编号">
        <![CDATA[
                  	SELECT ? ||
	LPAD(NVL(MAX(TO_NUMBER(SUBSTR(RESULT_NO, LENGTH(RESULT_NO) - 5))),
	0) + 1,
	6,
	'0') RESULT_NO
	FROM MCH_OFFLINE_RESULT
	WHERE RESULT_NO LIKE ? || '______'
        ]]>
	</query>
	
	
	<query id="FrmMchDownLineManage.deleteOfflineD" desc="返线后删除离线记录">
        <![CDATA[
	 DELETE MCH_OFFLINE_RESULT_D 
	 WHERE RESULT_NO = ? AND HEAT_PLAN_NO = ? AND PLINE_CODE = ?
        ]]>
	</query>
	
	<query id="FrmMchDownLineManage.QueryGroupResult" desc="查询组操作Id">
        <![CDATA[
	SELECT ? ||
  LPAD(SUBSTR(NVL(MAX(T.GROUP_ID),'000000'),-6,6) + 1, 6, '0') AS GROUP_ID
  FROM MCH_GROUP_RESULT T
  WHERE TO_CHAR(T.PRO_TIME,'YYYY-MM-DD') = ?
        ]]>
	</query>
	<query id="FrmMchDownLineManage.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
  FROM MCH_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="FrmMchDownLineManage.QueryOffLineGroupId" desc="查询组炉信息">
        <![CDATA[
SELECT COUNT(1) COUNT
  FROM MCH_OFFLINE_RESULT T
 WHERE T.GROUP_LOG = '1'
   AND T.RESULT_NO = ?
   AND T.GROUP_ID = ?
        ]]>
	</query>
	<query id="FrmMchDownLineManage.AddOffLineResu" desc="新增组炉实绩">
        <![CDATA[
INSERT INTO MCH_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, UPDATE_TIME, GROUP_LOG, GROUP_ID, ORD_LN_DLY_PK, ORDER_NO, ORDER_SEQ, 
DELIVERY_NO,ZY_BATCH_ID1,BATCH_GROUD_NO,PRO_TIME,UPDATE_NAME,FLAG_STOVE_NO,OUTNUM_CUT) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 
TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), '1', ?, ?, ?, ?, ?,?,?,TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),?,?,?)
        ]]>
	</query>
	<query id="FrmMchDownLineManage.UpdateOffLineResu" desc="修改离线组炉支，吨">
        <![CDATA[    
 DECLARE
BEGIN
  UPDATE MCH_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 MCH_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="FrmMchDownLineManage.UpdateOffLineComm" desc="修改离线表数据（改判）">
        <![CDATA[ 
        UPDATE MCH_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    = ?,
       PRO_PLAN_ID    = ?,
       GX_PLAN_NO     = ?
 WHERE RESULT_NO = ?  
        ]]>
	</query>
	<query id="FrmMchDownLineManage.DaeleteGroupResu" desc="修改离线组炉支，吨,删除组炉履历表">
        <![CDATA[    
 DECLARE
BEGIN
  UPDATE MCH_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 MCH_GROUP_RESULT
   WHERE GROUP_ID = ?
     AND GROUP_XH = ?;
END;
        ]]>
	</query>
	<query id="FrmMchDownLineManage.DeleteOffLineResu" desc="删除离线表组炉记录">
        <![CDATA[    
DELETE MCH_OFFLINE_RESULT
 WHERE RESULT_NO = ?
 AND GROUP_ID=?
        ]]>
	</query>
		<query id="FrmMchDownLineManage.UpdateStatus" desc=" 修改组炉返线材料状态">
	<![CDATA[
UPDATE PORT_MCH_BATCH_SAMPLE_RESULT
   SET MAT_STATUS = '30',LEVE_LOG = '00',BAL_YEAR_MONTH_FAIL =TO_CHAR(SYSDATE , 'YYYYMM'),IS_FAIL_CHECK='1'
 WHERE HEAT_PLAN_NO = ?
   AND MAT_NO = ?
	]]>
	</query>
	<query id="FrmMchDownLineManage.UpdateStatus1" desc=" 修改组炉返线材料状态">
	<![CDATA[
UPDATE PORT_MCH_BATCH_SAMPLE_RESULT
   SET MAT_STATUS = '20',LEVE_LOG = '10',BAL_YEAR_MONTH_FAIL ='',IS_FAIL_CHECK='0'
 WHERE  HEAT_PLAN_NO = ?
   AND MAT_NO = ?
	]]>
	</query>
		<query id="FrmMchDownLineManage.UpdatePlanStatus" desc="全组炉返线, 关闭原计划">
		<![CDATA[
UPDATE PLN_ZY_JGX_M T
   SET PLANSTATUS = DECODE((SELECT COUNT(1)
                             FROM PORT_MCH_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="FrmMchDownLineManage.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 MCH_GROUP_RESULT
 WHERE GROUP_ID = ?
        ]]>
	</query>
	<query id="FrmMchDownLineManage.doQuery" desc="查询工序点">
        <![CDATA[    
SELECT T.BASECODE,T.BASENAME
  FROM COM_BASE_INFO T
 WHERE T.SORTCODE = ?
   AND T.VALIDFLAG = '1'
   AND T.BASENAME NOT IN ('交库')
   ORDER BY T.BASECODE ASC
        ]]>
	</query>
		<query id="FrmMchDownLineManage.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 9
                    when STATION_NAMES = '测量点' then 10
                      when STATION_NAMES = '下线' then 11
                        end
        ]]>
	</query>

	<query id="FrmMchDownLineManage.doQueryLastGX" desc="查询工序点">
		<![CDATA[
SELECT T.*,
       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = T.STATION_CODES) STATION_NAMES
  FROM (SELECT REGEXP_SUBSTR(STATION_CODES, '[^;]+', 1, LEVEL) STATION_CODES
          FROM (SELECT SUBSTR(STATION_CODES,
                              0,
                              INSTR(STATION_CODES, ?) +
                              LENGTH(?)) STATION_CODES
                  FROM MCH_COM_SETPLINE
                 WHERE PLINE_CODE = ?)
        CONNECT BY REGEXP_SUBSTR(STATION_CODES, '[^;]+', 1, LEVEL) IS NOT NULL) T
        ]]>
	</query>


		<query id="FrmMchDownLineManage.queryGxPosition" desc="查询产线下工序的位置">
		<![CDATA[
SELECT LENGTH(SUBSTR(T.STATION_NAMES, 0, INSTR(STATION_NAMES, ?))) -
       LENGTH(REPLACE(SUBSTR(T.STATION_NAMES,0,INSTR(STATION_NAMES, ?)), ';', '')) + 1  CNUM
  FROM MCH_COM_SETPLINE T
 WHERE T.PLINE_CODE = ?
			]]>
	</query>
		<query id="FrmMchDownLineManage.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="FrmMchDownLineManage.AddReturnResu" desc="新增管加工计划表">
        <![CDATA[    
DECLARE
BEGIN
  FOR MROW 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,
                      WEIGTH_S,
                      NUM_S,
                      GX_PRO_SEQ,
                      PLAN_USETIME,
                      PLAN_TIME_B,
                      PLAN_TIME_E,
                      EXE_STATUS,
                      IS_REPAIR_PLN,
                      REPAIR_TYPE,
                      STEELCODE,
                      STEELNAME,
                      OUTDIAMETER,
                      WALLTHICK,
                      LENGTHMAX,
                      LENGTHMIN,
                      LENGTHDISC,
                      AIMWALLTHICK,
                      AIMLENGTH,
                      SHRT_LEN_RATO,
                      SHORTEST,
                      LONG_LEN_RATO,
                      LONGEST,
                      SHRT_STOVE,
                      AVG_LEN_MIN,
                      DIFRNC_LEN_MAX,
                      SIGL_LEN,
                      ENDLEN_SPECSTD,
                      MODEL_CODE,
                      MODEL_DESC,
                      LENGTHMAX_IN,
                      LENGTHMIN_IN,
                      LENGTH_IN,
                      OUTNUM_CUT,
                      IN_WEIGHT_S,
                      IN_NUM_S,
                      ADD_WT_IN,
                      ADD_NUM_IN,
                      MATCH_WT_IN,
                      MATCH_NUM_IN,
                      IF_MONITOR_JGX,
                      PRDCR_NO,
                      MONITOR_POINT,
                      CIC,
                      PIC,
                      SIC,
                      DIC,
                      WIC,
                      GIC,
                      CRAFT_FILE_NO,
                      CRAFT_FILE_MAN,
                      CRAFT_SEQ,
                      STATION_ROAD,
                      BATCHED_WT,
                      BATCHED_NUM,
                      FINISHWEIGHT,
                      FINISHNUM,
                      IS_PLAN_OK,
                      ZY_BATCH_ID,
                      PRO_MONTH,
                      PREVIOUS_GX,
                      PREV_GXPLAN_ID,
                      IF_EXPORT,
                      FINAL_USER_DESC,
                      PROCESS_DESC_C_ZG,
                      GROUP_ROLL_NAME,
                      BEGIN_TIME_ZG,
                      PRDCR_ADVC_DAY,
                      WHOLE_BACKLOG_DESC,
                      PRIORITY,
                      PRIORITY_MEMO,
                      DELVRY_EDATE,
                      STATION_NM,
                      OUTLINE_SITE_250,
                      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_JGX_S
                WHERE PRO_PLAN_ID = ?
                  AND GX_PLAN_NO = ?) LOOP
    INSERT INTO PLN_ZY_JGX_M
      (HEAT_PLAN_NO,
       ZY_BATCH_ID,
       PRO_PLAN_ID,
       GX_PLAN_NO,
      -- GX_NAME_LAST,
       --HEAT_PLAN_NO,
       JUDGE_STOVE_NO,
       BATCH_NO,
       --BATCH_GROUD_NO,
       PLINE_CODE,
       PLINE_NAME,
       ORDER_SOURCE,
       ORD_LN_DLY_PK,
       ORDER_NO,
       ORDER_SEQ,
       DELIVERY_NO,
       REQ_BL_ID,
       STEELCODE,
       STEELNAME,
       OUTDIAMETER,
       WALLTHICK,
       LENGTHMAX,
       LENGTHMIN,
       --LENGTHDISC,
       --AIMWALLTHICK,
      -- AIMLENGTH,
       MODEL_CODE,
       MODEL_DESC,
       LENGTHMAX_IN,
       LENGTHMIN_IN,
       INWL_ID,
       INWL_DESC,
       --IN_WT,
       --IN_NUM,
       --IF_WL_MATCHED,
       OUTWL_ID,
       OUTWL_DESC,
      -- OUT_WT,
      -- OUT_NUM,
       IF_MONITOR,
       PRDCR_NO,
       MONITOR_POINT,
       CRAFT_FILE_NO,
       CRAFT_FILE_MAN,
       CRAFT_SEQ,
       SEC_CRAFT_FILE_NO,
       STATION_ROAD,
       PLANSTATUS,
      -- IN_WT_REAL,
       --IN_NUM_REAL,
       CREATE_NAME,
       CREATE_TIME--,
       --IN_JUDGE_STD
       )
    VALUES
      (?,
       MROW.ZY_BATCH_ID,
       MROW.PRO_PLAN_ID,
       MROW.GX_PLAN_NO,
     --  MROW.PREVIOUS_GX,
      -- ?,
       ?,
       ?,
      -- ?,
       MROW.PLINE_CODE,
       MROW.PLINE_NAME,
       MROW.ORDER_SOURCE,
       MROW.ORD_LN_DLY_PK,
       MROW.ORDER_NO,
       MROW.ORDER_SEQ,
       MROW.DELIVERY_NO,
       MROW.REQ_BL_ID,
       MROW.STEELCODE,
       MROW.STEELNAME,
       MROW.OUTDIAMETER,
       MROW.WALLTHICK,
       MROW.LENGTHMAX,
       MROW.LENGTHMIN,
      -- MROW.LENGTHDISC,
       --MROW.AIMWALLTHICK,
       --MROW.AIMLENGTH,
       MROW.MODEL_CODE,
       MROW.MODEL_DESC,
       MROW.LENGTHMAX_IN,
       MROW.LENGTHMIN_IN,
       MROW.INWL_ID,
       MROW.INWL_DESC,
      -- ?,
      -- ?,
      -- '1',
       MROW.OUTWL_ID,
       MROW.OUTWL_DESC,
      -- ?,
     --  ?,
       MROW.IF_MONITOR_JGX,
       MROW.PRDCR_NO,
       MROW.MONITOR_POINT,
       MROW.CRAFT_FILE_NO,
       MROW.CRAFT_FILE_MAN,
       MROW.CRAFT_SEQ,
       ?,
       MROW.STATION_ROAD,
       ?,
      -- ?,
      -- ?,
       ?,
       TO_DATE(?,'YYYY-MM-DD HH24:MI:SS')--,
       --?
       );
  END LOOP;
END;
        ]]>
	</query>
	
		<query id="FrmMchDownLineManage.AddReturnResuC" desc="新增管加工计划从表">
        <![CDATA[    
DECLARE
BEGIN
  FOR MROW 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,
                      WEIGTH_S,
                      NUM_S,
                      GX_PRO_SEQ,
                      PLAN_USETIME,
                      PLAN_TIME_B,
                      PLAN_TIME_E,
                      EXE_STATUS,
                      IS_REPAIR_PLN,
                      REPAIR_TYPE,
                      STEELCODE,
                      STEELNAME,
                      OUTDIAMETER,
                      WALLTHICK,
                      LENGTHMAX,
                      LENGTHMIN,
                      LENGTHDISC,
                      AIMWALLTHICK,
                      AIMLENGTH,
                      SHRT_LEN_RATO,
                      SHORTEST,
                      LONG_LEN_RATO,
                      LONGEST,
                      SHRT_STOVE,
                      AVG_LEN_MIN,
                      DIFRNC_LEN_MAX,
                      SIGL_LEN,
                      ENDLEN_SPECSTD,
                      MODEL_CODE,
                      MODEL_DESC,
                      LENGTHMAX_IN,
                      LENGTHMIN_IN,
                      LENGTH_IN,
                      OUTNUM_CUT,
                      IN_WEIGHT_S,
                      IN_NUM_S,
                      ADD_WT_IN,
                      ADD_NUM_IN,
                      MATCH_WT_IN,
                      MATCH_NUM_IN,
                      IF_MONITOR_JGX,
                      PRDCR_NO,
                      MONITOR_POINT,
                      CIC,
                      PIC,
                      SIC,
                      DIC,
                      WIC,
                      GIC,
                      CRAFT_FILE_NO,
                      CRAFT_FILE_MAN,
                      CRAFT_SEQ,
                      STATION_ROAD,
                      BATCHED_WT,
                      BATCHED_NUM,
                      FINISHWEIGHT,
                      FINISHNUM,
                      IS_PLAN_OK,
                      ZY_BATCH_ID,
                      PRO_MONTH,
                      PREVIOUS_GX,
                      PREV_GXPLAN_ID,
                      IF_EXPORT,
                      FINAL_USER_DESC,
                      PROCESS_DESC_C_ZG,
                      GROUP_ROLL_NAME,
                      BEGIN_TIME_ZG,
                      PRDCR_ADVC_DAY,
                      WHOLE_BACKLOG_DESC,
                      PRIORITY,
                      PRIORITY_MEMO,
                      DELVRY_EDATE,
                      STATION_NM,
                      OUTLINE_SITE_250,
                      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_JGX_S
                WHERE PRO_PLAN_ID = ?
                  AND GX_PLAN_NO = ?) LOOP
    INSERT INTO PLN_ZY_JGX_C
      (HEAT_PLAN_NO,
       ZY_BATCH_ID,
       PRO_PLAN_ID,
       GX_PLAN_NO,
      -- GX_NAME_LAST,
       HEAT_PLAN_SQE,
       JUDGE_STOVE_NO,
       BATCH_NO,
       BATCH_GROUD_NO,
       PLINE_CODE,
       PLINE_NAME,
       --ORDER_SOURCE,
       --ORD_LN_DLY_PK,
       --ORDER_NO,
       --ORDER_SEQ,
       --DELIVERY_NO,
       --REQ_BL_ID,
       --STEELCODE,
       --STEELNAME,
       OUTDIAMETER_IN,
       WALLTHICK_IN,
       --LENGTHMAX,
       --LENGTHMIN,
       --LENGTHDISC,
       --AIMWALLTHICK,
       --AIMLENGTH,
       --MODEL_CODE,
       --MODEL_DESC,
       LENGTHMAX_IN,
       LENGTHMIN_IN,
       --INWL_ID,
       --INWL_DESC,
       --IN_WT,
       --IN_NUM,
       --IF_WL_MATCHED,
      -- OUTWL_ID,
      -- OUTWL_DESC,
      -- OUT_WT,
      -- OUT_NUM,
       --IF_MONITOR_JGX,
       --PRDCR_NO,
       --MONITOR_POINT,
       --CRAFT_FILE_NO,
       --CRAFT_FILE_MAN,
       --CRAFT_SEQ,
      -- SEC_CRAFT_FILE_NO,
       --STATION_ROAD,
       --PLANSTATUS,
       PLAN_INDOUBLE_NUM,
       PLAN_INDOUBLE_WT,
       REAL_INDOUBLE_NUM,
       REAL_INDOUBLE_WT
       --CREATE_NAME,
       --CREATE_TIME,
      -- IN_JUDGE_STD
       )
    VALUES
      (?,
       MROW.ZY_BATCH_ID,
       MROW.PRO_PLAN_ID,
       MROW.GX_PLAN_NO,
      -- MROW.PREVIOUS_GX,
       ?,
       ?,
       ?,
       ?,
       MROW.PLINE_CODE,
       MROW.PLINE_NAME,
       --MROW.ORDER_SOURCE,
       --MROW.ORD_LN_DLY_PK,
       --MROW.ORDER_NO,
       --MROW.ORDER_SEQ,
      -- MROW.DELIVERY_NO,
       --MROW.REQ_BL_ID,
       --MROW.STEELCODE,
      -- MROW.STEELNAME,
       MROW.OUTDIAMETER,
       MROW.WALLTHICK,
       --MROW.LENGTHMAX,
       --MROW.LENGTHMIN,
       --MROW.LENGTHDISC,
       --MROW.AIMWALLTHICK,
       --MROW.AIMLENGTH,
       --MROW.MODEL_CODE,
       --MROW.MODEL_DESC,
       MROW.LENGTHMAX_IN,
       MROW.LENGTHMIN_IN,
       --MROW.INWL_ID,
      -- MROW.INWL_DESC,
      -- ?,
       --?,
       --'1',
      -- MROW.OUTWL_ID,
      -- MROW.OUTWL_DESC,
      -- ?,
      -- ?,
      -- MROW.IF_MONITOR_JGX,
       --MROW.PRDCR_NO,
       --MROW.MONITOR_POINT,
       --MROW.CRAFT_FILE_NO,
       --MROW.CRAFT_FILE_MAN,
       --MROW.CRAFT_SEQ,
      -- ?,
      -- MROW.STATION_ROAD,
      -- ?,
       ?,
       ?,
       ?,
       ?
       --?,
      -- TO_DATE(?,'YYYY-MM-DD HH24:MI:SS'),
      -- ?
       );
  END LOOP;
END;
        ]]>
	</query>
	
			<query id="FrmMchDownLineManage.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_JGX_C T
 WHERE T.HEAT_PLAN_NO = ?
        ]]>
	</query>
	<query id="FrmMchDownLineManage.UpdatePortVrpReturn" desc="修改管号队列表">
        <![CDATA[          
UPDATE PORT_MCH_BATCH_SAMPLE_RESULT
   SET MAT_STATUS          = ?,
       LEVE_LOG            = ?,
       PRC_TECHNOLOGY_PATH = ?,
       RETURN_PROCESS      = ?,
       FLAG_STOVE_NO       = ?,
       TR_FLAG = ?,
       MEASURING_SEQ = ?,
        INSTORE_FLAG =?
 WHERE HEAT_PLAN_NO = ?
   AND MAT_NO = ?
         ]]>
	</query>

	<query id="FrmMchDownLineManage.QueryOffMatNo" desc="查询管号队列离线材料号">
        <![CDATA[  
        SELECT *
  FROM (SELECT T.MAT_NO
          FROM PORT_MCH_BATCH_SAMPLE_RESULT T
         WHERE T.MAT_STATUS = '20'
           AND T.HEAT_PLAN_NO = ?
           AND T.RESULT_NO = ?
           AND T.OP_PROCESS = ?
         ORDER BY T.MAT_NO ASC)
 WHERE ROWNUM < ?
          ]]>
	</query>
	<query id="FrmMchDownLineManage.QueryReturnMatNo" desc="查询管号队列返线的材料号">
        <![CDATA[  
        SELECT *
  FROM (SELECT T.MAT_NO
          FROM PORT_MCH_BATCH_SAMPLE_RESULT T
         WHERE T.LEVE_LOG = '20'
           AND T.HEAT_PLAN_NO = ?
           AND T.RETURN_PROCESS = ?
         ORDER BY T.MAT_NO ASC)
 WHERE ROWNUM < ?
          ]]>
	</query>
	<query id="FrmMchDownLineManage.AddPortVrpReturn" desc="新增管号队列表">
        <![CDATA[          
     INSERT INTO PORT_MCH_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,
   PRO_PLAN_ID,
   GX_PLAN_NO,
   FEED_HEAT_NO,
   PHY_BATCH_NO,
   HEAT_PLAN_SQE,
   OUTNUM_CUT,
   INSTORE_FLAG,
   IS_FAIL_CHECK,
   BAL_YEAR_MONTH_FAIL,
   BAL_YEAR_MONTH)
VALUES
  (?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?)

         ]]>
	</query>
	<query id="FrmMchDownLineManage.UpdateMatReturn" desc="修改材料表">
        <![CDATA[         
UPDATE MAT_BC_M T
   SET T.MAT_STATUS     = ?,
       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="FrmMchDownLineManage.DeleteButtReturn" desc="删除位置表">
        <![CDATA[   
        DELETE YDM_BC_BUTTRESS T WHERE T.MAT_NO=?
         ]]>
	</query>
	<query id="FrmMchDownLineManage.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="FrmMchDownLineManage.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="FrmMchDownLineManage.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.STEELCODE,
       T.STEELNAME,
       T.OUTDIAMETER,
       T.WALLTHICK,
       T.LENGTHMAX,
       T.LENGTHMIN,
       T.LENGTHDISC,
       T.AIMWALLTHICK,
       T.AIMLENGTH,
       T.SHRT_LEN_RATO,
       T.SHORTEST,
       T.LONG_LEN_RATO,
       T.LONGEST,
       T.SHRT_STOVE,
       T.AVG_LEN_MIN,
       T.DIFRNC_LEN_MAX,
       T.SIGL_LEN,
       T.ENDLEN_SPECSTD,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.LENGTHMAX_IN,
       T.LENGTHMIN_IN,
       T.LENGTH_IN,
       T.OUTNUM_CUT,
       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.IF_MONITOR_JGX,
       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.PRO_MONTH,
       T.PREVIOUS_GX,
       T.PREV_GXPLAN_ID,
       T.IF_EXPORT,
       T.FINAL_USER_DESC,
       T.PROCESS_DESC_C_ZG,
       T.GROUP_ROLL_NAME,
       TO_CHAR(T.BEGIN_TIME_ZG, 'YYYY-MM-DD HH24:MI:SS') BEGIN_TIME_ZG,
       T.PRDCR_ADVC_DAY,
       T.WHOLE_BACKLOG_DESC,
       T.PRIORITY,
       T.PRIORITY_MEMO,
       TO_CHAR(T.DELVRY_EDATE, 'YYYY-MM-DD HH24:MI:SS') DELVRY_EDATE,
       T.STATION_NM,
       T.OUTLINE_SITE_250,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T.MEMO,
       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.IF_STOVE_ISSUED,
       TO_CHAR(T.STOVE_ISSUED_TIME, 'YYYY-MM-DD HH24:MI:SS') STOVE_ISSUED_TIME,
       T.STOVE_ISSUED_MAN,
       T.IS_ONLOAD_LINE
  FROM PLN_ORDER_JGX_S T
 WHERE
T.PRO_PLAN_ID = ?
AND T.GX_PLAN_NO = ?
AND T.EXE_STATUS IN ('0','1')  
         ]]>
	</query>
	<query id="FrmMchDownLineManage.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_JGX_M T
 WHERE TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD') = ?
	]]>
	</query>
	<query id="FrmMchDownLineManage.UpdateOff" desc=" 修改离线表返线支数">
	<![CDATA[
UPDATE MCH_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="FrmMchDownLineManage.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="FrmMchDownLineManage.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="FrmMchDownLineManage.DeletePortVrpReturn" desc="删除管号队列表">
	 <![CDATA[ 
DELETE PORT_MCH_BATCH_SAMPLE_RESULT
 WHERE HEAT_PLAN_NO = ?
	  ]]>
	</query>

	<query id="FrmMchDownLineManage.DeleteOffLineRecode" desc="删除组炉炉计划的离线记录">
		<![CDATA[
DELETE MCH_OFFLINE_RESULT
 WHERE HEAT_PLAN_NO = ?  AND GROUP_LOG ='0'
	  ]]>
	</query>

	<query id="FrmMchDownLineManage.DeleteReturnResu" desc="删除计划表">
	 <![CDATA[ 
DELETE PLN_ZY_JGX_M WHERE HEAT_PLAN_NO = ?
	  ]]>
	</query>
	<query id="FrmMchDownLineManage.DeleteReturnResuC" desc="删除计划从表">
	 <![CDATA[ 
DELETE PLN_ZY_JGX_C WHERE HEAT_PLAN_NO = ?
	  ]]>
	</query>
	<query id="FrmMchDownLineManage.DeleteMatReturn" desc="删除材料表">
	 <![CDATA[ 
DELETE MAT_BC_M WHERE MAT_NO = ?
	  ]]>
	</query>
	<query id="FrmMchDownLineManage.QueryComVrpRes" desc="查询返线后是否存在实绩">
	 <![CDATA[ 

SELECT NVL(SUM(PRO_NUM),0)  COUNT  FROM MCH_COM_INFO T WHERE T.HEAT_PLAN_NO = ?
	  ]]>
	</query>
	<query id="FrmMchDownLineManage.QueryButtMatNo" desc="查询材料表材料号">
	 <![CDATA[ 
         SELECT * FROM PORT_MCH_BATCH_SAMPLE_RESULT WHERE HEAT_PLAN_NO =?  AND MAT_STATUS = '00'  AND INSTORE_FLAG = '0'
	  ]]>
	</query>

	<query id="FrmMchDownLineManage.QueryButtMatNo1" desc="查询材料表材料号">
		<![CDATA[

         SELECT * FROM PORT_MCH_BATCH_SAMPLE_RESULT WHERE HEAT_PLAN_NO =?  AND MAT_STATUS = '00'  AND INSTORE_FLAG = '0'  AND VALIDFLAG='1' AND RESULT_NO =? ORDER BY MAT_NO DESC
	  ]]>
	</query>
	<query id="FrmMchDownLineManage.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 MCH_ENTRUSTED_BILL T
 WHERE 1=1
	  ]]>
	</query>
	<query id="FrmMchDownLineManage.AddOutSourc" desc="新增委外加工表">
	 <![CDATA[
	 INSERT INTO MCH_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,SUBCONTRACT_PLINE_CODE,SUBCONTRACT_PLINE_NAME,SUBCONTRACT_TYPE,SUBCONTRACT_GX,BATCH_GROUD_NO) 
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 
TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?, ?,?,?,?,?,?,?)
	  ]]>
	</query>
	<query id="FrmMchDownLineManage.UpdateOffOutSourc" desc="修改离线表委外支数">
	 <![CDATA[
	 UPDATE MCH_OFFLINE_RESULT
   SET SUBCONTRACT_NUM      = ?,
       SUBCONTRACT_WT       = ?,
       SUBCONTRACT_TIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
       SUBCONTRACT_NAME = ?,
       SUBCONTRACT_NO=?,
       SUBCONTRACT_NO_SEQ=?
 WHERE RESULT_NO = ?
	  ]]>
	</query>
	<query id="FrmMchDownLineManage.deleteOutSourc" desc="删除委外加工表">
	 <![CDATA[
	DELETE MCH_ENTRUSTED_BILL
 WHERE SUBCONTRACT_NO = ?
   AND SUBCONTRACT_NO_SEQ = ?
	  ]]>
	</query>
	<query id="FrmMchDownLineManage.queryEntrustrMax" desc="获取最大委外单号">
	<![CDATA[
SELECT ? ||
       LPAD(SUBSTR(NVL(MAX(T.SUBCONTRACT_NO), '0000'), -4,4) + 1, 4, '0') AS SUBCONTRACT_NO
  FROM MCH_ENTRUSTED_BILL T
 WHERE TO_CHAR(T.SUBCONTRACT_TIME, 'YYYY-MM-DD') = ?
	]]>
	</query>
	<query id="FrmMchDownLineManage.QuerySubConStart" desc="查询委托状态">
	<![CDATA[
SELECT T.SUBCONTRACT_LOG
  FROM MCH_ENTRUSTED_BILL T
 WHERE T.SUBCONTRACT_NO = ?
   AND T.SUBCONTRACT_NO_SEQ = ?
	]]>
	</query>
	<query id="FrmMchDownLineManage.doQueryPlanStrat" desc="查询计划是否结炉">
	<![CDATA[
SELECT T.PLANSTATUS FROM PLN_ZY_JGX_M T WHERE T.HEAT_PLAN_NO = ?
	]]>
	</query>
		<query id="FrmMchDownLineManage.queryVrpMatNo" desc="查询待处理的材料号">
	  <![CDATA[
	SELECT T.MAT_NO MAT_NO FROM port_mch_batch_sample_result T where t.HEAT_PLAN_NO = ? AND T.MAT_STATUS='00'
	order by t.MAT_NO DESC
	  ]]>
	</query>
	<query id="FrmMchDownLineManage.doQueryComInfo" desc="查询返线最大实绩">
	<![CDATA[
SELECT ? ||
       LPAD(SUBSTR(NVL(MAX(T.RESULT_NO), '000000'), -6, 6) + 1, 6, '0') AS RESULT_NO
  FROM MCH_COM_INFO T
 WHERE TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD') = ?
   AND T.PLINE_CODE = ?

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

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

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

	<query id="FrmMchDownLineManage.updateJGXOffLine" desc="修改热处理排产">
		<![CDATA[
UPDATE MCH_OFFLINE_RESULT T
   SET PLINE_CODE   = ?,
       PLINE_NAME   = （SELECT PLINE_NAME FROM COM_BASE_PLINE WHERE PLINE_CODE = ?)
 WHERE 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="FrmMchDownLineManage.updateJGXCPlan" desc="修改热处理排产">
		<![CDATA[
UPDATE PLN_ZY_JGX_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, BATCH_NO) =
       (SELECT HEAT_PLAN_NO, BATCH_NO
          FROM MCH_OFFLINE_RESULT T
         WHERE 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 = "FrmMchDownLineManage.insertVrpTakeReslut" desc = "插入脱单实绩表,脱单,回写PLN_ORDER_ZG_S">
<![CDATA[
DECLARE
  v_JUDGE_STOVE_NO MCH_OFFLINE_RESULT.JUDGE_STOVE_NO%TYPE := ?;
  v_STATION_CODE    MCH_OFFLINE_RESULT.STATION_CODE%TYPE := ?;
  v_PLINE_CODE     MCH_OFFLINE_RESULT.PLINE_CODE%TYPE :=?;

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

  FOR MYROW IN (SELECT *
                  FROM MCH_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 MCH_TAKE_RESULT T
    WHERE ID LIKE TO_CHAR(SYSDATE, 'YYMMDD') || v_PLINE_CODE || '___';
  
   insert into MCH_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 MCH_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 = "FrmMchDownLineManage.doQueryTake" desc = "查询是否已脱单">
<![CDATA[
select count(1) ACOUNT
  from MCH_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>



	frmEntrust

</queryMap>