<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc = "轧管结转">
<query id = "FrmRunTimeRptZgNew.getOriginalLastB" desc = "查询期初数据">
SELECT T.JUDGE_STOVE_NO,
       T.PLINE_NAME,
       SUM(NVL(T.ACT_COUNT, 0)) COUNT,
       SUM(NVL(T.ACT_WEIGHT, 0)) WEIGHT
  FROM YDM_ZC_INITIAL_ZG T
 WHERE 1 = 1
   AND T.BAL_YEAR_MONTH = ?
</query>
<query id = "FrmRunTimeRptZgNew.getThisInB" desc = "查询入库">
 select t.JUDGE_STOVE_NO,
       nvl((case
             when t.BAL_YEAR_MONTH = ? then
              nvl(t.count, 0)
           end),
           0) weight_monthcount,
       nvl((case
             when t.BAL_YEAR_MONTH = ? then
              nvl(t.weight, 0)
           end),
           0) weight_month,
       t.PLINE_NAME
  from (SELECT REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '') JUDGE_STOVE_NO,
               (CEIL(T.ACT_COUNT / S.SAW_NUM)) AS count,
               t.weight,
               t.BAL_YEAR_MONTH,
               t.PLINE_NAME
          FROM (SELECT T1.JUDGE_STOVE_NO,
                       T1.BAL_YEAR_MONTH,
                       (CASE
                         WHEN T1.PLINE_CODE = 'C008' THEN
                          '250机组'
                         WHEN T1.PLINE_CODE = 'C009' THEN
                          '258机组'
                         WHEN T1.PLINE_CODE = 'C010' THEN
                          '168机组'
                         WHEN T1.PLINE_CODE = 'C017' THEN
                          '460机组'
                         WHEN T1.PLINE_CODE = 'C072' THEN
                          '天淮508机组'
                       END) PLINE_NAME,
                       SUM(T1.ACT_COUNT) ACT_COUNT,
                       SUM(T1.INPUT_WEIGHT) weight
                  FROM PORT_MIL_BATCH_SAMPLE_RESULT T1
                 WHERE T1.JUDGE_STOVE_NO =
                       REGEXP_REPLACE(T1.JUDGE_STOVE_NO, '-.*', '') || '-01'
                      --AND T1.GROUP_FLAG = '0'
                   AND T1.BAL_YEAR_MONTH = ? #PLINE_CODE#
                 GROUP BY T1.JUDGE_STOVE_NO, T1.BAL_YEAR_MONTH, T1.PLINE_CODE) T,
               MIL_PLAN S
         WHERE T.JUDGE_STOVE_NO = S.JUDGE_STOVE_NO
           AND S.BACK_PLAN_FLAG = '0'
           AND S.BACK_SLAB_FLAG = '0') t

