<?xml version="1.0" encoding="UTF-8"?><queryMap desc = "轧管收发存">
<query id = "FrmrptStoveBatchStorageZg.getTest" desc = "查询">
<![CDATA[
SELECT JUDGE_STOVE_NO,
       BATCH_NO,
       BATCH_GROUD_NO,
       MATERIAL_NAME,
       PRODUCNAME,
       STD_STYLE_DESC,
       STEELNAME,
       SPEC_NAME,
       MODEL_DESC,
       PLINE_NAME,
       SUM(ORIGINAL_COUNT) ORIGINAL_COUNT,
       SUM(ORIGINAL_AMOUNT) ORIGINAL_AMOUNT,
       SUM(DAY_1COUNT) DAY_1COUNT,
       SUM(DAY_1) DAY_1,
       SUM(MONTH_1COUNT) MONTH_1COUNT,
       SUM(MONTH_1) MONTH_1,
       SUM(DAY_2COUNT) DAY_2COUNT,
       SUM(DAY_2) DAY_2,
       SUM(MONTH_2COUNT) MONTH_2COUNT,
       SUM(MONTH_2) MONTH_2,
       SUM(AWEIGHT) AWEIGHT,
       SUM((ORIGINAL_COUNT + MONTH_1COUNT - MONTH_2COUNT)) AS END_COUNT,
       SUM((ORIGINAL_AMOUNT + MONTH_1 - MONTH_2 + AWEIGHT)) AS END_AMOUNT,
       SUM(MATCOUNT) MATCOUNT,
       SUM(MATWGT) MATWGT,
       SUM((ORIGINAL_COUNT + MONTH_1COUNT - MONTH_2COUNT - MATCOUNT)) AS QUANTITYCOUNT,
       SUM((ORIGINAL_AMOUNT + MONTH_1 - MONTH_2 + AWEIGHT - MATWGT)) AS QUANTITYWGT
  FROM (SELECT K.JUDGE_STOVE_NO,
               K.BATCH_NO,
               K.BATCH_GROUD_NO,
               K.MATERIAL_NAME,
               K.PRODUCNAME,
               K.STD_STYLE_DESC,
               K.STEELNAME,
               K.SPEC_NAME,
               K.MODEL_DESC,
               K.PLINE_NAME,
               K.BELONG_CODE,
               SUM(K.ORIGINAL_COUNT) AS ORIGINAL_COUNT,
               SUM(K.ORIGINAL_AMOUNT) AS ORIGINAL_AMOUNT,
               NVL(SUM(CASE
                         WHEN TRUNC(K.INSTOCK_TIME) = TO_DATE(?, 'YYYYMMDD') THEN
                          NVL(K.INLISTCOUNT, 0)
                       END),
                   0) DAY_1COUNT,
               NVL(SUM(CASE
                         WHEN TRUNC(K.INSTOCK_TIME) = TO_DATE(?, 'YYYYMMDD') THEN
                          NVL(K.INLISTWGT, 0)
                       END),
                   0) DAY_1,
               NVL(SUM(CASE
                         WHEN TRUNC(K.INSTOCK_TIME) >= TO_DATE(?, 'YYYYMMDD') AND
                              TRUNC(K.INSTOCK_TIME) <= TO_DATE(?, 'YYYYMMDD') THEN
                          NVL(K.INLISTCOUNT, 0)
                       END),
                   0) MONTH_1COUNT,
               NVL(SUM(CASE
                         WHEN TRUNC(K.INSTOCK_TIME) >= TO_DATE(?, 'YYYYMMDD') AND
                              TRUNC(K.INSTOCK_TIME) <= TO_DATE(?, 'YYYYMMDD') THEN
                          NVL(K.INLISTWGT, 0)
                       END),
                   0) MONTH_1,
               NVL(SUM(CASE
                         WHEN TRUNC(K.OUTSTOCK_TIME) = TO_DATE(?, 'YYYYMMDD') THEN
                          NVL(K.OUTLISTCOUNT, 0)
                       END),
                   0) DAY_2COUNT,
               NVL(SUM(CASE
                         WHEN TRUNC(K.OUTSTOCK_TIME) = TO_DATE(?, 'YYYYMMDD') THEN
                          NVL(K.OUTLISTWGT, 0)
                       END),
                   0) DAY_2,
               NVL(SUM(CASE
                         WHEN TRUNC(K.OUTSTOCK_TIME) >= TO_DATE(?, 'YYYYMMDD') AND
                              TRUNC(K.OUTSTOCK_TIME) <= TO_DATE(?, 'YYYYMMDD') THEN
                          NVL(K.OUTLISTCOUNT, 0)
                       END),
                   0) MONTH_2COUNT,
               NVL(SUM(CASE
                         WHEN TRUNC(K.OUTSTOCK_TIME) >= TO_DATE(?, 'YYYYMMDD') AND
                              TRUNC(K.OUTSTOCK_TIME) <= TO_DATE(?, 'YYYYMMDD') THEN
                          NVL(K.OUTLISTWGT, 0)
                       END),
                   0) MONTH_2,
               SUM(K.AWEIGHT) AS AWEIGHT,
               SUM(K.MATCOUNT) AS MATCOUNT,
               SUM(K.MATWGT) AS MATWGT
          FROM (SELECT T.JUDGE_STOVE_NO,
                       T.BATCH_NO,
                       T.BATCH_GROUD_NO,
                       T.MATERIAL_NAME,
                       T.PRODUCNAME,
                       T.STD_STYLE_DESC,
                       T.STEELNAME,
                       T.SPEC_NAME,
                       T.MODEL_DESC,
                       T.PLINE_NAME,
                       T.BELONG_CODE,
                       SUM(ACT_COUNT) ORIGINAL_COUNT,
                       SUM(ACT_WEIGHT) ORIGINAL_AMOUNT,
                       0 INLISTCOUNT,
                       0 INLISTWGT,
                       0 OUTLISTCOUNT,
                       0 OUTLISTWGT,
                       0 AWEIGHT,
                       0 MATCOUNT,
                       0 MATWGT,
                       NULL OUTSTOCK_TIME,
                       NULL INSTOCK_TIME
                  FROM YDM_ZC_INITIAL_ZG T
                 WHERE T.BAL_YEAR_MONTH = ?
                   AND T.BELONG_CODE #CONDTIONS#
                 GROUP BY T.JUDGE_STOVE_NO,
                          T.BATCH_NO,
                          T.BATCH_GROUD_NO,
                          T.MATERIAL_NAME,
                          T.PRODUCNAME,
                          T.STD_STYLE_DESC,
                          T.STEELNAME,
                          T.SPEC_NAME,
                          T.MODEL_DESC,
                          T.PLINE_NAME,
                          T.BELONG_CODE
                UNION ALL
                SELECT T.JUDGE_STOVE_NO,
                       T.BATCH_NO,
                       T.BATCH_GROUD_NO,
                       T.MATERIAL_NAME,
                       T.PRODUCNAME,
                       T.STD_STYLE_DESC,
                       T.STEELNAME,
                       T.SPEC_NAME,
                       T.MODEL_DESC,
                       T.PLINE_NAME,
                       T.BELONG_CODE,
                       0 ORIGINAL_COUNT,
                       0 ORIGINAL_AMOUNT,
                       SUM(T.ACT_COUNT) INLISTCOUNT,
                       SUM(T.ACT_WEIGHT) INLISTWGT,
                       0 OUTLISTCOUNT,
                       0 OUTLISTWGT,
                       0 AWEIGHT,
                       0 MATCOUNT,
                       0 MATWGT,
                       NULL OUTSTOCK_TIME,
                       MAX(T.INSTOCK_TIME) INSTOCK_TIME
                  FROM YDM_ZC_INLIST T
                 WHERE T.INSTOCK_TYPE_CODE IN
                       ('800701', '800702', '800704', '800706', '800707')
                   AND TRUNC(T.INSTOCK_TIME) >= TO_DATE(?, 'YYYYMMDD')
                   AND TRUNC(T.INSTOCK_TIME) <= TO_DATE(?, 'YYYYMMDD')
                   AND T.QCM_STAUS IN ('00', '11','22')
                   AND T.BELONG_CODE #CONDTIONS#
                 GROUP BY T.JUDGE_STOVE_NO,
                          T.BATCH_NO,
                          T.BATCH_GROUD_NO,
                          T.MATERIAL_NAME,
                          T.PRODUCNAME,
                          T.STD_STYLE_DESC,
                          T.STEELNAME,
                          T.SPEC_NAME,
                          T.MODEL_DESC,
                          T.PLINE_NAME,
                          T.BELONG_CODE
                UNION ALL
                SELECT T.JUDGE_STOVE_NO,
                       T.BATCH_NO,
                       T.BATCH_GROUD_NO,
                       T.MATERIAL_NAME,
                       T.PRODUCNAME,
                       T.STD_STYLE_DESC,
                       T.STEELNAME,
                       T.SPEC_NAME,
                       T.MODEL_DESC,
                       T.PLINE_NAME,
                       T.BELONG_CODE,
                       0 ORIGINAL_COUNT,
                       0 ORIGINAL_AMOUNT,
                       0 INLISTCOUNT,
                       0 INLISTWGT,
                       SUM(ACT_COUNT) OUTLISTCOUNT,
                       SUM((CASE
                             WHEN PONDER_NO IS NULL THEN
                              NVL(ACT_WEIGHT, 0)
                             ELSE
                              NVL(PONDER_GROSS_WT, 0)
                           END)) OUTLISTWGT,
                       0 AWEIGHT,
                       0 MATCOUNT,
                       0 MATWGT,
                       MAX(T.OUTSTOCK_TIME) OUTSTOCK_TIME,
                       NULL INSTOCK_TIME
                  FROM YDM_ZC_OUTLIST T
                 WHERE T.OUTSTOCK_TYPE_CODE IN ('800809','800806','800801','800810')
                   AND TRUNC(T.OUTSTOCK_TIME) >= TO_DATE(?, 'YYYYMMDD')
                   AND TRUNC(T.OUTSTOCK_TIME) <= TO_DATE(?, 'YYYYMMDD')
                   AND BELONG_CODE #CONDTIONS#
                 GROUP BY T.JUDGE_STOVE_NO,
                          T.BATCH_NO,
                          T.BATCH_GROUD_NO,
                          T.MATERIAL_NAME,
                          T.PRODUCNAME,
                          T.STD_STYLE_DESC,
                          T.STEELNAME,
                          T.SPEC_NAME,
                          T.MODEL_DESC,
                          T.PLINE_NAME,
                          T.BELONG_CODE
                UNION ALL
                SELECT F.JUDGE_STOVE_NO,
                       F.BATCH_NO,
                       F.BATCH_GROUD_NO,
                       F.MATERIAL_NAME,
                       F.PRODUCNAME,
                       F.STD_STYLE_DESC,
                       F.STEELNAME,
                       F.SPEC_NAME,
                       F.MODEL_DESC,
                       F.PLINE_NAME,
                       F.BELONG_CODE,
                       0 ORIGINAL_COUNT,
                       0 ORIGINAL_AMOUNT,
                       0 INLISTCOUNT,
                       0 INLISTWGT,
                       0 OUTLISTCOUNT,
                       0 OUTLISTWGT,
                       0 AWEIGHT,
                       SUM(F.ACT_COUNT) MATCOUNT,
                       SUM(F.ACT_WEIGHT) MATWGT,
                       NULL OUTSTOCK_TIME,
                       NULL INSTOCK_TIME
                  FROM MAT_ZC_M F, YDM_ZC_BUTTRESS G,YDM_ZC_INLIST T
                 WHERE F.MAT_NO = G.MAT_NO
                   AND F.MAT_NO = T.MAT_NO
                   AND TRUNC(T.INSTOCK_TIME)<= TO_DATE(?, 'YYYYMMDD')
                   AND T.INSTOCK_TYPE_CODE = '800701'
                   AND F.BELONG_CODE #CONDTIONS#
                   AND F.QCM_STAUS IN ('00', '11','22')
                 GROUP BY F.JUDGE_STOVE_NO,
                          F.BATCH_NO,
                          F.BATCH_GROUD_NO,
                          F.MATERIAL_NAME,
                          F.PRODUCNAME,
                          F.STD_STYLE_DESC,
                          F.STEELNAME,
                          F.SPEC_NAME,
                          F.MODEL_DESC,
                          F.PLINE_NAME,
                          F.BELONG_CODE) K
         GROUP BY K.JUDGE_STOVE_NO,
                  K.BATCH_NO,
                  K.BATCH_GROUD_NO,
                  K.MATERIAL_NAME,
                  K.PRODUCNAME,
                  K.STD_STYLE_DESC,
                  K.STEELNAME,
                  K.SPEC_NAME,
                  K.MODEL_DESC,
                  K.PLINE_NAME,
                  K.BELONG_CODE) H
 GROUP BY JUDGE_STOVE_NO,
       BATCH_NO,
       BATCH_GROUD_NO,
       MATERIAL_NAME,
       PRODUCNAME,
       STD_STYLE_DESC,
       STEELNAME,
       SPEC_NAME,
       MODEL_DESC,
       PLINE_NAME
       ]]>
