<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc = "运行年月收发存">
<query id = "FrmBcRunTimeReport.queryData" desc = "查询">
SELECT JUDGE_STOVE_NO,
       BATCH_NO,
       PRODUCNAME,
       STEELNAME,
       SPEC_NAME,
       GRADENAME,
    STD_STYLE_DESC,
    MODEL_DESC,
    BELONG_CODE,
    (SELECT T.DEPARTNAME FROM CORE_APP_DEPARTMENT T WHERE T.DEPARTID = K.BELONG_CODE)BELONG_NAME,
    MATERIAL_NAME,
       SUM(ORIGINAL_COUNT) ORIGINAL_COUNT,
       SUM(ORIGINAL_AMOUNT) ORIGINAL_AMOUNT,
       SUM(MONTH_1COUNT) MONTH_1COUNT,
       SUM(MONTH_1) MONTH_1,
       SUM(MONTH_2COUNT) MONTH_2COUNT,
       SUM(MONTH_2) MONTH_2,
       SUM((ORIGINAL_COUNT + MONTH_1COUNT + HC_COUNT + GP_COUNT - MONTH_2COUNT - GPC_COUNT)) AS END_COUNT,
       SUM((ORIGINAL_AMOUNT + MONTH_1 + HC_WGT + GP_WGT - MONTH_2 - GPC_WGT)) AS END_AMOUNT,
       SUM(HC_COUNT)HC_COUNT,
       SUM(HC_WGT)HC_WGT,
       SUM(GP_COUNT)GP_COUNT,
       SUM(GP_WGT)GP_WGT,
       SUM(GPC_COUNT)GPC_COUNT,
       SUM(GPC_WGT)GPC_WGT,
    PROCESS_CDOE,
      MAX(PLINE_CODE)PLINE_CODE,
    MAX(PLINE_NAME)PLINE_NAME
  FROM (SELECT JUDGE_STOVE_NO,
               BATCH_NO,
               PRODUCNAME,
               STEELNAME,
               SPEC_NAME,
               GRADENAME,
    STD_STYLE_DESC,
    MODEL_DESC,
               SUM(ACT_COUNT) ORIGINAL_COUNT,
               SUM(ACT_WEIGHT) ORIGINAL_AMOUNT,
               0 MONTH_1COUNT,
               0 MONTH_1,
               0 MONTH_2COUNT,
               0 MONTH_2,
               0 HC_COUNT,
               0 HC_WGT,
               0 GP_COUNT,
               0 GP_WGT,
               0 GPC_COUNT,
               0 GPC_WGT,
    PROCESS_CDOE,
           PLINE_CODE,
           PLINE_NAME,
    BELONG_CODE,
    MATERIAL_NAME
          FROM YDM_BC_INITIAL T
         WHERE T.BAL_YEAR_MONTH = ?
           #CONDTIONS#
         GROUP BY T.JUDGE_STOVE_NO,
                  T.BATCH_NO,
                  T.PRODUCNAME,
                  T.STEELNAME,
                  T.SPEC_NAME,
                  T.GRADENAME,
                  T.MODEL_DESC,
    T.PROCESS_CDOE,
    T.STD_STYLE_DESC,
                  T.PLINE_CODE，
    T.PLINE_NAME,
    T.BELONG_CODE,
    T.MATERIAL_NAME,
    T.PROCESS_CDOE
        UNION ALL
        SELECT JUDGE_STOVE_NO,
               BATCH_NO,
               PRODUCNAME,
               STEELNAME,
               SPEC_NAME,
               GRADENAME,
    STD_STYLE_DESC,
    MODEL_DESC,
               0 ORIGINAL_COUNT,
               0 ORIGINAL_AMOUNT,
               SUM(ACT_COUNT) MONTH_1COUNT,
               SUM(ACT_WEIGHT) MONTH_1,
               0 MONTH_2COUNT,
               0 MONTH_2,
               0 HC_COUNT,
               0 HC_WGT,
               0 GP_COUNT,
               0 GP_WGT,
               0 GPC_COUNT,
               0 GPC_WGT,
    PROCESS_CDOE，
    PLINE_CODE,
    PLINE_NAME,
    BELONG_CODE,
    MATERIAL_NAME
          FROM YDM_BC_INLIST T
         WHERE INSTOCK_TYPE_CODE IN
               ('800709', '800702', '800711', '800710')
           AND T.BAL_YEAR_MONTH = ?
           #CONDTIONS#
         GROUP BY T.JUDGE_STOVE_NO,
                  T.BATCH_NO,
                  T.PRODUCNAME,
                  T.STEELNAME,
                  T.SPEC_NAME,
                  T.GRADENAME,
    T.MODEL_DESC,
    T.STD_STYLE_DESC,
    T.PLINE_CODE,
    T.PLINE_NAME,
    T.BELONG_CODE,
    T.MATERIAL_NAME,
    T.PROCESS_CDOE
        UNION ALL
        SELECT JUDGE_STOVE_NO,
               BATCH_NO,
               PRODUCNAME,
               STEELNAME,
               SPEC_NAME,
               GRADENAME,
    STD_STYLE_DESC,
    MODEL_DESC,
               0 ORIGINAL_COUNT,
               0 ORIGINAL_AMOUNT,
               0 MONTH_1COUNT,
               0 MONTH_1,
               0 MONTH_2COUNT,
               0 MONTH_2,
               SUM(ACT_COUNT) HC_COUNT,
               SUM(ACT_WEIGHT) HC_WGT,
               0 GP_COUNT,
               0 GP_WGT,
               0 GPC_COUNT,
               0 GPC_WGT,
    PROCESS_CDOE，
    PLINE_CODE,
    PLINE_NAME,
    BELONG_CODE,
    MATERIAL_NAME
          FROM YDM_BC_INLIST T
         WHERE INSTOCK_TYPE_CODE = '800704'

           AND T.BAL_YEAR_MONTH = ?
           #CONDTIONS#
         GROUP BY T.JUDGE_STOVE_NO,
                  T.BATCH_NO,
                  T.PRODUCNAME,
                  T.STEELNAME,
                  T.SPEC_NAME,
                  T.GRADENAME,
    T.STD_STYLE_DESC,
    T.MODEL_DESC,
    T.PLINE_CODE,
    T.PLINE_NAME,
    T.BELONG_CODE,
    T.MATERIAL_NAME,
    T.PROCESS_CDOE
        UNION ALL
        SELECT JUDGE_STOVE_NO,
               BATCH_NO,
               PRODUCNAME,
               STEELNAME,
               SPEC_NAME,
               GRADENAME,
    STD_STYLE_DESC,
    MODEL_DESC,
               0 ORIGINAL_COUNT,
               0 ORIGINAL_AMOUNT,
               0 MONTH_1COUNT,
               0 MONTH_1,
               0 MONTH_2COUNT,
               0 MONTH_2,
               0 HC_COUNT,
               0 HC_WGT,
               SUM(ACT_COUNT) GP_COUNT,
               SUM(ACT_WEIGHT) GP_WGT,
               0 GPC_COUNT,
               0 GPC_WGT,
    PROCESS_CDOE，
    PLINE_CODE,
    PLINE_NAME,
    BELONG_CODE,
    MATERIAL_NAME
          FROM YDM_BC_INLIST T
         WHERE INSTOCK_TYPE_CODE = '800706'
           AND T.BAL_YEAR_MONTH = ?
           #CONDTIONS#
         GROUP BY T.JUDGE_STOVE_NO,
                  T.BATCH_NO,
                  T.PRODUCNAME,
                  T.STEELNAME,
                  T.SPEC_NAME,
                  T.GRADENAME,
    T.STD_STYLE_DESC,
    T.MODEL_DESC,
    T.PLINE_CODE,
    T.PLINE_NAME,
    T.BELONG_CODE,
    T.MATERIAL_NAME,
    T.PROCESS_CDOE
        UNION ALL
        SELECT JUDGE_STOVE_NO,
               BATCH_NO,
               PRODUCNAME,
               STEELNAME,
               SPEC_NAME,
               GRADENAME,
    STD_STYLE_DESC,
    MODEL_DESC,
               0 ORIGINAL_COUNT,
               0 ORIGINAL_AMOUNT,
               0 MONTH_1COUNT,
               0 MONTH_1,
               SUM(ACT_COUNT) MONTH_2COUNT,
               SUM(ACT_WEIGHT) MONTH_2,
               0 HC_COUNT,
               0 HC_WGT,
               0 GP_COUNT,
               0 GP_WGT,
               0 GPC_COUNT,
               0 GPC_WGT,
    PROCESS_CDOE，
    PLINE_CODE,
    PLINE_NAME,
    BELONG_CODE,
    MATERIAL_NAME
          FROM YDM_BC_OUTLIST T
         WHERE OUTSTOCK_TYPE_CODE IN
               ('800809', '800802', '800811', '800806', '800804')
           AND T.BAL_YEAR_MONTH = ?

           #CONDTIONS#
         GROUP BY T.JUDGE_STOVE_NO,
                  T.BATCH_NO,
                  T.PRODUCNAME,
                  T.STEELNAME,
                  T.SPEC_NAME,
                  T.GRADENAME,
    T.STD_STYLE_DESC,
    T.MODEL_DESC,
    T.PLINE_CODE,
    T.PLINE_NAME,
    T.BELONG_CODE,
    T.MATERIAL_NAME,
    T.PROCESS_CDOE
        UNION ALL
        SELECT JUDGE_STOVE_NO,
               BATCH_NO,
               PRODUCNAME,
               STEELNAME,
               SPEC_NAME,
               GRADENAME,
    STD_STYLE_DESC,
    MODEL_DESC,
               0 ORIGINAL_COUNT,
               0 ORIGINAL_AMOUNT,
               0 MONTH_1COUNT,
               0 MONTH_1,
               0 MONTH_2COUNT,
               0 MONTH_2,
               0 HC_COUNT,
               0 HC_WGT,
               0 GP_COUNT,
               0 GP_WGT,
               SUM(ACT_COUNT) GPC_COUNT,
               SUM(ACT_WEIGHT) GPC_WGT,
    PROCESS_CDOE，
    PLINE_CODE,
    PLINE_NAME,
    BELONG_CODE,
    MATERIAL_NAME
          FROM YDM_BC_OUTLIST T
         WHERE OUTSTOCK_TYPE_CODE = '800808'
           AND T.BAL_YEAR_MONTH = ?

           #CONDTIONS#
         GROUP BY T.JUDGE_STOVE_NO,
                  T.BATCH_NO,
                  T.PRODUCNAME,
                  T.STEELNAME,
                  T.SPEC_NAME,
                  T.GRADENAME,
    T.STD_STYLE_DESC,
    T.MODEL_DESC,
    T.PLINE_CODE,
    T.PLINE_NAME,
    T.BELONG_CODE,T.MATERIAL_NAME,T.PROCESS_CDOE) K
 GROUP BY JUDGE_STOVE_NO,
          BATCH_NO,
          PRODUCNAME,
          STEELNAME,
          SPEC_NAME,
          GRADENAME,
    STD_STYLE_DESC,
    MODEL_DESC,
    BELONG_CODE,
    MATERIAL_NAME,
    PROCESS_CDOE
