<?xml version="1.0" encoding="UTF-8"?>
<queryMap>
    <query id = "FrmStorageInfo.doQuery" desc = "查询">
        SELECT
        (SELECT T3.STORAGE_NAME FROM YDM_BS_STORAGE T3 WHERE T3.STORAGE_NO = T2.STORAGE_NO)  AS STORAGE_NAME,
        (SELECT T4.LOCATION_NAME FROM YDM_BS_LOCATION T4 WHERE T4.LOCATION_NO = T2.LOCATION_NO) AS LOCATION_NAME,
        SUM(T1.ACT_COUNT) AS ACT_COUNT,
        SUM(T1.ACT_WEIGHT) AS ACT_WEIGHT，
        SUM(T1.ACT_LEN) AS ACT_LEN
        FROM MAT_BC_M T1
        LEFT JOIN  YDM_BC_BUTTRESS T2 ON T1.MAT_NO=T2.MAT_NO
        LEFT JOIN YDM_BS_STORAGE S ON S.STORAGE_NO=T2.STORAGE_NO
        LEFT JOIN YDM_BS_LOCATION B ON B.LOCATION_NO = T2.LOCATION_NO
        WHERE
        T1.MAT_NO = T2.MAT_NO
       #STORAGE_NO# #STORAGE_NAME# #LOCATION_NAME#
        GROUP BY T2.STORAGE_NO,T2.LOCATION_NO
        UNION ALL
        SELECT
        (SELECT T3.STORAGE_NAME FROM YDM_BS_STORAGE T3 WHERE T3.STORAGE_NO = T2.STORAGE_NO)  AS STORAGE_NAME,
        (SELECT T4.LOCATION_NAME FROM YDM_BS_LOCATION T4 WHERE T4.LOCATION_NO = T2.LOCATION_NO) AS LOCATION_NAME,
        SUM(T1.ACT_COUNT) AS ACT_COUNT,
        SUM(T1.ACT_WEIGHT) AS ACT_WEIGHT,
        SUM(T1.ACT_LEN) AS ACT_LEN
        FROM MAT_ZC_M T1
        LEFT JOIN  YDM_ZC_BUTTRESS T2 ON T1.MAT_NO=T2.MAT_NO
        LEFT JOIN YDM_BS_STORAGE S ON S.STORAGE_NO=T2.STORAGE_NO
        LEFT JOIN YDM_BS_LOCATION B ON B.LOCATION_NO = T2.LOCATION_NO
        WHERE T1.MAT_NO = T2.MAT_NO
        #STORAGE_NO# #STORAGE_NAME# #LOCATION_NAME#
        GROUP BY T2.STORAGE_NO,T2.LOCATION_NO
    </query>

    <query>
        SELECT B.STORAGE_NO, B.STORAGE_NAME, T.LOCATION_NO, T.LOCATION_NAME
        , (
        SELECT NVL(SUM(Z.ACT_COUNT),0) + NVL(SUM(B.ACT_COUNT),0)
        FROM YDM_ZC_BUTTRESS Y
        LEFT JOIN MAT_ZC_M Z ON Z.MAT_NO = Y.MAT_NO
        LEFT JOIN MAT_BC_M B ON B.MAT_NO = Y.MAT_NO
        WHERE Y.LOCATION_NO = T.LOCATION_NO
        ) AS ACT_COUNT
        , (
        SELECT NVL(SUM(Z.ACT_WEIGHT),0) + NVL(SUM(B.ACT_WEIGHT),0)
        FROM YDM_ZC_BUTTRESS Y
        LEFT JOIN MAT_ZC_M Z ON Z.MAT_NO = Y.MAT_NO
        LEFT JOIN MAT_BC_M B ON B.MAT_NO = Y.MAT_NO
        WHERE Y.LOCATION_NO = T.LOCATION_NO
        ) AS ACT_WEIGHT
        FROM YDM_BS_LOCATION T
        LEFT JOIN YDM_BS_STORAGE B ON T.STORAGE_NO = B.STORAGE_NO
        WHERE
        1=1
    </query>
</queryMap>