</query>
<query id = "FrmrptStoveBatchStorageZg.getTestStore" desc = "仓库收发存">
<![CDATA[
select JUDGE_STOVE_NO,
       BATCH_NO,
       sum(ORIGINAL_COUNT)ORIGINAL_COUNT,
       sum(ORIGINAL_AMOUNT)ORIGINAL_AMOUNT,
       sum(DAY_1COUNT)DAY_1COUNT,
       sum(DAY_1)DAY_1,
       sum(MONTH_1COUNT)MONTH_1COUNT,
       sum(MONTH_1)MONTH_1,
       sum(DAY_2COUNT)DAY_2COUNT,
       sum(DAY_2)DAY_2,
       sum(MONTH_2COUNT)MONTH_2COUNT,
       sum(MONTH_2)MONTH_2,
       sum(AWEIGHT)AWEIGHT,
       sum((ORIGINAL_COUNT + MONTH_1COUNT - MONTH_2COUNT)) as END_COUNT,
       sum((ORIGINAL_AMOUNT + MONTH_1 - MONTH_2 + AWEIGHT)) as END_AMOUNT,
       sum(MATCOUNT)MATCOUNT,
       sum(MATWGT)MATWGT,
       sum((ORIGINAL_COUNT + MONTH_1COUNT - MONTH_2COUNT - MATCOUNT)) as QUANTITYCOUNT,
       sum((ORIGINAL_AMOUNT + MONTH_1 - MONTH_2 + AWEIGHT - MATWGT)) as QUANTITYWGT
  from (select JUDGE_STOVE_NO,
               BATCH_NO,
               BELONG_CODE,
               sum(k.ORIGINAL_COUNT) as ORIGINAL_COUNT,
               sum(k.ORIGINAL_AMOUNT) as ORIGINAL_AMOUNT,
               nvl(sum(case
                         when trunc(k.INSTOCK_TIME) = to_date(?, 'yyyymmdd') then
                          nvl(k.inListCount, 0)
                       end),
                   0) DAY_1COUNT,
               nvl(sum(case
                         when trunc(k.INSTOCK_TIME) = to_date(?, 'yyyymmdd') then
                          nvl(k.inListWgt, 0)
                       end),
                   0) DAY_1,
               nvl(sum(case
                         when trunc(k.INSTOCK_TIME) >=
                              to_date(?, 'yyyymmdd') and
                              trunc(k.INSTOCK_TIME) <=
                              to_date(?, 'yyyymmdd') then
                          nvl(k.inListCount, 0)
                       end),
                   0) MONTH_1COUNT,
               nvl(sum(case
                         when trunc(k.INSTOCK_TIME) >=
                              to_date(?, 'yyyymmdd') and
                              trunc(k.INSTOCK_TIME) <=
                              to_date(?, 'yyyymmdd') then
                          nvl(k.inListWgt, 0)
                       end),
                   0) MONTH_1,
               nvl(sum(case
                         when trunc(k.OUTSTOCK_TIME) =
                              to_date(?, 'yyyymmdd') then
                          nvl(k.outListCount, 0)
                       end),
                   0) DAY_2COUNT,
               nvl(sum(case
                         when trunc(k.OUTSTOCK_TIME) =
                              to_date(?, 'yyyymmdd') then
                          nvl(k.outListWgt, 0)
                       end),
                   0) DAY_2,
               nvl(sum(case
                         when trunc(k.OUTSTOCK_TIME) >=
                              to_date(?, 'yyyymmdd') and
                              trunc(k.OUTSTOCK_TIME) <=
                              to_date(?, 'yyyymmdd') then
                          nvl(k.outListCount, 0)
                       end),
                   0) MONTH_2COUNT,
               nvl(sum(case
                         when trunc(k.OUTSTOCK_TIME) >=
                              to_date(?, 'yyyymmdd') and
                              trunc(k.OUTSTOCK_TIME) <=
                              to_date(?, 'yyyymmdd') then
                          nvl(k.outListWgt, 0)
                       end),
                   0) MONTH_2,
               sum(k.AWEIGHT) as AWEIGHT,
               sum(k.MATCOUNT) as MATCOUNT,
               sum(k.MATWGT) as MATWGT
          from (select JUDGE_STOVE_NO,
                       BATCH_NO,
                       
                       BELONG_CODE,
                       sum(ACT_COUNT) ORIGINAL_COUNT,
                       sum(ACT_WEIGHT) ORIGINAL_AMOUNT,
                       0 inListCount,
                       0 inListWgt,
                       0 outListCount,
                       0 outListWgt,
                       0 AWEIGHT,
                       0 MATCOUNT,
                       0 MATWGT,
                       null OUTSTOCK_TIME,
                       null INSTOCK_TIME
                  from ydm_zc_initial_zg t
                 where t.bal_year_month = ?
                   and t.handle_log = '1'
                   #condtions#
                 group by t.judge_stove_no, t.batch_no,
                  BELONG_CODE
                union all
                SELECT JUDGE_STOVE_NO,
                       BATCH_NO,
                       BELONG_CODE,
                       0 ORIGINAL_COUNT,
                       0 ORIGINAL_AMOUNT,
                       ACT_COUNT inListCount,
                       ACT_WEIGHT inListWgt,
                       0 outListCount,
                       0 outListWgt,
                       0 AWEIGHT,
                       0 MATCOUNT,
                       0 MATWGT,
                       null OUTSTOCK_TIME,
                       INSTOCK_TIME INSTOCK_TIME
                  FROM YDM_ZC_INLIST T
                 WHERE INSTOCK_TYPE_CODE IN
                       ('800701', '800703')
                   AND TRUNC(INSTOCK_TIME) >= TO_DATE(?, 'YYYYMMDD')
                   AND TRUNC(INSTOCK_TIME) <= TO_DATE(?, 'YYYYMMDD')
                   #condtions#
                union all
                select JUDGE_STOVE_NO,
                       BATCH_NO,
                       BELONG_CODE,
                       0 ORIGINAL_COUNT,
                       0 ORIGINAL_AMOUNT,
                       0 inListCount,
                       0 inListWgt,
                       ACT_COUNT outListCount,
                       (case
                             when PONDER_NO is null then
                              nvl(ACT_WEIGHT, 0)
                             else
                              nvl(PONDER_GROSS_WT, 0)
                           end) outListWgt,
                       0 AWEIGHT,
                       0 MATCOUNT,
                       0 MATWGT,
                       OUTSTOCK_TIME OUTSTOCK_TIME,
                       null INSTOCK_TIME
                  from YDM_ZC_OUTLIST T
                 where OUTSTOCK_TYPE_CODE IN('800803','800805')
                   and TRUNC(OUTSTOCK_TIME) >= TO_DATE(?, 'YYYYMMDD')
                   AND TRUNC(OUTSTOCK_TIME) <= TO_DATE(?, 'YYYYMMDD')
                    #condtions#
                union all
                (
                 SELECT F.JUDGE_STOVE_NO,
                       F.BATCH_NO,
                       BELONG_CODE,
                       0 ORIGINAL_COUNT,
                       0 ORIGINAL_AMOUNT,
                       0 inListCount,
                       0 inListWgt,
                       0 outListCount,
                       0 outListWgt,
                       0 AWEIGHT,
                       sum(F.Act_Count) MATCOUNT,
                       sum(F.Act_Weight) MATWGT,
                       null OUTSTOCK_TIME,
                       null INSTOCK_TIME
                  FROM MAT_ZC_M F, YDM_ZC_BUTTRESS T
                 WHERE F.MAT_NO = T.MAT_NO
                 --and F.Judge_Stove_No = '572049'
                 #condtions#
                 group by F.Judge_Stove_No, F.Batch_No,
                  F.BELONG_CODE)) k
         group by k.Judge_Stove_No, k.Batch_No, 
         BELONG_CODE) h
         group by JUDGE_STOVE_NO,
       BATCH_NO
       ]]>
</query>
</queryMap>