From b74707a5e2e2860c6b0f99e29d538c5ad53411f2 Mon Sep 17 00:00:00 2001 From: wenlele Date: Wed, 9 Nov 2022 17:34:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A8=E9=80=81=2050%?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sections/control/containers/control.jsx | 57 ++++++++++++++++--- 1 file changed, 48 insertions(+), 9 deletions(-) diff --git a/web/client/src/sections/control/containers/control.jsx b/web/client/src/sections/control/containers/control.jsx index 2d301ac..4b3072b 100644 --- a/web/client/src/sections/control/containers/control.jsx +++ b/web/client/src/sections/control/containers/control.jsx @@ -56,22 +56,20 @@ const Control = ({ dispatch, actions, user, history, loading, socket, pepProject const [ask, setASk] = useState(true); //是否继续请求 const [setData, setSetData] = useState(); //设置总数 const [projectData, setProjectData] = useState([]); //项目总信息 + const [socketData, setSocketData] = useState(); //推送数据 const exhibition = useRef({ workbench: [], statistical: [] }) //页面结构 const FormApi = useRef() const querydata = useRef([])//最新动态数据 + // const socketData = useRef(1) //推送数据 // websocket 使用测试 useEffect(() => { if (socket) { - socket.on('alarmSendSocket', function (msg) { - // console.info(msg); - - // console.info(msg); - console.log(msg); + socket.on('alarmSendSocket', (msg) => { if (msg?.msgDataMap) { - + setSocketData(msg?.msgDataMap) } let a = msg; }); @@ -81,6 +79,47 @@ const Control = ({ dispatch, actions, user, history, loading, socket, pepProject } }, [socket]) + useEffect(() => { + if (socketData) { + console.log(socketData) + console.log(problemsList) + let workbench = workData + let problems = problemsList + + if (socketData?.appear?.length > 0) { + socketData?.appear?.map(v => { + if (v.type == '应用异常') { + workbench.appNewAdd++ + } else if (v.type == '设备异常') { + workbench.toolNewAdd++ + } else { + workbench.dataNewAdd++ + } + }) + } + if (socketData?.confirm?.length > 0) { + socketData?.confirm?.map(v => { + if (v.type == '应用异常') { + workbench.appConfirme++ + } else if (v.type == '设备异常') { + workbench.toolConfirme++ + } else { + workbench.dataConfirme++ + } + }) + } + workbench.appSurplus += (workbench.appNewAdd - workbench.appConfirme) + workbench.toolSurplus += (workbench.toolNewAdd - workbench.toolConfirme) + workbench.dataSurplus += (workbench.dataNewAdd - workbench.dataConfirme) + + setWorkData({ ...workbench }) + if (socketData?.notice?.length > 0) { + + } + + } + }, [socketData]) + useEffect(() => { consoleToollink() @@ -919,7 +958,7 @@ const Control = ({ dispatch, actions, user, history, loading, socket, pepProject pathname: v.url, query: { keywordTarget: v.groupName == '应用异常' ? "" : 'source', - keyword:v.SourceName, + keyword: v.SourceName, } }) }}> @@ -1157,9 +1196,9 @@ const Control = ({ dispatch, actions, user, history, loading, socket, pepProject {querydata.current?.map((v, index) => { let title = '' if (v.seed == 'discovery') { - title = v.project + v.sources + ',诊断为' + v.type + title = v.project + '【' + v.sources + '】' + ',诊断为' + v.type } else if (v.seed == 'confirm') { - title = v.userName + '确认并关闭' + v.project + v.sources + v.type + '的问题' + title = v.userName + '确认并关闭' + v.project + '【' + v.sources + '】' + v.type + '的问题' } else { title = '【信鸽-' + v.alarmPushConfig + '】已邮件通知' + v.userName?.map((u, i) => (i > 0 ? ',' + u : u)) + '【' + v.project + '】【' +