From f20a554bdb24e9dfde9dc6a69d78595944f61d15 Mon Sep 17 00:00:00 2001 From: mark <mark18340872469@163.com> Date: 星期二, 25 十月 2022 14:53:57 +0800 Subject: [PATCH] 设备管理 样式调整 --- src/Pool/PollData.ts | 112 ++++++++++++++++++++++++++++++-------------------------- 1 files changed, 60 insertions(+), 52 deletions(-) diff --git a/src/Pool/PollData.ts b/src/Pool/PollData.ts index 3ecfc8d..cbd192b 100644 --- a/src/Pool/PollData.ts +++ b/src/Pool/PollData.ts @@ -1,5 +1,11 @@ -import { getPollConfig, changeRunType, getCamerasByServer, statisticRunInfo, updateChannelCount } from "@/api/pollConfig"; -import { getSystemSummaryInfo, getSysThresholds } from "@/api/system" +import { getPollConfig, changeRunType, getCamerasByServer, updateChannelCount } from "@/api/pollConfig"; +import { getSysThresholds } from "@/api/system" +import { + clusterStatisticRunInfo, + deviceStatisticRunInfo, + devicesSysInfo, + clusterSysInfo +} from "@/api/clusterManage"; export default class PollData { public Config: Object = {}; @@ -62,6 +68,7 @@ //绠楀姏閰嶇疆涓粦鍧楁暟鎹� public sliderList: Array<any> = []; + public init() { this.fetchPollConfig(); this.fetchPollList(); @@ -118,68 +125,69 @@ } } public async statistics() { - let list = [] + // let list = [] - let rsp: any = await getCamerasByServer({ cameraName: "" }); - if (rsp && rsp.success) { - list = list.concat(rsp.data); - } + // let rsp: any = await getCamerasByServer({ cameraName: "" }); + // if (rsp && rsp.success) { + // list = list.concat(rsp.data); + // } - let RealTimeSum = 0, RealTimeRun = 0, PollSum = 0, PollRun = 0; + // let RealTimeSum = 0, RealTimeRun = 0, PollSum = 0, PollRun = 0; - list.forEach((cam: any) => { - if (cam.run_type === 1) { - RealTimeSum++ - if (cam.is_running) { - RealTimeRun++ - } - } + // list.forEach((cam: any) => { + // if (cam.run_type === 1) { + // RealTimeSum++ + // if (cam.is_running) { + // RealTimeRun++ + // } + // } - if (cam.run_type === 0) { - PollSum++ - if (cam.is_running) { - PollRun++ - } - } - }) + // if (cam.run_type === 0) { + // PollSum++ + // if (cam.is_running) { + // PollRun++ + // } + // } + // }) - this.Running = RealTimeRun + PollRun - this.Idle = RealTimeSum + PollSum - this.Running + // this.Running = RealTimeRun + PollRun + // this.Idle = RealTimeSum + PollSum - this.Running // 璁$畻绯荤粺淇℃伅 - rsp = await getSystemSummaryInfo() - if (rsp && rsp.success && rsp.data.cpu) { - let sysinfo = rsp.data - - // cpu - if (sysinfo.cpu) { - let cpuLoad = sysinfo.cpu.reduce((pre, item) => { - return pre + item; - }, 0) - - this.CpuUsedPercent = Number((cpuLoad / sysinfo.cpu.length).toFixed(2)) - } - - // 鍐呭瓨 - this.MemUsedPercent = Number(sysinfo.mem.usedPercent.toFixed(2)) - // 纭洏浣跨敤鎯呭喌 - this.DiskUsePercent = Number(sysinfo.disk.usedPercent.toFixed(2)) - - if (sysinfo.gpu) { - let gpuLoad = 0, gpuTotal = 0; - - for (let i = 0; i < sysinfo.gpu.length; i++) { - gpuLoad += sysinfo.gpu[i].used; - gpuTotal += sysinfo.gpu[i].memory; - } - this.GpuUsedPercent = Number((gpuLoad / gpuTotal * 100).toFixed(2)) - } + let res: any + if(sessionStorage.getItem("clusterId")) { + res = await clusterSysInfo({ + clusterId: "", + }); + } + else { + res = await devicesSysInfo({ + deviceId:[sessionStorage.getItem('devId')], + }); + } + if (res && res.success ) { + this.CpuUsedPercent =res.data.cpu.usedPercent.toFixed(2) + this.MemUsedPercent = res.data.mem.usedPercent.toFixed(2) + this.DiskUsePercent =res.data.disk.usedPercent.toFixed(2) + this.GpuUsedPercent = res.data.gpu.usedPercent.toFixed(2) this.barCharts = [this.DiskUsePercent,this.CpuUsedPercent,this.GpuUsedPercent,this.MemUsedPercent] + console.log(this.barCharts); + } } public async statisticTaskInfo() { - let res: any = await statisticRunInfo({}); + let res: any + if(sessionStorage.getItem("clusterId")) { + res = await clusterStatisticRunInfo({}); + } + else { + res = await deviceStatisticRunInfo({ + deviceId:[sessionStorage.getItem('devId')], + userId:'' + }); + } + if (res && res.success) { // console.log(res,'缁熻瀹炴椂銆佽疆璇㈡暟閲�') this.RealTimeSum = res.data.realTotal -- Gitblit v1.8.0