<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="压库管送判管理">
	<query id="OverstockPipe.doQueryOffline" desc="">
		<![CDATA[
	   SELECT M.*,
       (SELECT DBMS_LOB.SUBSTR(WMSYS.WM_CONCAT(NVL(Y.STORAGE_NAME, '在途') || '/' ||
                                               COUNT(1)),
                               4000)
          FROM MAT_BC_M BM, YDM_BC_BUTTRESS B
          LEFT JOIN YDM_BS_STORAGE Y
            ON B.STORAGE_NO = Y.STORAGE_NO
         WHERE BM.MAT_NO = B.MAT_NO
           AND BM.OFFLINE_DOC = M.RESULT_NO
         GROUP BY STORAGE_NAME) STORAGE_TYPE_NAME,

         (SELECT  MAX(BM.MEMO) FROM MAT_BC_M BM
         WHERE BM.OFFLINE_DOC = M.RESULT_NO) YCMEMO,

         DECODE(A.APPLY_FLAG,'1','已申请','2','审核通过') APPLY_FLAG,
         A.APPLY_FLAG_NAME,
         A.APPLY_FLAG_TIME,
         A.APPLY_OK_NAME,
         A.APPLY_OK_TIME,
         DECODE(A.VALIDFLAG,'1','有效','2','无效') VALIDFLAG
  FROM (SELECT OFFLINE_DOC RESULT_NO,
               T.PLINE_CODE,
               (SELECT PLINE_NAME
                  FROM COM_BASE_PLINE
                 WHERE PLINE_CODE = T.PLINE_CODE) PLINE_NAME,
               T.OFFLINE_PRO STATION_CODE,
               DECODE(T.OFFLINE_PRO,
                      'TS',
                      '探伤',
                      'ZJ',
                      '质检',
                      'JZ',
                      '矫直',
                      'XX',
                      '交库') STATION_DESC,
               '' HEAT_PLAN_NO,
               T.LOT_NO ZY_BATCH_ID,
               T.PRO_PLAN_ID PRO_PLAN_ID,
               T.GX_PLAN_NO GX_PLAN_NO,
               (SELECT MAX(FLAG_STOVE_NO_ZG)
                  FROM MAT_BC_M
                 WHERE ZG_STOVE_SQE = T.JUDGE_STOVE_NO) FLAG_STOVE_NO,
               T.JUDGE_STOVE_NO,
               '' BATCH_NO,
               T.PRODUCCODE PRODUCCODE,
               T.PRODUCNAME PRODUCNAME,
               T.STEELCODE STEELCODE,
               T.STEELNAME STEELNAME,
               T.GRADECODE GRADECODE,
               T.GRADENAME GRADENAME,
               T.MODEL_CODE MODEL_CODE,
               T.MODEL_DESC MODEL_DESC,
               T.STD_CODE STD_CODE,
               T.STD_NAME STD_NAME,
               '' STD_STYLE,
               T.STD_STYLE_DESC STD_STYLE_DESC,
               T.SPEC_CODE SPEC_CODE,
               T.SPEC_NAME SPEC_NAME,
               T.DIAMETER ACT_DIMATER,
               T.THICKNESS ACT_HEIGHT,
               T.LENGTH ACT_LEN,
               ACT_LEN_RANGE ACT_LEN_RANGE,
               T.CONTRACT_NO ORDER_NO,
               T.OFFLINE_NUM - NVL(T.BACKLINE_NUM,0) - NVL(T.GROUP_NUM,0) - NVL(T.RECHECK_NUM,0) OFFLINE_NUM,
               ROUND( T.ZP_HEIGHT * (T.OFFLINE_NUM - NVL(T.BACKLINE_NUM,0) - NVL(T.GROUP_NUM,0) - NVL(T.RECHECK_NUM,0))/T.OFFLINE_NUM,3) OFFLINE_WT,
               SUBCONTRACT_NO SUBCONTRACT_NO,
               T.SUBCONTRACT_NUM SUBCONTRACT_NUM,
               NULL SUBCONTRACT_WT,
               NULL SUBCONTRACT_TIME,
               '' SUBCONTRACT_NAME,
               T. SUBCONTRACTCOMPLETE_NUM SUBCONTRACTCOMPLETE_NUM,
               T.SUBCONTRACTCOMPLETE_WGT SUBCONTRACTCOMPLETE_WT,
               T.SUBCONTRACTSCRAP_NUM HB_FP_NUM,
               NULL HB_FP_WT,
               SUBCONTRACTCOMPLETE_TIME SUBCONTRACTCOMPLETE_TIME,
               SUBCONTRACTCOMPLETE_NAME SUBCONTRACTCOMPLETE_NAME,
               T.COL_USER PRO_USER,
               T.COL_SHIFT PRO_SHIFT,
               T.COL_GROUP PRO_GROUP,
               T.OFFLINE_TIME PRO_TIME,
               T.REMARK MEMO,
               T.LOT_NO,
               T.APPLY_RESULT_NO,
               'D' PROCESS
          FROM MIL_OFFLINE_RESLUT T
         WHERE T.STATUS = '0'
           AND T.ZP_FLAG = '0'
           AND (TO_NUMBER(NVL(T.OFFLINE_NUM, 0)) -
               TO_NUMBER(NVL(T.GROUP_NUM, 0)) -
               TO_NUMBER(NVL(T.RECHECK_NUM, 0)) -
               TO_NUMBER(NVL(T.BACKLINE_NUM, 0)) -
               TO_NUMBER(NVL(T.SUBCONTRACT_NUM, 0)) +
               TO_NUMBER(NVL(T.SUBCONTRACTCOMPLETE_NUM, 0))) > 0
        UNION ALL
        SELECT RESULT_NO,
               T.PLINE_CODE,
               T.PLINE_NAME,
               STATION_CODE,
               STATION_DESC,
               M.HEAT_PLAN_NO,
               T.ZY_BATCH_ID,
               T.PRO_PLAN_ID,
               T.GX_PLAN_NO,
               NVL(T.FLAG_STOVE_NO, T.JUDGE_STOVE_NO) FLAG_STOVE_NO,
               T.JUDGE_STOVE_NO,
               T.BATCH_NO,
               M.PRODUCCODE,
               M.PRODUCNAME,
               M.STEELCODE,
               M.STEELNAME,
               M.GRADECODE,
               M.GRADENAME,
               M.MODEL_CODE,
               M.MODEL_DESC,
               M.STD_CODE,
               M.STD_NAME,
               M.STD_STYLE,
               M.STD_STYLE_DESC,
               M.SPEC_CODE,
               M.SPEC_NAME,
               ACT_DIMATER,
               ACT_HEIGHT,
               ACT_LEN,
               ACT_LEN_MIN || '-' || ACT_LEN_MAX ACT_LEN_RANGE,
               T.ORDER_NO || '/' || T.ORDER_SEQ ORDER_NO,
               (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_NUM,
               (TO_NUMBER(NVL(T.OFFLINE_WT, 0)) -
               TO_NUMBER(NVL(T.GROUP_WT, 0)) - TO_NUMBER(NVL(T.RE_WT, 0)) -
               TO_NUMBER(NVL(T.SUBCONTRACT_WT, 0)) +
               TO_NUMBER(NVL(T.SUBCONTRACTCOMPLETE_WT, 0))) OFFLINE_WT,
               SUBCONTRACT_NO,
               SUBCONTRACT_NUM,
               SUBCONTRACT_WT,
               SUBCONTRACT_TIME,
               SUBCONTRACT_NAME,
               SUBCONTRACTCOMPLETE_NUM,
               SUBCONTRACTCOMPLETE_WT,
               HB_FP_NUM,
               HB_FP_WT,
               SUBCONTRACTCOMPLETE_TIME,
               SUBCONTRACTCOMPLETE_NAME,
               PRO_USER,
               PRO_SHIFT,
               PRO_GROUP,
               PRO_TIME,
               T.MEMO,
               '' LOT_NO,
               T.APPLY_RESULT_NO,
               'F' PROCESS
          FROM HTT_OFFLINE_RESULT T
          LEFT JOIN PLN_ZY_RCL_M M
            ON M.HEAT_PLAN_NO = T.HEAT_PLAN_NO
         WHERE 1 = 1
           AND T.GROUP_LOG = '0'
           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

        UNION ALL
        SELECT RESULT_NO,
               T.PLINE_CODE,
               T.PLINE_NAME,
               STATION_CODE,
               STATION_DESC,
               M.HEAT_PLAN_NO,
               T.ZY_BATCH_ID,
               T.PRO_PLAN_ID,
               T.GX_PLAN_NO,
               NVL(T.FLAG_STOVE_NO, T.JUDGE_STOVE_NO) FLAG_STOVE_NO,
               T.JUDGE_STOVE_NO,
               T.BATCH_NO,
               M.PRODUCCODE,
               M.PRODUCNAME,
               M.STEELCODE,
               M.STEELNAME,
               M.GRADECODE,
               M.GRADENAME,
               M.MODEL_CODE,
               M.MODEL_DESC,
               M.STD_CODE,
               M.STD_NAME,
               M.STD_STYLE,
               M.STD_STYLE_DESC,
               M.SPEC_CODE,
               M.SPEC_NAME,
               ACT_DIMATER,
               ACT_HEIGHT,
               ACT_LEN,
               ACT_LEN_MIN || '-' || ACT_LEN_MAX ACT_LEN_RANGE,
               T.ORDER_NO || '/' || T.ORDER_SEQ ORDER_NO,
               (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_NUM,
               (TO_NUMBER(NVL(T.OFFLINE_WT, 0)) -
               TO_NUMBER(NVL(T.GROUP_WT, 0)) - TO_NUMBER(NVL(T.RE_WT, 0)) -
               TO_NUMBER(NVL(T.SUBCONTRACT_WT, 0)) +
               TO_NUMBER(NVL(T.SUBCONTRACTCOMPLETE_WT, 0))) OFFLINE_WT,
               SUBCONTRACT_NO,
               SUBCONTRACT_NUM,
               SUBCONTRACT_WT,
               SUBCONTRACT_TIME,
               SUBCONTRACT_NAME,
               SUBCONTRACTCOMPLETE_NUM,
               SUBCONTRACTCOMPLETE_WT,
               HB_FP_NUM,
               HB_FP_WT,
               SUBCONTRACTCOMPLETE_TIME,
               SUBCONTRACTCOMPLETE_NAME,
               PRO_USER,
               PRO_SHIFT,
               PRO_GROUP,
               PRO_TIME,
               T.MEMO,
               ''LOT_NO,
               T.APPLY_RESULT_NO,
               'G' PROCESS
          FROM MCH_OFFLINE_RESULT T
          LEFT JOIN PLN_ZY_JGX_M M
            ON M.HEAT_PLAN_NO = T.HEAT_PLAN_NO
         WHERE 1 = 1
           AND T.GROUP_LOG = '0'
           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

        UNION ALL
        SELECT RESULT_NO,
               T.PLINE_CODE,
               T.PLINE_NAME,
               STATION_CODE,
               STATION_DESC,
               M.HEAT_PLAN_NO,
               T.ZY_BATCH_ID,
               T.PRO_PLAN_ID,
               T.GX_PLAN_NO,
               NVL(T.FLAG_STOVE_NO, T.JUDGE_STOVE_NO) FLAG_STOVE_NO,
               T.JUDGE_STOVE_NO,
               T.BATCH_NO,
               M.PRODUCCODE,
               M.PRODUCNAME,
               M.STEELCODE,
               M.STEELNAME,
               M.GRADECODE,
               M.GRADENAME,
               M.MODEL_CODE,
               M.MODEL_DESC,
               M.STD_CODE,
               M.STD_NAME,
               M.STD_STYLE,
               M.STD_STYLE_DESC,
               M.SPEC_CODE,
               M.SPEC_NAME,
               ACT_DIMATER,
               ACT_HEIGHT,
               ACT_LEN,
               ACT_LEN_MIN || '-' || ACT_LEN_MAX ACT_LEN_RANGE,
               T.ORDER_NO || '/' || T.ORDER_SEQ ORDER_NO,
               (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_NUM,
               (TO_NUMBER(NVL(T.OFFLINE_WT, 0)) -
               TO_NUMBER(NVL(T.GROUP_WT, 0)) - TO_NUMBER(NVL(T.RE_WT, 0)) -
               TO_NUMBER(NVL(T.SUBCONTRACT_WT, 0)) +
               TO_NUMBER(NVL(T.SUBCONTRACTCOMPLETE_WT, 0))) OFFLINE_WT,
               SUBCONTRACT_NO,
               SUBCONTRACT_NUM,
               SUBCONTRACT_WT,
               SUBCONTRACT_TIME,
               SUBCONTRACT_NAME,
               SUBCONTRACTCOMPLETE_NUM,
               SUBCONTRACTCOMPLETE_WT,
               HB_FP_NUM,
               HB_FP_WT,
               SUBCONTRACTCOMPLETE_TIME,
               SUBCONTRACTCOMPLETE_NAME,
               PRO_USER,
               PRO_SHIFT,
               PRO_GROUP,
               PRO_TIME,
               T.MEMO MEMO,
               ''LOT_NO,
               T.APPLY_RESULT_NO,
               'E' PROCESS
          FROM VRP_OFFLINE_RESULT T
          LEFT JOIN PLN_ZY_DBK_M M
            ON M.HEAT_PLAN_NO = T.HEAT_PLAN_NO

         WHERE 1 = 1
           AND T.GROUP_LOG = '0'
           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
        UNION ALL
        SELECT RESULT_NO || '_' || OFF_XH RESULT_NO,
               T.PLINE_CODE,
               T.PLINE_NAME,
               STATION_CODE,
               STATION_DESC,
               HEAT_PLAN_NO,
               '' ZY_BATCH_ID,
               T.WO_ID PRO_PLAN_ID,
               '' GX_PLAN_NO,
               T.JUDGE_STOVE_NO FLAG_STOVE_NO,
               T.JUDGE_STOVE_NO,
               T.BATCH_NO,
               B.PRODUCCODE_JG PRODUCCODE,
               B.PRODUCCODE_JG_DESC PRODUCNAME,
               B.STEELCODE,
               B.STEELNAME,
               B.GRADECODE,
               B.GRADENAME,
               J.MODEL_CODE,
               J.MODEL_DESC,
               J.STD_CODE,
               J.STD_NAME,
               J.STD_STYLE,
               J.STD_STYLE_DESC,
               J.SPEC_JG SPEC_CODE,
               J.SPEC_JG_DESC SPEC_NAME,
               J.DIAMETER_JG ACT_DIMATER,
               J.HEIGHT_JG ACT_HEIGHT,
               TO_NUMBER(J.LENGTH_JG) ACT_LEN,
               J.LENGTH_MIN || '-' || J.LENGTH_MAX ACT_LEN_RANGE,
               B.ORDER_NO || '/' || B.ORDER_SEQ ORDER_NO,
               (TO_NUMBER(NVL(T.OFFLINE_NUM, 0)) -
               TO_NUMBER(NVL(T.RE_NUM, 0)) -
               TO_NUMBER(NVL(T.SUBCONTRACT_NUM, 0)) +
               TO_NUMBER(NVL(T.SUBCONTRACTCOMPLETE_NUM, 0))) OFFLINE_NUM,
               (TO_NUMBER(NVL(T.OFFLINE_WT, 0)) - TO_NUMBER(NVL(T.RE_WT, 0)) -
               TO_NUMBER(NVL(T.SUBCONTRACT_WT, 0)) +
               TO_NUMBER(NVL(T.SUBCONTRACTCOMPLETE_WT, 0))) OFFLINE_WT,
               T.SUBCONTRACT_NO,
               SUBCONTRACT_NUM,
               SUBCONTRACT_WT,
               SUBCONTRACT_TIME,
               SUBCONTRACT_NAME,
               SUBCONTRACTCOMPLETE_NUM,
               SUBCONTRACTCOMPLETE_WT,
               HB_FP_NUM,
               HB_FP_WT,
               SUBCONTRACTCOMPLETE_TIME,
               SUBCONTRACTCOMPLETE_NAME,
               COL_USER PRO_USER,
               COL_SHIFT PRO_SHIFT,
               COL_GROUP PRO_GROUP,
               COL_TIME PRO_TIME,
               '' MEMO,
               '' LOT_NO,
               T.APPLY_RESULT_NO,
               'H' PROCESS
          FROM COUPLING_OFFLINE_RESULT T, PLN_ZY_JG_WORKBILL B, COM_MSC_JG J
         WHERE T.WO_ID = B.WO_ID
           AND B.CODE_JG = J.CODE_JG
           AND  1 <> 1  ---暂不查接箍
           AND (TO_NUMBER(NVL(T.OFFLINE_NUM, 0)) -
               TO_NUMBER(NVL(T.RE_NUM, 0)) -
               TO_NUMBER(NVL(T.SUBCONTRACT_NUM, 0)) +
               TO_NUMBER(NVL(T.SUBCONTRACTCOMPLETE_NUM, 0))) > 0) M LEFT JOIN YDM_OVERSTOCKPIPE_APPLY A
               ON M.APPLY_RESULT_NO = A.APPLY_RESULT_NO
 WHERE 1 = 1
		]]>
	</query>

<query id="OverstockPipe.doQueryYC" desc="">
		<![CDATA[
		 SELECT T.JUDGE_STOVE_NO,
       T.LOT_NO,
       T.STOVE_NO,
       T.BATCH_NO,
       T.BATCH_GROUD_NO,
       T.HEAT_PLAN_NO,
       T.ORDER_NO,
       T.ORDER_SEQ,
       T.ORDER_SEQ_NO,
       T.ORD_PK,
       T.ORD_LN_PK,
       T.ORD_LN_DLY_PK,
       T.CRAF_NO,
       T.CRAFT_SEQ,
       T.JUDGE_RESULT,
       T.JUDGE_MAKER,
       T.JUGDE_APPLY_CODE,
       T.JUGDE_APPLY_SEQUENO,
       T.PROCESS_CDOE,
       T.PROCESS_DESC,
       T.PRODUCCODE,
       T.PRODUCNAME,
       T.STEELCODE,
       T.STEELNAME,
       T.SPEC_CODE,
       T.SPEC_NAME,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.STD_CODE,
       (SELECT SUBSTR(L.STD_NAME, 1, 70) ||
               decode(L.USE_DESC, '/', '', '', '', ',' || L.USE_DESC)
          FROM SLM_ORDER_LINE L
         WHERE L.ORD_LN_PK = T.ORD_LN_PK
           AND L.VALIDFLAG = '1') STD_NAME,
       T.ACT_DIMATER,
       T.ACT_HEIGHT,
       T.BELONG_CODE,
       T.BELONG_NAME,
       T.STD_STYLE,
       T.STD_STYLE_DESC,
       T.GRADECODE,
       T.GRADENAME,
       sum(T.ACT_COUNT) ACT_COUNT,
       to_char(sum(T.Act_Weight), 'FM999999990.000') Act_Weight,
       to_char(sum(T.ACT_THEORY_WEIGHT), 'FM999999990.000') ACT_THEORY_WEIGHT,
       sum(nvl(T.ACT_LEN, 0)) as ACT_LEN,
       sum(NVL(T.PONDER_GROSS_WT, 0)) PONDER_GROSS_WT,

       to_char(T.ACT_LEN_MIN, 'FM999990.00') AS ACT_LEN_MIN,
       to_char(T.ACT_LEN_MAX, 'FM999990.00') AS ACT_LEN_MAX,
       to_char(T.ACT_LEN_MIN, 'FM999990.00') || '-' ||
       to_char(T.ACT_LEN_MAX, 'FM999990.00') as LEN,
       T.MATERIAL_NO,
       T.MATERIAL_NAME,
       T.INPUT_MATERIAL_NO,
       T.INPUT_MATERIAL_NAME,
       T.MEMO,
       T.PIPMEMO,
       T.JUDGE_STD_NAME,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.MAT_STATUS,
       T.PRODUCT_FLAG,
       T.TARGET,
       DECODE(T.PACK_FLAG, '0', '否', '1', '是') PACK_FLAG,
       T.PRO_ORDER_ID,
       T.GX_PLAN_NO,
       T.APPLY_RESULT_NO,
       DECODE(A.APPLY_FLAG,'1','已申请','2','审核通过') APPLY_FLAG,
		 A.APPLY_FLAG_NAME,
		 A.APPLY_FLAG_TIME,
		 A.APPLY_OK_NAME,
		 A.APPLY_OK_TIME,
		 DECODE(A.VALIDFLAG,'1','有效','2','无效') VALIDFLAG
  FROM MAT_BC_M T LEFT JOIN YDM_OVERSTOCKPIPE_APPLY A ON T.APPLY_RESULT_NO = A.APPLY_RESULT_NO
 where T.QCM_STAUS = '00'
   AND ((T.PRODUCT_FLAG = '801401' AND
       T.JUDGE_RESULT_CODE IN ('40740701', '40740709')) OR
       (T.PRODUCT_FLAG = '801402' AND T.JUDGE_RESULT_CODE IS NULL AND
       T.ORDER_NO IS NULL))
   AND T.PRO_PLAN_ID_NEXT IS NULL #someThing#
 GROUP BY T.JUDGE_STOVE_NO,
          T.STOVE_NO,
          T.BATCH_NO,
          T.BATCH_GROUD_NO,
          T.HEAT_PLAN_NO,
          T.INPUT_MATERIAL_NO,
          T.INPUT_MATERIAL_NAME,
          T.ORDER_NO,
          T.ORDER_SEQ,
          T.ORDER_SEQ_NO,
          T.ORD_PK,
          T.ORD_LN_PK,
          T.ORD_LN_DLY_PK,
          T.CRAF_NO,
          T.CRAFT_SEQ,
          T.JUDGE_RESULT,
          T.JUDGE_MAKER,
          T.JUGDE_APPLY_CODE,
          T.JUGDE_APPLY_SEQUENO,
          T.PROCESS_CDOE,
          T.PROCESS_DESC,
          T.PRODUCCODE,
          T.PRODUCNAME,
          T.STEELCODE,
          T.STEELNAME,
          T.SPEC_CODE,
          T.SPEC_NAME,
          T.MODEL_CODE,
          T.GRADECODE,
          T.GRADENAME,
          T.STD_STYLE,
          T.STD_STYLE_DESC,
          T.PIPMEMO,
          T.MAT_STATUS,
          T.MODEL_DESC,
          T.STD_CODE,
          T.STD_NAME,
          T.ACT_DIMATER,
          T.ACT_HEIGHT,
          T.BELONG_CODE,
          T.BELONG_NAME,
          T.PLINE_CODE,
          T.PLINE_NAME,
          T.MATERIAL_NO,
          T.MATERIAL_NAME,
          T.ACT_LEN_MIN,
          T.ACT_LEN_MAX,
          T.MEMO,
          T.PRODUCT_FLAG,
          T.JUDGE_STD_NAME,
          T.TARGET,
          T.PACK_FLAG,
          T.LOT_NO,
          T.ORD_LN_PK,
          T.PRO_ORDER_ID,
          T.GX_PLAN_NO,
          T.APPLY_RESULT_NO,
          A.APPLY_FLAG,
		 A.APPLY_FLAG_NAME,
		 A.APPLY_FLAG_TIME,
		 A.APPLY_OK_NAME,
		 A.APPLY_OK_TIME,
		 A.VALIDFLAG
     
		]]>
	</query>


	<query id="OverstockPipe.doQueryResult" desc="">
		<![CDATA[
		 select result_no,
       result_no_lx,
       outstock_doc,
       jugde_apply_code,
       pro_shift,
       pro_group,
       create_time,
       pro_time,
       validflag,
       judge_stove_no,
       batch_no,
       pro_user,
       pline_code,
       pline_name,
       process_code,
       act_count,
       act_weight,
       delete_user,
       delete_time,
       heat_plan_no,
       DECODE(flag, '1', '离线转压库', '2', '余材转压库') flag,
       outstock_doc1,
       outstock_doc2
  from ydm_overstockpipe_result T
 WHERE 1 = 1
		]]>
	</query>

	<query id = "OverstockPipe.jugdeApplyNo" desc = "申请判定单号">
		SELECT ? || ? || TO_CHAR(SYSDATE, 'yyyyMMDD') ||
		LPAD(NVL(MAX(TO_NUMBER(SUBSTR(JUGDE_APPLY_CODE, LENGTH(JUGDE_APPLY_CODE) - 5))),
		0) + 1,
		6,
		'0') JUGDE_APPLY_CODE
		FROM  QCM_ZG_JUGDE_APPLY
		WHERE JUGDE_APPLY_CODE LIKE  ?  || ? || TO_CHAR(SYSDATE, 'yyyyMMDD') || '______'
	</query>


	<query id="OverstockPipe.GetId" desc="">
		<![CDATA[
    SELECT ? || TO_CHAR(SYSDATE, 'yyyyMMDD') ||
           LPAD(NVL(MAX(TO_NUMBER(SUBSTR(RESULT_NO, LENGTH(RESULT_NO) - 5))),
                    0) + 1,
                6,
                '0') RESULT_NO
      FROM YDM_OVERSTOCKPIPE_RESULT
     WHERE RESULT_NO LIKE ? || TO_CHAR(SYSDATE, 'yyyyMMDD') || '______'
		]]>
	</query>

	<query id="OverstockPipe.doAdd" desc="">
		<![CDATA[
	   INSERT INTO YDM_OVERSTOCKPIPE_RESULT
  (RESULT_NO,
   RESULT_NO_LX,
   OUTSTOCK_DOC,
   JUGDE_APPLY_CODE,
   PRO_SHIFT,
   PRO_GROUP,
   CREATE_TIME,
   PRO_TIME,
   VALIDFLAG,
   JUDGE_STOVE_NO,
   BATCH_NO,
   PRO_USER,
   PLINE_CODE,
   PLINE_NAME,
   PROCESS_CODE,
   ACT_COUNT,
   ACT_WEIGHT,
   HEAT_PLAN_NO,
   FLAG,
   OUTSTOCK_DOC1,
   OUTSTOCK_DOC2)
VALUES
  ('#RESULT_NO#',
   '#RESULT_NO_LX#',
   '#OUTSTOCK_DOC#',
   '#JUGDE_APPLY_CODE#',
   '#PRO_SHIFT#',
   '#PRO_GROUP#',
   SYSDATE,
   SYSDATE,
   '1',
   '#JUDGE_STOVE_NO#',
   '#BATCH_NO#',
   '#PRO_USER#',
   '#PLINE_CODE#',
   '#PLINE_NAME#',
   '#PROCESS_CODE#',
   '#ACT_COUNT#',
   '#ACT_WEIGHT#',
   '#HEAT_PLAN_NO#',
   '#FLAG#',
   '#OUTSTOCK_DOC1#',
   '#OUTSTOCK_DOC2#')

		]]>
	</query>


	<query id="OverstockPipe.doDelete" desc="">
		<![CDATA[
	   UPDATE  YDM_OVERSTOCKPIPE_RESULT T SET T.VALIDFLAG = '0', DELETE_USER =? ,DELETE_TIME = SYSDATE
	    WHERE T.RESULT_NO = ?
		]]>
	</query>

	<query id="OverstockPipe.HandleOfflineE" desc="">
		<![CDATA[
     UPDATE VRP_OFFLINE_RESULT T
   SET T.RE_NUM = NVL(T.RE_NUM, 0) + ?,
       T.RE_WT  = NVL(T.RE_WT, 0) + ?,
       RE_NAME  = ?,
       RE_TIME = SYSDATE,
       RETURN_PROCESS = STATION_CODE
 WHERE T.RESULT_NO = ?

		]]>
	</query>

	<query id="OverstockPipe.RecoverOfflineE" desc="">
		<![CDATA[
     UPDATE VRP_OFFLINE_RESULT T
   SET T.RE_NUM = NVL(T.RE_NUM, 0) - ?,
       T.RE_WT  = NVL(T.RE_WT, 0) - ?,
       RE_NAME  = '',
       RE_TIME = '',
       RETURN_PROCESS = ''
 WHERE T.RESULT_NO = ?

		]]>
	</query>

	<query id="OverstockPipe.HandleOfflineF" desc="">
		<![CDATA[
UPDATE HTT_OFFLINE_RESULT T
   SET T.RE_NUM = NVL(T.RE_NUM, 0) + ?,
       T.RE_WT  = NVL(T.RE_WT, 0) + ?,
       RE_NAME  = ?,
       RE_TIME = SYSDATE,
       RETURN_PROCESS = STATION_CODE
 WHERE T.RESULT_NO = ?

		]]>
	</query>

	<query id="OverstockPipe.RecoverOfflineF" desc="">
		<![CDATA[
     UPDATE HTT_OFFLINE_RESULT T
   SET T.RE_NUM = NVL(T.RE_NUM, 0) - ?,
       T.RE_WT  = NVL(T.RE_WT, 0) - ?,
       RE_NAME  = '',
       RE_TIME = '',
       RETURN_PROCESS = ''
 WHERE T.RESULT_NO = ?

		]]>
	</query>


	<query id="OverstockPipe.HandleOfflineG" desc="">
		<![CDATA[
UPDATE MCH_OFFLINE_RESULT T
   SET T.RE_NUM = NVL(T.RE_NUM, 0) + ?,
       T.RE_WT  = NVL(T.RE_WT, 0) + ?,
       RE_NAME  = ?,
       RE_TIME = SYSDATE,
       RETURN_PROCESS = STATION_CODE
 WHERE T.RESULT_NO = ?
		]]>
	</query>

	<query id="OverstockPipe.RecoverOfflineG" desc="">
		<![CDATA[
     UPDATE MCH_OFFLINE_RESULT T
   SET T.RE_NUM = NVL(T.RE_NUM, 0) - ?,
       T.RE_WT  = NVL(T.RE_WT, 0) - ?,
       RE_NAME  = '',
       RE_TIME = '',
       RETURN_PROCESS = ''
 WHERE T.RESULT_NO = ?

		]]>
	</query>
	
	<query id="OverstockPipe.HandleMatData" desc="处理库存数据（离线）">
		<![CDATA[
UPDATE MAT_BC_M T
   SET PRODUCT_FLAG = '801402', --材料状态
       MAT_STATUS   = '80150201',
       
       QCM_STAUS        = '00', -- 改成合格
       T.BATCH_GROUD_NO = '001', --转压库组号默认001
       
       PRO_ORDER_NO  = '', --- 清空合同相关信息
       PRO_ORDER_ID  = '',
       ORD_LN_DLY_PK = '',
       ORDER_NO      = '',
       ORDER_SEQ     = '',
       ORDER_SEQ_NO  = '',
       ORD_PK        = '',
       ORD_LN_PK     = '',
       
       TARGET = 'A', -- 改成A字头
       
       --MEMO                  = '', --清空离线备注
       T.JUGDE_APPLY_CODE    = ?, -- 送判单号
       T.JUGDE_APPLY_SEQUENO = '1',
       T.JUDGE_RESULT_CODE   = '40740701', -- 工序判定结果默认合格
       T.JUDGE_RESULT        = '合格',
       T.JUDGE_RESULT_TIME   = SYSDATE,
       T.JUDGE_MAKER         = 'SYSTEM'
 WHERE OFFLINE_DOC = ?
   AND QCM_STAUS = '11'
		]]>
	</query>
	
	<query id="OverstockPipe.HandleMatData2" desc="处理库存数据(余材)">
		<![CDATA[
DECLARE
  V_JUGDE_APPLY_CODE MAT_BC_M.JUGDE_APPLY_CODE%TYPE := ?;
  V_JUDGE_STOVE_NO   MAT_BC_M.JUDGE_STOVE_NO%TYPE := ?;

  V_PLINE_CODE MAT_BC_M.PLINE_CODE%TYPE := ?;
  V_BATCH_NO   MAT_BC_M.BATCH_NO%TYPE := ?;

  V_APPLY_NAME     QCM_ZG_JUGDE_APPLY.APPLY_NAME%TYPE := ?;
  V_BAL_YEAR_MONTH QCM_ZG_JUGDE_APPLY.BAL_YEAR_MONTH%TYPE := ?; --结转年月

  V_OUTSTOCK_DOC  YDM_BC_OUTLIST.OUTSTOCK_DOC%TYPE := ?; --改判出库单号
  V_OUTSTOCK_DOC2 YDM_BC_OUTLIST.OUTSTOCK_DOC%TYPE := ?; --产权出库单号
  V_INSTOCK_DOC   YDM_BC_INLIST.INSTOCK_DOC%TYPE := ?; --改判入库单号

  V_ACT_COUNT   MAT_BC_M.ACT_COUNT%TYPE := ?;
  V_SUPPLY_UNIT QCM_ZG_JUGDE_APPLY.SUPPLY_UNIT%TYPE := ?;
  V_ICOUNT      NUMBER := 1;
BEGIN

  FOR MYROW1 IN (SELECT *
                   FROM (SELECT T.*
                           FROM MAT_BC_M T
                          WHERE T.QCM_STAUS = '00'
                            AND T.PRO_PLAN_ID_NEXT IS NULL
                            AND ((T.PRODUCT_FLAG = '801401' AND
                                T.JUDGE_RESULT_CODE IN
                                ('40740701', '40740709')) OR
                                (T.PRODUCT_FLAG = '801402' AND
                                T.JUDGE_RESULT_CODE IS NULL AND
                                T.ORDER_NO IS NULL))
                            AND T.JUDGE_STOVE_NO = V_JUDGE_STOVE_NO
                            AND T.BATCH_NO = V_BATCH_NO
                            AND T.PLINE_CODE = V_PLINE_CODE
                          ORDER BY T.MAT_NO ASC)
                  WHERE ROWNUM <= V_ACT_COUNT) LOOP
    IF (MYROW1.TARGET <> 'A') THEN
      insert into ydm_bc_outlist
        (outstock_sqe,
         outstock_doc,
         outstock_type_code,
         outstock_type_name,
         mat_no,
         lot_no,
         stove_no,
         judge_stove_no,
         batch_no,
         batch_groud_no,
         material_no,
         material_name,
         produccode,
         producname,
         std_code,
         std_name,
         gradecode,
         gradename,
         steelcode,
         steelname,
         std_style,
         std_style_desc,
         spec_code,
         spec_name,
         model_code,
         model_desc,
         pro_order_no,
         pline_code,
         pline_name,
         act_dimater,
         act_height,
         act_len,
         act_len_min,
         act_len_max,
         act_count,
         act_weight,
         act_theory_weight,
         belong_code,
         belong_name,
         outstock_time,
         create_name,
         create_time,
         ord_pk,
         ord_ln_pk,
         ord_ln_dly_pk,
         /*department_code,
         department_desc,
         tar_department_code,
         tar_department_desc,*/
         order_no,
         order_seq,
         delivery_no,
         product_flag,
         mat_status,
         /*judge_std_name,
         judge_std_code,*/
         bal_year_month,
         qcm_staus,
         PROCESS_CDOE,
         PROCESS_DESC)
      values
        (V_OUTSTOCK_DOC || LPAD(V_ICOUNT, 4, 0),
         V_OUTSTOCK_DOC,
         '800808',
         '改判出库',
         MYROW1.MAT_NO,
         MYROW1.LOT_NO,
         MYROW1.STOVE_NO,
         MYROW1.JUDGE_STOVE_NO,
         MYROW1.BATCH_NO,
         MYROW1.batch_groud_no,
         MYROW1.material_no,
         MYROW1.material_name,
         MYROW1.produccode,
         MYROW1.producname,
         MYROW1.std_code,
         MYROW1.std_name,
         MYROW1.gradecode,
         MYROW1.gradename,
         MYROW1.steelcode,
         MYROW1.steelname,
         MYROW1.std_style,
         MYROW1.std_style_desc,
         MYROW1.spec_code,
         MYROW1.spec_name,
         MYROW1.model_code,
         MYROW1.model_desc,
         MYROW1.ORDER_NO || '/' || MYROW1.ORDER_SEQ,
         MYROW1.pline_code,
         MYROW1.pline_name,
         MYROW1.ACT_DIMATER,
         MYROW1.ACT_HEIGHT,
         MYROW1.act_len,
         MYROW1.act_len_min,
         MYROW1.act_len_max,
         MYROW1.act_count,
         MYROW1.act_weight,
         MYROW1.act_theory_weight,
         MYROW1.belong_code,
         MYROW1.belong_name,
         SYSDATE,
         V_APPLY_NAME,
         SYSDATE,
         MYROW1.ord_pk,
         MYROW1.ord_ln_pk,
         MYROW1.ord_ln_dly_pk,
         
         MYROW1.order_no,
         MYROW1.order_seq,
         MYROW1.ORDER_SEQ_NO,
         MYROW1.product_flag,
         MYROW1.mat_status,
         V_BAL_YEAR_MONTH,
         MYROW1.qcm_staus,
         MYROW1.PROCESS_CDOE,
         MYROW1.PROCESS_DESC);
    END IF;
  
    --备份材料信息，转成品          
    INSERT INTO MAT_BC_M_BACK_UP
      SELECT * FROM MAT_BC_M T WHERE T.MAT_NO = MYROW1.MAT_NO;
    UPDATE MAT_BC_M T
       SET PRODUCT_FLAG   = '801402', --材料状态
           MAT_STATUS     = '80150202',
           QCM_STAUS      = '00', -- 改成合格
           BATCH_GROUD_NO = '001', --转压库组号默认001
           PRO_ORDER_NO   = '', --- 清空合同相关信息
           PRO_ORDER_ID   = '',
           ORD_LN_DLY_PK  = '',
           ORDER_NO       = '',
           ORDER_SEQ      = '',
           ORDER_SEQ_NO   = '',
           ORD_PK         = '',
           ORD_LN_PK      = '',
           TARGET         = 'A', -- 改成A字头
           T.OFFLINE_DOC  = T.PROCESS_CDOE || T.JUDGE_STOVE_NO || T.BATCH_NO, --方便撤销标识
           
           T.JUGDE_APPLY_CODE    = V_JUGDE_APPLY_CODE, -- 送判单号
           T.JUGDE_APPLY_SEQUENO = '1',
           T.JUDGE_RESULT_CODE   = '40740701', -- 工序判定结果默认合格
           T.JUDGE_RESULT        = '合格',
           T.JUDGE_RESULT_TIME   = SYSDATE,
           T.JUDGE_MAKER         = 'SYSTEM',
           T.PLINE_CODE          = DECODE(V_SUPPLY_UNIT,
                                          '120504',
                                          'C100',
                                          'C095'),
           T.PLINE_NAME          = DECODE(V_SUPPLY_UNIT,
                                          '120504',
                                          '天淮余材转压库',
                                          '半成品转压库')
     WHERE T.MAT_NO = MYROW1.MAT_NO;
  
    IF (MYROW1.TARGET <> 'A') THEN
      INSERT INTO YDM_BC_INLIST
        (INSTOCK_SQE,
         INSTOCK_DOC,
         INSTOCK_TYPE_CODE,
         INSTOCK_TYPE_NAME,
         MAT_NO,
         LOT_NO,
         STOVE_NO,
         JUDGE_STOVE_NO,
         BATCH_NO,
         BATCH_GROUD_NO,
         MATERIAL_NO,
         MATERIAL_NAME,
         PRODUCCODE,
         PRODUCNAME,
         STD_CODE,
         STD_NAME,
         GRADECODE,
         GRADENAME,
         STEELCODE,
         STEELNAME,
         STD_STYLE,
         STD_STYLE_DESC,
         SPEC_CODE,
         SPEC_NAME,
         MODEL_CODE,
         MODEL_DESC,
         PRO_ORDER_NO,
         PLINE_CODE,
         PLINE_NAME,
         ACT_DIMATER,
         ACT_HEIGHT,
         ACT_LEN,
         ACT_LEN_MIN,
         ACT_LEN_MAX,
         ACT_COUNT,
         ACT_WEIGHT,
         ACT_THEORY_WEIGHT,
         BELONG_CODE,
         BELONG_NAME,
         INSTOCK_TIME,
         CREATE_NAME,
         CREATE_TIME,
         ORD_PK,
         ORD_LN_PK,
         ORD_LN_DLY_PK,
         ORDER_NO,
         ORDER_SEQ,
         DELIVERY_NO,
         PRODUCT_FLAG,
         MAT_STATUS,
         JUDGE_STD_NAME,
         IN_TIME_F,
         BAL_YEAR_MONTH,
         QCM_STAUS,
         PROCESS_CDOE,
         PROCESS_DESC)
      VALUES
        (V_INSTOCK_DOC || LPAD(V_ICOUNT, 4, 0),
         V_INSTOCK_DOC,
         '800706',
         '改判入库',
         MYROW1.MAT_NO,
         MYROW1.LOT_NO,
         MYROW1.STOVE_NO,
         MYROW1.JUDGE_STOVE_NO,
         MYROW1.BATCH_NO,
         MYROW1.BATCH_GROUD_NO,
         MYROW1.material_no,
         MYROW1.material_name,
         MYROW1.produccode,
         MYROW1.producname,
         MYROW1.std_code,
         MYROW1.std_name,
         MYROW1.gradecode,
         MYROW1.gradename,
         MYROW1.steelcode,
         MYROW1.steelname,
         MYROW1.std_style,
         MYROW1.std_style_desc,
         MYROW1.spec_code,
         MYROW1.spec_name,
         MYROW1.model_code,
         MYROW1.model_desc,
         '',
         MYROW1.pline_code,
         MYROW1.pline_name,
         MYROW1.ACT_DIMATER,
         MYROW1.ACT_HEIGHT,
         MYROW1.ACT_LEN,
         MYROW1.ACT_LEN_MIN,
         MYROW1.ACT_LEN_MAX,
         MYROW1.ACT_COUNT,
         MYROW1.ACT_WEIGHT,
         MYROW1.ACT_THEORY_WEIGHT,
         MYROW1.BELONG_CODE,
         MYROW1.BELONG_NAME,
         SYSDATE,
         V_APPLY_NAME,
         SYSDATE,
         '',
         '',
         '',
         '',
         '',
         '',
         MYROW1.PRODUCT_FLAG,
         MYROW1.MAT_STATUS,
         MYROW1.JUDGE_STD_DES,
         SYSDATE,
         V_BAL_YEAR_MONTH,
         MYROW1.qcm_staus,
         MYROW1.PROCESS_CDOE,
         MYROW1.PROCESS_DESC);
    
      insert into ydm_bc_outlist
        (outstock_sqe,
         outstock_doc,
         outstock_type_code,
         outstock_type_name,
         mat_no,
         lot_no,
         stove_no,
         judge_stove_no,
         batch_no,
         batch_groud_no,
         material_no,
         material_name,
         produccode,
         producname,
         std_code,
         std_name,
         gradecode,
         gradename,
         steelcode,
         steelname,
         std_style,
         std_style_desc,
         spec_code,
         spec_name,
         model_code,
         model_desc,
         pro_order_no,
         pline_code,
         pline_name,
         act_dimater,
         act_height,
         act_len,
         act_len_min,
         act_len_max,
         act_count,
         act_weight,
         act_theory_weight,
         belong_code,
         belong_name,
         outstock_time,
         create_name,
         create_time,
         ord_pk,
         ord_ln_pk,
         ord_ln_dly_pk,
         /*department_code,
         department_desc,
         tar_department_code,
         tar_department_desc,*/
         order_no,
         order_seq,
         delivery_no,
         product_flag,
         mat_status,
         bal_year_month,
         qcm_staus,
         PROCESS_CDOE,
         PROCESS_DESC)
      values
        (V_OUTSTOCK_DOC2 || LPAD(V_ICOUNT, 4, 0),
         V_OUTSTOCK_DOC2,
         '800809',
         '产权出库',
         MYROW1.MAT_NO,
         MYROW1.LOT_NO,
         MYROW1.STOVE_NO,
         MYROW1.JUDGE_STOVE_NO,
         MYROW1.BATCH_NO,
         MYROW1.batch_groud_no,
         MYROW1.material_no,
         MYROW1.material_name,
         MYROW1.produccode,
         MYROW1.producname,
         MYROW1.std_code,
         MYROW1.std_name,
         MYROW1.gradecode,
         MYROW1.gradename,
         MYROW1.steelcode,
         MYROW1.steelname,
         MYROW1.std_style,
         MYROW1.std_style_desc,
         MYROW1.spec_code,
         MYROW1.spec_name,
         MYROW1.model_code,
         MYROW1.model_desc,
         '',
         MYROW1.pline_code,
         MYROW1.pline_name,
         MYROW1.ACT_DIMATER,
         MYROW1.ACT_HEIGHT,
         MYROW1.act_len,
         MYROW1.act_len_min,
         MYROW1.act_len_max,
         MYROW1.act_count,
         MYROW1.act_weight,
         MYROW1.act_theory_weight,
         MYROW1.belong_code,
         MYROW1.belong_name,
         SYSDATE,
         V_APPLY_NAME,
         SYSDATE,
         '',
         '',
         '',
         '',
         '',
         '',
         MYROW1.product_flag,
         MYROW1.mat_status,
         V_BAL_YEAR_MONTH,
         MYROW1.qcm_staus,
         MYROW1.PROCESS_CDOE,
         MYROW1.PROCESS_DESC);
    END IF;
    V_ICOUNT := V_ICOUNT + 1;
  END LOOP;
END;
		]]>
	</query>

	<query id="OverstockPipe.RecoverMatDataE" desc="离线">
		<![CDATA[
UPDATE MAT_BC_M T
   SET PRODUCT_FLAG = '801401', --材料状态
       MAT_STATUS = '80150101',
       QCM_STAUS = '11',
       T.JUGDE_APPLY_CODE = '',
       T.JUGDE_APPLY_SEQUENO = '',
       T.JUDGE_RESULT_CODE = '',
       T.JUDGE_RESULT = '',
       T.JUDGE_RESULT_TIME = '',
       T.JUDGE_MAKER = '',
       (PRO_ORDER_NO,
        PRO_ORDER_ID,
        ORD_LN_DLY_PK,
        ORDER_NO,
        ORDER_SEQ,
        ORDER_SEQ_NO,
        ORD_PK,
        ORD_LN_PK,
        TARGET,
        MEMO) =
       (SELECT M.ORDER_NO || '/' || M.ORDER_SEQ,
               M.PRO_PLAN_ID,
               M.ORD_LN_DLY_PK,
               M.ORDER_NO,
               M.ORDER_SEQ,
               M.DELIVERY_NO,
               (SELECT MAX(ORD_PK)
                  FROM SLM_ORDER_LINE_DELIVERY
                 WHERE ORD_LN_DLY_PK = M.ORD_LN_DLY_PK),
               (SELECT MAX(ORD_LN_PK)
                  FROM SLM_ORDER_LINE_DELIVERY
                 WHERE ORD_LN_DLY_PK = M.ORD_LN_DLY_PK),
               M.DECISION,
               O.MEMO
          FROM PLN_ZY_DBK_M M, VRP_OFFLINE_RESULT O
         WHERE M.HEAT_PLAN_NO = O.HEAT_PLAN_NO
           AND O.RESULT_NO = ?
           AND ROWNUM = 1)
 WHERE MAT_NO IN (SELECT MAT_NO FROM YDM_BC_INLIST WHERE INSTOCK_DOC = ?)
		]]>
	</query>
	
	<query id="OverstockPipe.RecoverMatDataE2" desc="余材">
		<![CDATA[
UPDATE MAT_BC_M T
   SET PRODUCT_FLAG = '801401', --材料状态
       MAT_STATUS = '80150102',
       QCM_STAUS = '00',
       T.JUGDE_APPLY_CODE = '',
       T.JUGDE_APPLY_SEQUENO = '',
       T.JUDGE_RESULT_CODE = '40740701',
       T.JUDGE_RESULT = '合格',
       T.JUDGE_RESULT_TIME = '',
       T.JUDGE_MAKER = '',
       (PRO_ORDER_NO,
        PRO_ORDER_ID,
        ORD_LN_DLY_PK,
        ORDER_NO,
        ORDER_SEQ,
        ORDER_SEQ_NO,
        ORD_PK,
        ORD_LN_PK,
        TARGET,
        MEMO) =
       (SELECT M.ORDER_NO || '/' || M.ORDER_SEQ,
               M.PRO_PLAN_ID,
               M.ORD_LN_DLY_PK,
               M.ORDER_NO,
               M.ORDER_SEQ,
               M.DELIVERY_NO,
               (SELECT MAX(ORD_PK)
                  FROM SLM_ORDER_LINE_DELIVERY
                 WHERE ORD_LN_DLY_PK = M.ORD_LN_DLY_PK),
               (SELECT MAX(ORD_LN_PK)
                  FROM SLM_ORDER_LINE_DELIVERY
                 WHERE ORD_LN_DLY_PK = M.ORD_LN_DLY_PK),
               M.DECISION,
               ''
          FROM PLN_ZY_DBK_M M 
         WHERE M.HEAT_PLAN_NO = ?
           AND ROWNUM = 1)
 WHERE MAT_NO IN (SELECT MAT_NO FROM YDM_BC_INLIST WHERE INSTOCK_DOC = ?)
		]]>
	</query>


	<query id="OverstockPipe.RecoverMatDataF" desc="离线">
		<![CDATA[
UPDATE MAT_BC_M T
   SET PRODUCT_FLAG = '801401', --材料状态
       MAT_STATUS = '80150101',
       QCM_STAUS = '11',
       T.JUGDE_APPLY_CODE = '',
       T.JUGDE_APPLY_SEQUENO = '',
       T.JUDGE_RESULT_CODE = '',
       T.JUDGE_RESULT = '',
       T.JUDGE_RESULT_TIME = '',
       T.JUDGE_MAKER = '',
       (PRO_ORDER_NO,
        PRO_ORDER_ID,
        ORD_LN_DLY_PK,
        ORDER_NO,
        ORDER_SEQ,
        ORDER_SEQ_NO,
        ORD_PK,
        ORD_LN_PK,
        TARGET,
        MEMO) =
       (SELECT M.ORDER_NO || '/' || M.ORDER_SEQ,
               M.PRO_PLAN_ID,
               M.ORD_LN_DLY_PK,
               M.ORDER_NO,
               M.ORDER_SEQ,
               M.DELIVERY_NO,
               (SELECT MAX(ORD_PK)
                  FROM SLM_ORDER_LINE_DELIVERY
                 WHERE ORD_LN_DLY_PK = M.ORD_LN_DLY_PK),
               (SELECT MAX(ORD_LN_PK)
                  FROM SLM_ORDER_LINE_DELIVERY
                 WHERE ORD_LN_DLY_PK = M.ORD_LN_DLY_PK),
               M.DECISION,
               O.MEMO
          FROM PLN_ZY_RCL_M M, HTT_OFFLINE_RESULT O
         WHERE M.HEAT_PLAN_NO = O.HEAT_PLAN_NO
           AND O.RESULT_NO = ?
           AND ROWNUM = 1)
 WHERE MAT_NO IN (SELECT MAT_NO FROM YDM_BC_INLIST WHERE INSTOCK_DOC = ?)
		]]>
	</query>
	
	<query id="OverstockPipe.RecoverMatDataF2" desc="余材">
		<![CDATA[
UPDATE MAT_BC_M T
   SET PRODUCT_FLAG = '801401', --材料状态
       MAT_STATUS = '80150102',
       QCM_STAUS = '00',
       T.JUGDE_APPLY_CODE = '',
       T.JUGDE_APPLY_SEQUENO = '',
       T.JUDGE_RESULT_CODE = '40740701',
       T.JUDGE_RESULT = '合格',
       T.JUDGE_RESULT_TIME = '',
       T.JUDGE_MAKER = '',
       (PRO_ORDER_NO,
        PRO_ORDER_ID,
        ORD_LN_DLY_PK,
        ORDER_NO,
        ORDER_SEQ,
        ORDER_SEQ_NO,
        ORD_PK,
        ORD_LN_PK,
        TARGET,
        MEMO) =
       (SELECT M.ORDER_NO || '/' || M.ORDER_SEQ,
               M.PRO_PLAN_ID,
               M.ORD_LN_DLY_PK,
               M.ORDER_NO,
               M.ORDER_SEQ,
               M.DELIVERY_NO,
               (SELECT MAX(ORD_PK)
                  FROM SLM_ORDER_LINE_DELIVERY
                 WHERE ORD_LN_DLY_PK = M.ORD_LN_DLY_PK),
               (SELECT MAX(ORD_LN_PK)
                  FROM SLM_ORDER_LINE_DELIVERY
                 WHERE ORD_LN_DLY_PK = M.ORD_LN_DLY_PK),
               M.DECISION,
               ''
          FROM PLN_ZY_RCL_M M 
         WHERE M.HEAT_PLAN_NO ?
           AND ROWNUM = 1)
 WHERE MAT_NO IN (SELECT MAT_NO FROM YDM_BC_INLIST WHERE INSTOCK_DOC = ?)
		]]>
	</query>
	

	<query id="OverstockPipe.RecoverMatDataG" desc="离线">
		<![CDATA[
UPDATE MAT_BC_M T
   SET PRODUCT_FLAG = '801401', --材料状态
       MAT_STATUS = '80150101',
       QCM_STAUS = '11',
       T.JUGDE_APPLY_CODE = '',
       T.JUGDE_APPLY_SEQUENO = '',
       T.JUDGE_RESULT_CODE = '',
       T.JUDGE_RESULT = '',
       T.JUDGE_RESULT_TIME = '',
       T.JUDGE_MAKER = '',
       (PRO_ORDER_NO,
        PRO_ORDER_ID,
        ORD_LN_DLY_PK,
        ORDER_NO,
        ORDER_SEQ,
        ORDER_SEQ_NO,
        ORD_PK,
        ORD_LN_PK,
        TARGET,
        MEMO) =
       (SELECT M.ORDER_NO || '/' || M.ORDER_SEQ,
               M.PRO_PLAN_ID,
               M.ORD_LN_DLY_PK,
               M.ORDER_NO,
               M.ORDER_SEQ,
               M.DELIVERY_NO,
               (SELECT MAX(ORD_PK)
                  FROM SLM_ORDER_LINE_DELIVERY
                 WHERE ORD_LN_DLY_PK = M.ORD_LN_DLY_PK),
               (SELECT MAX(ORD_LN_PK)
                  FROM SLM_ORDER_LINE_DELIVERY
                 WHERE ORD_LN_DLY_PK = M.ORD_LN_DLY_PK),
               M.DECISION,
               O.MEMO
          FROM PLN_ZY_JGX_M M, MCH_OFFLINE_RESULT O
         WHERE M.HEAT_PLAN_NO = O.HEAT_PLAN_NO
           AND O.RESULT_NO = ?
           AND ROWNUM = 1)
 WHERE MAT_NO IN (SELECT MAT_NO FROM YDM_BC_INLIST WHERE INSTOCK_DOC = ?)
		]]>
	</query>
	
	<query id="OverstockPipe.RecoverMatDataG2" desc="余材">
		<![CDATA[
UPDATE MAT_BC_M T
   SET PRODUCT_FLAG = '801401', --材料状态
       MAT_STATUS = '80150102',
       QCM_STAUS = '00',
       T.JUGDE_APPLY_CODE = '',
       T.JUGDE_APPLY_SEQUENO = '',
       T.JUDGE_RESULT_CODE = '40740701',
       T.JUDGE_RESULT = '合格',
       T.JUDGE_RESULT_TIME = '',
       T.JUDGE_MAKER = '',
       (PRO_ORDER_NO,
        PRO_ORDER_ID,
        ORD_LN_DLY_PK,
        ORDER_NO,
        ORDER_SEQ,
        ORDER_SEQ_NO,
        ORD_PK,
        ORD_LN_PK,
        TARGET,
        MEMO) =
       (SELECT M.ORDER_NO || '/' || M.ORDER_SEQ,
               M.PRO_PLAN_ID,
               M.ORD_LN_DLY_PK,
               M.ORDER_NO,
               M.ORDER_SEQ,
               M.DELIVERY_NO,
               (SELECT MAX(ORD_PK)
                  FROM SLM_ORDER_LINE_DELIVERY
                 WHERE ORD_LN_DLY_PK = M.ORD_LN_DLY_PK),
               (SELECT MAX(ORD_LN_PK)
                  FROM SLM_ORDER_LINE_DELIVERY
                 WHERE ORD_LN_DLY_PK = M.ORD_LN_DLY_PK),
               M.DECISION,
               ''
          FROM PLN_ZY_JGX_M M 
         WHERE M.HEAT_PLAN_NO = ?
           AND ROWNUM = 1)
 WHERE MAT_NO IN (SELECT MAT_NO FROM YDM_BC_INLIST WHERE INSTOCK_DOC = ?)
		]]>
	</query>
	
	<query id="OverstockPipe.RecoverMatDataD" desc="离线">
		<![CDATA[
UPDATE MAT_BC_M T
   SET PRODUCT_FLAG = '801401', --材料状态
       MAT_STATUS = '80150101',
       QCM_STAUS = '11',
       T.JUGDE_APPLY_CODE = '',
       T.JUGDE_APPLY_SEQUENO = '',
       T.JUDGE_RESULT_CODE = '',
       T.JUDGE_RESULT = '',
       T.JUDGE_RESULT_TIME = '',
       T.JUDGE_MAKER = '',
       (PRO_ORDER_NO,
        PRO_ORDER_ID,
        ORD_LN_DLY_PK,
        ORDER_NO,
        ORDER_SEQ,
        ORDER_SEQ_NO,
        ORD_PK,
        ORD_LN_PK,
        TARGET,
        MEMO) =
       (SELECT M.ORDER_NO || '/' || M.ORDER_SEQ,
               M.PRO_PLAN_ID,
               M.ORD_LN_DLY_PK,
               M.ORDER_NO,
               M.ORDER_SEQ,
               M.DELIVERY_NO,
               (SELECT MAX(ORD_PK)
                  FROM SLM_ORDER_LINE_DELIVERY
                 WHERE ORD_LN_DLY_PK = M.ORD_LN_DLY_PK),
               (SELECT MAX(ORD_LN_PK)
                  FROM SLM_ORDER_LINE_DELIVERY
                 WHERE ORD_LN_DLY_PK = M.ORD_LN_DLY_PK),
               M.DECISION,
               '' MEMO
          FROM PLN_ZY_ZG_M M, MIL_OFFLINE_RESLUT O
         WHERE M.PRO_PLAN_ID = O.PRO_PLAN_ID
           AND M.GX_PLAN_NO = O.GX_PLAN_NO
           AND M.JUDGE_STOVE_NO = O.JUDGE_STOVE_NO
           AND O.OFFLINE_DOC = ?
           AND ROWNUM = 1)
 WHERE MAT_NO IN (SELECT MAT_NO FROM YDM_BC_INLIST WHERE INSTOCK_DOC = ?)
		]]>
	</query>
	
	<query id="OverstockPipe.RecoverMatDataD2" desc="余材">
		<![CDATA[
UPDATE MAT_BC_M T
   SET PRODUCT_FLAG = '801401', --材料状态
       MAT_STATUS = '80150102',
       QCM_STAUS = '00',
       T.JUGDE_APPLY_CODE = '',
       T.JUGDE_APPLY_SEQUENO = '',
       T.JUDGE_RESULT_CODE = '40740701',
       T.JUDGE_RESULT = '合格',
       T.JUDGE_RESULT_TIME = '',
       T.JUDGE_MAKER = '',
       (PRO_ORDER_NO,
        PRO_ORDER_ID,
        ORD_LN_DLY_PK,
        ORDER_NO,
        ORDER_SEQ,
        ORDER_SEQ_NO,
        ORD_PK,
        ORD_LN_PK,
        TARGET,
        MEMO) =
       (SELECT M.ORDER_NO || '/' || M.ORDER_SEQ,
               M.PRO_PLAN_ID,
               M.ORD_LN_DLY_PK,
               M.ORDER_NO,
               M.ORDER_SEQ,
               M.DELIVERY_NO,
               (SELECT MAX(ORD_PK)
                  FROM SLM_ORDER_LINE_DELIVERY
                 WHERE ORD_LN_DLY_PK = M.ORD_LN_DLY_PK),
               (SELECT MAX(ORD_LN_PK)
                  FROM SLM_ORDER_LINE_DELIVERY
                 WHERE ORD_LN_DLY_PK = M.ORD_LN_DLY_PK),
               M.DECISION,
               '' MEMO
          FROM PLN_ZY_ZG_M M
         WHERE M.HEAT_PLAN_NO = ?
           AND ROWNUM = 1)
 WHERE MAT_NO IN (SELECT MAT_NO FROM YDM_BC_INLIST WHERE INSTOCK_DOC = ?)
		]]>
	</query>

	<query id="OverstockPipe.AddInstoreRecord" desc="增加产出入库记录(离线)">
		<![CDATA[

  INSERT INTO YDM_BC_INLIST
    (INSTOCK_SQE,
     INSTOCK_DOC,
     INSTOCK_TYPE_CODE,
     INSTOCK_TYPE_NAME,
     MAT_NO,
     LOT_NO,
     STOVE_NO,
     JUDGE_STOVE_NO,
     BATCH_NO,
     BATCH_GROUD_NO,
     MATERIAL_NO,
     MATERIAL_NAME,
     PRODUCCODE,
     PRODUCNAME,
     STD_CODE,
     STD_NAME,
     GRADECODE,
     GRADENAME,
     STEELCODE,
     STEELNAME,
     STD_STYLE,
     STD_STYLE_DESC,
     SPEC_CODE,
     SPEC_NAME,
     MODEL_CODE,
     MODEL_DESC,
     PRO_ORDER_NO,
     PLINE_CODE,
     PLINE_NAME,
     ACT_DIMATER,
     ACT_HEIGHT,
     ACT_LEN,
     ACT_LEN_MIN,
     ACT_LEN_MAX,
     ACT_COUNT,
     ACT_WEIGHT,
     ACT_THEORY_WEIGHT,
     BELONG_CODE,
     BELONG_NAME,
     STORAGE_NO,
     LOCATION_NO,
     LARY_NO,
     INSTOCK_TIME,
     CREATE_NAME,
     CREATE_TIME,
     PRODUCT_FLAG,
     MAT_STATUS,
     IN_TIME_F,
     BAL_YEAR_MONTH,
     MAT_ORIGIN_CODE,
     MAT_ORIGIN_NAME,
     QCM_STAUS,
     GX_PLAN_NO)
    SELECT ? || LPAD(ROWNUM, 4, '0'),
           ?,
           '800701',
           '产出入库',
           M.MAT_NO,
           M.LOT_NO,
           M.STOVE_NO,
           M.JUDGE_STOVE_NO,
           M.BATCH_NO,
           M.BATCH_GROUD_NO,
           MATERIAL_NO,
           MATERIAL_NAME,
           PRODUCCODE,
           PRODUCNAME,
           STD_CODE,
           STD_NAME,
           GRADECODE,
           GRADENAME,
           STEELCODE,
           STEELNAME,
           STD_STYLE,
           STD_STYLE_DESC,
           SPEC_CODE,
           SPEC_NAME,
           MODEL_CODE,
           MODEL_DESC,
           PRO_ORDER_NO,
           M.PLINE_CODE,
           M.PLINE_NAME,
           ACT_DIMATER,
           ACT_HEIGHT,
           ACT_LEN,
           ACT_LEN_MIN,
           ACT_LEN_MAX,
           ACT_COUNT,
           ACT_WEIGHT,
           ACT_THEORY_WEIGHT,
           BELONG_CODE,
           BELONG_NAME,
           STORAGE_NO,
           LOCATION_NO,
           LARY_NO,
           SYSDATE,
           '',
           SYSDATE,
           PRODUCT_FLAG,
           MAT_STATUS,
           SYSDATE,
           BAL_YEAR_MONTH,
           MAT_ORIGIN_CODE,
           MAT_ORIGIN_NAME,
           QCM_STAUS,
           GX_PLAN_NO
      FROM MAT_BC_M M, YDM_BC_BUTTRESS B
     WHERE M.MAT_NO = B.MAT_NO
       AND M.OFFLINE_DOC = ?
		]]>
	</query>
	
	<query id="OverstockPipe.AddInstoreRecord2" desc="增加产出入库记录(余材)">
		<![CDATA[
  INSERT INTO YDM_BC_INLIST
  (INSTOCK_SQE,
   INSTOCK_DOC,
   INSTOCK_TYPE_CODE,
   INSTOCK_TYPE_NAME,
   MAT_NO,
   LOT_NO,
   STOVE_NO,
   JUDGE_STOVE_NO,
   BATCH_NO,
   BATCH_GROUD_NO,
   MATERIAL_NO,
   MATERIAL_NAME,
   PRODUCCODE,
   PRODUCNAME,
   STD_CODE,
   STD_NAME,
   GRADECODE,
   GRADENAME,
   STEELCODE,
   STEELNAME,
   STD_STYLE,
   STD_STYLE_DESC,
   SPEC_CODE,
   SPEC_NAME,
   MODEL_CODE,
   MODEL_DESC,
   PRO_ORDER_NO,
   PLINE_CODE,
   PLINE_NAME,
   ACT_DIMATER,
   ACT_HEIGHT,
   ACT_LEN,
   ACT_LEN_MIN,
   ACT_LEN_MAX,
   ACT_COUNT,
   ACT_WEIGHT,
   ACT_THEORY_WEIGHT,
   BELONG_CODE,
   BELONG_NAME,
   STORAGE_NO,
   LOCATION_NO,
   LARY_NO,
   INSTOCK_TIME,
   CREATE_NAME,
   CREATE_TIME,
   PRODUCT_FLAG,
   MAT_STATUS,
   IN_TIME_F,
   BAL_YEAR_MONTH,
   MAT_ORIGIN_CODE,
   MAT_ORIGIN_NAME,
   QCM_STAUS,
   GX_PLAN_NO)
  SELECT ? || LPAD(ROWNUM, 4, '0'),
         ?,
         '800701',
         '产出入库',
         M.MAT_NO,
         M.LOT_NO,
         M.STOVE_NO,
         M.JUDGE_STOVE_NO,
         M.BATCH_NO,
         M.BATCH_GROUD_NO,
         MATERIAL_NO,
         MATERIAL_NAME,
         PRODUCCODE,
         PRODUCNAME,
         STD_CODE,
         STD_NAME,
         GRADECODE,
         GRADENAME,
         STEELCODE,
         STEELNAME,
         STD_STYLE,
         STD_STYLE_DESC,
         SPEC_CODE,
         SPEC_NAME,
         MODEL_CODE,
         MODEL_DESC,
         PRO_ORDER_NO,
         M.PLINE_CODE,
         M.PLINE_NAME,
         ACT_DIMATER,
         ACT_HEIGHT,
         ACT_LEN,
         ACT_LEN_MIN,
         ACT_LEN_MAX,
         ACT_COUNT,
         ACT_WEIGHT,
         ACT_THEORY_WEIGHT,
         BELONG_CODE,
         BELONG_NAME,
         STORAGE_NO,
         LOCATION_NO,
         LARY_NO,
         SYSDATE,
         '',
         SYSDATE,
         PRODUCT_FLAG,
         MAT_STATUS,
         SYSDATE,
         BAL_YEAR_MONTH,
         MAT_ORIGIN_CODE,
         MAT_ORIGIN_NAME,
         QCM_STAUS,
         GX_PLAN_NO
    FROM MAT_BC_M M, YDM_BC_BUTTRESS B
   WHERE M.MAT_NO = B.MAT_NO
     AND M.JUDGE_STOVE_NO = ?
     AND M.PLINE_CODE = ?
     AND M.OFFLINE_DOC = ?
     AND M.QCM_STAUS = '00'
     AND M.PRO_PLAN_ID_NEXT IS NULL
     AND (M.JUDGE_RESULT_CODE IN ('40740701', '40740709') OR (M.JUDGE_RESULT_CODE IS NULL AND M.ORDER_NO IS NULL))
		]]>
	</query>

	<query id="OverstockPipe.DeleteInstoreRecord" desc="删除入库记录">
		<![CDATA[
DELETE FROM YDM_BC_INLIST T WHERE T.INSTOCK_DOC = ?
		]]>
	</query>
	
	<query id="OverstockPipe.DeleteOutRecord" desc="删除出库记录">
		<![CDATA[
DECLARE
BEGIN
  DELETE FROM YDM_BC_OUTLIST T WHERE T.OUTSTOCK_DOC = ?;
  DELETE FROM YDM_BC_OUTLIST T WHERE T.OUTSTOCK_DOC = ?;
END;
		]]>
	</query>


	<query id="OverstockPipe.ApplyJudge" desc="压库管送判（离线）">
		<![CDATA[
INSERT INTO QCM_ZG_JUGDE_APPLY
  (JUGDE_APPLY_CODE,
   JUDGE_STOVE_NO,
   BATCH_NO,
   BATCH_GROUD_NO,
   PROCESS_CODE,
   PLINE_CODE,
   ACT_COUNT,
   ACT_WEIGHT,
   ACT_THEORY_WEIGHT,
   PRO_ORDER_ID,
   VALIDFLAG,
   APPLY_NAME,
   APPLY_TIME,
   MATERIAL_NO,
   MATERIAL_NAME,
   PRODUCCODE,
   PRODUCNAME,
   STEELCODE,
   STEELNAME,
   GRADECODE,
   GRADENAME,
   SPEC_CODE,
   SPEC_NAME,
   MODEL_CODE,
   MODEL_DESC,
   STD_CODE,
   STD_NAME,
   STD_STYLE,
   STD_STYLE_DESC,
   CRAF_NO,
   LOT_NO,
   PLINE_NAME,
   MAT_GOWHERE_CODE,
   MAT_GOWHERE_NAME,
   ACT_DIMATER,
   ACT_HEIGHT,
   ACT_LEN_MIN,
   ACT_LEN_MAX,
   BELONG_CODE,
   BELONG_NAME,
   ISENDGX,
   ACT_LEN,
   BELONG_CODE_JUGDE,
   BELONG_NAME_JUGDE,
   STOVE_NO,
   JUGDE_APPLY_SEQUENO,
   TARGET,
   HEAT_PLAN_NO,
   SUPPLY_UNIT,
   SUPPLY_UNIT_DESC,
   QUALITY_GROUP,
   JUDGE_RESULT_CODE,
   JUDGE_RESULT,
   JUDGE_RESULT_TIME,
   JUDGE_MAKER,
   IS_ALL_SCRAP,
   MEMO)
  SELECT MAX(M.JUGDE_APPLY_CODE),
         MAX(M.JUDGE_STOVE_NO),
         MAX(M.BATCH_NO),
         '001',
         MAX(M.PROCESS_CDOE),
         MAX(M.PLINE_CODE),
         SUM(M.ACT_COUNT),
         SUM(M.ACT_WEIGHT),
         SUM(M.ACT_WEIGHT),
         MAX(M.PRO_ORDER_ID),
         '20',
         ?,
         SYSDATE,
         MAX(M.MATERIAL_NO),
         MAX(M.MATERIAL_NAME),
         MAX(M.PRODUCCODE),
         MAX(M.PRODUCNAME),
         MAX(M.STEELCODE),
         MAX(M.STEELNAME),
         MAX(M.GRADECODE),
         MAX(M.GRADENAME),
         MAX(M.SPEC_CODE),
         MAX(M.SPEC_NAME),
         MAX(M.MODEL_CODE),
         MAX(M.MODEL_DESC),
         MAX(M.STD_CODE),
         MAX(M.STD_NAME),
         MAX(M.STD_STYLE),
         MAX(M.STD_STYLE_DESC),
         MAX(M.CRAF_NO),
         MAX(M.LOT_NO),
         MAX(M.PLINE_NAME),
         NVL(MAX(M.MAT_GOWHERE_CODE), '/'),
         NVL(MAX(M.MAT_GOWHERE_NAME), '/'),
         MAX(M.ACT_DIMATER),
         MAX(M.ACT_HEIGHT),
         MAX(M.ACT_LEN_MIN),
         MAX(M.ACT_LEN_MAX),
         MAX(M.BELONG_CODE),
         MAX(M.BELONG_NAME),
         '1',
         SUM(M.ACT_LEN),
         '100101',
         '国内贸易部',
         MAX(M.STOVE_NO),
         MAX(M.JUGDE_APPLY_SEQUENO),
         MAX(M.TARGET),
         MAX(M.HEAT_PLAN_NO),
         ?,
         DECODE(?, '120504', '江苏天淮钢管有限公司', '天津钢管制造有限公司'),
         '1',
         MAX(JUDGE_RESULT_CODE),
         MAX(JUDGE_RESULT),
         MAX(JUDGE_RESULT_TIME),
         MAX(JUDGE_MAKER),
         '7',
         MAX(M.MEMO)
    FROM MAT_BC_M M
    LEFT JOIN COM_BASE_PLINE P
      ON P.PLINE_CODE = M.PLINE_CODE, YDM_BC_BUTTRESS B
   WHERE M.MAT_NO = B.MAT_NO
     AND M.OFFLINE_DOC = ?

		]]>
	</query>
	
	<query id="OverstockPipe.ApplyJudge2" desc="压库管送判（余材）">
		<![CDATA[
INSERT INTO QCM_ZG_JUGDE_APPLY
  (JUGDE_APPLY_CODE,
   JUDGE_STOVE_NO,
   BATCH_NO,
   BATCH_GROUD_NO,
   PROCESS_CODE,
   PLINE_CODE,
   ACT_COUNT,
   ACT_WEIGHT,
   ACT_THEORY_WEIGHT,
   PRO_ORDER_ID,
   VALIDFLAG,
   APPLY_NAME,
   APPLY_TIME,
   MATERIAL_NO,
   MATERIAL_NAME,
   PRODUCCODE,
   PRODUCNAME,
   STEELCODE,
   STEELNAME,
   GRADECODE,
   GRADENAME,
   SPEC_CODE,
   SPEC_NAME,
   MODEL_CODE,
   MODEL_DESC,
   STD_CODE,
   STD_NAME,
   STD_STYLE,
   STD_STYLE_DESC,
   CRAF_NO,
   LOT_NO,
   PLINE_NAME,
   MAT_GOWHERE_CODE,
   MAT_GOWHERE_NAME,
   ACT_DIMATER,
   ACT_HEIGHT,
   ACT_LEN_MIN,
   ACT_LEN_MAX,
   BELONG_CODE,
   BELONG_NAME,
   ISENDGX,
   ACT_LEN,
   BELONG_CODE_JUGDE,
   BELONG_NAME_JUGDE,
   STOVE_NO,
   JUGDE_APPLY_SEQUENO,
   TARGET,
   HEAT_PLAN_NO,
   SUPPLY_UNIT,
   SUPPLY_UNIT_DESC,
   QUALITY_GROUP,
   JUDGE_RESULT_CODE,
   JUDGE_RESULT,
   JUDGE_RESULT_TIME,
   JUDGE_MAKER,
   IS_ALL_SCRAP,
   MEMO)
  SELECT MAX(M.JUGDE_APPLY_CODE),
         MAX(M.JUDGE_STOVE_NO),
         MAX(M.BATCH_NO),
         '001',
         MAX(M.PROCESS_CDOE),
         DECODE(?, '120504', 'C100', 'C095'),
         SUM(M.ACT_COUNT),
         SUM(M.ACT_WEIGHT),
         SUM(M.ACT_WEIGHT),
         MAX(M.PRO_ORDER_ID),
         '20',
         ?,
         SYSDATE,
         MAX(M.MATERIAL_NO),
         MAX(M.MATERIAL_NAME),
         MAX(M.PRODUCCODE),
         MAX(M.PRODUCNAME),
         MAX(M.STEELCODE),
         MAX(M.STEELNAME),
         MAX(M.GRADECODE),
         MAX(M.GRADENAME),
         MAX(M.SPEC_CODE),
         MAX(M.SPEC_NAME),
         MAX(M.MODEL_CODE),
         MAX(M.MODEL_DESC),
         MAX(M.STD_CODE),
         MAX(M.STD_NAME),
         MAX(M.STD_STYLE),
         MAX(M.STD_STYLE_DESC),
         MAX(M.CRAF_NO),
         MAX(M.LOT_NO),
         DECODE(?, '120504', '天淮余材转压库', '半成品转压库'),
         NVL(MAX(M.MAT_GOWHERE_CODE), '/'),
         NVL(MAX(M.MAT_GOWHERE_NAME), '/'),
         MAX(M.ACT_DIMATER),
         MAX(M.ACT_HEIGHT),
         MAX(M.ACT_LEN_MIN),
         MAX(M.ACT_LEN_MAX),
         MAX(M.BELONG_CODE),
         MAX(M.BELONG_NAME),
         '1',
         SUM(M.ACT_LEN),
         '100101',
         '国内贸易部',
         MAX(M.STOVE_NO),
         MAX(M.JUGDE_APPLY_SEQUENO),
         MAX(M.TARGET),
         MAX(M.HEAT_PLAN_NO),
         ?,
         DECODE(?, '120504', '江苏天淮钢管有限公司', '天津钢管制造有限公司'),
         '1',
         MAX(JUDGE_RESULT_CODE),
         MAX(JUDGE_RESULT),
         MAX(JUDGE_RESULT_TIME),
         MAX(JUDGE_MAKER),
         '8',
         MAX(M.MEMO)
    FROM MAT_BC_M M
    LEFT JOIN COM_BASE_PLINE P
      ON P.PLINE_CODE = M.PLINE_CODE, YDM_BC_BUTTRESS B
   WHERE M.MAT_NO = B.MAT_NO
     AND M.JUDGE_STOVE_NO = ?
        --AND M.PLINE_CODE = ?
        AND M.OFFLINE_DOC = ?
     AND M.JUGDE_APPLY_CODE = ?
     AND M.QCM_STAUS = '00'
     AND (M.JUDGE_RESULT_CODE IN ('40740701', '40740709') OR (M.JUDGE_RESULT_CODE IS NULL AND M.ORDER_NO IS NULL))

		]]>
	</query>


	<query id="OverstockPipe.getJudgeResult" desc="">
		<![CDATA[
SELECT T.* FROM QCM_ZG_JUGDE_APPLY T WHERE T.JUGDE_APPLY_CODE = ?
		]]>
	</query>

	<query id="OverstockPipe.CancelApplyJudge" desc="">
		<![CDATA[
 DELETE  FROM QCM_ZG_JUGDE_APPLY T WHERE T.JUGDE_APPLY_CODE=?

		]]>
	</query>


	<query id="OverstockPipe.HandlePortE" desc="">
		<![CDATA[
  UPDATE PORT_VRP_BATCH_SAMPLE_RESULT T
   SET T.MAT_STATUS          = '00',
       T.INSTORE_FLAG        = '1',
       T.JUGDE_APPLY_CODE    = ?,
       T.JUGDE_APPLY_SEQUENO = '1'
 WHERE T.RESULT_NO = ?
   AND T.MAT_STATUS = '20'


		]]>
	</query>


	<query id="OverstockPipe.RecoverPortE" desc="">
		<![CDATA[
  UPDATE PORT_VRP_BATCH_SAMPLE_RESULT T
   SET T.MAT_STATUS          = '20',
       T.INSTORE_FLAG        = '0',
       T.JUGDE_APPLY_CODE    = '',
       T.JUGDE_APPLY_SEQUENO = ''
 WHERE T.RESULT_NO = ?
   AND T.MAT_STATUS = '00'
   AND T.INSTORE_FLAG = '1'
   AND T.JUGDE_APPLY_CODE = ?
		]]>
	</query>


	<query id="OverstockPipe.HandlePortF" desc="">
		<![CDATA[
  UPDATE PORT_HTT_BATCH_SAMPLE_RESULT T
   SET T.MAT_STATUS          = '00',
       T.INSTORE_FLAG        = '1',
       T.JUGDE_APPLY_CODE    = ?,
       T.JUGDE_APPLY_SEQUENO = '1'
 WHERE T.RESULT_NO = ?
   AND T.MAT_STATUS = '20'


		]]>
	</query>


	<query id="OverstockPipe.RecoverPortF" desc="">
		<![CDATA[
  UPDATE PORT_HTT_BATCH_SAMPLE_RESULT T
   SET T.MAT_STATUS          = '20',
       T.INSTORE_FLAG        = '0',
       T.JUGDE_APPLY_CODE    = '',
       T.JUGDE_APPLY_SEQUENO = ''
 WHERE T.RESULT_NO = ?
   AND T.MAT_STATUS = '00'
   AND T.INSTORE_FLAG = '1'
   AND T.JUGDE_APPLY_CODE = ?
		]]>
	</query>

	<query id="OverstockPipe.HandlePortG" desc="">
		<![CDATA[
  UPDATE PORT_MCH_BATCH_SAMPLE_RESULT T
   SET T.MAT_STATUS          = '00',
       T.INSTORE_FLAG        = '1',
       T.JUGDE_APPLY_CODE    = ?,
       T.JUGDE_APPLY_SEQUENO = '1'
 WHERE T.RESULT_NO = ?
   AND T.MAT_STATUS = '20'


		]]>
	</query>

	<query id="OverstockPipe.RecoverPortG" desc="">
		<![CDATA[
  UPDATE PORT_MCH_BATCH_SAMPLE_RESULT T
   SET T.MAT_STATUS          = '20',
       T.INSTORE_FLAG        = '0',
       T.JUGDE_APPLY_CODE    = '',
       T.JUGDE_APPLY_SEQUENO = ''
 WHERE T.RESULT_NO = ?
   AND T.MAT_STATUS = '00'
   AND T.INSTORE_FLAG = '1'
   AND T.JUGDE_APPLY_CODE = ?
		]]>
	</query>
	
	<query id="OverstockPipe.HandlePortD" desc="">
		<![CDATA[
  UPDATE PORT_MIL_BATCH_SAMPLE_RESULT T
   SET T.STATUS = '7', T.JUGDE_APPLY_CODE = ?
 WHERE T.JUDGE_STOVE_NO = ?
   AND T.STATUS = '3'
   AND TRIM(T.OP_PROCESS) =
       DECODE(?, 'JZ', '9', 'TS', '10', 'ZJ', '11', 'XX', '12')
		]]>
	</query>
	
	<query id="OverstockPipe.RecoverPortD" desc="">
		<![CDATA[
  UPDATE PORT_MIL_BATCH_SAMPLE_RESULT T
   SET T.STATUS = '3', T.JUGDE_APPLY_CODE = ''
 WHERE T.JUDGE_STOVE_NO = ?
   AND T.STATUS = '7'
       AND T.JUGDE_APPLY_CODE = ?
		]]>
	</query>
	
	<query id="OverstockPipe.HandleOfflineD" desc="">
		<![CDATA[
     UPDATE MIL_OFFLINE_RESLUT T
   SET T.RECHECK_NUM = NVL(T.RECHECK_NUM, 0) + ?, T.STATUS = '1',T.YC_FLAG = '1'
 WHERE T.JUDGE_STOVE_NO = ?
   AND T.OFFLINE_DOC = ?
		]]>
	</query>
	
	<query id="OverstockPipe.RecoverOfflineD" desc="">
		<![CDATA[
     UPDATE MIL_OFFLINE_RESLUT T
   SET T.RECHECK_NUM = NVL(T.RECHECK_NUM, 0) - ?,
       T.STATUS = '0',T.YC_FLAG = '0'
 WHERE T.JUDGE_STOVE_NO = ?
   AND T.OFFLINE_DOC = ?
		]]>
	</query>
	
	<query id="OverstockPipe.RecoverMatData3" desc="还原库存数据（余材）">
		<![CDATA[
DECLARE
  V_APPLY_FLAG QCM_ZG_JUGDE_APPLY.APPLY_FLAG%TYPE := NULL;
BEGIN

  FOR MYROW IN (SELECT T1.*
                  FROM MAT_BC_M T, MAT_BC_M_BACK_UP T1
                 WHERE T.JUGDE_APPLY_CODE = ?
                   AND T.JUDGE_STOVE_NO = ?
                   AND T.BATCH_NO = ?
                   --AND T.PLINE_CODE = ?
                   AND T.MAT_NO = T1.MAT_NO) LOOP
    --还原材料表
    DELETE FROM MAT_BC_M T WHERE T.MAT_NO = MYROW.MAT_NO;
  
    INSERT INTO MAT_BC_M
      SELECT * FROM MAT_BC_M_BACK_UP T1 WHERE T1.MAT_NO = MYROW.MAT_NO;
    --删除备份信息
    DELETE FROM MAT_BC_M_BACK_UP T1 WHERE T1.MAT_NO = MYROW.MAT_NO;
  
    --删除产权出库记录
    DELETE FROM YDM_BC_OUTLIST T2
     WHERE T2.MAT_NO = MYROW.MAT_NO
       AND T2.OUTSTOCK_TYPE_NAME = '产权出库'
       AND T2.OUTSTOCK_DOC = ?;
  END LOOP;
END;
		]]>
	</query>

	<query desc="查询离线压库申请信息" id="OverstockPipe.doQueryApplyOffline">
		SELECT M.*
		FROM(
		SELECT
			T.APPLY_RESULT_NO,
			T.JUDGE_STOVE_NO,
			T.BATCH_NO,
			T.PLINE_CODE,
			T.PLINE_NAME,
			T.PROCESS_CODE,
			T.ACT_COUNT,
			T.ACT_WEIGHT,
			DECODE(T.APPLY_FLAG,'0','未申请','1','已申请','2','审核通过') APPLY_FLAG,
			T.APPLY_FLAG_NAME,
			T.APPLY_FLAG_TIME,
			T.APPLY_OK_NAME,
			T.APPLY_OK_TIME,
			T.HEAT_PLAN_NO,
			DECODE(T.VALIDFLAG,'0','无效','1','有效') VALIDFLAG,
			T.PRODUCCODE,
			T.PRODUCNAME,
			T.STEELCODE,
			T.STEELNAME,
			T.GRADECODE,
			T.GRADENAME,
			T.SPEC_CODE,
			T.SPEC_NAME,
			T.MODEL_CODE,
			T.MODEL_DESC,
			T.STD_CODE,
			T.STD_NAME,
			T.STD_STYLE,
			T.STD_STYLE_DESC,
			T.ORDER_NO,
			T.ORDER_SEQ,
			T.MEMO
		FROM YDM_OVERSTOCKPIPE_APPLY T INNER JOIN MIL_OFFLINE_RESLUT MILO ON T.APPLY_RESULT_NO = MILO.APPLY_RESULT_NO

		UNION ALL
		SELECT
			T.APPLY_RESULT_NO,
			T.JUDGE_STOVE_NO,
			T.BATCH_NO,
			T.PLINE_CODE,
			T.PLINE_NAME,
			T.PROCESS_CODE,
			T.ACT_COUNT,
			T.ACT_WEIGHT,
			DECODE(T.APPLY_FLAG,'0','未申请','1','已申请','2','审核通过') APPLY_FLAG,
			T.APPLY_FLAG_NAME,
			T.APPLY_FLAG_TIME,
			T.APPLY_OK_NAME,
			T.APPLY_OK_TIME,
			T.HEAT_PLAN_NO,
			DECODE(T.VALIDFLAG,'0','无效','1','有效') VALIDFLAG,
			T.PRODUCCODE,
			T.PRODUCNAME,
			T.STEELCODE,
			T.STEELNAME,
			T.GRADECODE,
			T.GRADENAME,
			T.SPEC_CODE,
			T.SPEC_NAME,
			T.MODEL_CODE,
			T.MODEL_DESC,
			T.STD_CODE,
			T.STD_NAME,
			T.STD_STYLE,
			T.STD_STYLE_DESC,
			T.ORDER_NO,
			T.ORDER_SEQ,
			T.MEMO
		FROM YDM_OVERSTOCKPIPE_APPLY T INNER JOIN HTT_OFFLINE_RESULT HTTO ON T.APPLY_RESULT_NO = HTTO.APPLY_RESULT_NO

		UNION ALL
		SELECT
			T.APPLY_RESULT_NO,
			T.JUDGE_STOVE_NO,
			T.BATCH_NO,
			T.PLINE_CODE,
			T.PLINE_NAME,
			T.PROCESS_CODE,
			T.ACT_COUNT,
			T.ACT_WEIGHT,
			DECODE(T.APPLY_FLAG,'0','未申请','1','已申请','2','审核通过') APPLY_FLAG,
			T.APPLY_FLAG_NAME,
			T.APPLY_FLAG_TIME,
			T.APPLY_OK_NAME,
			T.APPLY_OK_TIME,
			T.HEAT_PLAN_NO,
			DECODE(T.VALIDFLAG,'0','无效','1','有效') VALIDFLAG,
			T.PRODUCCODE,
			T.PRODUCNAME,
			T.STEELCODE,
			T.STEELNAME,
			T.GRADECODE,
			T.GRADENAME,
			T.SPEC_CODE,
			T.SPEC_NAME,
			T.MODEL_CODE,
			T.MODEL_DESC,
			T.STD_CODE,
			T.STD_NAME,
			T.STD_STYLE,
			T.STD_STYLE_DESC,
			T.ORDER_NO,
			T.ORDER_SEQ,
			T.MEMO
		FROM YDM_OVERSTOCKPIPE_APPLY T INNER JOIN MCH_OFFLINE_RESULT MCHO ON T.APPLY_RESULT_NO = MCHO.APPLY_RESULT_NO

		UNION ALL
		SELECT
			T.APPLY_RESULT_NO,
			T.JUDGE_STOVE_NO,
			T.BATCH_NO,
			T.PLINE_CODE,
			T.PLINE_NAME,
			T.PROCESS_CODE,
			T.ACT_COUNT,
			T.ACT_WEIGHT,
			DECODE(T.APPLY_FLAG,'0','未申请','1','已申请','2','审核通过') APPLY_FLAG,
			T.APPLY_FLAG_NAME,
			T.APPLY_FLAG_TIME,
			T.APPLY_OK_NAME,
			T.APPLY_OK_TIME,
			T.HEAT_PLAN_NO,
			DECODE(T.VALIDFLAG,'0','无效','1','有效') VALIDFLAG,
			T.PRODUCCODE,
			T.PRODUCNAME,
			T.STEELCODE,
			T.STEELNAME,
			T.GRADECODE,
			T.GRADENAME,
			T.SPEC_CODE,
			T.SPEC_NAME,
			T.MODEL_CODE,
			T.MODEL_DESC,
			T.STD_CODE,
			T.STD_NAME,
			T.STD_STYLE,
			T.STD_STYLE_DESC,
			T.ORDER_NO,
			T.ORDER_SEQ,
			T.MEMO
		FROM YDM_OVERSTOCKPIPE_APPLY T INNER JOIN VRP_OFFLINE_RESULT VRPO ON T.APPLY_RESULT_NO = VRPO.APPLY_RESULT_NO

		UNION ALL
		SELECT
			T.APPLY_RESULT_NO,
			T.JUDGE_STOVE_NO,
			T.BATCH_NO,
			T.PLINE_CODE,
			T.PLINE_NAME,
			T.PROCESS_CODE,
			T.ACT_COUNT,
			T.ACT_WEIGHT,
			DECODE(T.APPLY_FLAG,'0','未申请','1','已申请','2','审核通过') APPLY_FLAG,
			T.APPLY_FLAG_NAME,
			T.APPLY_FLAG_TIME,
			T.APPLY_OK_NAME,
			T.APPLY_OK_TIME,
			T.HEAT_PLAN_NO,
			DECODE(T.VALIDFLAG,'0','无效','1','有效') VALIDFLAG,
			T.PRODUCCODE,
			T.PRODUCNAME,
			T.STEELCODE,
			T.STEELNAME,
			T.GRADECODE,
			T.GRADENAME,
			T.SPEC_CODE,
			T.SPEC_NAME,
			T.MODEL_CODE,
			T.MODEL_DESC,
			T.STD_CODE,
			T.STD_NAME,
			T.STD_STYLE,
			T.STD_STYLE_DESC,
			T.ORDER_NO,
			T.ORDER_SEQ,
			T.MEMO
		FROM YDM_OVERSTOCKPIPE_APPLY T INNER JOIN COUPLING_OFFLINE_RESULT COUO ON T.APPLY_RESULT_NO = COUO.APPLY_RESULT_NO) M
		WHERE
			1 = 1 #someThing# ORDER BY M.VALIDFLAG,M.APPLY_FLAG_NAME

	</query>

	<query desc="查询余材压库申请信息" id="OverstockPipe.doQueryApplyYC">
		SELECT
			M.APPLY_RESULT_NO,
			M.JUDGE_STOVE_NO,
			M.BATCH_NO,
			M.PLINE_CODE,
			M.PLINE_NAME,
			M.PROCESS_CODE,
			M.ACT_COUNT,
			M.ACT_WEIGHT,
			DECODE(M.APPLY_FLAG,'0','未申请','1','已申请','2','审核通过') APPLY_FLAG,
			M.APPLY_FLAG_NAME,
			TO_CHAR(M.APPLY_FLAG_TIME, 'YYYY-MM-DD HH24:MI:SS') APPLY_FLAG_TIME,
			M.APPLY_OK_NAME,
			TO_CHAR(M.APPLY_OK_TIME, 'YYYY-MM-DD HH24:MI:SS') APPLY_OK_TIME,
			M.HEAT_PLAN_NO,
			DECODE(M.VALIDFLAG,'0','无效','1','有效') VALIDFLAG,
			M.PRODUCCODE,
			M.PRODUCNAME,
			M.STEELCODE,
			M.STEELNAME,
			M.GRADECODE,
			M.GRADENAME,
			M.SPEC_CODE,
			M.SPEC_NAME,
			M.MODEL_CODE,
			M.MODEL_DESC,
			M.STD_CODE,
			M.STD_NAME,
			M.STD_STYLE,
			M.STD_STYLE_DESC,
			M.ORDER_NO,
			M.ORDER_SEQ,
			M1.MEMO
		FROM YDM_OVERSTOCKPIPE_APPLY M INNER JOIN MAT_BC_M M1 ON M.APPLY_RESULT_NO = M1.APPLY_RESULT_NO
		WHERE 1 = 1 #someThing#
		GROUP BY
			M.APPLY_RESULT_NO,
			M.JUDGE_STOVE_NO,
			M.BATCH_NO,
			M.PLINE_CODE,
			M.PLINE_NAME,
			M.PROCESS_CODE,
			M.ACT_COUNT,
			M.ACT_WEIGHT,
			M.APPLY_FLAG,
			M.APPLY_FLAG_NAME,
			M.APPLY_FLAG_TIME,
			M.APPLY_OK_NAME,
			M.APPLY_OK_TIME,
			M.HEAT_PLAN_NO,
			M.VALIDFLAG,
			M.PRODUCCODE,
			M.PRODUCNAME,
			M.STEELCODE,
			M.STEELNAME,
			M.GRADECODE,
			M.GRADENAME,
			M.SPEC_CODE,
			M.SPEC_NAME,
			M.MODEL_CODE,
			M.MODEL_DESC,
			M.STD_CODE,
			M.STD_NAME,
			M.STD_STYLE,
			M.STD_STYLE_DESC,
			M.ORDER_NO,
			M.ORDER_SEQ,
			M1.MEMO
		ORDER BY M.VALIDFLAG,M.APPLY_FLAG_NAME
	</query>


	<query desc="新增离线压库申请" id="OverstockPipe.ApplyOfflineYK">
		INSERT INTO YDM_OVERSTOCKPIPE_APPLY(
		APPLY_RESULT_NO,
		JUDGE_STOVE_NO,
		BATCH_NO,
		PLINE_CODE,
		PLINE_NAME,
		PROCESS_CODE,
		ACT_COUNT,
		ACT_WEIGHT,
		APPLY_FLAG,
		APPLY_FLAG_NAME,
		APPLY_FLAG_TIME,
		HEAT_PLAN_NO,
		VALIDFLAG,
		PRODUCCODE,
		PRODUCNAME,
		STEELCODE,
		STEELNAME,
		GRADECODE,
		GRADENAME,
		SPEC_CODE,
		SPEC_NAME,
		MODEL_CODE,
		MODEL_DESC,
		STD_CODE,
		STD_NAME,
		STD_STYLE,
		STD_STYLE_DESC,
		ORDER_NO,
		ORDER_SEQ,
		MEMO)
		VALUES(
		'#APPLY_RESULT_NO#',
		'#JUDGE_STOVE_NO#',
		'#BATCH_NO#',
		'#PLINE_CODE#',
		'#PLINE_NAME#',
		'#PROCESS_CODE#',
		'#ACT_COUNT#',
		'#ACT_WEIGHT#',
		'#APPLY_FLAG#',
		'#APPLY_FLAG_NAME#',
		SYSDATE,
		'#HEAT_PLAN_NO#',
		'#VALIDFLAG#',
		'#PRODUCCODE#',
		'#PRODUCNAME#',
		'#STEELCODE#',
		'#STEELNAME#',
		'#GRADECODE#',
		'#GRADENAME#',
		'#SPEC_CODE#',
		'#SPEC_NAME#',
		'#MODEL_CODE#',
		'#MODEL_DESC#',
		'#STD_CODE#',
		'#STD_NAME#',
		'#STD_STYLE#',
		'#STD_STYLE_DESC#',
		'#ORDER_NO#',
		'#ORDER_SEQ#',
		'#MEMO#')

	</query>

	<query desc="获取转压库申请编号" id="OverstockPipe.ApplyResultNo">
		SELECT  TO_CHAR(SYSDATE, 'yyyyMMDD') ||
		LPAD(NVL(MAX(TO_NUMBER(SUBSTR(APPLY_RESULT_NO, LENGTH(APPLY_RESULT_NO) - 5))),
		0) + 1,
		6,
		'0') APPLY_RESULT_NO
		FROM  YDM_OVERSTOCKPIPE_APPLY
		WHERE APPLY_RESULT_NO LIKE   TO_CHAR(SYSDATE, 'yyyyMMDD') || '______'

	</query>

	<query desc="按工序修改applyresultno的值" id="OverstockPipe.UpdateApplynobyProcessD">
		UPDATE MIL_OFFLINE_RESLUT T
		SET
			T.APPLY_RESULT_NO = ?
		WHERE
			1 = 1
	</query>
	<query desc="按工序修改applyresultno的值" id="OverstockPipe.UpdateApplynobyProcessF">
		UPDATE HTT_OFFLINE_RESULT T
		SET
			T.APPLY_RESULT_NO = ?
		WHERE
			1 = 1
	</query>
	<query desc="按工序修改applyresultno的值" id="OverstockPipe.UpdateApplynobyProcessG">
		UPDATE MCH_OFFLINE_RESULT T
		SET
			T.APPLY_RESULT_NO = ?
		WHERE
			1 = 1
	</query>
	<query desc="按工序修改applyresultno的值" id="OverstockPipe.UpdateApplynobyProcessE">
		UPDATE VRP_OFFLINE_RESULT T
		SET
			T.APPLY_RESULT_NO = ?
		WHERE
			1 = 1
	</query>
	<query desc="按工序修改applyresultno的值" id="OverstockPipe.UpdateApplynobyProcessH">
		UPDATE COUPLING_OFFLINE_RESULT T
		SET
			T.APPLY_RESULT_NO = ?
		WHERE
			1 = 1
	</query>



	<query desc="离线压库审核通过修改" id="OverstockPipe.AuditOfflineYK">
		UPDATE YDM_OVERSTOCKPIPE_APPLY T
		SET
			T.APPLY_FLAG = 2,
			T.APPLY_OK_NAME = ?,
			T.APPLY_OK_TIME = SYSDATE
		WHERE
			1 = 1
	</query>

	<query desc="新增余材压库数据" id="OverstockPipe.ApplyYucaiYK">
		INSERT INTO YDM_OVERSTOCKPIPE_APPLY(
		APPLY_RESULT_NO,
		JUDGE_STOVE_NO,
		BATCH_NO,
		PLINE_CODE,
		PLINE_NAME,
		PROCESS_CODE,
		ACT_COUNT,
		ACT_WEIGHT,
		APPLY_FLAG,
		APPLY_FLAG_NAME,
		APPLY_FLAG_TIME,
		HEAT_PLAN_NO,
		VALIDFLAG,
		PRODUCCODE,
		PRODUCNAME,
		STEELCODE,
		STEELNAME,
		GRADECODE,
		GRADENAME,
		SPEC_CODE,
		SPEC_NAME,
		MODEL_CODE,
		MODEL_DESC,
		STD_CODE,
		STD_NAME,
		STD_STYLE,
		STD_STYLE_DESC,
		ORDER_NO,
		ORDER_SEQ,
		MEMO)
		VALUES(
		'#APPLY_RESULT_NO#',
		'#JUDGE_STOVE_NO#',
		'#BATCH_NO#',
		'#PLINE_CODE#',
		'#PLINE_NAME#',
		'#PROCESS_CODE#',
		'#ACT_COUNT#',
		'#ACT_WEIGHT#',
		'#APPLY_FLAG#',
		'#APPLY_FLAG_NAME#',
		SYSDATE,
		'#HEAT_PLAN_NO#',
		'#VALIDFLAG#',
		'#PRODUCCODE#',
		'#PRODUCNAME#',
		'#STEELCODE#',
		'#STEELNAME#',
		'#GRADECODE#',
		'#GRADENAME#',
		'#SPEC_CODE#',
		'#SPEC_NAME#',
		'#MODEL_CODE#',
		'#MODEL_DESC#',
		'#STD_CODE#',
		'#STD_NAME#',
		'#STD_STYLE#',
		'#STD_STYLE_DESC#',
		'#ORDER_NO#',
		'#ORDER_SEQ#',
		'#MEMO#')
	</query>

	<query desc="按工序修改applyresultno的值" id="OverstockPipe.UpdateApplynobyYucai">
		UPDATE MAT_BC_M T
		SET
		T.APPLY_RESULT_NO = ?
		WHERE
		1 = 1
	</query>

	<query desc="撤销压库申请" id="OverstockPipe.CancelApply">
		DELETE FROM YDM_OVERSTOCKPIPE_APPLY
		WHERE APPLY_RESULT_NO = ?
	</query>

	<query desc="查询送判记录" id="OverstockPipe.doQueryYDMResult">
		SELECT
			T.RESULT_NO,
			T.RESULT_NO_LX,
			T.OUTSTOCK_DOC,
			T.JUGDE_APPLY_CODE,
			T.PRO_SHIFT,
			T.PRO_GROUP,
			TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
			TO_CHAR(T.PRO_TIME, 'YYYY-MM-DD HH24:MI:SS') PRO_TIME,
			T.VALIDFLAG,
			T.JUDGE_STOVE_NO,
			T.BATCH_NO,
			T.PRO_USER,
			T.PLINE_CODE,
			T.PLINE_NAME,
			T.PROCESS_CODE,
			T.ACT_COUNT,
			T.ACT_WEIGHT,
			T.DELETE_USER,
			TO_CHAR(T.DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
			T.HEAT_PLAN_NO,
			T.FLAG,
			T.OUTSTOCK_DOC1,
			T.OUTSTOCK_DOC2,
			T.APPLY_FLAG,
			T.APPLY_FLAG_NAME,
			TO_CHAR(T.APPLY_FLAG_TIME, 'YYYY-MM-DD HH24:MI:SS') APPLY_FLAG_TIME,
			T.APPLY_OK_NAME,
			TO_CHAR(T.APPLY_OK_TIME, 'YYYY-MM-DD HH24:MI:SS') APPLY_OK_TIME
			FROM YDM_OVERSTOCKPIPE_RESULT T
		WHERE
			1 = 1

	</query>


	<query desc="撤销审核" id="OverstockPipe.CancelAudit">
		UPDATE YDM_OVERSTOCKPIPE_APPLY T
		SET
			T.APPLY_FLAG = 1,
			T.APPLY_OK_NAME = '',
			T.APPLY_OK_TIME = ''
		WHERE
			1 = 1
	</query>

	<query desc="压库申请废除" id="OverstockPipe.Del">
		UPDATE YDM_OVERSTOCKPIPE_APPLY T
		SET
			T.VALIDFLAG = 0
		WHERE
			1 = 1
	</query>

	<query desc="压库申请撤销废除" id="OverstockPipe.CancelDel">
		UPDATE YDM_OVERSTOCKPIPE_APPLY T
		SET
			T.VALIDFLAG = 1
		WHERE
			1 = 1
	</query>

</queryMap>