From 6bdde941afeedf111d5f9974c933d65fcc06032f Mon Sep 17 00:00:00 2001 From: wenlele Date: Mon, 4 Sep 2023 10:07:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=9C=A8=E7=BA=BF=E7=8E=87?= =?UTF-8?q?=E5=92=8C=E4=B8=AD=E6=96=AD=E6=8E=92=E5=90=8D=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=AE=9A=E6=97=B6=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../projectGroup/containers/bigscreen.jsx | 162 ++---------------- 1 file changed, 14 insertions(+), 148 deletions(-) diff --git a/web/client/src/sections/projectGroup/containers/bigscreen.jsx b/web/client/src/sections/projectGroup/containers/bigscreen.jsx index 781dfc8..8ab2c4e 100644 --- a/web/client/src/sections/projectGroup/containers/bigscreen.jsx +++ b/web/client/src/sections/projectGroup/containers/bigscreen.jsx @@ -34,6 +34,8 @@ const Bigscreen = ({ dispatch, actions, user, match, history, clientHeight, grou useEffect(() => { let groupId = JSON.parse(localStorage.getItem('project_group'))?.find(v => user?.id == v.userId)?.projectGroupId statisticOnline(groupId) + //计算当前时间,定时更新 + timeRequest(groupId) dispatch(actions.projectGroup.groupStatisticAlarm({ groupId })).then(res => { if (res.success) { setMockData(res.payload.data) @@ -63,86 +65,7 @@ const Bigscreen = ({ dispatch, actions, user, match, history, clientHeight, grou } }, []) - // const mockData=[ - // { - // "name": "西腰墩水库", - // "id": 2957, - // "alarmCount": 6, - // "dealAlarmCount": 0 - // }, - // { - // "name": "智慧排涝-雄溪河绿新桥南侧智能分流井排口", - // "id": 2966, - // "alarmCount": 1, - // "dealAlarmCount": 0 - // }, - // { - // "name": "智慧排涝-雄溪河东侧绿地山庄红色廊厅排口", - // "id": 2967, - // "alarmCount": 3, - // "dealAlarmCount": 0 - // }, - // { - // "name": "鲍家湖水库", - // "id": 2973, - // "alarmCount": 0, - // "dealAlarmCount": 0 - // }, - // { - // "name": "长春市九台区水旱灾害防御中心小型水库", - // "id": 2975, - // "alarmCount": 0, - // "dealAlarmCount": 0 - // }, - // { - // "name": "重庆观音峡项目", - // "id": 2977, - // "alarmCount": 0, - // "dealAlarmCount": 0 - // }, - // { - // "name": "杭州宝坞口隧道监测", - // "id": 2988, - // "alarmCount": 0, - // "dealAlarmCount": 0 - // }, - // { - // "name": "大湖湾水库", - // "id": 3004, - // "alarmCount": 0, - // "dealAlarmCount": 0 - // }, - // { - // "name": "上高高情远韵驿站智慧公厕", - // "id": 3007, - // "alarmCount": 0, - // "dealAlarmCount": 0 - // }, - // { - // "name": "大湖湾水库", - // "id": 3004, - // "alarmCount": 0, - // "dealAlarmCount": 0 - // }, - // { - // "name": "上高高情远韵驿站智慧公厕", - // "id": 3007, - // "alarmCount": 0, - // "dealAlarmCount": 0 - // }, - // { - // "name": "大湖湾水库", - // "id": 3004, - // "alarmCount": 0, - // "dealAlarmCount": 0 - // }, - // { - // "name": "上高高情远韵驿站智慧公厕", - // "id": 3007, - // "alarmCount": 0, - // "dealAlarmCount": 0 - // }, - // ] + useEffect(() => { const overview = document.getElementById("alarmRank"); if (overview) { @@ -192,31 +115,6 @@ const Bigscreen = ({ dispatch, actions, user, match, history, clientHeight, grou } }, [mockData]) - // const mockData=[ - // {id: 1,name: '测试结构物测试结构物',alarmCount: 200,dealAlarmCount: 23}, - // {id: 2,name: '测试结构物2',alarmCount: 300,dealAlarmCount: 22}, - // {id: 3,name: '测试结构物3',alarmCount: 140,dealAlarmCount: 21}, - // {id: 4,name: '测试结构物4',alarmCount: 120,dealAlarmCount: 23}, - // {id: 5,name: '测试结构物5',alarmCount: 110,dealAlarmCount: 22}, - // {id: 6,name: '测试结构物6',alarmCount: 109,dealAlarmCount: 21}, - // {id: 7,name: '测试结构物7',alarmCount: 100,dealAlarmCount: 23}, - // {id: 8,name: '测试结构物8',alarmCount: 99,dealAlarmCount: 22}, - // {id: 9,name: '测试结构物9',alarmCount: 98,dealAlarmCount: 21}, - // {id: 10,name: '测试结构物10',alarmCount: 97,dealAlarmCount: 23}, - // {id: 11,name: '测试结构物11',alarmCount: 96,dealAlarmCount: 22}, - // {id: 12,name: '测试结构物12',alarmCount: 95,dealAlarmCount: 21}, - // {id: 13,name: '测试结构物13',alarmCount: 100,dealAlarmCount: 23}, - // {id: 14,name: '测试结构物14',alarmCount: 49,dealAlarmCount: 22}, - // {id: 15,name: '测试结构物15',alarmCount: 48,dealAlarmCount: 21}, - // {id: 16,name: '测试结构物16',alarmCount: 47,dealAlarmCount: 23}, - // {id: 17,name: '测试结构物17',alarmCount: 46,dealAlarmCount: 22}, - // {id: 18,name: '测试结构物18',alarmCount: 45,dealAlarmCount: 21}, - // {id: 19,name: '测试结构物19',alarmCount: 30,dealAlarmCount: 22}, - // {id: 20,name: '测试结构物20',alarmCount: 29,dealAlarmCount: 21}, - // {id: 21,name: '测试结构物21',alarmCount: 28,dealAlarmCount: 23}, - // {id: 22,name: '测试结构物22',alarmCount: 27,dealAlarmCount: 22}, - // {id: 23,name: '测试结构物23',alarmCount: 26,dealAlarmCount: 21}, - // ] let statisticOnline = (groupId) => { dispatch(actions.projectGroup.groupStatisticOnline({ groupId })).then(res => { if (res.success) { @@ -230,53 +128,21 @@ const Bigscreen = ({ dispatch, actions, user, match, history, clientHeight, grou setInterruptRank(Interrupt) setOnline(res.payload.data?.slice(0, 10) || []) setValue(res.payload.data?.map(v => v.id)?.slice(0, 10) || []) - // eChartsData(res.payload.data || [], res.payload.data?.map(v => v.id) || []) } }) } - // const eChartsData = (data, value) => { - // // 调用函数获取时间节点数组 - // let timeNodes = getTimeNodes() - // let dataList = [] - // data?.forEach(v => { - // if (value?.includes(v.id)) { - // v.timeNodes = [] - // timeNodes?.forEach(s => { - // if (v.online?.find(d => moment(d.collect_time).format('YYYY-MM-DD HH') == s)?.structure) { - // v.timeNodes.push([s,]) - // } else { - // v.timeNodes.push([s,null]) - // } - // }) - // } - // }) - // } - - - - - function formatDate (date) { - var year = date.getFullYear(); - var month = String(date.getMonth() + 1).padStart(2, '0'); - var day = String(date.getDate()).padStart(2, '0'); - var hour = String(date.getHours()).padStart(2, '0'); - - return year + '-' + month + '-' + day + ' ' + hour; - } - - function getTimeNodes () { - var currentTime = new Date(); // 当前时间 - var timeNodes = []; - - for (var i = 0; i < 24; i++) { - var timeNode = formatDate(currentTime); - timeNodes.push(timeNode); - - currentTime.setHours(currentTime.getHours() - 1); // 减去1小时 - } - - return timeNodes; + const timeRequest = (groupId) => { + // 获取当前时间 + const currentTime = moment(); + // 获取下一个小时的时间 + const nextHour = moment().add(1, 'hour').startOf('hour'); + // 计算分钟差 + const minuteDifference = nextHour.diff(currentTime, 'minutes'); + setTimeout(function () { + statisticOnline(groupId) + timeRequest(groupId) + }, 1000 * 60 * (minuteDifference + 1 || 61)); }