feat: 看板上下行数据
This commit is contained in:
@@ -123,10 +123,9 @@ export async function getGoldTitleByNE(neType: string) {
|
|||||||
* @returns object
|
* @returns object
|
||||||
*/
|
*/
|
||||||
export async function listUPFData(timeArr: any) {
|
export async function listUPFData(timeArr: any) {
|
||||||
|
|
||||||
const initTime: Date = new Date();
|
const initTime: Date = new Date();
|
||||||
const twentyFourHoursAgo: Date = new Date(
|
const twentyFourHoursAgo: Date = new Date(
|
||||||
initTime.getTime() - 10*60 * 1000
|
initTime.getTime() - 10 * 60 * 1000
|
||||||
);
|
);
|
||||||
|
|
||||||
return await Promise.allSettled([
|
return await Promise.allSettled([
|
||||||
@@ -135,7 +134,9 @@ export async function listUPFData(timeArr: any) {
|
|||||||
url: `/api/rest/databaseManagement/v1/select/omc_db/gold_kpi`,
|
url: `/api/rest/databaseManagement/v1/select/omc_db/gold_kpi`,
|
||||||
method: 'get',
|
method: 'get',
|
||||||
params: {
|
params: {
|
||||||
SQL: `SELECT gold_kpi.*,kpi_title.en_title FROM gold_kpi LEFT JOIN kpi_title on gold_kpi.kpi_id=kpi_title.kpi_id where 1=1 and gold_kpi.kpi_id ='UPF.06' and timestamp BETWEEN '${parseDateToStr(twentyFourHoursAgo)}' AND '${parseDateToStr(initTime)}' `,
|
SQL: `SELECT gold_kpi.*,kpi_title.en_title FROM gold_kpi LEFT JOIN kpi_title on gold_kpi.kpi_id=kpi_title.kpi_id where 1=1 and gold_kpi.kpi_id ='UPF.06' and timestamp BETWEEN '${parseDateToStr(
|
||||||
|
twentyFourHoursAgo
|
||||||
|
)}' AND '${parseDateToStr(initTime)}' `,
|
||||||
// SQL: `SELECT gold_kpi.kpi_id, sum(gold_kpi.value) as index, kpi_title.en_title
|
// SQL: `SELECT gold_kpi.kpi_id, sum(gold_kpi.value) as index, kpi_title.en_title
|
||||||
// FROM gold_kpi
|
// FROM gold_kpi
|
||||||
// LEFT JOIN kpi_title on gold_kpi.kpi_id=kpi_title.kpi_id
|
// LEFT JOIN kpi_title on gold_kpi.kpi_id=kpi_title.kpi_id
|
||||||
@@ -151,7 +152,9 @@ export async function listUPFData(timeArr: any) {
|
|||||||
url: `/api/rest/databaseManagement/v1/select/omc_db/gold_kpi`,
|
url: `/api/rest/databaseManagement/v1/select/omc_db/gold_kpi`,
|
||||||
method: 'get',
|
method: 'get',
|
||||||
params: {
|
params: {
|
||||||
SQL: `SELECT gold_kpi.*,kpi_title.en_title FROM gold_kpi LEFT JOIN kpi_title on gold_kpi.kpi_id=kpi_title.kpi_id where 1=1 and gold_kpi.kpi_id ='UPF.03' and timestamp BETWEEN '${parseDateToStr(twentyFourHoursAgo)}' AND '${parseDateToStr(initTime)}' `,
|
SQL: `SELECT gold_kpi.*,kpi_title.en_title FROM gold_kpi LEFT JOIN kpi_title on gold_kpi.kpi_id=kpi_title.kpi_id where 1=1 and gold_kpi.kpi_id ='UPF.03' and timestamp BETWEEN '${parseDateToStr(
|
||||||
|
twentyFourHoursAgo
|
||||||
|
)}' AND '${parseDateToStr(initTime)}' `,
|
||||||
},
|
},
|
||||||
timeout: 60_000,
|
timeout: 60_000,
|
||||||
}),
|
}),
|
||||||
@@ -200,33 +203,3 @@ export async function listUPFData(timeArr: any) {
|
|||||||
return { upData, downData };
|
return { upData, downData };
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 首页查询UPF上下行字节数
|
|
||||||
* @param query 查询参数
|
|
||||||
* @returns object
|
|
||||||
*/
|
|
||||||
export async function listUPFIndex() {
|
|
||||||
const initTime: Date = new Date();
|
|
||||||
const twentyFourHoursAgo: Date = new Date(
|
|
||||||
initTime.getTime() - 24 * 60 * 60 * 1000
|
|
||||||
);
|
|
||||||
// 发起请求
|
|
||||||
const result = await request({
|
|
||||||
url: `/api/rest/databaseManagement/v1/select/omc_db/gold_kpi`,
|
|
||||||
method: 'get',
|
|
||||||
params: {
|
|
||||||
SQL: `SELECT gold_kpi.kpi_id, sum(gold_kpi.value) as Total FROM gold_kpi WHERE 1=1 AND gold_kpi.kpi_id in('UPF.06','UPF.03') AND timestamp BETWEEN '${parseDateToStr(
|
|
||||||
twentyFourHoursAgo
|
|
||||||
)}' AND '${parseDateToStr(initTime)}' GROUP BY gold_kpi.kpi_id`,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
// 解析数据
|
|
||||||
if (result.code === RESULT_CODE_SUCCESS && Array.isArray(result.data.data)) {
|
|
||||||
let data = result.data.data[0];
|
|
||||||
return Object.assign(result, {
|
|
||||||
data: parseObjLineToHump(data['gold_kpi']),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -151,15 +151,25 @@ export function parseSizeFromKbs(sizeByte: number, timeInterval: number): any {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 字节数转换单位
|
* 字节数转换单位
|
||||||
* @param sizeByte 数值大小
|
* @param bits 比特b大小
|
||||||
* @returns
|
* @returns MB
|
||||||
*/
|
*/
|
||||||
export function formatBytes(bytes: number): string {
|
export function parseSizeFromBytes(bits: number | string): string {
|
||||||
if (bytes === 0) {
|
bits = Number(bits) || 0;
|
||||||
return '0 B'; // 处理 bytes 为 0 的情况
|
const byte = bits / 8;
|
||||||
|
const kb = byte / 1024;
|
||||||
|
const mb = kb / 1024;
|
||||||
|
const gb = mb / 1024;
|
||||||
|
const tb = gb / 1024;
|
||||||
|
|
||||||
|
if (tb >= 1) {
|
||||||
|
return tb.toFixed(2) + ' TB';
|
||||||
|
} else if (gb >= 1) {
|
||||||
|
return gb.toFixed(2) + ' GB';
|
||||||
|
} else if (mb >= 1) {
|
||||||
|
return mb.toFixed(2) + ' MB';
|
||||||
|
} else if (kb >= 1) {
|
||||||
|
return kb.toFixed(2) + ' KB';
|
||||||
}
|
}
|
||||||
const units = ['B', 'KB', 'MB', 'GB', 'TB'];
|
return bits + ' B';
|
||||||
const unitIndex = Math.floor(Math.log2(bytes) / 10);
|
|
||||||
const result =(bytes / Math.pow(1024, unitIndex)).toFixed(2) + ' ' + units[unitIndex];
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|||||||
38
src/views/dashboard/overview/hooks/useUPFTotalFlow.ts
Normal file
38
src/views/dashboard/overview/hooks/useUPFTotalFlow.ts
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
import { parseSizeFromBytes } from '@/utils/parse-utils';
|
||||||
|
import { reactive, ref } from 'vue';
|
||||||
|
|
||||||
|
type TFType = {
|
||||||
|
/**上行 N3 */
|
||||||
|
up: string;
|
||||||
|
/**下行 N6 */
|
||||||
|
down: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**UPF-总流量数 */
|
||||||
|
export const upfTotalFlow = ref<TFType[]>([
|
||||||
|
// 0天 当天24小时
|
||||||
|
{
|
||||||
|
up: '0 B',
|
||||||
|
down: '0 B',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
up: '0 B',
|
||||||
|
down: '0 B',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
up: '0 B',
|
||||||
|
down: '0 B',
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
/**UPF-总流量数 数据解析 */
|
||||||
|
export function upfTFParse(data: Record<string, string>) {
|
||||||
|
let { up, down } = data;
|
||||||
|
up = parseSizeFromBytes(up);
|
||||||
|
down = parseSizeFromBytes(down);
|
||||||
|
return { up, down };
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**UPF-总流量数 选中 */
|
||||||
|
export const upfTFActive = ref<number>(0);
|
||||||
Reference in New Issue
Block a user