diff --git a/public/assets/noData.png b/public/assets/noData.png new file mode 100644 index 0000000..cf9cdd5 Binary files /dev/null and b/public/assets/noData.png differ diff --git a/src/models/apiurl.js b/src/models/apiurl.js index b0cad56..fd8d091 100644 --- a/src/models/apiurl.js +++ b/src/models/apiurl.js @@ -15,16 +15,23 @@ const guishiPro = '/shzh/ptjstest' const shengUrl2Pro = '' const nmjPro = '/shzh/jcsj' - - - const jsapi = { - ptjs: { czrz: shengUrlPro + '/prod-api/baseplat-system/operlog/hb/list', czdbl: guishiPro + '/monitor/summary', + export:guishiPro + '/monitor/export/', resource:guishiPro + '/resource/page', - treeList:shengUrlPro + "/prod-api/baseplat-basic/hb/village/getChild/" + treeList: shengUrlPro + "/prod-api/baseplat-basic/hb/village/getChild/", + cpuPage: guishiPro + '/cpu/page', + cpuQuery: guishiPro + '/cpu/list/query', + memoryQuery: guishiPro + '/memory/list/query', + diskQuery: guishiPro + '/disk/list/query', + memoryPage: guishiPro + '/memory/page', + diskPage: guishiPro + '/disk/page', + diskList: guishiPro + '/disk/list', + realCpu: guishiPro + '/cpu/latest', + realMemory: guishiPro + '/memory/latest', + realDisk: guishiPro + '/disk/latest', }, service: { diff --git a/src/models/session/index.js b/src/models/session/index.js index b8ee523..a036e41 100644 --- a/src/models/session/index.js +++ b/src/models/session/index.js @@ -274,7 +274,14 @@ const session = { id:121, redirect: "/ptjs/czrz", parent_id: -1, name: "平台监视", type: 1, order: 1, children: [ { id: 402, path: "/ptjs/czrz", parent_id: 500, name: "操作日志", type: 0, order: 1}, { id: 403, path: "/ptjs/czdbl", parent_id: 500, name: "测站到报率", type: 0, order: 1}, - { id: 404, path: "/ptjs/zysy", parent_id: 500, name: "资源使用", type: 0, order: 1}, + { + id: 404, path: "/ptjs/zysy", parent_id: 500, name: "资源使用", type: 0, order: 1, + children: [ + // { id: 407, path: "/ptjs/zysy/ls", parent_id: 500, name: "历史", type: 0, order: 1 }, + { id: 405, path: "/ptjs/zysy/sssj", parent_id: 500, name: "实时数据", type: 0, order: 1 }, + { id: 406, path: "/ptjs/zysy/lssj", parent_id: 500, name: "历史数据", type: 0, order: 1 }, + ] + }, ] }, diff --git a/src/routes.js b/src/routes.js index fe55fe3..3e07c70 100644 --- a/src/routes.js +++ b/src/routes.js @@ -44,8 +44,13 @@ const routes = [ // 测站到报率 { path: '/ptjs/czdbl', exact: true, component: lazy(() => import('./views/Ptjs/Czdbl')) }, + // 资源使用-实时数据 + { path: '/ptjs/zysy/sssj', exact: true, component: lazy(() => import('./views/Ptjs/Sssj')) }, + // 资源使用-历史数据 + { path: '/ptjs/zysy/lssj', exact: true, component: lazy(() => import('./views/Ptjs/Lssj')) }, + // 资源使用 - { path: '/ptjs/zysy', exact: true, component: lazy(() => import('./views/Ptjs/Zysy')) }, + { path: '/ptjs/zysy/ls', exact: true, component: lazy(() => import('./views/Ptjs/Zysy')) }, //监测站点 { path: '/jczd/zdbg', exact: true, component: lazy(() => import('./views/Jczd/Bg')) }, { path: '/jczd/zdsp', exact: true, component: lazy(() => import('./views/Jczd/Sp')) }, diff --git a/src/views/Ptjs/Czdbl/dblOption.js b/src/views/Ptjs/Czdbl/dblOption.js index b234666..42fdba2 100644 --- a/src/views/Ptjs/Czdbl/dblOption.js +++ b/src/views/Ptjs/Czdbl/dblOption.js @@ -68,7 +68,8 @@ export default function dblOption(sellist,selday) { }, saveAsImage: { show: true, - title: '保存为图片' + name:'日到报率详情', + title: '保存为图片' } } }, diff --git a/src/views/Ptjs/Czdbl/index.js b/src/views/Ptjs/Czdbl/index.js index 6717a23..01b96a1 100644 --- a/src/views/Ptjs/Czdbl/index.js +++ b/src/views/Ptjs/Czdbl/index.js @@ -3,7 +3,7 @@ import { Card, message, Table, Space, Button, Spin, Tree } from 'antd'; import ToolBar from './toolbar.js'; import ToolBottom from './toolBottom.js'; import apiurl from '../../../models/apiurl' -import { xyt_httpget2, httpPostFile } from "../../../utils/request"; +import { xyt_httpget2, httpPostFile,httpGetFile } from "../../../utils/request"; import { exportFile } from '../../../utils/tools' import { resJson } from './res.js'; import ReactEcharts from 'echarts-for-react'; @@ -410,6 +410,20 @@ export default function Czrz() { return node; }) } + + // 山洪数据映射 + const dataUpdate = (data) => { + return data.map(item => { + if (item.adcd == '420391000000000') { + item.adcd = '420381450000000'; + item.adnm = '武当山'; + } + if (item.adcd == '421303000000000') { + item.adcd = '421302000000000'; + } + return item + }) + } const onLoadData = async ({ key, children }) => { if (key.substr(4) != '00000000000') { return @@ -417,8 +431,10 @@ export default function Czrz() { try { const res = await xyt_httpget2(apiurl.ptjs.treeList + key) if (res.code == 200) { + const filterData =res.data.filter(item => item.adcd != '420891000000000') + const results = dataUpdate(filterData) setTreeList(origin => - updateTreeData(origin, key, res.data.map(item => ({ ...item, isLeaf: true }))) + updateTreeData(origin, key, results.map(item => ({ ...item, isLeaf: true }))) ) } } catch (error) { @@ -472,11 +488,11 @@ export default function Czrz() { } // 下载测站离线表 const download = () => { - // httpPostFile(apiurl.service.yjgx.downLoad, params).then((res) => { - // if (res) { - // exportFile('测站离线表.xlsx', res.data) - // } - // }) + httpGetFile(apiurl.ptjs.export + '?' + `tm=${SearchBottom.operTime}`).then((res) => { + if (res) { + exportFile('测站离线表.xlsx', res.data) + } + }) } useEffect(() => { if (searchVal) { diff --git a/src/views/Ptjs/Czdbl/qsOption.js b/src/views/Ptjs/Czdbl/qsOption.js index a7f9c57..d5a853a 100644 --- a/src/views/Ptjs/Czdbl/qsOption.js +++ b/src/views/Ptjs/Czdbl/qsOption.js @@ -88,7 +88,9 @@ export default function qsOption(timeList, listObj, hbobj, list) { chartTimeList[idx] = str.substring(5, 10); }); -console.log("miny",minY); + console.log("chartTimeList", chartTimeList); + console.log("addSerise",addSerise.data); + return { @@ -150,6 +152,7 @@ console.log("miny",minY); }, saveAsImage: { show: true, + name:'到报率变化趋势', title: '保存为图片' } } diff --git a/src/views/Ptjs/Lssj/index.js b/src/views/Ptjs/Lssj/index.js new file mode 100644 index 0000000..2461968 --- /dev/null +++ b/src/views/Ptjs/Lssj/index.js @@ -0,0 +1,275 @@ +import React, { useState, useMemo } from 'react' +import { Card, Tabs,Table } from "antd"; +import ReactEcharts from 'echarts-for-react'; +import ToolBar from './toolbar'; +import zyOptions from './qsOption' +import moment from 'moment'; +import NormalSelect from '../../../components/Form/NormalSelect'; +import usePageTable from '../../../components/Crud/usePageTable.js' +import { findPage2 } from '../../../components/Crud/_.js' +import apiurl from '../../../models/apiurl' +import { httppost,httpget } from '../../../utils/request.js'; +import { useEffect } from 'react'; +export default function Lssj() { + const [searchVal, setSearchVal] = useState(false) + const [cbOptions, setCbOptions] = useState([]) + const [cbValue, setCbValue] = useState("/") + const [optionsData, setOptionsData] = useState([]) + const cpuColumn = [ + { + title: '时间', + dataIndex: 'tm', + key: 'tm', + width: 120, + align: "center", + }, + { + title: '用户态CPU时间(s)', + dataIndex: 'userTime', + key: 'userTime', + width: 120, + align: "center", + }, + { + title: '系统态CPU时间(s)', + dataIndex: 'system', + key: 'system', + width: 120, + align: "center", + }, + { + title: '空闲态CPU时间(s)', + dataIndex: 'idle', + key: 'idle', + width: 120, + align: "center", + },{ + title: 'I/O等待时间(s)', + dataIndex: 'iowait', + key: 'iowait', + width: 120, + align: "center", + }, + { + title: 'CPU使用率(%)', + dataIndex: 'rate', + key: 'rate', + width: 120, + align: "center", + }, + ] + const ncColumn = [ + { + title: '时间', + dataIndex: 'tm', + key: 'tm', + width: 120, + align: "center", + }, + { + title: '总内存(MB)', + dataIndex: 'totalSpace', + key: 'totalSpace', + width: 120, + align: "center", + }, + { + title: '已用内存(MB)', + dataIndex: 'usedSpace', + key: 'usedSpace', + width: 120, + align: "center", + }, + { + title: '可用内存(MB)', + dataIndex: 'freeSpace', + key: 'freeSpace', + width: 120, + align: "center", + }, + { + title: '内存使用率(%)', + dataIndex: 'rate', + key: 'rate', + width: 120, + align: "center", + }, + ] + const ccColumn = [ + { + title: '时间', + dataIndex: 'tm', + key: 'tm', + width: 120, + align: "center", + }, + { + title: '挂载点', + dataIndex: 'mount', + key: 'mount', + width: 120, + align: "center", + }, + { + title: '磁盘名称', + dataIndex: 'name', + key: 'name', + width: 120, + align: "center", + }, + { + title: '总磁盘量(GB)', + dataIndex: 'totalSpace', + key: 'totalSpace', + width: 120, + align: "center", + }, + { + title: '已用磁盘量(GB)', + dataIndex: 'usedSpace', + key: 'usedSpace', + width: 120, + align: "center", + }, + { + title: '可用磁盘量(GB)', + dataIndex: 'freeSpace', + key: 'freeSpace', + width: 120, + align: "center", + }, + { + title: '磁盘使用率(%)', + dataIndex: 'rate', + key: 'rate', + width: 120, + align: "center", + }, + ] + + const url = useMemo(() => { + if (searchVal) { + switch (searchVal.type) { + case 0: + return apiurl.ptjs.cpuPage + case 1: + return apiurl.ptjs.memoryPage + case 2: + return apiurl.ptjs.diskPage + } + } else { + return apiurl.ptjs.cpuPage + } + },[searchVal]) + const { tableProps, search, refresh } = usePageTable((params) => findPage2(url, params)) + + const options = useMemo(() => { + if (searchVal && optionsData.length >0) { + return zyOptions(optionsData || [],searchVal.type) + } else { + return zyOptions() + } + }, [searchVal,optionsData]) + + const newColumns = useMemo(() => { + if (searchVal) { + switch (searchVal.type) { + case 0: + return cpuColumn + case 1: + return ncColumn + case 2: + return ccColumn + } + + } else { + return cpuColumn + } + }, [searchVal]) + + + const getDiskList = async () => { + try { + const res = await httpget(apiurl.ptjs.diskList) + if (res.code == 200) { + setCbOptions(res.data.map(item => ({ label: item.mount, value: item.mount }))) + } + } catch (error) { + console.log(error); + } + } + + // 获取cpu整个时间范围内数据 + const getTotalList = async (params,url) => { + try { + const res = await httppost(url,params) + if (res.code == 200) { + const result = res.data.map(item => ({...item,tm:moment(item.tm).format('HH:mm:ss')})) + setOptionsData(result) + } + } catch (error) { + console.log(error); + } + } + useEffect(() => { + if (searchVal) { + const params = { + ...searchVal, + mount: searchVal?.type == 2 ? cbValue :undefined + }; + search(params) + const url = searchVal.type == 0 ? apiurl.ptjs.cpuQuery : + searchVal.type == 1 ? apiurl.ptjs.memoryQuery : + searchVal.type == 2 ? apiurl.ptjs.diskQuery : + apiurl.ptjs.cpuQuery + getTotalList({...params,type:undefined},url) + } + }, [searchVal,cbValue]) + useEffect(() => { + getDiskList(); + }, []) + + + + return ( +
+ 资源使用
+
+ }
+
+
+ 资源使用
+