<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc = "炉批收发存">
<query id = "FrmrptStoveBatchStorage.getOriginaldate" desc = "收发货期初时间查询">
<![CDATA[
select distinct min(t.original_date) over() original_date,
                max(case
                      when substr(t.original_date, 1, 4) <
                           substr(?, 1, 4) then
                       t.original_date
                    end) over() original_date1,
                max(case
                      when t.original_date <= ? then
                       t.original_date
                    end) over() original_date_last
  from ydm_zc_initial t  
]]>
</query>
<query id = "FrmrptStoveBatchStorage.getOriginalLast" desc = "查询上期期初">
<![CDATA[
select t.JUDGE_STOVE_NO,t.BATCH_NO,t.BATCH_GROUD_NO,
                    sum(nvl(t.ACT_COUNT,0))count,
                    sum(nvl(t.ACT_WEIGHT, 0)) weight
                    from ydm_zc_initial t
                    where 1=1 and t.HANDLE_LOG = '1' and  t.BAL_YEAR_MONTH LIKE '%'||?||'%' 
                    --and t.JUDGE_STOVE_NO = '455162'
                     #condtions#
                    ]]>
</query>
<query id = "FrmrptStoveBatchStorage.getLastIn" desc = "上期入库量">
<![CDATA[
                             select t.JUDGE_STOVE_NO,t.BATCH_NO,t.BATCH_GROUD_NO,
                               sum(nvl(t.count,0)) count,
                               sum(nvl(t.weight, 0)) weight
                          from (select t.JUDGE_STOVE_NO,t.BATCH_NO,t.BATCH_GROUD_NO,t.BELONG_CODE,
                                    nvl(t.ACT_COUNT,0) count,
                                    nvl(t.ACT_WEIGHT, 0) weight
                                 from ydm_zc_inlist t
                               where 1=1
                                and t.VALIDFLAG = '1'
                                and t.INSTOCK_TYPE_CODE in ('800701','800702','800704','800712')
                                and t.BAL_YEAR_MONTH >= ?
                                --and trunc(t.INSTOCK_TIME) >= to_date(?, 'yyyymmdd')
                                  and trunc(t.INSTOCK_TIME) <= to_date(?, 'yyyymmdd') 
                                  #condtions#)t where 1=1
                       
                          ]]>                  
</query>
<query id = "FrmrptStoveBatchStorage.getLastOut" desc = "上期出库量">
<![CDATA[
select t.JUDGE_STOVE_NO,
                             t.BATCH_NO,
                             t.BATCH_GROUD_NO,
                              sum(nvl(t.count,0))count,
                               sum(nvl(t.weight, 0)) weight
                          from (select t.JUDGE_STOVE_NO,
                             t.BATCH_NO,
                             t.BATCH_GROUD_NO,
                             t.BELONG_CODE,
                               nvl(t.ACT_COUNT,0)count,
                                       nvl(t.ACT_WEIGHT, 0) weight
                                  from ydm_zc_outlist t
                                where t.OUTSTOCK_TYPE_CODE in ('800805','800806','800802','800804','800812')
                                  and t.validflag = '1'
                                  and t.BAL_YEAR_MONTH >= ?
                                  --and trunc(t.OUTSTOCK_TIME) >=to_date(?, 'yyyymmdd')
                                   and trunc(t.OUTSTOCK_TIME) <= to_date(?, 'yyyymmdd') #condtions#
                                  )t where 1=1 
                             ]]>
</query>

<query id = "FrmrptStoveBatchStorage.getThisIn" desc = "本期入库量">
<![CDATA[
                     select t.JUDGE_STOVE_NO,t.BATCH_NO,t.BATCH_GROUD_NO,
                              nvl(sum(case
                                        when trunc(t.INSTOCK_TIME) = to_date(?, 'yyyymmdd') then
                                         nvl(t.count, 0)
                                      end),
                                   0) weight_daycount,
                               nvl(sum(case
                                        when trunc(t.INSTOCK_TIME) = to_date(?, 'yyyymmdd') then
                                         nvl(t.weight, 0)
                                      end),
                                   0) weight_day,
                                   nvl(sum(case
                                        when t.BAL_YEAR_MONTH >= ? and
                                            trunc(t.INSTOCK_TIME) <= to_date(?, 'yyyymmdd') then
                                         nvl(t.count, 0)
                                      end),
                                   0) weight_monthcount,
                              nvl(sum(case
                                        when t.BAL_YEAR_MONTH >= ? and
                                            trunc(t.INSTOCK_TIME) <= to_date(?, 'yyyymmdd') then
                                         nvl(t.weight, 0)
                                      end),
                                   0) weight_month  
                          from (select t.JUDGE_STOVE_NO,t.BATCH_NO,t.BATCH_GROUD_NO,t.BELONG_CODE,
                                     t.INSTOCK_TIME,  
                                      nvl(t.ACT_COUNT,0)count,
                                       nvl(t.ACT_WEIGHT, 0) weight
                                  from ydm_zc_inlist t
                                 where t.validflag = '1'
                                  and t.INSTOCK_TYPE_CODE in ('800701','800702','800704','800706','800707','800712')
                                  --and t.JUDGE_STOVE_NO = '455162'
                                  and t.BAL_YEAR_MONTH >= ?
                                   and trunc(t.INSTOCK_TIME) <= to_date(?, 'yyyymmdd')  #condtions# 
                                   )t where 1=1
                                   
                             ]]>
</query>
<query id = "FrmrptStoveBatchStorage.getThisOut" desc = "本期出库量">
<![CDATA[
                      select t.JUDGE_STOVE_NO,t.BATCH_NO,t.BATCH_GROUD_NO,
                             nvl(sum(case
                                     when trunc(t.OUTSTOCK_TIME) = to_date(?, 'yyyymmdd') then
                                         nvl(t.count, 0)
                                      end),
                                  0) weight_daycount,
                              nvl(sum(case
                                     when trunc(t.OUTSTOCK_TIME) = to_date(?, 'yyyymmdd') then
                                         nvl(t.weight, 0)
                                      end),
                                  0) weight_day,
                                  nvl(sum(case
                                         when t.BAL_YEAR_MONTH >= ? and
                                             trunc(t.OUTSTOCK_TIME) <= to_date(?, 'yyyymmdd') then
                                         nvl(t.count, 0)
                                      end),
                                  0) weight_monthcount,
                              nvl(sum(case
                                         when t.BAL_YEAR_MONTH >= ? and
                                             trunc(t.OUTSTOCK_TIME) <= to_date(?, 'yyyymmdd') then
                                         nvl(t.weight, 0)
                                      end),
                                  0) weight_month
                         from (select t.JUDGE_STOVE_NO,t.BATCH_NO,t.BATCH_GROUD_NO,t.BELONG_CODE,
                         t.OUTSTOCK_TIME,
                                    nvl(t.ACT_COUNT,0)count,
                                    case when t.PONDER_NO is null
                                       then nvl(t.ACT_WEIGHT, 0)
                                       else nvl(t.PONDER_GROSS_WT, 0) end as weight
                             from ydm_zc_outlist t
                           where t.OUTSTOCK_TYPE_CODE in ('800805','800806','800802','800808','800806','800812')
                               and t.validflag = '1'
                               --and t.JUDGE_STOVE_NO = '455162'
                                   t.BAL_YEAR_MONTH >= ?
                                  and trunc(t.OUTSTOCK_TIME) <=
                                      to_date(?, 'yyyymmdd') #condtions# 
                             )t where 1=1
                             
                             ]]>
</query>

<query id = "FrmrptStoveBatchStorage.getAdjust" desc = "本期调差量">
<![CDATA[
                             select t.JUDGE_STOVE_NO,t.BATCH_NO,t.BATCH_GROUD_NO,
                               sum(nvl(t.weight, 0)) aweight
                          from (select t.JUDGE_STOVE_NO,t.BATCH_NO,t.BATCH_GROUD_NO,t.BELONG_CODE,
                                    nvl(t.ACT_WEIGHT, 0) weight
                                 from ydm_zc_stocktakinglist t
                               where 1=1
                                --AND T.STOCKTAKING_TYPE_CODE = '800603'
                                and t.VALIDFLAG = '1'
                                --and t.JUDGE_STOVE_NO = '083969'
                                   and trunc(t.STOCKTAKING_TIME) >= to_date(?, 'yyyymmdd')
                                  and trunc(t.STOCKTAKING_TIME) <= to_date(?, 'yyyymmdd') 
                                  #condtions#)t where 1=1
                       
                          ]]>    
</query>
<query id = "FrmrptStoveBatchStorage.getMatData" desc = "实时库存">
<![CDATA[
select t.JUDGE_STOVE_NO,
       t.BATCH_NO,
       t.BATCH_GROUD_NO,
       sum(nvl(t.count,0))count,
       sum(nvl(t.weight, 0)) aweight
  from (select t.JUDGE_STOVE_NO,
       t.BATCH_NO,
       t.BATCH_GROUD_NO,
               t.BELONG_CODE,
               nvl(t.ACT_COUNT,0)count,
               nvl(t.ACT_WEIGHT, 0) weight
          from mat_zc_m t,ydm_zc_buttress s
         where 1 = 1
           and t.MAT_NO = s.mat_no
           --and t.JUDGE_STOVE_NO = '455162'
         #condtions#) t
 where 1 = 1
  ]]>
</query>
<query id = "FrmrptStoveBatchStorage.insertAdjustData" desc = "插入调差数据">
INSERT INTO YDM_ZC_STOCKTAKINGLIST
  (DEPARTMENT_CODE,
   DEPARTMENT_DESC,
   STOCKTAKING_DOC,
   STOCKTAKING_SQE,
   
   STOCKTAKING_TYPE_CODE,
   STOCKTAKING_TYPE_NAME,
   STOCKTAKING_RSN_CODE,
   STOCKTAKING_RSN_NAME,
   JUDGE_STOVE_NO,
   BATCH_NO,
   BATCH_GROUD_NO,
   ACT_COUNT,
   ACT_WEIGHT,
   BELONG_CODE,
   BELONG_NAME,
   STOCKTAKING_TIME,
   MATERIAL_NO,
   MATERIAL_NAME,
   VALIDFLAG,
   CREATE_NAME,
   CREATE_TIME,
   OLD_WEIGHT,
   BAL_YEAR_MONTH,
   PRODUCCODE,
   PRODUCNAME,
   STEELCODE,
   STEELNAME,
   SPEC_CODE,
   SPEC_NAME,
   MODEL_CODE,
   MODEL_DESC,
   STD_STYLE,
   STD_STYLE_DESC,
   STORAGE_NO,
   F_STOCKTAKING_TIME,
   MANAGEMENT_NO,
   MANAGEMENT_NAME,
 SUPPLY_UNIT_CODE,
 SUPPLY_UNIT,
 IS_DEALER,
 PLINE_CODE,
 PLINE_NAME,
 GRADECODE,
 GRADENAME,
 PROCESS_CDOE,
 PROCESS_DESC)
VALUES
  (?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   '0',
   ?,
   ?,
   ?,
   to_date(?,'yyyy-MM-dd HH24:mi:ss'),
   ?,
   ?,
   '1',
   ?,
   to_date(?,'yyyy-MM-dd HH24:mi:ss'),?,?,?,?,?,?,?,?,?,?,?,?,?,to_date(?,'yyyy-MM-dd HH24:mi:ss'),?,?,?,?,?,?,?,?,?,?,?)
</query>
<query id = "FrmrptStoveBatchStorage.SelectMatNo" desc = "查询需要插入的信息">
<![CDATA[
	SELECT T.MAT_NO,
	   T.PRODUCCODE,
       T.PRODUCNAME,
       T.STEELCODE,
       T.STEELNAME,
       T.SPEC_CODE,
       T.SPEC_NAME,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.STD_STYLE,
       T.STD_STYLE_DESC,
       T.BELONG_CODE,
       T.BELONG_NAME,
       T.IS_DEALER,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.GRADECODE,
       T.GRADENAME,
       T.PROCESS_CDOE
       --B.STORAGE_NO
  FROM MAT_ZC_M T,ydm_zc_buttress s
  --LEFT JOIN YDM_BS_STORAGE C ON C.STORAGE_NO = B.STORAGE_NO
 WHERE T.MAT_NO = s.MAT_NO
   AND T.JUDGE_STOVE_NO =  ?
   AND T.BATCH_NO = ?
   --AND T.BATCH_GROUD_NO = ?
   --AND T.BELONG_CODE = ?

   
   ]]>
</query>
<query id = "FrmrptStoveBatchStorage.SelectMatNo_1" desc = "查询需要插入的信息">
<![CDATA[
	SELECT T.MATERIAL_NO,
       T.MATERIAL_NAME,
       T.PRODUCCODE,
       T.PRODUCNAME,
       T.STEELCODE,
       T.STEELNAME,
       T.SPEC_CODE,
       T.SPEC_NAME,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.STD_STYLE,
       T.STD_STYLE_DESC,
       T.BELONG_CODE,
       T.BELONG_NAME,
       T.IS_DEALER,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.GRADECODE,
       T.GRADENAME,
       T.PROCESS_CDOE
  FROM MAT_ZC_M T
 WHERE T.JUDGE_STOVE_NO = ?
   AND T.BATCH_NO = ?
   --AND T.BATCH_GROUD_NO = ?
   --AND T.BELONG_CODE = ?
   --#BELONG_CODE#
 GROUP BY T.JUDGE_STOVE_NO,
          T.BATCH_NO,
          T.BATCH_GROUD_NO,
          T.PRODUCCODE,
          T.MATERIAL_NO,
          T.MATERIAL_NAME,
          T.PRODUCNAME,
          T.STEELCODE,
          T.STEELNAME,
          T.SPEC_CODE,
          T.SPEC_NAME,
          T.MODEL_CODE,
          T.MODEL_DESC,
          T.STD_STYLE,
          T.STD_STYLE_DESC,
          T.BELONG_CODE,
          T.BELONG_NAME,
          T.IS_DEALER,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.GRADECODE,
       T.GRADENAME,
       T.PROCESS_CDOE
          UNION ALL
SELECT T.MATERIAL_NO,
       T.MATERIAL_NAME,
       T.PRODUCCODE,
       T.PRODUCNAME,
       T.STEELCODE,
       T.STEELNAME,
       T.SPEC_CODE,
       T.SPEC_NAME,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.STD_STYLE,
       T.STD_STYLE_DESC,
       T.BELONG_CODE,
       T.BELONG_NAME,
       T.IS_DEALER,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.GRADECODE,
       T.GRADENAME,
       T.PROCESS_CDOE
  FROM YDM_ZC_OUTLIST T
 WHERE T.JUDGE_STOVE_NO = ?
   AND T.BATCH_NO = ?
   --AND T.BATCH_GROUD_NO = ?
   AND T.OUTSTOCK_TYPE_CODE IN('800802','800805','800812')
   --AND T.BELONG_CODE = ?
   --#BELONG_CODE#
 GROUP BY T.JUDGE_STOVE_NO,
          T.BATCH_NO,
          T.BATCH_GROUD_NO,
          T.PRODUCCODE,
          T.MATERIAL_NO,
          T.MATERIAL_NAME,
          T.PRODUCNAME,
          T.STEELCODE,
          T.STEELNAME,
          T.SPEC_CODE,
          T.SPEC_NAME,
          T.MODEL_CODE,
          T.MODEL_DESC,
          T.STD_STYLE,
          T.STD_STYLE_DESC,
          T.BELONG_CODE,
          T.BELONG_NAME,
          T.IS_DEALER,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.GRADECODE,
       T.GRADENAME,
       T.PROCESS_CDOE
      -- ORDER BY T.BAL_YEAR_MONTH DESC
       UNION ALL
SELECT T.MATERIAL_NO,
       T.MATERIAL_NAME,
       T.PRODUCCODE,
       T.PRODUCNAME,
       T.STEELCODE,
       T.STEELNAME,
       T.SPEC_CODE,
       T.SPEC_NAME,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.STD_STYLE,
       T.STD_STYLE_DESC,
       T.BELONG_CODE,
       T.BELONG_NAME,
       T.IS_DEALER,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.GRADECODE,
       T.GRADENAME,
       T.PROCESS_CDOE
  FROM MAT_ZC_BACKUP T
 WHERE T.JUDGE_STOVE_NO = ?
   AND T.BATCH_NO = ?
   --AND T.BATCH_GROUD_NO = ?
   --AND T.BELONG_CODE = ?
   --#BELONG_CODE#
 GROUP BY T.JUDGE_STOVE_NO,
          T.BATCH_NO,
          T.BATCH_GROUD_NO,
          T.PRODUCCODE,
          T.MATERIAL_NO,
          T.MATERIAL_NAME,
          T.PRODUCNAME,
          T.STEELCODE,
          T.STEELNAME,
          T.SPEC_CODE,
          T.SPEC_NAME,
          T.MODEL_CODE,
          T.MODEL_DESC,
          T.STD_STYLE,
          T.STD_STYLE_DESC,
          T.BELONG_CODE,
          T.BELONG_NAME,
          T.IS_DEALER,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.GRADECODE,
       T.GRADENAME,
       T.PROCESS_CDOE

   ]]>
</query>
<query id = "FrmrptStoveBatchStorage.getTest" desc = "查询">
<![CDATA[
SELECT JUDGE_STOVE_NO,
       BATCH_NO,
       SUM(ORIGINAL_COUNT) AS ORIGINAL_COUNT,
       SUM(ORIGINAL_AMOUNT) AS ORIGINAL_AMOUNT,
       SUM(DAY_1COUNT) AS DAY_1COUNT,
       SUM(DAY_1) AS DAY_1,
       SUM(MONTH_1COUNT) AS MONTH_1COUNT,
       SUM(MONTH_1) AS MONTH_1,
       SUM(DAY_2COUNT) AS DAY_2COUNT,
       SUM(DAY_2) AS DAY_2,
       SUM(MONTH_2COUNT) AS MONTH_2COUNT,
       SUM(MONTH_2) AS MONTH_2,
       SUM(AWEIGHT) AS AWEIGHT,
       SUM((ORIGINAL_COUNT + MONTH_1COUNT - MONTH_2COUNT)) AS END_COUNT,
       SUM((ORIGINAL_AMOUNT + MONTH_1 - MONTH_2 + AWEIGHT)) AS END_AMOUNT,
       SUM(MATCOUNT) AS MATCOUNT,
       SUM(MATWGT) AS 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,
               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) AS DAY_1COUNT,
               NVL(SUM(CASE WHEN TRUNC(k.INSTOCK_TIME) = TO_DATE(?, 'yyyymmdd') THEN NVL(k.inListWgt, 0) END), 0) AS DAY_1,
               NVL(SUM(CASE WHEN k.BAL_YEAR_MONTH >= ? AND TRUNC(k.INSTOCK_TIME) <= TO_DATE(?, 'yyyymmdd') THEN NVL(k.inListCount, 0) END), 0) AS MONTH_1COUNT,
               NVL(SUM(CASE WHEN k.BAL_YEAR_MONTH >= ? AND TRUNC(k.INSTOCK_TIME) <= TO_DATE(?, 'yyyymmdd') THEN NVL(k.inListWgt, 0) END), 0) AS MONTH_1,
               NVL(SUM(CASE WHEN TRUNC(k.OUTSTOCK_TIME) = TO_DATE(?, 'yyyymmdd') THEN NVL(k.outListCount, 0) END), 0) AS DAY_2COUNT,
               NVL(SUM(CASE WHEN TRUNC(k.OUTSTOCK_TIME) = TO_DATE(?, 'yyyymmdd') THEN NVL(k.outListWgt, 0) END), 0) AS DAY_2,
               NVL(SUM(CASE WHEN k.BAL_YEAR_MONTH >= ? AND TRUNC(k.OUTSTOCK_TIME) <= TO_DATE(?, 'yyyymmdd') THEN NVL(k.outListCount, 0) END), 0) AS MONTH_2COUNT,
               NVL(SUM(CASE WHEN k.BAL_YEAR_MONTH >= ? AND TRUNC(k.OUTSTOCK_TIME) <= TO_DATE(?, 'yyyymmdd') THEN NVL(k.outListWgt, 0) END), 0) AS MONTH_2,
               SUM(k.AWEIGHT) AS AWEIGHT,
               SUM(k.MATCOUNT) AS MATCOUNT,
               SUM(k.MATWGT) AS MATWGT
          FROM (SELECT JUDGE_STOVE_NO,
                       BATCH_NO,
                       SUM(ACT_COUNT) AS ORIGINAL_COUNT,
                       SUM(ACT_WEIGHT) AS ORIGINAL_AMOUNT,
                       0 AS inListCount,
                       0 AS inListWgt,
                       0 AS outListCount,
                       0 AS outListWgt,
                       0 AS AWEIGHT,
                       0 AS MATCOUNT,
                       0 AS MATWGT,
                       NULL AS OUTSTOCK_TIME,
                       NULL AS INSTOCK_TIME,
                       NULL AS BAL_YEAR_MONTH
                  FROM ydm_zc_initial t
                 WHERE t.bal_year_month = ?
                   AND t.handle_log = '1'
                   #condtions##condtions2#
                 GROUP BY t.JUDGE_STOVE_NO, t.BATCH_NO
                UNION ALL
                SELECT JUDGE_STOVE_NO,
                       BATCH_NO,
                       0 AS ORIGINAL_COUNT,
                       0 AS ORIGINAL_AMOUNT,
                       ACT_COUNT AS inListCount,
                       ACT_WEIGHT AS inListWgt,
                       0 AS outListCount,
                       0 AS outListWgt,
                       0 AS AWEIGHT,
                       0 AS MATCOUNT,
                       0 AS MATWGT,
                       NULL AS OUTSTOCK_TIME,
                       INSTOCK_TIME,
                       BAL_YEAR_MONTH
                  FROM YDM_ZC_INLIST
                 WHERE BAL_YEAR_MONTH >= ?
                   AND TRUNC(INSTOCK_TIME) <= TO_DATE(?, 'YYYYMMDD')
                   #condtions##condtions3# #ssqrkString#
                UNION ALL
                SELECT JUDGE_STOVE_NO,
                       BATCH_NO,
                       0 AS ORIGINAL_COUNT,
                       0 AS ORIGINAL_AMOUNT,
                       0 AS inListCount,
                       0 AS inListWgt,
                       ACT_COUNT AS outListCount,
                       CASE WHEN PONDER_NO IS NULL THEN NVL(ACT_WEIGHT, 0) ELSE NVL(PONDER_GROSS_WT, 0) END AS outListWgt,
                       0 AS AWEIGHT,
                       0 AS MATCOUNT,
                       0 AS MATWGT,
                       OUTSTOCK_TIME,
                       NULL AS INSTOCK_TIME,
                       BAL_YEAR_MONTH
                  FROM YDM_ZC_OUTLIST
                 WHERE BAL_YEAR_MONTH >= ?
                   AND TRUNC(OUTSTOCK_TIME) <= TO_DATE(?, 'YYYYMMDD')
                   #condtions##condtions4# #ssqckString#
                UNION ALL
                SELECT JUDGE_STOVE_NO,
                       BATCH_NO,
                       0 AS ORIGINAL_COUNT,
                       0 AS ORIGINAL_AMOUNT,
                       0 AS inListCount,
                       0 AS inListWgt,
                       0 AS outListCount,
                       0 AS outListWgt,
                       SUM(ACT_WEIGHT) AS AWEIGHT,
                       0 AS MATCOUNT,
                       0 AS MATWGT,
                       NULL AS OUTSTOCK_TIME,
                       NULL AS INSTOCK_TIME,
                       BAL_YEAR_MONTH
                  FROM YDM_ZC_STOCKTAKINGLIST e
                 WHERE e.BAL_YEAR_MONTH >= ?
                   AND TRUNC(e.stocktaking_time) <= TO_DATE(?, 'YYYYMMDD')
                   AND e.STOCKTAKING_TYPE_CODE = '800603'
                   #condtions##condtions5#
                 GROUP BY JUDGE_STOVE_NO, BATCH_NO, BAL_YEAR_MONTH
                UNION ALL
                SELECT F.JUDGE_STOVE_NO,
                       F.BATCH_NO,
                       0 AS ORIGINAL_COUNT,
                       0 AS ORIGINAL_AMOUNT,
                       0 AS inListCount,
                       0 AS inListWgt,
                       0 AS outListCount,
                       0 AS outListWgt,
                       0 AS AWEIGHT,
                       SUM(F.ACT_COUNT) AS MATCOUNT,
                       SUM(F.ACT_WEIGHT) AS MATWGT,
                       NULL AS OUTSTOCK_TIME,
                       NULL AS INSTOCK_TIME,
                       NULL AS BAL_YEAR_MONTH
                  FROM MAT_ZC_M F
                 JOIN YDM_ZC_BUTTRESS G ON F.MAT_NO = G.MAT_NO
                 WHERE F.PRODUCT_FLAG IN ('801403', '801402')
                   #condtions##condtions6#
                 GROUP BY F.JUDGE_STOVE_NO, F.BATCH_NO) k
         GROUP BY k.JUDGE_STOVE_NO, k.BATCH_NO) h
GROUP BY JUDGE_STOVE_NO, BATCH_NO
]]>
</query>
</queryMap>