</query>
<query id = "FrmBcRunTimeReport.doQueryInialData" desc = "查询下月是否存在期初">
SELECT COUNT(1) FROM YDM_BC_INITIAL T WHERE T.BAL_YEAR_MONTH = ?
</query>
<query id = "FrmBcRunTimeReport.selectMatInformation" desc = "查询材料信息">
SELECT * FROM ( SELECT 
       T.MAT_NO,
       T.PRODUCT_FLAG,
       T.MAT_STATUS,
       T.LOT_NO,
       T.STOVE_NO,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.BATCH_GROUD_NO,
       T.SAMPLE_FLAG,
       T.MATERIAL_NO,
       T.MATERIAL_NAME,
       T.INPUT_MATERIAL_NAME,
       T.INPUT_MATERIAL_NO,
       T.PRODUCCODE,
       T.PRODUCNAME,
       T.STEELCODE,
       T.STEELNAME,
       T.GRADECODE,
       T.GRADENAME,
       T.SPEC_CODE,
       T.SPEC_NAME,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.STD_CODE,
       T.STD_NAME,
       T.STD_STYLE,
       T.STD_STYLE_DESC,
       T.PRO_ORDER_NO,
       T.PRO_ORDER_ID,
       T.ORDER_NO,
       T.ORDER_SEQ,
       T.ORDER_SEQ_NO,
       T.CRAF_NO,
       T.PROCESS_CDOE,
       T.PROCESS_DESC,
       T.NEXT_PROCESS_CDOE,
       T.NEXT_PROCESS_DESC,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.MAT_ORIGIN_CODE,
       T.MAT_ORIGIN_NAME,
       T.ACT_DIMATER,
       T.ACT_HEIGHT,
       T.ACT_LEN,
       T.ACT_LEN_MIN,
       T.ACT_LEN_MAX,
       T.ACT_COUNT,
       T.ACT_WEIGHT,
       T.ACT_THEORY_WEIGHT,
       T.MEASURE_FLAG,
       T.BELONG_CODE,
       T.BELONG_NAME,
       T.PACK_FLAG,
       T.MAT_GOWHERE_CODE,
       T.MAT_GOWHERE_NAME,
       T.MAT_RETURN_FLAG,
       T.LOCK_FLAG,
       T.MNG_LOCK_FLAG,
       T.JUGDE_APPLY_FLAG,
       T.JUGDE_APPLY_CODE,
       TO_CHAR(T.JUGDE_APPLY_TIME, 'YYYY-MM-DD HH24:MI:SS') JUGDE_APPLY_TIME,
       T.FACE_RESULT_CODE,
       TO_CHAR(T.FACE_RESULT_TIME, 'YYYY-MM-DD HH24:MI:SS') FACE_RESULT_TIME,
       T.FACE_MAKER,
       T.SPEC_RESULT_CODE,
       TO_CHAR(T.SPEC_RESULT_TIME, 'YYYY-MM-DD HH24:MI:SS') SPEC_RESULT_TIME,
       T.SPEC_MAKER,
       T.CHEM_RESULT_CODE,
       TO_CHAR(T.CHEM_RESULT_TIME, 'YYYY-MM-DD HH24:MI:SS') CHEM_RESULT_TIME,
       T.CHEM_MAKER,
       T.PHY_RESULT_CODE,
       TO_CHAR(T.PHY_RESULT_TIME, 'YYYY-MM-DD HH24:MI:SS') PHY_RESULT_TIME,
       T.PHY_MAKER,
       T.DETECT_RESULT_CODE,
       T.WPRESSURE_RESULT_CODE,
       T.JUDGE_RESULT_CODE,
       T.JUDGE_RESULT,
       TO_CHAR(T.JUDGE_RESULT_TIME, 'YYYY-MM-DD HH24:MI:SS') JUDGE_RESULT_TIME,
       T.JUDGE_MAKER,
       T.INSTOCK_FLAG,
       TO_CHAR(T.INSTOCK_TIME, 'YYYY-MM-DD HH24:MI:SS') INSTOCK_TIME,
       T.BAR_CODE,
       T.MEMO,
       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.ORD_PK,
       T.ORD_LN_PK,
       T.ORD_LN_DLY_PK,
       T.BAL_YEAR_MONTH,
       T.JUDGE_STD_NAME,
       T.PIPMEMO,
       T.SOURE_CODE,
       T.SOURE_NAME,
       T.PONDER_NO,
       T.PONDER_GROSS_WT,
       T.JUDGE_ID,
       T.LOCK_LIKU,
       T.QCM_STAUS,
       T.OUTSTOCK_DOC,
       T.HEAT_PLAN_NO,
       T.ZG_STOVE_SQE,
       T.GX_PLAN_NO,
       T.ZG_MAT_NO,
       T.TARGET,
       T.PROCESS_STATUS,
       T.JUGDE_CONVICTED,
       T.FIXTYPE_CODE,
       T.QUALITY_GROUP_ZG,
       T.FLAG_STOVE_NO_ZG,
       T.DETECT_RESULT_CODE1,
       T.TESTING_GRADE,
       T.TESTING_TYPE,
       T.TESTING_GRADE1,
       T.TESTING_TYPE1,
       T.JUDGE_STOVE_NO_UP,
       T.CRAFT_SEQ,
       T.PRO_PLAN_ID_NEXT,
       T.GX_PLAN_NO_NEXT,
       T.HANGING_FLAG,
       T.CUT_NUM,
       T.JUDGE_TOLRESULT_CODE,
       T.JUDGE_TOLRESULT,
       TO_CHAR(T.JUDGE_TOLRESULT_TIME, 'YYYY-MM-DD HH24:MI:SS') JUDGE_TOLRESULT_TIME,
       T.JUDGE_TOLMAKER,
       T.INSTANCY_FLAG,
       T.JUGDE_TOLCONVICTED,
       T.JUDGE_STD_DES,
       T.MNG_LOCK_REMARK,
       T.LOCK_REMARK,
       T.JUGDE_APPLY_SEQUENO,
       T.HEAT_PLAN_NO_NEXT
 FROM MAT_BC_M T
 WHERE T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
 AND T.BATCH_NO = '#BATCH_NO#'
 AND T.PROCESS_CDOE = '#PROCESS_CDOE#'
    AND T.MATERIAL_NAME = '#MATERIAL_NAME#'
 AND T.BELONG_CODE = '#BELONG_CODE#'
UNION ALL
 SELECT 
       T.MAT_NO,
       T.PRODUCT_FLAG,
       T.MAT_STATUS,
       T.LOT_NO,
       T.STOVE_NO,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.BATCH_GROUD_NO,
       T.SAMPLE_FLAG,
       T.MATERIAL_NO,
       T.MATERIAL_NAME,
       T.INPUT_MATERIAL_NAME,
       T.INPUT_MATERIAL_NO,
       T.PRODUCCODE,
       T.PRODUCNAME,
       T.STEELCODE,
       T.STEELNAME,
       T.GRADECODE,
       T.GRADENAME,
       T.SPEC_CODE,
       T.SPEC_NAME,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.STD_CODE,
       T.STD_NAME,
       T.STD_STYLE,
       T.STD_STYLE_DESC,
       T.PRO_ORDER_NO,
       T.PRO_ORDER_ID,
       T.ORDER_NO,
       T.ORDER_SEQ,
       T.ORDER_SEQ_NO,
       T.CRAF_NO,
       T.PROCESS_CDOE,
       T.PROCESS_DESC,
       T.NEXT_PROCESS_CDOE,
       T.NEXT_PROCESS_DESC,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.MAT_ORIGIN_CODE,
       T.MAT_ORIGIN_NAME,
       T.ACT_DIMATER,
       T.ACT_HEIGHT,
       T.ACT_LEN,
       T.ACT_LEN_MIN,
       T.ACT_LEN_MAX,
       T.ACT_COUNT,
       T.ACT_WEIGHT,
       T.ACT_THEORY_WEIGHT,
       T.MEASURE_FLAG,
       T.BELONG_CODE,
       T.BELONG_NAME,
       T.PACK_FLAG,
       T.MAT_GOWHERE_CODE,
       T.MAT_GOWHERE_NAME,
       T.MAT_RETURN_FLAG,
       T.LOCK_FLAG,
       T.MNG_LOCK_FLAG,
       T.JUGDE_APPLY_FLAG,
       T.JUGDE_APPLY_CODE,
       TO_CHAR(T.JUGDE_APPLY_TIME, 'YYYY-MM-DD HH24:MI:SS') JUGDE_APPLY_TIME,
       T.FACE_RESULT_CODE,
       TO_CHAR(T.FACE_RESULT_TIME, 'YYYY-MM-DD HH24:MI:SS') FACE_RESULT_TIME,
       T.FACE_MAKER,
       T.SPEC_RESULT_CODE,
       TO_CHAR(T.SPEC_RESULT_TIME, 'YYYY-MM-DD HH24:MI:SS') SPEC_RESULT_TIME,
       T.SPEC_MAKER,
       T.CHEM_RESULT_CODE,
       TO_CHAR(T.CHEM_RESULT_TIME, 'YYYY-MM-DD HH24:MI:SS') CHEM_RESULT_TIME,
       T.CHEM_MAKER,
       T.PHY_RESULT_CODE,
       TO_CHAR(T.PHY_RESULT_TIME, 'YYYY-MM-DD HH24:MI:SS') PHY_RESULT_TIME,
       T.PHY_MAKER,
       T.DETECT_RESULT_CODE,
       T.WPRESSURE_RESULT_CODE,
       T.JUDGE_RESULT_CODE,
       T.JUDGE_RESULT,
       TO_CHAR(T.JUDGE_RESULT_TIME, 'YYYY-MM-DD HH24:MI:SS') JUDGE_RESULT_TIME,
       T.JUDGE_MAKER,
       T.INSTOCK_FLAG,
       TO_CHAR(T.INSTOCK_TIME, 'YYYY-MM-DD HH24:MI:SS') INSTOCK_TIME,
       T.BAR_CODE,
       T.MEMO,
       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.ORD_PK,
       T.ORD_LN_PK,
       T.ORD_LN_DLY_PK,
       T.BAL_YEAR_MONTH,
       T.JUDGE_STD_NAME,
       T.PIPMEMO,
       T.SOURE_CODE,
       T.SOURE_NAME,
       T.PONDER_NO,
       T.PONDER_GROSS_WT,
       T.JUDGE_ID,
       T.LOCK_LIKU,
       T.QCM_STAUS,
       T.OUTSTOCK_DOC,
       T.HEAT_PLAN_NO,
       T.ZG_STOVE_SQE,
       T.GX_PLAN_NO,
       T.ZG_MAT_NO,
       T.TARGET,
       T.PROCESS_STATUS,
       T.JUGDE_CONVICTED,
       T.FIXTYPE_CODE,
       T.QUALITY_GROUP_ZG,
       T.FLAG_STOVE_NO_ZG,
       T.DETECT_RESULT_CODE1,
       T.TESTING_GRADE,
       T.TESTING_TYPE,
       T.TESTING_GRADE1,
       T.TESTING_TYPE1,
       T.JUDGE_STOVE_NO_UP,
       T.CRAFT_SEQ,
       T.PRO_PLAN_ID_NEXT,
       T.GX_PLAN_NO_NEXT,
       T.HANGING_FLAG,
       T.CUT_NUM,
       T.JUDGE_TOLRESULT_CODE,
       T.JUDGE_TOLRESULT,
       TO_CHAR(T.JUDGE_TOLRESULT_TIME, 'YYYY-MM-DD HH24:MI:SS') JUDGE_TOLRESULT_TIME,
       T.JUDGE_TOLMAKER,
       T.INSTANCY_FLAG,
       T.JUGDE_TOLCONVICTED,
       T.JUDGE_STD_DES,
       T.MNG_LOCK_REMARK,
       T.LOCK_REMARK,
       T.JUGDE_APPLY_SEQUENO,
       T.HEAT_PLAN_NO_NEXT
 FROM MAT_BC_BACKUP T
 WHERE T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
 AND T.BATCH_NO = '#BATCH_NO#'
 AND T.PROCESS_CDOE = '#PROCESS_CDOE#'
    AND T.BELONG_CODE = '#BELONG_CODE#'
    AND T.MATERIAL_NAME = '#MATERIAL_NAME#')
 WHERE ROWNUM = 1
