<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc = "热处理交库管理">
<query id = "FrmHttInStore.querySinglePlan" desc = "查询热处理炉计划">
 SELECT 
       T.HEAT_PLAN_NO,
       T.GX_PRO_SEQ,
       T.ZY_BATCH_ID,
       T.STOVE_NO,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.PLANSTATUS,
       T.PER_STATUS,
       DECODE(T.BESIDE_STATUS,'00','上料结炉','10','高温结炉','20','淬火结炉','30','低温结炉','40','定径结炉','50','热矫结炉','60','冷矫结炉','70','表检结炉','80','探伤结炉','90','交库结炉')BESIDE_STATUS,
       T.UPPER_HEATPLAN_ID,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       NVL(T.PLINE_CODE_W,T.PLINE_CODE) PLINE_CODE,
       NVL(T.PLINE_NAME_W,PLINE_NAME) PLINE_NAME,
    T.PLINE_CODE_W,
    T.PLINE_NAME_W,
       T.PROCESS_CODE_C,
       T.PROCESS_DESC_C,
       T.UPPER_PROCESS_CODE,
       T.NEXT_PROCESS_CODE,
       T.GOWHERE_CODE,
       T.GOWHERE_NAME,
       T.PROD_STANDARD,
       T.OUTPUT_STANDARD,
       DECODE(T.ISENDGX,'0','否','1','是') ISENDGX,
       T.IF_MATCH_ODD,
       T.IF_DO_HEAT_PLAN,
       T.ORDER_SOURCE,
       T.ORD_LN_DLY_PK,
       T.STD_CODE,
       T.STD_NAME,
       T.STD_STYLE,
       T.ORDER_NO,
       T.ORDER_SEQ,
       T.DELIVERY_NO,
       T.REQ_BL_ID,
       T.IF_EXPORT,
       T.PRIORITY,
       T.PRIORITY_MEMO,
       T.PRO_MONTH,
       T.PRO_DAY,
       T.BAL_YEAR_MONTH,
       DECODE(T.IF_MONITOR,'0','否','1','是') IF_MONITOR,
       T.PRDCR_NO,
       T.MONITOR_POINT,
       T.BOM,
       T.WHOLE_BACKLOG,
       T.WHOLE_BACKLOG_DESC,
       T.STATION_ROAD,
       T.CIC,
       T.PIC,
       T.SIC,
       T.DIC,
       T.CRAFT_FILE_NO,
       T.CRAFT_FILE_MAN,
       T.CRAFT_SEQ,
       T.SEC_CRAFT_FILE_NO,
       T.GRADECODE,
       T.GRADENAME,
       T.STEELCODE,
       T.STEELNAME,
       T.PRODUCCODE,
       T.PRODUCNAME,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.INWL_ID,
       T.INWL_DESC,
       T.OUTWL_ID,
       T.OUTWL_DESC,
       T.OUTDIAMETER_IN,
       T.WALLTHICK_IN,
       T.LENGTH_IN,
       T.LENGTHMAX_IN,
       T.LENGTHMIN_IN,
       T.OUTNUM_CUT,
       T.OUTDIAMETER,
       T.WALLTHICK,
       T.LENGTHMIN,
       T.LENGTHMAX,
       T.PLN_INSINGLE_NUM,
       T.PLN_INSINGLE_WT,
       T.PLN_INDOUBLE_NUM,
       T.PLN_INDOUBLE_WT,
       T.PLN_OUTSINGLE_NUM,
       T.PLN_OUTSINGLE_W,
       T.PLN_OUTDOUBLE_NUM,
       T.PLN_OUTDOUBLE_W,
       T.CREATE_NAME,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T.UPDATE_NAME,
       TO_CHAR(T.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       T.DOWNMAN,
       TO_CHAR(T.DOWNTIME, 'YYYY-MM-DD HH24:MI:SS') DOWNTIME,
       T.INDEX_SEQ,
       T.DECISION,
       T.STD_STYLE_DESC,
       T.SPEC_NAME,
       T.SPEC_CODE,
       T.FEED_HEAT_NO,
       T.IF_PRODUCT,
       NVL(T.PROCESS_SEQ,1) PROCESS_SEQ,
       NVL(T.REAL_PROCESS_SEQ,1) REAL_PROCESS_SEQ
 FROM PLN_ZY_RCL_M T
 WHERE 1 =1 
</query>
<query id = "FrmHttInStore.doQueryInList" desc = "查询入库实绩">
SELECT T.INSTOCK_DOC,
       T.LOT_NO,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.BATCH_GROUD_NO,
       T.PRODUCCODE,
       T.PRODUCNAME,
       T.STD_CODE,
       T.STD_NAME,
       T.STEELCODE,
       T.STEELNAME,
       T.STD_STYLE,
       T.STD_STYLE_DESC,
       T.SPEC_CODE,
       T.SPEC_NAME,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.ACT_DIMATER,
       T.ACT_HEIGHT,
       TO_CHAR(T.ACT_LEN_MIN, 'FM999990.00') AS ACT_LEN_MIN,
       TO_CHAR(T.ACT_LEN_MAX, 'FM999990.00') AS ACT_LEN_MAX,
       SUM(T.ACT_COUNT) AS ACT_COUNT,
       TO_CHAR(SUM(T.ACT_WEIGHT), 'FM999999990.000') AS ACT_WEIGHT,
       T.ACT_LEN,
       T.BELONG_CODE,
       T.BELONG_NAME,
      B.STORAGE_NO,
       T.MEMO,
       T.CREATE_NAME,
       MAX(TO_CHAR(T.INSTOCK_TIME, 'YYYY-MM-DD HH24:MI:SS')) AS INSTOCK_TIME,
       MAX(TO_CHAR(T.IN_TIME_F, 'YYYY-MM-DD')) AS IN_TIME_F,
       TO_CHAR(TO_DATE(T.BAL_YEAR_MONTH, 'YYYY-MM'), 'YYYY-MM') AS BAL_YEAR_MONTH,
       T.ORDER_NO,
       T.ORDER_SEQ,
       T.DELIVERY_NO,
       T.JUDGE_STD_CODE,
       T.JUDGE_STD_NAME,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.GRADECODE,
       T.GRADENAME,
       T.MATERIAL_NO,
       T.MATERIAL_NAME,
       DECODE(T.PRODUCT_FLAG,
              '801401',
              '在制品',
              '801402',
              '成品',
              '801403',
              '商品') PRODUCT_FLAG,
       T.MAT_STATUS,
       T.PIPMEMO,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
        DECODE(B.STORAGE_NO,NULL,'已倒运','未倒运') STATUS
  FROM YDM_BC_INLIST T  LEFT JOIN (SELECT M.MAT_NO, B.STORAGE_NO, M.JUDGE_STOVE_NO, M.BATCH_NO
    FROM MAT_BC_M M, YDM_BC_BUTTRESS B, COM_BASE_PLINE C
    WHERE M.MAT_NO = B.MAT_NO
    AND B.STORAGE_NO = C.OUT_REPOSITORY
    AND M.PLINE_CODE = C.PLINE_CODE
    UNION ALL
    SELECT M.MAT_NO, B.STORAGE_NO, M.JUDGE_STOVE_NO, M.BATCH_NO
    FROM MAT_ZC_M M, YDM_ZC_BUTTRESS B, COM_BASE_PLINE C
    WHERE M.MAT_NO = B.MAT_NO
    AND B.STORAGE_NO = C.OUT_REPOSITORY
    AND M.PLINE_CODE = C.PLINE_CODE
    ) B
    ON T.MAT_NO = B.MAT_NO
    AND T.JUDGE_STOVE_NO = B.JUDGE_STOVE_NO
    AND T.BATCH_NO = B.BATCH_NO
 WHERE T.INSTOCK_TYPE_CODE = '800701'
   AND T.HAND_FLAG = '0'
   AND T.QCM_STAUS = '00'
</query>
<query id = "FrmHttInStore.doQueryVrpRack" desc = "查询管号队列信息">
SELECT T.HEAT_PLAN_NO,
       T.JUDGE_STOVE_NO,
       T.FLAG_STOVE_NO,
       T.GROUP_NO,
       (SELECT NVL((SUM(P.ACT_COUNT)),0) FROM PORT_HTT_BATCH_SAMPLE_RESULT P WHERE P.JUDGE_STOVE_NO = ? AND T.PHY_BATCH_NO = P.PHY_BATCH_NO AND T.IS_SAMPLE_PIPE = P.IS_SAMPLE_PIPE 
    AND P.INSTORE_FLAG='1' AND T.FLAG_STOVE_NO = P.FLAG_STOVE_NO AND T.ACT_LEN = P.ACT_LEN) INACT_COUNT,
       SUM(T.ACT_COUNT) ACT_COUNT,
       SUM(T.ACT_WEIGHT) ACT_WEIGHT,
       DECODE(T.IS_SAMPLE_PIPE,'0','非样管','1','样管')IS_SAMPLE_PIPE,
       T.PHY_BATCH_NO,
       NVL((T.ACT_LEN),0) ACT_LEN
  FROM PORT_HTT_BATCH_SAMPLE_RESULT T
 WHERE T.HEAT_PLAN_NO = ?
   AND T.JUDGE_STOVE_NO = ?
   AND T.MAT_STATUS = '00'
   AND T.INSTORE_FLAG = '0'
   AND T.VALIDFLAG = '1'
 GROUP BY T.HEAT_PLAN_NO,
 		  T.FLAG_STOVE_NO,
 		  T.GROUP_NO,
          T.JUDGE_STOVE_NO,
          T.IS_SAMPLE_PIPE,
          T.PHY_BATCH_NO,
          T.ACT_LEN
</query>
<query id = "FrmHttInStore.doQueryStausRack" desc = "查询指定炉批支数">
SELECT NVL(SUM(S.ACT_COUNT),'0')ACOUNT
  FROM PORT_HTT_BATCH_SAMPLE_RESULT S
 WHERE S.MAT_STATUS = '00'
   AND S.INSTORE_FLAG = '0'
   AND S.HEAT_PLAN_NO = ?
   AND S.JUDGE_STOVE_NO = ?
   AND S.PHY_BATCH_NO = ?
   AND S.IS_SAMPLE_PIPE = ?
</query>
<query id = "FrmHttInStore.doQueryStausRackWgt" desc = "查询指定炉批下支数重量">
<![CDATA[
SELECT NVL(SUM(ACT_WEIGHT),'0') ACT_WEIGHT
  FROM (SELECT S.ACT_WEIGHT
          FROM PORT_HTT_BATCH_SAMPLE_RESULT S
         WHERE S.MAT_STATUS = '00'
           AND S.INSTORE_FLAG = '0'
           AND S.HEAT_PLAN_NO = ?
           AND S.JUDGE_STOVE_NO = ?
           AND S.PHY_BATCH_NO = ?
           AND S.IS_SAMPLE_PIPE = ?
         ORDER BY S.MAT_NO ASC)
 WHERE ROWNUM <= ?
 ]]>
</query>
<query id = "FrmHttInStore.selectMatBc" desc = "查询库存">
SELECT T.LIKU_PROCESS_CODE
  FROM MAT_BC_M T
 WHERE T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
   AND T.PROCESS_CDOE = 'F'
</query>
<query id = "FrmHttInStore.insertMatBcM" desc = "交库">
   <![CDATA[
   DECLARE
  V_INSTOCK_SQE YDM_BC_INLIST.INSTOCK_SQE%TYPE := NULL;
  V_ICOUNT      NUMBER := 1;
  V_ICOUNT1     NUMBER := 1;
BEGIN
  SELECT NVL(MAX(SUBSTR(T.INSTOCK_SQE, LENGTH(T.INSTOCK_SQE) - 3)), 0) + 1
    INTO V_ICOUNT
    FROM YDM_BC_INLIST T
   WHERE T.INSTOCK_DOC LIKE '#INSTOCK_DOC#' || '%';
  FOR MYROW IN (SELECT *
                  FROM (SELECT *
                          FROM PORT_HTT_BATCH_SAMPLE_RESULT T
                         WHERE T.HEAT_PLAN_NO = '#HEAT_PLAN_NO#'
                           AND T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
                           AND T.PHY_BATCH_NO = '#PHY_BATCH_NO#'
                           AND T.IS_SAMPLE_PIPE = '#IS_SAMPLE_PIPE#'
                           AND T.ACT_LEN = '#ACT_LEN#'
                           AND T.MAT_STATUS = '00'
                           AND T.INSTORE_FLAG = '0'
                           AND T.VALIDFLAG = '1'
                         ORDER BY T.MAT_NO ASC)
                 WHERE ROWNUM <= #ACT_COUNT#) LOOP
  
    SELECT COUNT(1)
      INTO V_ICOUNT1
      FROM YDM_BC_BUTTRESS_BACK
     WHERE MAT_NO = MYROW.MAT_NO
       AND PLINE_CODE = MYROW.PLINE_CODE;
  
    IF (V_ICOUNT1 = 0) THEN
      INSERT INTO YDM_BC_BUTTRESS
        (MAT_NO,
         JUDGE_STOVE_NO,
         BATCH_NO,
         BATCH_GROUD_NO,
         STORAGE_NO,
         LOCATION_NO,
         LARY_NO,
         CREATE_NAME,
         CREATE_TIME,
         PLINE_CODE)
      VALUES
        (MYROW.MAT_NO,
         MYROW.JUDGE_STOVE_NO,
         MYROW.PHY_BATCH_NO,
         '#BATCH_GROUD_NO#',
         '#STORAGE_NO#',
         '#LOCATION_NO#',
         '#LARY_NO#',
         '#CREATE_NAME#',
         TO_DATE('#CREATE_TIME#', 'YYYY-MM-DD HH24:MI:SS'),
         MYROW.PLINE_CODE);
    
    ELSE
      INSERT INTO YDM_BC_BUTTRESS
        (MAT_NO,
         JUDGE_STOVE_NO,
         BATCH_NO,
         BATCH_GROUD_NO,
         STORAGE_NO,
         LOCATION_NO,
         LARY_NO,
         LOC_NO,
         STORAGE_ATTR,
         STORAGE_ATTR_NAME,
         STORAGE_TYPE_NO,
         STORAGE_TYPE_NAME,
         MANAGEMENT_NO,
         MANAGEMENT_NAME,
         MEMO,
         CREATE_NAME,
         CREATE_TIME,
         UPDATE_NAME,
         UPDATE_TIME,
         DELETE_NAME,
         DELETE_TIME,
         DEPARTMENT_CODE,
         DEPARTMENT_DESC,
         PLINE_CODE)
        SELECT MYROW.MAT_NO,
               MYROW.JUDGE_STOVE_NO,
               MYROW.PHY_BATCH_NO,
               '#BATCH_GROUD_NO#',
               STORAGE_NO,
               LOCATION_NO,
               LARY_NO,
               LOC_NO,
               STORAGE_ATTR,
               STORAGE_ATTR_NAME,
               STORAGE_TYPE_NO,
               STORAGE_TYPE_NAME,
               MANAGEMENT_NO,
               MANAGEMENT_NAME,
               MEMO,
               CREATE_NAME,
               CREATE_TIME,
               UPDATE_NAME,
               UPDATE_TIME,
               DELETE_NAME,
               DELETE_TIME,
               DEPARTMENT_CODE,
               DEPARTMENT_DESC,
               PLINE_CODE
          FROM YDM_BC_BUTTRESS_BACK
         WHERE MAT_NO = MYROW.MAT_NO
           AND PLINE_CODE = MYROW.PLINE_CODE;
    END IF;
  
    INSERT INTO MAT_BC_M
      (MAT_NO,
       PRODUCT_FLAG,
       MAT_STATUS,
       LOT_NO,
       STOVE_NO,
       JUDGE_STOVE_NO,
       BATCH_NO,
       BATCH_GROUD_NO,
       SAMPLE_FLAG,
       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,
       PRO_ORDER_NO,
       PRO_ORDER_ID,
       PROCESS_CDOE,
       PROCESS_DESC,
       NEXT_PROCESS_CDOE,
       NEXT_PROCESS_DESC,
       PLINE_CODE,
       PLINE_NAME,
       MAT_ORIGIN_CODE,
       MAT_ORIGIN_NAME,
       ACT_DIMATER,
       ACT_HEIGHT,
       ACT_LEN,
       ACT_LEN_MIN,
       ACT_LEN_MAX,
       ACT_COUNT,
       ACT_WEIGHT,
       ACT_THEORY_WEIGHT,
       BELONG_CODE,
       BELONG_NAME,
       MAT_GOWHERE_CODE,
       MAT_GOWHERE_NAME,
       INSTOCK_TIME,
       CREATE_NAME,
       CREATE_TIME,
       BAL_YEAR_MONTH,
       JUDGE_STD_DES,
       QCM_STAUS,
       HEAT_PLAN_NO,
       GX_PLAN_NO,
       CRAF_NO,
       CRAFT_SEQ,
       ORD_LN_DLY_PK,
       ORDER_NO,
       ORDER_SEQ,
       ORDER_SEQ_NO,
       HEAT_PLAN_NO_NEXT,
       FLAG_STOVE_NO_ZG,
       TARGET,
       CIC,
       BAR_CODE,
       HEAT_PLAN_NO_OLD,
       ORD_PK,
       ORD_LN_PK,
       IS_DEALER,
       PIPMEMO)
    VALUES
      (MYROW.MAT_NO,
       '#PRODUCT_FLAG#',
       '#MAT_STATUS#',
       MYROW.LOT_NO,
       MYROW.STOVE_NO,
       MYROW.JUDGE_STOVE_NO,
       MYROW.PHY_BATCH_NO,
       '#BATCH_GROUD_NO#',
       MYROW.IS_SAMPLE_PIPE,
       '#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#',
       '#PRO_ORDER_NO#',
       '#PRO_ORDER_ID#',
       '#PROCESS_CDOE#',
       '#PROCESS_DESC#',
       '#NEXT_PROCESS_CDOE#',
       '#NEXT_PROCESS_DESC#',
       '#PLINE_CODE#',
       '#PLINE_NAME#',
       '#MAT_ORIGIN_CODE#',
       '#MAT_ORIGIN_NAME#',
       '#ACT_DIMATER#',
       '#ACT_HEIGHT#',
       MYROW.ACT_LEN,
       '#ACT_LEN_MIN#',
       '#ACT_LEN_MAX#',
       MYROW.ACT_COUNT,
       MYROW.ACT_WEIGHT,
       MYROW.ACT_WEIGHT,
       '#BELONG_CODE#',
       '#BELONG_NAME#',
       '#MAT_GOWHERE_CODE#',
       '#MAT_GOWHERE_NAME#',
       TO_DATE('#CREATE_TIME#', 'YYYY-MM-DD HH24:MI:SS'),
       '#CREATE_NAME#',
       TO_DATE('#CREATE_TIME#', 'YYYY-MM-DD HH24:MI:SS'),
       '#BAL_YEAR_MONTH#',
       '#JUDGE_STD_DES#',
       '#QCM_STAUS#',
       '#HEAT_PLAN_NO#',
       '#GX_PLAN_NO#',
       '#CRAF_NO#',
       '#CRAFT_SEQ#',
       '#ORD_LN_DLY_PK#',
       '#ORDER_NO#',
       '#ORDER_SEQ#',
       '#ORDER_SEQ_NO#',
       '#HEAT_PLAN_NO_NEXT#',
       '#FLAG_STOVE_NO_ZG#',
       '#TARGET#',
       '#CIC#',
       MYROW.BAR_CODE,
       '#HEAT_PLAN_NO_OLD#',
       '#ORD_PK#',
       '#ORD_LN_PK#',
       (SELECT DECODE(H.ORDER_TYP, '120108', '1','120107','2','120109','3', '0')
          FROM SLM_ORDER_HEAD H
         WHERE H.ORD_PK = '#ORD_PK#'),
           '#MEMO#');
  
    V_INSTOCK_SQE := '#INSTOCK_DOC#' || LPAD(V_ICOUNT, 4, 0);
  
    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,
       JUDGE_STD_NAME,
       JUDGE_STD_CODE,
       IN_TIME_F,
       BAL_YEAR_MONTH,
       MAT_ORIGIN_CODE,
       MAT_ORIGIN_NAME,
       QCM_STAUS,
       PRO_PLAN_ID,
       GX_PLAN_NO,
       ORD_LN_DLY_PK,
       IN_BC,
       IN_BZ,
       ORDER_NO,
       ORDER_SEQ,
       DELIVERY_NO)
      SELECT V_INSTOCK_SQE,
             '#INSTOCK_DOC#',
             '#INSTOCK_TYPE_CODE#',
             '#INSTOCK_TYPE_NAME#',
             MYROW.MAT_NO,
             MYROW.LOT_NO,
             MYROW.STOVE_NO,
             MYROW.JUDGE_STOVE_NO,
             MYROW.PHY_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#',
             MYROW.ACT_LEN,
             '#ACT_LEN_MIN#',
             '#ACT_LEN_MAX#',
             MYROW.ACT_COUNT,
             MYROW.ACT_WEIGHT,
             MYROW.ACT_WEIGHT,
             '#BELONG_CODE#',
             '#BELONG_NAME#',
             STORAGE_NO,
             LOCATION_NO,
             LARY_NO,
             TO_DATE('#CREATE_TIME#', 'YYYY-MM-DD HH24:MI:SS'),
             '#CREATE_NAME#',
             TO_DATE('#CREATE_TIME#', 'YYYY-MM-DD HH24:MI:SS'),
             '#PRODUCT_FLAG#',
             '#MAT_STATUS#',
             '#JUDGE_STD_NAME#',
             '#JUDGE_STD_CODE#',
             TO_DATE('#CREATE_TIME#', 'YYYY-MM-DD HH24:MI:SS'),
             '#BAL_YEAR_MONTH#',
             '#MAT_ORIGIN_CODE#',
             '#MAT_ORIGIN_NAME#',
             '#QCM_STAUS#',
             '#PRO_ORDER_ID#',
             '#GX_PLAN_NO#',
             '#ORD_LN_DLY_PK#',
             '#IN_BC#',
             '#IN_BZ#',
             '#ORDER_NO#',
             '#ORDER_SEQ#',
             '#ORDER_SEQ_NO#'
        FROM YDM_BC_BUTTRESS
       WHERE MAT_NO = MYROW.MAT_NO;
  
    UPDATE PORT_HTT_BATCH_SAMPLE_RESULT T
       SET T.INSTORE_FLAG = '1'
     WHERE T.MAT_NO = MYROW.MAT_NO
       AND PROCESS_SEQ =
           (SELECT real_process_seq
              FROM pln_zy_rcl_m
             WHERE heat_plan_no = t.heat_plan_no);
    V_ICOUNT := V_ICOUNT + 1;
  END LOOP;
END;
   ]]>
   </query>
   <query id = "FrmHttInStore.insertVrpComInfo" desc = "插入公共信息表">
   DECLARE
  V_VRP_STATION_CODE VRP_COM_INFO.PLINE_CODE%TYPE := NULL;
  V_RESULT_NO        VRP_COM_INFO.RESULT_NO%TYPE := NULL;
BEGIN
  V_VRP_STATION_CODE := '600211';
  SELECT '#PLINE_CODE#' || V_VRP_STATION_CODE || TO_CHAR(SYSDATE, 'YYMMDD') ||
         LPAD(NVL(MAX(SUBSTR(T.RESULT_NO, LENGTH(T.RESULT_NO) - 5)), 0) + 1,
              6,
              0)
    INTO V_RESULT_NO
    FROM HTT_COM_INFO T
   WHERE TRUNC(T.CREATE_TIME) = TRUNC(SYSDATE);
   
   INSERT INTO HTT_COM_INFO(
        RESULT_NO,
        HEAT_PLAN_NO,
        STATION_CODE,
        STATION_DESC,
        PLINE_CODE,
        PLINE_NAME,
        ZY_BATCH_ID,
        PRO_PLAN_ID,
        GX_PLAN_NO,
        IF_MONITOR_RCL,
        PRDCR_NO,
        MONITORDEMAND,
        CRAFT_FILE_NO,
        CRAFT_FILE_MAN,
        CRAFT_SEQ,
        JUDGE_STOVE_NO,
        BATCH_NO,
        BATCH_GROUD_NO,
        GRADECODE,
        GRADENAME,
        STEELCODE,
        STEELNAME,
        SPEC_CODE,
        SPEC_NAME,
        LEN,
        DIMATER,
        PLN_LEN,
        PLN_LEN_MIN,
        PLN_LEN_MAX,
        HEIGHT,
        LEN_MIN,
        LEN_MAX,
        LEN_CUT_HEAD,
        LEN_CUT_END,
        ACT_SPEC_CODE,
        ACT_SPEC_NAME,
        ACT_DIMATER,
        ACT_HEIGHT,
        ACT_LEN,
        ACT_LEN_MIN,
        ACT_LEN_MAX,
        ACT_MATERIAL_NO,
        ACT_MATERIAL_NAME,
        INWL_ID,
        INWL_DESC,
        PRO_NUM,
        PRO_WT,
        STATION_STATUS,
        RRO_TIME,
        RRO_TIME_NU,
        PRO_USER,
        PRO_SHIFT,
        PRO_GROUP,
        CREATE_TIME,
        COL_OPERATOR,
        PRO_YEAR_MONTH_DAY,
        BAL_YEAR_MONTH,
        INSTOCK_DOC)
 VALUES( 
        V_RESULT_NO,
        '#HEAT_PLAN_NO#',
        V_VRP_STATION_CODE,
        '交库',
        '#PLINE_CODE#',
        '#PLINE_NAME#',
        '#ZY_BATCH_ID#',
        '#PRO_PLAN_ID#',
        '#GX_PLAN_NO#',
        '#IF_MONITOR_RCL#',
        '#PRDCR_NO#',
        '#MONITORDEMAND#',
        '#CRAFT_FILE_NO#',
        '#CRAFT_FILE_MAN#',
        '#CRAFT_SEQ#',
        '#JUDGE_STOVE_NO#',
        '#BATCH_NO#',
        '#BATCH_GROUD_NO#',
        '#GRADECODE#',
        '#GRADENAME#',
        '#STEELCODE#',
        '#STEELNAME#',
        '#SPEC_CODE#',
        '#SPEC_NAME#',
        '#LEN#',
        '#DIMATER#',
        '#PLN_LEN#',
        '#PLN_LEN_MIN#',
        '#PLN_LEN_MAX#',
        '#HEIGHT#',
        '#LEN_MIN#',
        '#LEN_MAX#',
        '#LEN_CUT_HEAD#',
        '#LEN_CUT_END#',
        '#ACT_SPEC_CODE#',
        '#ACT_SPEC_NAME#',
        '#ACT_DIMATER#',
        '#ACT_HEIGHT#',
        '#ACT_LEN#',
        '#ACT_LEN_MIN#',
        '#ACT_LEN_MAX#',
        '#ACT_MATERIAL_NO#',
        '#ACT_MATERIAL_NAME#',
        '#INWL_ID#',
        '#INWL_DESC#',
        '#PRO_NUM#',
        '#PRO_WT#',
        '#STATION_STATUS#',
        TO_DATE('#CREATE_TIME#','YYYY-MM-DD HH24:MI:SS'),
        '#RRO_TIME_NU#',
        '#PRO_USER#',
        '#PRO_SHIFT#',
        '#PRO_GROUP#',
        TO_DATE('#CREATE_TIME#','YYYY-MM-DD HH24:MI:SS'),
        '#COL_OPERATOR#',
        '#PRO_YEAR_MONTH_DAY#',
        '#BAL_YEAR_MONTH#',
        '#INSTOCK_DOC#');
END;
   </query>

    <query id = "FrmHttInStore.insertVrpComInfo2" desc = "插入公共信息表">
        DECLARE
        V_VRP_STATION_CODE HTT_COM_INFO.Station_Code%TYPE := NULL;
        V_RESULT_NO        HTT_COM_INFO.RESULT_NO%TYPE := NULL;
        BEGIN
        FOR MYROW IN (SELECT PLINE_CODE,
        PLINE_NAME,
        LOT_NO,
        PRO_PLAN_ID,
        GX_PLAN_NO,
        JUDGE_STOVE_NO,
        BATCH_NO,
        BATCH_GROUD_NO,
        GRADECODE,
        GRADENAME,
        STEELCODE,
        STEELNAME,
        SPEC_CODE,
        SPEC_NAME,
        ACT_DIMATER,
        ACT_HEIGHT,
        ACT_LEN_MIN,
        ACT_LEN_MAX,
        CREATE_NAME,
        PRO_BC,
        PRO_BZ,
        BAL_YEAR_MONTH,
        INSTOCK_DOC,
        SUM(T.ACT_COUNT) ACT_COUNT,
        SUM(T.ACT_WEIGHT) ACT_WEIGHT,
        ACT_LEN
        FROM YDM_BC_INLIST T
        WHERE T.INSTOCK_DOC = ?
        GROUP BY PLINE_CODE,
        PLINE_NAME,
        LOT_NO,
        PRO_PLAN_ID,
        GX_PLAN_NO,
        JUDGE_STOVE_NO,
        BATCH_NO,
        BATCH_GROUD_NO,
        GRADECODE,
        GRADENAME,
        STEELCODE,
        STEELNAME,
        SPEC_CODE,
        SPEC_NAME,
        ACT_HEIGHT,
        ACT_DIMATER,
        ACT_HEIGHT,
        ACT_LEN,
        ACT_LEN_MIN,
        ACT_LEN_MAX,
        ACT_DIMATER,
        ACT_HEIGHT,
        ACT_LEN_MIN,
        ACT_LEN_MAX,
        CREATE_NAME,
        PRO_BC,
        PRO_BZ,
        BAL_YEAR_MONTH,
        INSTOCK_DOC
        ) LOOP

        V_VRP_STATION_CODE := '600211';

        SELECT MYROW.PLINE_CODE  || V_VRP_STATION_CODE || TO_CHAR(SYSDATE, 'YYMMDD') ||
        LPAD(NVL(MAX(SUBSTR(T.RESULT_NO, LENGTH(T.RESULT_NO) - 5)), 0) + 1,
        6,
        0)
        INTO V_RESULT_NO
        FROM HTT_COM_INFO T
        WHERE RESULT_NO LIKE  MYROW.PLINE_CODE  || V_VRP_STATION_CODE || TO_CHAR(SYSDATE, 'YYMMDD') || '______';

        INSERT INTO HTT_COM_INFO(
        RESULT_NO,
        HEAT_PLAN_NO,
        STATION_CODE,
        STATION_DESC,
        PLINE_CODE,
        PLINE_NAME,
        ZY_BATCH_ID,
        PRO_PLAN_ID,
        GX_PLAN_NO,
        PRDCR_NO,
        MONITORDEMAND,
        CRAFT_FILE_NO,
        CRAFT_FILE_MAN,
        CRAFT_SEQ,
        JUDGE_STOVE_NO,
        BATCH_NO,
        BATCH_GROUD_NO,
        GRADECODE,
        GRADENAME,
        STEELCODE,
        STEELNAME,
        SPEC_CODE,
        SPEC_NAME,
        LEN,
        DIMATER,
        PLN_LEN,
        PLN_LEN_MIN,
        PLN_LEN_MAX,
        HEIGHT,
        LEN_MIN,
        LEN_MAX,
        LEN_CUT_HEAD,
        LEN_CUT_END,
        ACT_SPEC_CODE,
        ACT_SPEC_NAME,
        ACT_DIMATER,
        ACT_HEIGHT,
        ACT_LEN,
        ACT_LEN_MIN,
        ACT_LEN_MAX,
        ACT_MATERIAL_NO,
        ACT_MATERIAL_NAME,
        INWL_ID,
        INWL_DESC,
        PRO_NUM,
        PRO_WT,
        STATION_STATUS,
        RRO_TIME,
        RRO_TIME_NU,
        COL_OPERATOR,
        PRO_SHIFT,
        PRO_GROUP,
        CREATE_TIME,
        BAL_YEAR_MONTH,
        INSTOCK_DOC)
        VALUES(
        V_RESULT_NO,
        ?,
        V_VRP_STATION_CODE,
        '交库',
        MYROW.PLINE_CODE,
        MYROW.PLINE_NAME,
        MYROW.LOT_NO,
        MYROW.PRO_PLAN_ID,
        MYROW.GX_PLAN_NO,
        '',
        '',
        '',
        '',
        '',
        MYROW.JUDGE_STOVE_NO,
        MYROW.BATCH_NO,
        MYROW.BATCH_GROUD_NO,
        MYROW.GRADECODE,
        MYROW.GRADENAME,
        MYROW.STEELCODE,
        MYROW.STEELNAME,
        MYROW.SPEC_CODE,
        MYROW.SPEC_NAME,
        '',
        MYROW.ACT_DIMATER,
        MYROW.ACT_LEN,
        MYROW.ACT_LEN_MIN,
        MYROW.ACT_LEN_MAX,
        MYROW.ACT_HEIGHT,
        MYROW.ACT_LEN_MIN,
        MYROW.ACT_LEN_MAX,
        '',
        '',
        MYROW.SPEC_CODE,
        MYROW.SPEC_NAME,
        MYROW.ACT_DIMATER,
        MYROW.ACT_HEIGHT,
        MYROW.ACT_LEN,
        MYROW.ACT_LEN_MIN,
        MYROW.ACT_LEN_MAX,
        '',
        '',
        '',
        '',
        MYROW.ACT_COUNT,
        MYROW.ACT_WEIGHT,
        '1',
        SYSDATE,
        '',
        MYROW.CREATE_NAME,
        MYROW.PRO_BC,
        MYROW.PRO_BZ,
        SYSDATE,
        MYROW.BAL_YEAR_MONTH,
        MYROW.INSTOCK_DOC);

        END LOOP;
        END;

    </query>

     <query id = "FrmHttInStore.selectNodeFlag" desc = "查询结炉标识">
   SELECT T.BESIDE_STATUS
  FROM PLN_ZY_RCL_M T
 WHERE T.HEAT_PLAN_NO = '#HEAT_PLAN_NO#'
   AND T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
   </query>
   <query id = "FrmHttInStore.DeleteInList" desc = "撤销交库">
<![CDATA[
DECLARE
 V_COUNT NUMBER := 0;
  V_ICOUNT NUMBER := 0;


  T_COUNT NUMBER := 0;
  T_WT    NUMBER := 0;
  T_WT_1  NUMBER := 0;
BEGIN

  FOR MYROW IN (SELECT T.PLINE_CODE,
                       T.MAT_NO,
                       BATCH_NO,
                       BATCH_GROUD_NO,
                       JUDGE_STOVE_NO,
                       INSTOCK_SQE,
                       T.ACT_WEIGHT,
                       T.ACT_THEORY_WEIGHT
                  FROM (SELECT T.*, S.STORAGE_NO CSTORAGE_NO
                          FROM YDM_BC_INLIST   T,
                               MAT_BC_M        T1,
                               YDM_BC_BUTTRESS S
                         WHERE T.MAT_NO = T1.MAT_NO
                           AND T.MAT_NO = S.MAT_NO
                    AND T.INSTOCK_DOC = '#INSTOCK_DOC#'
    AND T1.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
    AND T1.BATCH_NO = '#BATCH_NO#'
    AND T1.ACT_LEN = '#ACT_LEN#'
    AND T1.BATCH_GROUD_NO = '#BATCH_GROUD_NO#'
    AND T1.PLINE_CODE = '#PLINE_CODE#'
                           AND T1.QCM_STAUS = '00'
                           AND T1.PROCESS_CDOE = 'F') T
                  LEFT JOIN COM_BASE_PLINE C
                    ON C.OUT_REPOSITORY = T.CSTORAGE_NO
                   AND C.PLINE_CODE = T.PLINE_CODE
                 WHERE DECODE(C.OUT_REPOSITORY, NULL, '已倒运', '未倒运') = '未倒运') LOOP

    T_COUNT := T_COUNT + 1;
    T_WT    := T_WT + MYROW.ACT_WEIGHT;
    T_WT_1  := T_WT_1 + MYROW.ACT_THEORY_WEIGHT;



     UPDATE PORT_Htt_BATCH_SAMPLE_RESULT T SET T.INSTORE_FLAG = '0' WHERE T.MAT_NO = MYROW.MAT_NO AND PROCESS_SEQ = (SELECT real_process_seq FROM pln_zy_rcl_m WHERE heat_plan_no = t.heat_plan_no) ;

    DELETE FROM MAT_BC_M T
     WHERE T.MAT_NO = MYROW.MAT_NO
       AND T.JUDGE_STOVE_NO = MYROW.JUDGE_STOVE_NO
       AND T.BATCH_NO = MYROW.BATCH_NO
       AND T.BATCH_GROUD_NO = MYROW.BATCH_GROUD_NO
       AND T.PLINE_CODE = MYROW.PLINE_CODE;



SELECT COUNT(1)
    INTO V_ICOUNT
    FROM YDM_BC_BUTTRESS_BACK
   WHERE MAT_NO = MYROW.MAT_NO
     AND PLINE_CODE = MYROW.PLINE_CODE;

  IF (V_ICOUNT =0) THEN
    INSERT INTO YDM_BC_BUTTRESS_BACK
      (MAT_NO,
       JUDGE_STOVE_NO,
       BATCH_NO,
       BATCH_GROUD_NO,
       STORAGE_NO,
       LOCATION_NO,
       LARY_NO,
       LOC_NO,
       STORAGE_ATTR,
       STORAGE_ATTR_NAME,
       STORAGE_TYPE_NO,
       STORAGE_TYPE_NAME,
       MANAGEMENT_NO,
       MANAGEMENT_NAME,
       MEMO,
       CREATE_NAME,
       CREATE_TIME,
       UPDATE_NAME,
       UPDATE_TIME,
       DELETE_NAME,
       DELETE_TIME,
       DEPARTMENT_CODE,
       DEPARTMENT_DESC,
       PLINE_CODE)
      SELECT MAT_NO,
             JUDGE_STOVE_NO,
             BATCH_NO,
             BATCH_GROUD_NO,
             STORAGE_NO,
             LOCATION_NO,
             LARY_NO,
             LOC_NO,
             STORAGE_ATTR,
             STORAGE_ATTR_NAME,
             STORAGE_TYPE_NO,
             STORAGE_TYPE_NAME,
             MANAGEMENT_NO,
             MANAGEMENT_NAME,
             MEMO,
             CREATE_NAME,
             CREATE_TIME,
             UPDATE_NAME,
             UPDATE_TIME,
             DELETE_NAME,
             DELETE_TIME,
             DEPARTMENT_CODE,
             DEPARTMENT_DESC,
             MYROW.PLINE_CODE
        FROM YDM_BC_BUTTRESS
    WHERE MAT_NO = MYROW.MAT_NO;

  ELSE
    UPDATE YDM_BC_BUTTRESS_BACK T
       SET (MAT_NO,
            JUDGE_STOVE_NO,
            BATCH_NO,
            BATCH_GROUD_NO,
            STORAGE_NO,
            LOCATION_NO,
            LARY_NO,
            LOC_NO,
            STORAGE_ATTR,
            STORAGE_ATTR_NAME,
            STORAGE_TYPE_NO,
            STORAGE_TYPE_NAME,
            MANAGEMENT_NO,
            MANAGEMENT_NAME,
            MEMO,
            CREATE_NAME,
            CREATE_TIME,
            UPDATE_NAME,
            UPDATE_TIME,
            DELETE_NAME,
            DELETE_TIME,
            DEPARTMENT_CODE,
            DEPARTMENT_DESC,
            PLINE_CODE) =
           (SELECT MAT_NO,
                   JUDGE_STOVE_NO,
                   BATCH_NO,
                   BATCH_GROUD_NO,
                   STORAGE_NO,
                   LOCATION_NO,
                   LARY_NO,
                   LOC_NO,
                   STORAGE_ATTR,
                   STORAGE_ATTR_NAME,
                   STORAGE_TYPE_NO,
                   STORAGE_TYPE_NAME,
                   MANAGEMENT_NO,
                   MANAGEMENT_NAME,
                   MEMO,
                   CREATE_NAME,
                   CREATE_TIME,
                   UPDATE_NAME,
                   UPDATE_TIME,
                   DELETE_NAME,
                   DELETE_TIME,
                   DEPARTMENT_CODE,
                   DEPARTMENT_DESC,
                   MYROW.PLINE_CODE
              FROM YDM_BC_BUTTRESS
             WHERE MAT_NO = T.MAT_NO)
        WHERE MAT_NO = MYROW.MAT_NO
     AND PLINE_CODE = MYROW.PLINE_CODE;
  END IF;


    DELETE FROM YDM_BC_BUTTRESS T     WHERE MAT_NO = MYROW.MAT_NO;




    DELETE FROM YDM_BC_INLIST F WHERE F.INSTOCK_SQE = MYROW.INSTOCK_SQE;
  END LOOP;


  INSERT INTO HTT_COM_INFO
  (RESULT_NO,
   HEAT_PLAN_NO,
   ZY_BATCH_ID,
   PROD_INDEX,
   PRO_PLAN_ID,
   GX_PLAN_NO,
   ORDER_SOURCE,
   ORDER_NO,
   ORDER_SEQ,
   REQ_BL_ID,
   PLINE_CODE,
   PLINE_NAME,
   STATION_CODE,
   STATION_DESC,
   JUDGE_STOVE_NO,
   BATCH_NO,
   BATCH_GROUD_NO,
   PRODUCCODE,
   PRODUCNAME,
   GRADECODE,
   GRADENAME,
   STEELCODE,
   STEELNAME,
   MODEL_CODE,
   MODEL_DESC,
   STD_CODE,
   STD_NAME,
   STD_STYLE,
   STD_STYLE_DESC,
   SPEC_CODE,
   SPEC_NAME,
   DIMATER,
   HEIGHT,
   LEN,
   LEN_MIN,
   LEN_MAX,
   PLN_LEN,
   PLN_LEN_MIN,
   PLN_LEN_MAX,
   ACT_SPEC_CODE,
   ACT_SPEC_NAME,
   ACT_DIMATER,
   ACT_HEIGHT,
   ACT_LEN,
   ACT_LEN_MIN,
   ACT_LEN_MAX,
   LEN_CUT_HEAD,
   LEN_CUT_END,
   ACT_MATERIAL_NO,
   ACT_MATERIAL_NAME,
   INWL_ID,
   INWL_DESC,
   MONITOR_POINT,
   IF_MONITOR_RCL,
   MONITORDEMAND,
   PRDCR_NO,
   PRODUCER,
   PRODUCER_TIME,
   STATION_ROAD,
   CRAFT_FILE_NO,
   CRAFT_FILE_MAN,
   CRAFT_SEQ,
   PRO_NUM,
   PRO_WT,
   FAIL_NUM,
   FAIL_WT,
   OFFLINE_NUM,
   OFFLINE_WT,
   RE_NUM,
   RE_WT,
   PONDER_GROSS_WT,
   INSTOCK_DOC,
   STATION_STATUS,
   RRO_TIME,
   RRO_TIME_NU,
   PRO_USER,
   PRO_SHIFT,
   PRO_GROUP,
   CREATE_TIME,
   COL_OPERATOR,
   PRO_YEAR_MONTH_DAY,
   BAL_YEAR_MONTH,
   VALIDFLAG,
   BELONG_CODE,
   BELONG_NAME,
   PROCESS_SEQ)
  SELECT  (SELECT T.RESULT_NO || LPAD(NVL(MAX(TO_NUMBER(SUBSTR(RESULT_NO,
                                                                LENGTH(RESULT_NO) - 1))),
                                           0) + 1,
                                       2,
                                       '0') RESULT_NO
              FROM HTT_COM_INFO
             WHERE RESULT_NO LIKE T.RESULT_NO || '__'),
         HEAT_PLAN_NO,
         ZY_BATCH_ID,
         PROD_INDEX,
         PRO_PLAN_ID,
         GX_PLAN_NO,
         ORDER_SOURCE,
         ORDER_NO,
         ORDER_SEQ,
         REQ_BL_ID,
         PLINE_CODE,
         PLINE_NAME,
         STATION_CODE,
         STATION_DESC,
         JUDGE_STOVE_NO,
         BATCH_NO,
         BATCH_GROUD_NO,
         PRODUCCODE,
         PRODUCNAME,
         GRADECODE,
         GRADENAME,
         STEELCODE,
         STEELNAME,
         MODEL_CODE,
         MODEL_DESC,
         STD_CODE,
         STD_NAME,
         STD_STYLE,
         STD_STYLE_DESC,
         SPEC_CODE,
         SPEC_NAME,
         DIMATER,
         HEIGHT,
         LEN,
         LEN_MIN,
         LEN_MAX,
         PLN_LEN,
         PLN_LEN_MIN,
         PLN_LEN_MAX,
         ACT_SPEC_CODE,
         ACT_SPEC_NAME,
         ACT_DIMATER,
         ACT_HEIGHT,
         ACT_LEN,
         ACT_LEN_MIN,
         ACT_LEN_MAX,
         LEN_CUT_HEAD,
         LEN_CUT_END,
         ACT_MATERIAL_NO,
         ACT_MATERIAL_NAME,
         INWL_ID,
         INWL_DESC,
         MONITOR_POINT,
         IF_MONITOR_RCL,
         MONITORDEMAND,
         PRDCR_NO,
         PRODUCER,
         PRODUCER_TIME,
         STATION_ROAD,
         CRAFT_FILE_NO,
         CRAFT_FILE_MAN,
         CRAFT_SEQ,
        0- T_COUNT,
           0 - T_WT,
         FAIL_NUM,
         FAIL_WT,
         OFFLINE_NUM,
         OFFLINE_WT,
         RE_NUM,
         RE_WT,
         PONDER_GROSS_WT,
         INSTOCK_DOC,
         STATION_STATUS,
         RRO_TIME,
         RRO_TIME_NU,
         PRO_USER,
         PRO_SHIFT,
         PRO_GROUP,
         CREATE_TIME,
         COL_OPERATOR,
         PRO_YEAR_MONTH_DAY,
         BAL_YEAR_MONTH,
         VALIDFLAG,
         BELONG_CODE,
         BELONG_NAME,
         PROCESS_SEQ
    FROM HTT_COM_INFO  T WHERE T.INSTOCK_DOC = '#INSTOCK_DOC#'
     AND T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
     AND T.BATCH_NO = '#BATCH_NO#'
     AND T.BATCH_GROUD_NO = '#BATCH_GROUD_NO#'
     AND T.ACT_LEN = '#ACT_LEN#'
     AND T.PRO_NUM >0
      AND ROWNUM = 1;
END;
]]>
</query>
  <query id = "FrmHttInStore.selectLxCount" desc= "查询待处理支数">
   SELECT COUNT(1) ACOUNT
  FROM PORT_HTT_BATCH_SAMPLE_RESULT T
 WHERE T.MAT_STATUS IN ('00', '20')
   AND T.INSTORE_FLAG = '0'
   AND T.HEAT_PLAN_NO = '#HEAT_PLAN_NO#'
   AND T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
   </query>
  <query id = "FrmHttInStore.selectNode" desc = "查询是否结炉">
   SELECT COUNT(1) ACOUNT
  FROM PLN_ZY_RCL_M T
 WHERE T.PRO_PLAN_ID = '#PRO_PLAN_ID#'
   AND T.GX_PLAN_NO = '#GX_PLAN_NO#'
   AND T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
   AND (T.BESIDE_STATUS = '90' OR (T.REAL_PROCESS_SEQ>1 AND '#BATCH_NO#'  LIKE '__000'))
   </query>
   <query id = "FrmHttInStore.selectHeatPlanNo" desc = "查询炉计划">
   SELECT T.*
  FROM PLN_ZY_RCL_M T
 WHERE T.PRO_PLAN_ID = '#PRO_PLAN_ID#'
   AND T.GX_PLAN_NO = '#GX_PLAN_NO#'
   AND T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
   </query>
   <query id = "FrmHttInStore.UpdateNodeFlag" desc = "结炉">
    DECLARE
    BEGIN
      FOR MYROW IN (SELECT SUM(S.ACT_COUNT) ACT_COUNT,
                       SUM(S.ACT_WEIGHT) ACT_WEIGHT,
                       S.HEAT_PLAN_NO,
                       S.HEAT_PLAN_SQE
                  FROM PORT_HTT_BATCH_SAMPLE_RESULT S
                 WHERE S.HEAT_PLAN_NO = '#HEAT_PLAN_NO#'
                   AND S.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
                   AND S.MAT_STATUS = '00'
                 AND S.PROCESS_SEQ = (SELECT REAL_PROCESS_SEQ FROM PLN_ZY_RCL_M WHERE HEAT_PLAN_NO = S.HEAT_PLAN_NO)
                 GROUP BY S.HEAT_PLAN_NO, S.HEAT_PLAN_SQE) LOOP
    UPDATE PLN_ZY_RCL_C S
       SET S.REAL_OUTDOUBLE_NUM = MYROW.ACT_COUNT,
           S.REAL_OUTDOUBLE_WT  = MYROW.ACT_WEIGHT
     WHERE S.HEAT_PLAN_NO = MYROW.HEAT_PLAN_NO
       AND S.HEAT_PLAN_SQE = MYROW.HEAT_PLAN_SQE;
  END LOOP;
    UPDATE PLN_ZY_RCL_M T
    SET T.BESIDE_STATUS = '90',
    T.PLANSTATUS = '30'
    WHERE T.HEAT_PLAN_NO = '#HEAT_PLAN_NO#'
    AND T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#';
    UPDATE HTT_COM_INFO T SET T.STATION_STATUS = '2'
    WHERE T.HEAT_PLAN_NO = '#HEAT_PLAN_NO#'
    AND T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
    AND T.STATION_CODE ='600211';
    END;
</query>
<query id = "FrmHttInStore.QueryMatbcmPiece" desc = "查询交库后库存表支数">
SELECT NVL(SUM(REAL_OUTDOUBLE_NUM),0) REAL_OUTDOUBLE_NUM FROM (
SELECT NVL(SUM(T.ACT_COUNT), 0) REAL_OUTDOUBLE_NUM
  FROM MAT_BC_M T
 WHERE T.HEAT_PLAN_NO = '#HEAT_PLAN_NO#'
   AND T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
   AND T.QCM_STAUS = '00'
   AND T.PROCESS_CDOE = 'F'
UNION
SELECT NVL(SUM(T.ACT_COUNT), 0) REAL_OUTDOUBLE_NUM
  FROM MAT_BC_BACKUP T
 WHERE T.HEAT_PLAN_NO = '#HEAT_PLAN_NO#'
   AND T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
   AND T.QCM_STAUS = '00'
   AND T.PROCESS_CDOE = 'F')
</query>

<query id = "FrmHttInStore.QuerydoJudgePiece" desc = "查询判定支数">
SELECT NVL(SUM(T.ACT_COUNT),0) ACT_COUNT
  FROM QCM_ZG_JUGDE_APPLY T
 WHERE T.HEAT_PLAN_NO = '#HEAT_PLAN_NO#'
   AND T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
   AND T.PROCESS_CODE = 'F'
   AND T.VALIDFLAG = '20'
</query>

<query id = "FrmHttInStore.QueryLoadingPiece" desc = "查询上料支数">
SELECT SUM(NVL(T.ACT_COUNT, 0)) REAL_INDOUBLE_NUM
  FROM PORT_HTT_BATCH_SAMPLE_RESULT T, PLN_ZY_RCL_M T1
 WHERE T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
   AND T.HEAT_PLAN_NO = '#HEAT_PLAN_NO#'
   AND T.PROCESS_SEQ = T1.REAL_PROCESS_SEQ
   AND T.HEAT_PLAN_NO = T1.HEAT_PLAN_NO
   AND T.JUDGE_STOVE_NO = T1.JUDGE_STOVE_NO
</query>
<query id = "FrmHttInStore.QueryOfflinePiece" desc = "查询离线支数">
select NVL(SUM(T.OFFLINE_NUM),0) OFFLINE_NUM, NVL(SUM(T.RE_NUM),0) RE_NUM,NVL(SUM(T.GROUP_NUM),0) GROUP_NUM
  from HTT_OFFLINE_RESULT T
 WHERE T.HEAT_PLAN_NO = '#HEAT_PLAN_NO#'
   AND T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
</query>
<query id = "FrmHttInStore.QueryVrpPortFailPiece" desc = "查询各实绩废品和">
select NVL(SUM(T.ACT_COUNT), 0) ACT_COUNT
  from PORT_HTT_BATCH_SAMPLE_RESULT t
 WHERE T.HEAT_PLAN_NO = '#HEAT_PLAN_NO#'
   AND T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
   AND T.PROCESS_SEQ = '#REAL_PROCESS_SEQ#'
   AND ((T.MAT_STATUS = '00' and t.instore_flag='0')
   or t.mat_status = '20')
</query>
<query id="FrmHttInStore.queryPortStuts" desc="查询管号队列废品">
        <![CDATA[
	SELECT NVL(SUM(T.ACT_COUNT),0) ACT_COUNT FROM PORT_HTT_BATCH_SAMPLE_RESULT T 
WHERE T.HEAT_PLAN_NO = '#HEAT_PLAN_NO#' AND T.PLINE_CODE = '#PLINE_CODE#'
 AND T.MAT_STATUS not in ('10','40','30') 
        ]]>
	</query>
<query id="FrmHttInStore.plnupdateStuts" desc="结炉修改计划表状态为关闭">
		<![CDATA[
 UPDATE pln_zy_rcl_m
    SET  PLANSTATUS = '40'
  WHERE HEAT_PLAN_NO = '#HEAT_PLAN_NO#'
			]]>
	</query>
<query id = "FrmHttInStore.UpdatePlanStatus" desc = "修改炉计划状态关闭">
 UPDATE PLN_ZY_RCL_M T
      SET T.PLANSTATUS = '40'
    WHERE T.HEAT_PLAN_NO = '#HEAT_PLAN_NO#'
      AND T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
</query>
    <query id = "FrmHttInStore.UpdateNodeFlag1" desc = "结炉">
        DECLARE
BEGIN
  UPDATE HTT_COM_INFO T
     SET T.STATION_STATUS = '2'
   WHERE T.HEAT_PLAN_NO = '#HEAT_PLAN_NO#'
     AND T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
     AND T.STATION_CODE = '600211'
     AND PROCESS_SEQ = '#REAL_PROCESS_SEQ#';

  UPDATE PLN_ZY_RCL_M T
     SET T.BESIDE_STATUS  = '',
         PER_STATUS       = '',
         REAL_PROCESS_SEQ = REAL_PROCESS_SEQ + 1,
         T.PLANSTATUS     = '10'
   WHERE T.HEAT_PLAN_NO = '#HEAT_PLAN_NO#'
     AND T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#';

  UPDATE MAT_BC_M
     SET MAT_STATUS = '80150103'
   WHERE MAT_NO IN (SELECT MAT_NO
                      FROM PORT_HTT_BATCH_SAMPLE_RESULT
                     WHERE HEAT_PLAN_NO = '#HEAT_PLAN_NO#'
                       AND PROCESS_SEQ = '#REAL_PROCESS_SEQ#'
                       AND MAT_STATUS = '00')
     AND QCM_STAUS = '00';
END;
    </query>

   <query id = "FrmHttInStore.CancelupdateNodeFlag" desc = "结炉回退">
DECLARE
BEGIN
  UPDATE PLN_ZY_RCL_M T
     SET T.BESIDE_STATUS = '80', T.PLANSTATUS = '20'
   WHERE T.HEAT_PLAN_NO = '#HEAT_PLAN_NO#'
     AND T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#';
  UPDATE HTT_COM_INFO T
     SET T.STATION_STATUS = '1'
   WHERE T.HEAT_PLAN_NO = '#HEAT_PLAN_NO#'
     AND T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
     AND T.STATION_CODE = '600211'
     AND T.PROCESS_SEQ = '#REAL_PROCESS_SEQ#';
END;
</query>

    <query id = "FrmHttInStore.CancelupdateNodeFlag1" desc = "结炉回退">
        DECLARE
BEGIN
  UPDATE PLN_ZY_RCL_M T
     SET T.PER_STATUS     = '90',
         T.BESIDE_STATUS  = '70',
         T.PLANSTATUS     = '20',
         REAL_PROCESS_SEQ = REAL_PROCESS_SEQ - 1
   WHERE T.HEAT_PLAN_NO = '#HEAT_PLAN_NO#'
     AND T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#';

  UPDATE HTT_COM_INFO T
     SET T.STATION_STATUS = '1'
   WHERE T.HEAT_PLAN_NO = '#HEAT_PLAN_NO#'
     AND T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
     AND PROCESS_SEQ = #REAL_PROCESS_SEQ# - 1
     AND T.STATION_CODE = '600211';

  UPDATE MAT_BC_M
     SET MAT_STATUS = '80150101'
   WHERE MAT_NO IN (SELECT MAT_NO
                      FROM PORT_HTT_BATCH_SAMPLE_RESULT
                     WHERE HEAT_PLAN_NO = '#HEAT_PLAN_NO#'
                       AND PROCESS_SEQ = #REAL_PROCESS_SEQ# - 1
                       AND MAT_STATUS = '00')
     AND QCM_STAUS = '00';
END;
    </query>

</queryMap>
