From 994e5e08cba4e6b9ce321b7cf5cb1ec8d19dfa22 Mon Sep 17 00:00:00 2001 From: ZZJ <zzjdsg2300@163.com> Date: 星期二, 12 四月 2022 17:50:21 +0800 Subject: [PATCH] 摄像机管理 --- src/Pool/PollData.ts | 110 +++++++++++++++++++++++++++---------------------------- 1 files changed, 54 insertions(+), 56 deletions(-) diff --git a/src/Pool/PollData.ts b/src/Pool/PollData.ts index e30b8ad..da79eb0 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,71 +125,62 @@ } } 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)) - } - this.barCharts = [this.DiskUsePercent,this.CpuUsedPercent,this.GpuUsedPercent,this.MemUsedPercent] + let res: any + if(sessionStorage.getItem("clusterId")) { + res = await clusterSysInfo({}); } - - console.log(this); - + else { + res = await devicesSysInfo({}); + } + 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({}); + } + if (res && res.success) { // console.log(res,'缁熻瀹炴椂銆佽疆璇㈡暟閲�') this.RealTimeSum = res.data.realTotal -- Gitblit v1.8.0