</query>
    <query id = "FrmBcRunTimeReport.selectMatInformation1" desc = "查询材料信息">
        SELECT MAX(T.PRODUCT_FLAG) PRODUCT_FLAG,
        MAX(T.MAT_STATUS) MAT_STATUS,
        MAX(T.LOT_NO) LOT_NO,
        MAX(T.STOVE_NO) STOVE_NO,
        T.JUDGE_STOVE_NO,
        T.BATCH_NO,
        MAX(T.BATCH_GROUD_NO)BATCH_GROUD_NO,
        MAX(T.MATERIAL_NO) MATERIAL_NO,
        MAX(T.MATERIAL_NAME) MATERIAL_NAME,
        MAX(T.PRODUCCODE) PRODUCCODE,
        MAX(T.PRODUCNAME) PRODUCNAME,
        MAX(T.STEELCODE) STEELCODE,
        MAX(T.STEELNAME) STEELNAME,
        MAX(T.GRADECODE) GRADECODE,
        MAX(T.GRADENAME) GRADENAME,
        MAX(T.SPEC_CODE) SPEC_CODE,
        MAX(T.SPEC_NAME) SPEC_NAME,
        MAX(T.MODEL_CODE) MODEL_CODE,
        MAX(T.MODEL_DESC) MODEL_DESC,
        MAX(T.STD_CODE) STD_CODE,
        MAX(T.STD_NAME) STD_NAME,
        MAX(T.STD_STYLE) STD_STYLE,
        MAX(T.STD_STYLE_DESC) STD_STYLE_DESC,

        MAX(T.PLINE_CODE) PLINE_CODE,
        MAX(T.PLINE_NAME) PLINE_NAME,
        MAX(T.ACT_DIMATER) ACT_DIMATER,
        MAX(T.ACT_HEIGHT) ACT_HEIGHT,
        MAX(T.ACT_LEN_MIN) ACT_LEN_MIN,
        MAX(T.ACT_LEN_MAX) ACT_LEN_MAX,
        MAX(T.ACT_LEN)ACT_LEN,
        SUM(T.ACT_COUNT) ACT_COUNT,
        SUM(T.ACT_WEIGHT) ACT_WEIGHT,
        MAX(TO_CHAR(T.INSTOCK_TIME, 'YYYY-MM-DD HH24:MI:SS')) INSTOCK_TIME,
        S.STORAGE_NO,
        (SELECT S1.STORAGE_NAME
        FROM YDM_BS_STORAGE S1
        WHERE S1.STORAGE_NO = S.STORAGE_NO) STORAGE_NAME
        FROM MAT_BC_M T
        LEFT JOIN YDM_BC_BUTTRESS S
        ON T.MAT_NO = S.MAT_NO
        WHERE T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
        AND T.BATCH_NO = '#BATCH_NO#'
        AND T.PLINE_CODE = '#PLINE_CODE#'
        AND T.BELONG_CODE = '#BELONG_CODE#'
        GROUP BY T.JUDGE_STOVE_NO, T.BATCH_NO, T.BATCH_GROUD_NO, S.STORAGE_NO

    </query>