</query>
<query id = "FrmRunTimeRptZgNew.getThisOutB" desc = "查询出库">
<![CDATA[
select t.JUDGE_STOVE_NO,
       nvl((case
             when t.BAL_YEAR_MONTH = ? then
              nvl(t.count, 0)
           end),
           0) weight_monthcount,
       nvl((case
             when t.BAL_YEAR_MONTH = ? then
              nvl(t.weight, 0)
           end),
           0) weight_month,
       t.PLINE_NAME
  from (SELECT JUDGE_STOVE_NO,
               BAL_YEAR_MONTH,
               PLINE_NAME,
               SUM(COUNT) COUNT,
               SUM(WEIGHT) WEIGHT
          FROM (SELECT T1.JUDGE_STOVE_NO,
                       T1.BAL_YEAR_MONTH,
                       (CASE
                         WHEN T1.PLINE_CODE = 'C008' THEN
                          '250机组'
                         WHEN T1.PLINE_CODE = 'C009' THEN
                          '258机组'
                         WHEN T1.PLINE_CODE = 'C010' THEN
                          '168机组'
                         WHEN T1.PLINE_CODE = 'C017' THEN
                          '460机组'
                         WHEN T1.PLINE_CODE = 'C072' THEN
                          '天淮508机组'
                       END) PLINE_NAME,
                       SUM(T1.OUTPUT_COUNT) AS COUNT,
                       SUM(T1.OUTPUT_WEIGHT) AS WEIGHT
                  FROM QCM_ZG_JUGDE_APPLY T1, MIL_PLAN S5
                 WHERE T1.JUDGE_STOVE_NO || '-01' = S5.JUDGE_STOVE_NO
                   AND S5.BACK_PLAN_FLAG = '0'
                   AND S5.BACK_SLAB_FLAG = '0'
                   AND T1.BAL_YEAR_MONTH = ?
                   AND ((T1.VALIDFLAG = '20' AND
                                        T1.TARGET <> 'A' AND
                                        T1.JUDGE_RESULT_CODE IN
                                        ('40740701', '40740705', '40740709')) OR
                                        (T1.VALIDFLAG = '20' AND T1.TARGET = 'A' AND
                                        T1.JUDGE_TOLRESULT_CODE IN
                                        ('40740701', '40740705', '40740709')) OR
                                        (T1.VALIDFLAG = '20' AND T1.TARGET = 'A' AND
                                        T1.IS_ALL_SCRAP = '1') OR
                                        T1.INSTANCY_FLAG = '1')
                   /*AND ((T1.VALIDFLAG = '20' AND
                       T1.JUDGE_RESULT_CODE IN ('40740701', '40740706')) OR
                       T1.INSTANCY_FLAG = '1' OR
                       (T1.VALIDFLAG = '20' AND
                       T1.IS_ALL_SCRAP IN ('1', '2')))*/
                   AND T1.PLINE_CODE NOT IN ('C065', 'C066')
                   AND T1.PROCESS_CODE = 'D'
                   AND T1.IS_ALL_SCRAP <> '6'
                
                 #PLINE_CODE#
                 GROUP BY T1.JUDGE_STOVE_NO, T1.BAL_YEAR_MONTH, T1.PLINE_CODE
                UNION ALL
                SELECT REGEXP_REPLACE(F.JUDGE_STOVE_NO, '-.*', '') JUDGE_STOVE_NO,
                       F.BAL_YEAR_MONTH,
                       S1.PLINE_NAME,
                       COUNT(1) COUNT,
                       SUM(S1.INPUT_WEIGHT) WEIGHT
                  FROM (SELECT COUNT(1) ACOUNT,
                               T3.JUDGE_STOVE_NO,
                               T3.NEW_HEAT_NO,
                               T3.BAL_YEAR_MONTH
                          FROM (SELECT G2.*, T1.BAL_YEAR_MONTH
                                  FROM MIL_SLAB_SCRAP G2, QCM_ZG_JUGDE_APPLY T1
                                 WHERE REGEXP_REPLACE(G2.NEW_HEAT_NO, '-.*', '') =
                                       T1.JUDGE_STOVE_NO
                                       AND (G2.REMARK <> '无' OR G2.REMARK IS NULL)
                                   AND ((T1.VALIDFLAG = '20' AND
                                        T1.JUDGE_RESULT_CODE IN
                                        ('40740701', '40740706')) OR
                                        T1.INSTANCY_FLAG = '1' OR
                                        (T1.VALIDFLAG = '20' AND
                                        T1.IS_ALL_SCRAP IN ('1', '2')))
                                   AND T1.IS_FLAG = '0'
                                   AND T1.BAL_YEAR_MONTH = ?
                                   AND T1.PROCESS_CODE = 'D' #PLINE_CODE#) T3
                         WHERE T3.PROCESS_NO <= 6
                           AND T3.NEW_HEAT_NO IS NOT NULL
                         GROUP BY T3.JUDGE_STOVE_NO,
                                  T3.NEW_HEAT_NO,
                                  T3.BAL_YEAR_MONTH) F,
                       (SELECT SUM(S.INPUT_WEIGHT) INPUT_WEIGHT,
                               S.JUDGE_STOVE_NO,
                               S.M_MAT_NO,
                               (CASE
                                 WHEN S.PLINE_CODE = 'C008' THEN
                                  '250机组'
                                 WHEN S.PLINE_CODE = 'C009' THEN
                                  '258机组'
                                 WHEN S.PLINE_CODE = 'C010' THEN
                                  '168机组'
                                 WHEN S.PLINE_CODE = 'C017' THEN
                                  '460机组'
                                 WHEN S.PLINE_CODE = 'C072' THEN
                                  '天淮508机组'
                               END) PLINE_NAME,
                               ROW_NUMBER() OVER(PARTITION BY JUDGE_STOVE_NO ORDER BY JUDGE_STOVE_NO) RNUM
                          FROM PORT_MIL_BATCH_SAMPLE_RESULT S
                         WHERE
                        --S.OP_PROCESS IN('2','3','4')
                        --AND S.GROUP_FLAG = '1'
                        --AND
                        
                         S.TR_FLAG = '0'
                         GROUP BY S.M_MAT_NO, S.JUDGE_STOVE_NO, S.PLINE_CODE) S1
                 WHERE F.JUDGE_STOVE_NO = S1.JUDGE_STOVE_NO
                   AND RNUM <= F.ACOUNT
                 GROUP BY F.JUDGE_STOVE_NO, F.BAL_YEAR_MONTH, S1.PLINE_NAME
                UNION ALL
                SELECT REGEXP_REPLACE(S.JUDGE_STOVE_NO, '-.*', '') JUDGE_STOVE_NO,
                       T.BAL_YEAR_MONTH,
                       S.PLINE_NAME,
                       COUNT(1) COUNT,
                       SUM(S.INPUT_WEIGHT) WEIGHT
                  FROM (SELECT G1.*, T1.BAL_YEAR_MONTH
                          FROM MIL_FURNACES_RESLUT_DETIA G1,
                               QCM_ZG_JUGDE_APPLY        T1
                         WHERE REGEXP_REPLACE(G1.ZP_JUDGE_STOVE_NO, '-.*', '') =
                               T1.JUDGE_STOVE_NO
                           AND (G1.REMARK <> '无' OR G1.REMARK IS NULL)
                           AND ((T1.VALIDFLAG = '20' AND
                                T1.JUDGE_RESULT_CODE IN
                                ('40740701', '40740706')) OR
                                T1.INSTANCY_FLAG = '1' OR
                                (T1.VALIDFLAG = '20' AND
                                T1.IS_ALL_SCRAP IN ('1', '2')))
                           AND T1.IS_FLAG = '0'
                           AND T1.BAL_YEAR_MONTH = ?
                           AND T1.PROCESS_CODE = 'D' #PLINE_CODE#) T,
                       (SELECT SUM(S1.INPUT_WEIGHT) INPUT_WEIGHT,
                               S1.M_MAT_NO,
                               S1.JUDGE_STOVE_NO,
                               (CASE
                                 WHEN S1.PLINE_CODE = 'C008' THEN
                                  '250机组'
                                 WHEN S1.PLINE_CODE = 'C009' THEN
                                  '258机组'
                                 WHEN S1.PLINE_CODE = 'C010' THEN
                                  '168机组'
                                 WHEN S1.PLINE_CODE = 'C017' THEN
                                  '460机组'
                                 WHEN S1.PLINE_CODE = 'C072' THEN
                                  '天淮508机组'
                               END) PLINE_NAME,
                               ROW_NUMBER() OVER(PARTITION BY JUDGE_STOVE_NO ORDER BY JUDGE_STOVE_NO) RNUM
                          FROM PORT_MIL_BATCH_SAMPLE_RESULT S1
                         WHERE
                        --S1.OP_PROCESS = '5'
                        --AND S1.GROUP_FLAG = '1'
                        --AND 
                         S1.TR_FLAG = '0'
                         GROUP BY S1.JUDGE_STOVE_NO,
                                  S1.M_MAT_NO,
                                  S1.PLINE_CODE) S
                 WHERE T.JUDGE_STOVE_NO = S.JUDGE_STOVE_NO
                   AND RNUM <= T.GROUP_NUM
                 GROUP BY S.JUDGE_STOVE_NO, S.PLINE_NAME, T.BAL_YEAR_MONTH
                UNION ALL
                SELECT REGEXP_REPLACE(T8.JUDGE_STOVE_NO, '-.*', '') JUDGE_STOVE_NO,
                       T7.BAL_YEAR_MONTH,
                       T8.PLINE_NAME,
                       COUNT(1) COUNT,
                       SUM(INPUT_WEIGHT) WEIGHT
                  FROM (SELECT T.OLD_ZP_JUDGE_STOVE_NO,
                               CEIL(SUM(T.ZP_COUNT) / S.SAW_NUM) AS RN,
                               T1.BAL_YEAR_MONTH
                          FROM MIL_OFFLINE_GROUP  T,
                               MIL_PLAN           S,
                               QCM_ZG_JUGDE_APPLY T1
                         WHERE T.Old_Zp_Judge_Stove_No = S.JUDGE_STOVE_NO
                           AND REGEXP_REPLACE(T.ZP_JUDGE_STOVE_NO, '-.*', '') =
                               T1.Judge_Stove_No
                           AND (T.REMARK <> '无' OR T.REMARK IS NULL)
                           AND ((T1.VALIDFLAG = '20' AND
                               T1.JUDGE_RESULT_CODE IN
                               ('40740701', '40740706')) OR
                               T1.INSTANCY_FLAG = '1' OR
                               (T1.VALIDFLAG = '20' AND
                               T1.IS_ALL_SCRAP IN ('1', '2')))
                           AND T1.IS_FLAG = '0'
                           AND T1.BAL_YEAR_MONTH = ?
                           AND T1.PROCESS_CODE = 'D' #PLINE_CODE#
                         GROUP BY T.OLD_ZP_JUDGE_STOVE_NO,
                                  S.SAW_NUM,
                                  T1.BAL_YEAR_MONTH) T7,
                       (SELECT SUM(S2.INPUT_WEIGHT) INPUT_WEIGHT,
                               S2.JUDGE_STOVE_NO,
                               S2.M_MAT_NO,
                               (CASE
                                 WHEN S2.PLINE_CODE = 'C008' THEN
                                  '250机组'
                                 WHEN S2.PLINE_CODE = 'C009' THEN
                                  '258机组'
                                 WHEN S2.PLINE_CODE = 'C010' THEN
                                  '168机组'
                                 WHEN S2.PLINE_CODE = 'C017' THEN
                                  '460机组'
                                 WHEN S2.PLINE_CODE = 'C072' THEN
                                  '天淮508机组'
                               END) PLINE_NAME,
                               ROW_NUMBER() OVER(PARTITION BY JUDGE_STOVE_NO ORDER BY JUDGE_STOVE_NO) RNUM
                          FROM PORT_MIL_BATCH_SAMPLE_RESULT S2
                         WHERE
                        --S2.OP_PROCESS IN('10','11')
                        --AND S2.GROUP_FLAG = '1'
                         S2.TR_FLAG = '0'
                         GROUP BY S2.M_MAT_NO,
                                  S2.JUDGE_STOVE_NO,
                                  S2.PLINE_CODE) T8
                 WHERE REGEXP_REPLACE(T7.OLD_ZP_JUDGE_STOVE_NO, '-.*', '') ||
                       '-01' = T8.JUDGE_STOVE_NO
                   AND RNUM <= RN
                 GROUP BY T8.JUDGE_STOVE_NO, T7.BAL_YEAR_MONTH, T8.PLINE_NAME)
         GROUP BY JUDGE_STOVE_NO, BAL_YEAR_MONTH, PLINE_NAME) t
  ]]>
</query>
<!-- select t.JUDGE_STOVE_NO,
       nvl((case
                 when t.BAL_YEAR_MONTH = ? then
                  nvl(t.count, 0)
               end),
           0) weight_monthcount,
       nvl((case
                 when t.BAL_YEAR_MONTH = ? then
                  nvl(t.weight, 0)
               end),
           0) weight_month,
           t.PLINE_NAME
  from (
  SELECT T2.JUDGE_STOVE_NO,
       T2.BAL_YEAR_MONTH,
       T2.PLINE_NAME,
       (TO_NUMBER(T2.COUNT) + TO_NUMBER(NVL(T4.INPUT_COUNT, 0))+TO_NUMBER(NVL(T5.INPUT_COUNT,0))+TO_NUMBER(NVL(T6.INPUT_COUNT,0)))COUNT,
       (TO_NUMBER(T2.WEIGHT) + TO_NUMBER(NVL(T4.INPUT_WEIGHT, 0))+TO_NUMBER(NVL(T5.INPUT_WEIGHT,0))+TO_NUMBER(NVL(T6.INPUT_WEIGHT,0)))WEIGHT
  FROM (SELECT T1.JUDGE_STOVE_NO,
               T1.BAL_YEAR_MONTH,
               (CASE
                 WHEN T1.PLINE_CODE = 'C008' THEN
                  '250机组'
                 WHEN T1.PLINE_CODE = 'C009' THEN
                  '258机组'
                 WHEN T1.PLINE_CODE = 'C010' THEN
                  '168机组'
                 WHEN T1.PLINE_CODE = 'C017' THEN
                  '460机组'
               END) PLINE_NAME,
               SUM(T1.OUTPUT_COUNT) AS COUNT,
               SUM(T1.OUTPUT_WEIGHT) AS WEIGHT
          FROM QCM_ZG_JUGDE_APPLY T1, MIL_PLAN S5
         WHERE T1.JUDGE_STOVE_NO || '-01' = S5.JUDGE_STOVE_NO
           AND S5.BACK_PLAN_FLAG = '0'
           AND S5.BACK_SLAB_FLAG = '0'
           AND T1.BAL_YEAR_MONTH = ?
           AND T1.VALIDFLAG = '20'
           AND T1.PLINE_CODE NOT IN ('C065', 'C066')
         GROUP BY T1.JUDGE_STOVE_NO, T1.BAL_YEAR_MONTH, T1.PLINE_CODE) T2
  LEFT JOIN (SELECT SUM(S1.INPUT_WEIGHT) INPUT_WEIGHT,
          COUNT(1) INPUT_COUNT,
          F.JUDGE_STOVE_NO,
          F.NEW_HEAT_NO
  FROM (SELECT COUNT(1) ACOUNT, T3.JUDGE_STOVE_NO, T3.NEW_HEAT_NO
          FROM (SELECT G2.*
                               FROM MIL_SLAB_SCRAP G2, QCM_ZG_JUGDE_APPLY F2
                              WHERE SUBSTR(G2.NEW_HEAT_NO, 0, 6) =
                                    F2.JUDGE_STOVE_NO
                                AND F2.VALIDFLAG = '00'
                                AND F2.IS_FLAG = '0') T3
          WHERE T3.PROCESS_NO <= 6
          AND T3.NEW_HEAT_NO IS NOT NULL
         GROUP BY T3.JUDGE_STOVE_NO, T3.NEW_HEAT_NO) F,
       (SELECT SUM(S.INPUT_WEIGHT) INPUT_WEIGHT,
               S.JUDGE_STOVE_NO,
               S.M_MAT_NO,
               ROW_NUMBER() OVER(PARTITION BY JUDGE_STOVE_NO ORDER BY JUDGE_STOVE_NO) RNUM
          FROM PORT_MIL_BATCH_SAMPLE_RESULT S
         WHERE S.TR_FLAG = '0'
         GROUP BY S.M_MAT_NO, S.JUDGE_STOVE_NO) S1
 WHERE F.JUDGE_STOVE_NO = S1.JUDGE_STOVE_NO
   AND RNUM <= F.ACOUNT
 GROUP BY F.JUDGE_STOVE_NO, F.NEW_HEAT_NO) T4 ON T2.JUDGE_STOVE_NO =SUBSTR(T4.JUDGE_STOVE_NO,0,6)
  LEFT JOIN (SELECT SUM(S.INPUT_WEIGHT) INPUT_WEIGHT,
                    S.JUDGE_STOVE_NO,
                    COUNT(1) INPUT_COUNT
               FROM (SELECT G1.*
                       FROM MIL_FURNACES_RESLUT_DETIA G1,
                            QCM_ZG_JUGDE_APPLY        F1
                      WHERE SUBSTR(G1.Zp_Judge_Stove_No, 0, 6) =
                            F1.JUDGE_STOVE_NO
                        AND F1.VALIDFLAG = '20'
                        AND F1.IS_FLAG = '0') T,
                    (SELECT SUM(S1.INPUT_WEIGHT) INPUT_WEIGHT,
                            S1.M_MAT_NO,
                            S1.JUDGE_STOVE_NO,
                            ROW_NUMBER() OVER(PARTITION BY JUDGE_STOVE_NO ORDER BY JUDGE_STOVE_NO) RNUM
                       FROM PORT_MIL_BATCH_SAMPLE_RESULT S1
                      WHERE S1.TR_FLAG = '0'
                      GROUP BY S1.JUDGE_STOVE_NO, S1.M_MAT_NO) S
              WHERE T.JUDGE_STOVE_NO = S.JUDGE_STOVE_NO
                AND RNUM <= T.GROUP_NUM
              GROUP BY S.JUDGE_STOVE_NO)T5 ON T2.JUDGE_STOVE_NO = SUBSTR(T5.JUDGE_STOVE_NO,0,6)
  LEFT JOIN (SELECT SUM(INPUT_WEIGHT) INPUT_WEIGHT,
                    JUDGE_STOVE_NO,
                    COUNT(1) INPUT_COUNT
               FROM (SELECT T.OLD_ZP_JUDGE_STOVE_NO,
                            CEIL(T.ZP_COUNT / S.SAW_NUM) AS RN
                       FROM MIL_OFFLINE_GROUP T, MIL_PLAN S,QCM_ZG_JUGDE_APPLY F
                      WHERE T.Old_Zp_Judge_Stove_No = S.JUDGE_STOVE_NO
                      AND SUBSTR(T.ZP_JUDGE_STOVE_NO,0,6) = F.Judge_Stove_No
                      AND F.VALIDFLAG = '20'
                      AND F.IS_FLAG = '0') T7,
                    (SELECT SUM(S2.INPUT_WEIGHT) INPUT_WEIGHT,
                            S2.JUDGE_STOVE_NO,
                            S2.M_MAT_NO,
                            ROW_NUMBER() OVER(PARTITION BY JUDGE_STOVE_NO ORDER BY JUDGE_STOVE_NO) RNUM
                       FROM PORT_MIL_BATCH_SAMPLE_RESULT S2
                      WHERE S2.TR_FLAG = '0'
                      GROUP BY S2.M_MAT_NO, S2.JUDGE_STOVE_NO) T8
              WHERE SUBSTR(T7.OLD_ZP_JUDGE_STOVE_NO, 0, 6) || '-01' =
                    T8.JUDGE_STOVE_NO
                AND RNUM <= RN
              GROUP BY JUDGE_STOVE_NO)T6 ON T2.JUDGE_STOVE_NO = SUBSTR(T6.JUDGE_STOVE_NO,0,6)
  )t
 -->
 <query id ="FrmRunTimeRptZgNew.SelectInitalBelog" desc ="查询计划基本信息">
SELECT * FROM MIL_PLAN T WHERE REGEXP_REPLACE(T.JUDGE_STOVE_NO, '-.*', '') =  ? AND ROWNUM = 1
 </query>
 <query id = "FrmRunTimeRptZgNew.insertInitalBelog" desc = "插入结转表">
  INSERT INTO YDM_ZC_INITIAL_ZG(
        JUDGE_STOVE_NO,
        PRODUCT_FLAG,
        MAT_STATUS,
        PRODUCCODE,
        PRODUCNAME,
        STEELCODE,
        STEELNAME,
        SPEC_CODE,
        SPEC_NAME,
        MODEL_CODE,
        MODEL_DESC,
        STD_CODE,
        STD_NAME,
        STD_STYLE,
        STD_STYLE_DESC,
        
        ACT_COUNT,
        ACT_WEIGHT,
        PRO_ORDER_NO,
        PRO_ORDER_ID,
        CREATE_NAME,
        CREATE_TIME,
        BAL_YEAR_MONTH,
        GRADECODE,
        GRADENAME,
        PLINE_CODE,
        PLINE_NAME,
        INSTOCK_TIME,
        BELONG_CODE,
        BELONG_NAME,
        LOT_NO,
        TUBE_TYPE,
        TUBE_SUORCE,
        PIPE_SECTION)
 VALUES( 
        '#JUDGE_STOVE_NO#',
        '801401',
        '80150101',
        '#PRODUCCODE#',
        '#PRODUCNAME#',
        '#STEELCODE#',
        '#STEELNAME#',
        '#SPEC_CODE#',
        '#SPEC_NAME#',
        '#MODEL_CODE#',
        '#MODEL_DESC#',
        '#STD_CODE#',
        '#STD_NAME#',
        '#STD_STYLE#',
        '#STD_STYLE_DESC#',
        
        '#ACT_COUNT#',
        '#ACT_WEIGHT#',
        '#PRO_ORDER_NO#',
        '#PRO_ORDER_ID#',
        '#CREATE_NAME#',
        TO_DATE('#INSTOCK_TIME#','YYYY-MM-DD HH24:MI:SS'),
        '#BAL_YEAR_MONTH#',
        '#GRADECODE#',
        '#GRADENAME#',
        '#PLINE_CODE#',
        '#PLINE_NAME#',
        TO_DATE('#INSTOCK_TIME#','YYYY-MM-DD HH24:MI:SS'),
        '#BELONG_CODE#',
        '#BELONG_NAME#',
        '#LOT_NO#',
        '#TUBE_TYPE#',
        '#TUBE_SUORCE#',
        '#PIPE_SECTION#')
 </query>
 <query id = "FrmRunTimeRptZgNew.SelectInitalZg" desc = "查询期初基本信息">
 SELECT 
       JUDGE_STOVE_NO,
       PRODUCCODE AS VARIETIES_CODE,
       PRODUCNAME AS VARIETIES,
       STEELCODE ,
       STEELNAME,
       SPEC_CODE AS PIPE_SIZE_CODE,
       SPEC_NAME AS PIPE_SIZE,
       MODEL_CODE AS BUCKLE_TYPE_CODE,
       MODEL_DESC AS BUCKLE_TYPE,
       STD_CODE AS ROLL_STANDRAD_CODE,
       STD_NAME AS ROLL_STANDRAD,
       STD_STYLE,
       STD_STYLE_DESC,
       PRO_ORDER_NO AS CONTRACT_NO,
       PRO_ORDER_ID AS PRO_PLAN_ID,
       GRADECODE,
       GRADENAME,
       PLINE_CODE,
       LOT_NO,
       TUBE_TYPE,
       TUBE_SUORCE,
       PIPE_SECTION
  FROM YDM_ZC_INITIAL_ZG T
 WHERE T.JUDGE_STOVE_NO = ?
   AND ROWNUM = 1
 </query>
 <query id = "FrmRunTimeRptZgNew.UpdateQcmStatus" desc = "对判定表进行封账状态修改">
UPDATE QCM_ZG_JUGDE_APPLY T
   SET T.IS_CARRY_VOER = '1'
 WHERE T.BAL_YEAR_MONTH = ?
   AND T.VALIDFLAG = '20'
   AND T.IS_FLAG = '0'
   AND T.PROCESS_CODE = 'D'
 </query>
 
 <query id = "FrmRunTimeRptZgNew.UpdateQcmStatusBack" desc = "撤销对判定表当月判定记录封账">
UPDATE QCM_ZG_JUGDE_APPLY T
   SET T.IS_CARRY_VOER = '0'
 WHERE T.BAL_YEAR_MONTH = ?
   AND T.VALIDFLAG = '20'
   AND T.IS_FLAG = '0'
   AND T.PROCESS_CODE = 'D'
 </query>
 
  <query id = "FrmRunTimeRptZgNew.deleteQcmStatus" desc = "删除结转数据">
DELETE FROM YDM_ZC_INITIAL_ZG T WHERE T.BAL_YEAR_MONTH = ?
 </query>
</queryMap>