<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc  = "非合格品申请用车">
    <query id = "FrmBcM.doQuery" desc = "查询非合格品库存">
        SELECT
        DECODE(T.PRODUCT_FLAG,'801401','在制品','801402','成品','801403','商品')PRODUCT_FLAG,
        T.STOVE_NO,
        T.LOT_NO,
        T.FLAG_STOVE_NO_ZG,
        T.JUDGE_STOVE_NO,
        T.BATCH_NO,
        T.MATERIAL_NO,
        T.MATERIAL_NAME,
        T.MATERIAL_NO OLD_MATERIAL_NO,
        T.MATERIAL_NAME OLD_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,
        T.PRO_ORDER_ID,
        T.PROCESS_CDOE,
        T.PROCESS_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,
        SUM(T.ACT_LEN)ACT_LEN,
        MAX(T.ACT_LEN_MIN)ACT_LEN_MIN,
        MAX(T.ACT_LEN_MAX)ACT_LEN_MAX,
        SUM(T.ACT_COUNT)ACT_COUNT,
        SUM(T.ACT_WEIGHT)ACT_WEIGHT,
        MAX(T.BAL_YEAR_MONTH)BAL_YEAR_MONTH,
        MAX(T.TARGET)TARGET,
        DECODE(T.QCM_STAUS,'00','合格','11','待处理','22','判废','33','判废待审核')QCM_STAUS,
        MAX(T.JUDGE_RESULT_CODE)SPEC_RESULT_CODE,
        (SELECT S1.STORAGE_NAME FROM YDM_BS_STORAGE S1 WHERE S1.STORAGE_NO = S.STORAGE_NO)STORAGE_NAME,
        S.STORAGE_NO,
        MAX(T.CRAF_NO)CRAF_NO,
        T.HEAT_PLAN_NO
        FROM MAT_BC_M T,YDM_BC_BUTTRESS S
        WHERE T.MAT_NO = S.MAT_NO
        #JUDGE_STOVE_NO#
        #FLAG_STOVE_NO_ZG#
        #GROUP#
        UNION ALL
        SELECT DECODE(T.PRODUCT_FLAG,'801401','在制品','801402','成品','801403','商品')PRODUCT_FLAG,
        T.STOVE_NO,
        T.LOT_NO,
        T.FLAG_STOVE_NO_ZG,
        T.JUDGE_STOVE_NO,
        T.BATCH_NO,
        T.MATERIAL_NO,
        T.MATERIAL_NAME,
        T.MATERIAL_NO OLD_MATERIAL_NO,
        T.MATERIAL_NAME OLD_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,
        T.PRO_ORDER_ID,
        T.PROCESS_CDOE,
        T.PROCESS_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,
        SUM(T.ACT_LEN)ACT_LEN,
        MAX(T.ACT_LEN_MIN)ACT_LEN_MIN,
        MAX(T.ACT_LEN_MAX)ACT_LEN_MAX,
        SUM(T.ACT_COUNT)ACT_COUNT,
        SUM(T.ACT_WEIGHT)ACT_WEIGHT,
        MAX(T.BAL_YEAR_MONTH)BAL_YEAR_MONTH,
        MAX(T.TARGET)TARGET,
        '合格' QCM_STAUS,
        MAX(T.JUDGE_RESULT_CODE)SPEC_RESULT_CODE,
        (SELECT S1.STORAGE_NAME FROM YDM_BS_STORAGE S1 WHERE S1.STORAGE_NO = S.STORAGE_NO)STORAGE_NAME,
        S.STORAGE_NO,
        MAX(T.CRAF_NO)CRAF_NO,
        ''HEAT_PLAN_NO
        FROM MAT_ZC_M T,YDM_ZC_BUTTRESS S
        WHERE T.MAT_NO = S.MAT_NO
        AND T.PRODUCT_FLAG = '801402'
        #JUDGE_STOVE_NO#
        #FLAG_STOVE_NO_ZG#
        #GROUP#
        UNION ALL
        SELECT DECODE(T.PRODUCT_FLAG,'801401','在制品','801402','成品','801403','商品')PRODUCT_FLAG,
        T.STOVE_NO,
        T.LOT_NO,
        T.FLAG_STOVE_NO_ZG,
        T.JUDGE_STOVE_NO,
        T.BATCH_NO,
        T.MATERIAL_NO,
        T.MATERIAL_NAME,
        T.MATERIAL_NO OLD_MATERIAL_NO,
        T.MATERIAL_NAME OLD_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,
        T.PRO_ORDER_ID,
        T.PROCESS_CDOE,
        T.PROCESS_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,
        SUM(T.ACT_LEN)ACT_LEN,
        MAX(T.ACT_LEN_MIN)ACT_LEN_MIN,
        MAX(T.ACT_LEN_MAX)ACT_LEN_MAX,
        SUM(T.ACT_COUNT)ACT_COUNT,
        SUM(T.ACT_WEIGHT)ACT_WEIGHT,
        MAX(T.BAL_YEAR_MONTH)BAL_YEAR_MONTH,
        MAX(T.TARGET)TARGET,
        '合格' QCM_STAUS,
        MAX(T.JUDGE_RESULT_CODE)SPEC_RESULT_CODE,
        (SELECT S1.STORAGE_NAME FROM YDM_BS_STORAGE S1 WHERE S1.STORAGE_NO = S.STORAGE_NO)STORAGE_NAME,
        S.STORAGE_NO,
        MAX(T.CRAF_NO)CRAF_NO,
        ''HEAT_PLAN_NO
        FROM MAT_ZC_M T,YDM_ZC_BUTTRESS S
        WHERE T.MAT_NO = S.MAT_NO
        AND T.PRODUCT_FLAG = '801403'
        #JUDGE_STOVE_NO#
        #FLAG_STOVE_NO_ZG#
        #GROUP#
    </query>
    <query id = "FrmBcM.getDemandUser" desc = "查询需求单位">
        SELECT T.PLINE_NAME,T.PLINE_CODE FROM COM_BASE_PLINE T WHERE 1 = 1
    </query>
    <query id = "FrmBcM.getUnLoad" desc = "查询产线下的装卸点">
        SELECT T.UNLOADING_DESC,T.UNLOADING_CODE FROM TMS_COM_UNLOADING T WHERE T.UNLOADING_AREA_CODE = ?
    </query>
    <query id = "FrmBcM.doQueryWeight" desc = "查询重量">
        <![CDATA[
        SELECT NVL(SUM(T.ACT_WEIGHT),0)ACT_WEIGHT
        FROM MAT_BC_M T, YDM_BC_BUTTRESS S
        WHERE T.MAT_NO = S.MAT_NO
        AND T.JUDGE_STOVE_NO = '#JUDGE_STOVE_NO#'
        AND T.BATCH_NO = '#BATCH_NO#'
        AND T.QCM_STAUS = '#QCM_STAUS#'
        AND T.PLINE_CODE = '#PLINE_CODE#'
        AND S.STORAGE_NO = '#STORAGE_NO#'
        AND ROWNUM <=#ACT_COUNT#
        ]]>
    </query>
</queryMap>