<query id = "FrmBcRunTimeReport.selectOutList" desc = "查询">
 SELECT 
       T.OUTSTOCK_SQE,
       T.OUTSTOCK_PLAN_NO,
       T.OUTSTOCK_DOC,
       T.OUTSTOCK_TYPE_CODE,
       T.OUTSTOCK_TYPE_NAME,
       T.ICCAR_NO,
       T.VEHICLE_NO,
       T.MAT_NO,
       T.LOT_NO,
       T.STOVE_NO,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.BATCH_GROUD_NO,
       T.MATERIAL_NO,
       T.MATERIAL_NAME,
       T.PRODUCCODE,
       T.PRODUCNAME,
       T.STD_CODE,
       T.STD_NAME,
       T.GRADECODE,
       T.GRADENAME,
       T.STEELCODE,
       T.STEELNAME,
       T.STD_STYLE,
       T.STD_STYLE_DESC,
       T.SPEC_CODE,
       T.SPEC_NAME,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.PRO_ORDER_NO,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.ACT_DIMATER,
       T.ACT_HEIGHT,
       T.ACT_LEN,
       T.ACT_LEN_MIN,
       T.ACT_LEN_MAX,
       T.ACT_COUNT,
       T.ACT_WEIGHT,
       T.ACT_THEORY_WEIGHT,
       T.BELONG_CODE,
       T.BELONG_NAME,
       T.BAR_CODE,
       T.STORAGE_NO,
       T.LOCATION_NO,
       T.LARY_NO,
       T.LOC_NO,
       T.STORAGE_ATTR,
       T.STORAGE_ATTR_NAME,
       T.STORAGE_TYPE_NO,
       T.STORAGE_TYPE_NAME,
       T.MANAGEMENT_NO,
       T.MANAGEMENT_NAME,
       T.TAR_STORAGE_NO,
       T.TAR_LOCATION_NO,
       T.TAR_LARY_NO,
       T.TAR_LOC_NO,
       T.TAR_STORAGE_ATTR,
       T.TAR_STORAGE_ATTR_NAME,
       T.TAR_STORAGE_TYPE_NO,
       T.TAR_STORAGE_TYPE_NAME,
       T.TAR_MANAGEMENT_NO,
       T.TAR_MANAGEMENT_NAME,
       T.TAR_REC_FLAG,
       TO_CHAR(T.RPO_TIME, 'YYYY-MM-DD HH24:MI:SS') RPO_TIME,
       T.PRO_BC,
       T.PRO_BZ,
       TO_CHAR(T.INSTOCK_TIME, 'YYYY-MM-DD HH24:MI:SS') INSTOCK_TIME,
       T.IN_BC,
       T.IN_BZ,
       TO_CHAR(T.OUTSTOCK_TIME, 'YYYY-MM-DD HH24:MI:SS') OUTSTOCK_TIME,
       T.OUT_BC,
       T.OUT_BZ,
       T.MEMO,
       T.HAND_FLAG,
       T.VALIDFLAG,
       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.DELETE_NAME,
       TO_CHAR(T.DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
       T.ORD_PK,
       T.ORD_LN_PK,
       T.ORD_LN_DLY_PK,
       T.DEPARTMENT_CODE,
       T.DEPARTMENT_DESC,
       T.TAR_DEPARTMENT_CODE,
       T.TAR_DEPARTMENT_DESC,
       T.ORDER_NO,
       T.ORDER_SEQ,
       T.DELIVERY_NO,
       T.PRODUCT_FLAG,
       T.MAT_STATUS,
       T.JUDGE_STD_NAME,
       T.JUDGE_STD_CODE,
       T.PONDER_NO,
       T.PONDER_GROSS_WT,
       T.VSTEL,
       T.VSTEL_DESC,
       T.BAL_YEAR_MONTH,
       T.M_BILL_NO,
       T.SEND_NUM,
       T.RECEIV_NO,
       T.RECEIV_NM,
       T.FINISHPRO_MOLD,
       T.IN_MOLD,
       T.LOAD_PLINE_CODE,
       T.LOAD_PLINE_NAME,
       T.PROCESS_CDOE,
       T.PROCESS_DESC
 FROM YDM_BC_OUTLIST T
 WHERE T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
 AND T.BATCH_NO = '#BATCH_NO#'
 AND T.PROCESS_CDOE = '#PROCESS_CDOE#'
    AND T.BELONG_CODE = '#BELONG_CODE#'
    AND T.MATERIAL_NAME = '#MATERIAL_NAME#'
 AND T.OUTSTOCK_TYPE_CODE = '800806'
</query>
<query id = "FrmBcRunTimeReport.selectInList" desc = "查询入库记录">
 SELECT 
       T.INSTOCK_SQE,
       T.INSTOCK_DOC,
       T.INSTOCK_TYPE_CODE,
       T.INSTOCK_TYPE_NAME,
       T.INSTOCK_BAR_CODE,
       T.ICCAR_NO,
       T.VEHICLE_NO,
       T.MAT_NO,
       T.LOT_NO,
       T.STOVE_NO,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.BATCH_GROUD_NO,
       T.MATERIAL_NO,
       T.MATERIAL_NAME,
       T.PRODUCCODE,
       T.PRODUCNAME,
       T.STD_CODE,
       T.STD_NAME,
       T.GRADECODE,
       T.GRADENAME,
       T.STEELCODE,
       T.STEELNAME,
       T.STD_STYLE,
       T.STD_STYLE_DESC,
       T.SPEC_CODE,
       T.SPEC_NAME,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.PRO_ORDER_NO,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.ACT_DIMATER,
       T.ACT_HEIGHT,
       T.ACT_LEN,
       T.ACT_LEN_MIN,
       T.ACT_LEN_MAX,
       T.ACT_COUNT,
       T.ACT_WEIGHT,
       T.ACT_THEORY_WEIGHT,
       T.BELONG_CODE,
       T.BELONG_NAME,
       T.STORAGE_NO,
       T.LOCATION_NO,
       T.LARY_NO,
       T.LOC_NO,
       T.STORAGE_ATTR,
       T.STORAGE_ATTR_NAME,
       T.STORAGE_TYPE_NO,
       T.STORAGE_TYPE_NAME,
       T.MANAGEMENT_NO,
       T.MANAGEMENT_NAME,
       TO_CHAR(T.RPO_TIME, 'YYYY-MM-DD HH24:MI:SS') RPO_TIME,
       T.PRO_BC,
       T.PRO_BZ,
       TO_CHAR(T.INSTOCK_TIME, 'YYYY-MM-DD HH24:MI:SS') INSTOCK_TIME,
       T.IN_BC,
       T.IN_BZ,
       T.BAR_CODE,
       T.HAND_FLAG,
       T.MEMO,
       T.VALIDFLAG,
       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.DELETE_NAME,
       TO_CHAR(T.DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
       T.ORD_PK,
       T.ORD_LN_PK,
       T.ORD_LN_DLY_PK,
       T.DEPARTMENT_CODE,
       T.DEPARTMENT_DESC,
       T.ORDER_NO,
       T.ORDER_SEQ,
       T.DELIVERY_NO,
       T.PRODUCT_FLAG,
       T.MAT_STATUS,
       T.ZB_RCDID,
       T.JUDGE_STD_NAME,
       T.JUDGE_STD_CODE,
       TO_CHAR(T.IN_TIME_F, 'YYYY-MM-DD HH24:MI:SS') IN_TIME_F,
       T.BAL_YEAR_MONTH,
       T.LEN_NO,
       T.LEN_DESC,
       T.LEN_UNIT,
       T.PIPMEMO,
       T.SOURE_CODE,
       T.SOURE_NAME,
       T.MAT_ORIGIN_CODE,
       T.MAT_ORIGIN_NAME,
       T.AFFIRM_LOG,
       T.M_BILL_NO,
       T.ZG_STOVE_SQE,
       T.IN_MOLD,
       T.PACK_NO,
       T.QCM_STAUS,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       T.SUBCONTRACT_NO,
       T.DATA_SUORCE,
       T.OUTSTOCK_DOC,
       T.PROCESS_CDOE,
       T.PROCESS_DESC
 FROM YDM_BC_INLIST T
 WHERE T.INSTOCK_TYPE_CODE IN('800709','800704')
   AND T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
   AND T.BATCH_NO = '#BATCH_NO#'
   AND T.PROCESS_CDOE = '#PROCESS_CDOE#'
    AND T.BELONG_CODE = '#BELONG_CODE#'
    AND NVL(T.MATERIAL_NAME,'/') = NVL('#MATERIAL_NAME#','/')
</query>
<query id = "FrmBcRunTimeReport.insertInital" desc = "插入期初表">
 INSERT INTO YDM_BC_INITIAL(
        JUDGE_STOVE_NO,
        BATCH_NO,
        BATCH_GROUD_NO,
        PRODUCT_FLAG,
        MAT_STATUS,
        MATERIAL_NO,
        MATERIAL_NAME,
        PRODUCCODE,
        PRODUCNAME,
        STEELCODE,
        STEELNAME,
        SPEC_CODE,
        SPEC_NAME,
        MODEL_CODE,
        MODEL_DESC,
        STD_CODE,
        STD_NAME,
        STD_STYLE,
        STD_STYLE_DESC,
        DIMATER,
        HEIGHT,
        LEN,
        LEN_MIN,
        LEN_MAX,
        ACT_COUNT,
        ACT_WEIGHT,
        CREATE_NAME,
        CREATE_TIME,
        BAL_YEAR_MONTH,
        GRADECODE,
        GRADENAME,
        PLINE_CODE,
        PLINE_NAME,
        INSTOCK_TIME,
        BELONG_CODE,
        BELONG_NAME,
        LOT_NO,
        STOVE_NO,
        JUDGE_STD_DES,
    STORAGE_NO,
    STORAGE_NAME,
    PROCESS_CDOE,
    PROCESS_DESC)
 VALUES( 
        '#JUDGE_STOVE_NO#',
        '#BATCH_NO#',
        '#BATCH_GROUD_NO#',
        '#PRODUCT_FLAG#',
        '#MAT_STATUS#',
        '#MATERIAL_NO#',
        '#MATERIAL_NAME#',
        '#PRODUCCODE#',
        '#PRODUCNAME#',
        '#STEELCODE#',
        '#STEELNAME#',
        '#SPEC_CODE#',
        '#SPEC_NAME#',
        '#MODEL_CODE#',
        '#MODEL_DESC#',
        '#STD_CODE#',
        '#STD_NAME#',
        '#STD_STYLE#',
        '#STD_STYLE_DESC#',
        '#DIMATER#',
        '#HEIGHT#',
        '#LEN#',
        '#LEN_MIN#',
        '#LEN_MAX#',
        '#ACT_COUNT#',
        '#ACT_WEIGHT#',
        '#CREATE_NAME#',
        SYSDATE,
        '#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#',
        '#STOVE_NO#',
        '#JUDGE_STD_DES#',
        '#STORAGE_NO#',
        '#STORAGE_NAME#',
    '#PROCESS_CDOE#',
    '#PROCESS_DESC#')
</query>
<query id = "FrmBcRunTimeReport.updateCarry" desc = "修改判定数据结转标识">
UPDATE QCM_ZG_JUGDE_APPLY T
   SET T.IS_CARRY_VOER = '1'
 WHERE T.BAL_YEAR_MONTH = '#BAL_YEAR_MONTH#'
    AND T.BELONG_CODE_JUGDE = '#BELONG_CODE_JUGDE#'
   AND ((T.VALIDFLAG = '20' AND T.JUDGE_RESULT_CODE IN('40740701','40740709')) OR
       (T.VALIDFLAG = '00' AND T.INSTANCY_FLAG = '1'))
   AND T.IS_FLAG = '0'
   AND T.TARGET IN('B','C')
</query>
</queryMap>