From ef20532d9ada39cb35ee7fb2d07b8cbe64366332 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?zhaobing=E2=80=99?= Date: Thu, 31 Aug 2023 16:16:01 +0800 Subject: [PATCH 1/5] =?UTF-8?q?feat:=E5=91=8A=E8=AD=A6=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script/3.1/schema/3.updata_struc_off .sql | 11 ++++++ .../projectGroup/containers/bigscreen.jsx | 38 +++++++++++-------- 2 files changed, 34 insertions(+), 15 deletions(-) create mode 100644 script/3.1/schema/3.updata_struc_off .sql diff --git a/script/3.1/schema/3.updata_struc_off .sql b/script/3.1/schema/3.updata_struc_off .sql new file mode 100644 index 0000000..8f61563 --- /dev/null +++ b/script/3.1/schema/3.updata_struc_off .sql @@ -0,0 +1,11 @@ + + alter table t_structure_off + add totnum integer; + +comment on column t_structure_off.totnum is '测点总数'; + +alter table t_structure_off + add offnum integer; + +comment on column t_structure_off.offnum is '离线个数'; + diff --git a/web/client/src/sections/projectGroup/containers/bigscreen.jsx b/web/client/src/sections/projectGroup/containers/bigscreen.jsx index 14d5e4b..8790292 100644 --- a/web/client/src/sections/projectGroup/containers/bigscreen.jsx +++ b/web/client/src/sections/projectGroup/containers/bigscreen.jsx @@ -94,12 +94,17 @@ const Bigscreen = ({ dispatch, actions, user, match, history, clientHeight, grou return combinedMax; } return max; - }, -Infinity) - const bigD = Math.ceil(maxCombinedValue / 50) * 50 - 50, 40, 30, 20, 10, 0 - setXData([bigD, (bigD - bigD / 5), (bigD - bigD * 2 / 5), (bigD - bigD * 3 / 5), (bigD - bigD * 4 / 5), 0, (bigD - bigD * 4 / 5), (bigD - bigD * 3 / 5), (bigD - bigD * 2 / 5), (bigD - bigD / 5), bigD]) - setBiggest(bigD) - }, []) + }, -Infinity) + console.log('setAlarmData4',maxCombinedValue) + const bigD= Math.ceil(maxCombinedValue/50)*50 + if(bigD==0){ + setXData([5,4,3,2,1,0,1,2,3,4,5])//最大值为0,默认横坐标 + }else{ + setXData([bigD,(bigD-bigD/5),(bigD-bigD*2/5),(bigD-bigD*3/5),(bigD-bigD*4/5),0,(bigD-bigD*4/5),(bigD-bigD*3/5),(bigD-bigD*2/5),(bigD-bigD/5),bigD]) + } + setBiggest(bigD) + },[]) + // const mockData=[ // {id: 1,name: '测试结构物测试结构物',alarmCount: 200,dealAlarmCount: 23}, // {id: 2,name: '测试结构物2',alarmCount: 300,dealAlarmCount: 22}, @@ -180,6 +185,7 @@ const Bigscreen = ({ dispatch, actions, user, match, history, clientHeight, grou + function formatDate (date) { var year = date.getFullYear(); var month = String(date.getMonth() + 1).padStart(2, '0'); @@ -241,6 +247,8 @@ const Bigscreen = ({ dispatch, actions, user, match, history, clientHeight, grou }, [proportion]); +console.log('setAlarmData3',alarmData) + console.log(groupStatisticOnline); return (
@@ -423,7 +431,7 @@ const Bigscreen = ({ dispatch, actions, user, match, history, clientHeight, grou
- {mockData && mockData.length > 0 ? (
@@ -443,10 +451,10 @@ const Bigscreen = ({ dispatch, actions, user, match, history, clientHeight, grou
{mockData[0]?.name?.length > 5 ? {mockData[0]?.name.substring(0, 5) + '...'} : mockData[0]?.name}
-
+
0? ((mockData[0].alarmCount / biggest) * 100 || '%'):0), height: '100%' }}>
-
+
0? ((mockData[0].dealAlarmCount / biggest) * 100 || '%'):0), height: '100%' }}>
) : '' @@ -458,10 +466,10 @@ const Bigscreen = ({ dispatch, actions, user, match, history, clientHeight, grou
{mockData[1]?.name?.length > 5 ? {mockData[1]?.name.substring(0, 5) + '...'} : mockData[0]?.name}
-
+
0? ((mockData[1].alarmCount / biggest) * 100 || '%'):0), height: '100%' }}>
-
+
0? ((mockData[1].dealAlarmCount / biggest) * 100 || '%'):0), height: '100%' }}>
) : '' @@ -473,10 +481,10 @@ const Bigscreen = ({ dispatch, actions, user, match, history, clientHeight, grou
{mockData[2]?.name?.length > 5 ? {mockData[2]?.name.substring(0, 5) + '...'} : mockData[0]?.name}
-
+
0? ((mockData[2].alarmCount / biggest) * 100 || '%'):0), height: '100%' }}>
-
+
0? ((mockData[2].dealAlarmCount / biggest) * 100 || '%'):0), height: '100%' }}>
) : '' @@ -490,10 +498,10 @@ const Bigscreen = ({ dispatch, actions, user, match, history, clientHeight, grou
{item.name?.length > 5 ? {item.name.substring(0, 5) + '...'} : item.name}
-
+
0?((item.alarmCount / biggest) * 100 || '%'):0), height: '100%' }}>
-
+
0? ((item.dealAlarmCount / biggest) * 100 || '%'):0), height: '100%' }}>
From 0f188eb122c9a76343c7b29858ed904cccde3d5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?zhaobing=E2=80=99?= Date: Thu, 31 Aug 2023 16:47:00 +0800 Subject: [PATCH 2/5] feat:fix bugs --- .../projectGroup/containers/bigscreen.jsx | 215 ++++++++++++++++-- 1 file changed, 194 insertions(+), 21 deletions(-) diff --git a/web/client/src/sections/projectGroup/containers/bigscreen.jsx b/web/client/src/sections/projectGroup/containers/bigscreen.jsx index 8790292..f43416d 100644 --- a/web/client/src/sections/projectGroup/containers/bigscreen.jsx +++ b/web/client/src/sections/projectGroup/containers/bigscreen.jsx @@ -64,7 +64,188 @@ const Bigscreen = ({ dispatch, actions, user, match, history, clientHeight, grou } }, []) - + // const mockData=[ + // { + // "name": "西腰墩水库", + // "id": 2957, + // "alarmCount": 0, + // "dealAlarmCount": 0 + // }, + // { + // "name": "智慧排涝-雄溪河绿新桥南侧智能分流井排口", + // "id": 2966, + // "alarmCount": 0, + // "dealAlarmCount": 0 + // }, + // { + // "name": "智慧排涝-雄溪河东侧绿地山庄红色廊厅排口", + // "id": 2967, + // "alarmCount": 0, + // "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": 3008, + // "alarmCount": 0, + // "dealAlarmCount": 0 + // }, + // { + // "name": "灵宝边坡项目", + // "id": 3010, + // "alarmCount": 0, + // "dealAlarmCount": 0 + // }, + // { + // "name": "大河峡水库", + // "id": 3023, + // "alarmCount": 0, + // "dealAlarmCount": 0 + // }, + // { + // "name": "公家墩水库", + // "id": 3024, + // "alarmCount": 0, + // "dealAlarmCount": 0 + // }, + // { + // "name": "黑达坂水库", + // "id": 3025, + // "alarmCount": 0, + // "dealAlarmCount": 0 + // }, + // { + // "name": "白家明塘湖水库", + // "id": 3033, + // "alarmCount": 0, + // "dealAlarmCount": 0 + // }, + // { + // "name": "天城湖水库", + // "id": 3034, + // "alarmCount": 0, + // "dealAlarmCount": 0 + // }, + // { + // "name": "马尾湖水库", + // "id": 3035, + // "alarmCount": 0, + // "dealAlarmCount": 0 + // }, + // { + // "name": "芦湾墩上库", + // "id": 3036, + // "alarmCount": 0, + // "dealAlarmCount": 0 + // }, + // { + // "name": "寺沟水库", + // "id": 3037, + // "alarmCount": 0, + // "dealAlarmCount": 0 + // }, + // { + // "name": "北台子水库", + // "id": 3038, + // "alarmCount": 0, + // "dealAlarmCount": 0 + // }, + // { + // "name": "流水口水库", + // "id": 3039, + // "alarmCount": 0, + // "dealAlarmCount": 0 + // }, + // { + // "name": "三十六道沟水库", + // "id": 3040, + // "alarmCount": 0, + // "dealAlarmCount": 0 + // }, + // { + // "name": "三坝水库", + // "id": 3041, + // "alarmCount": 0, + // "dealAlarmCount": 0 + // }, + // { + // "name": "瓷窑口水库", + // "id": 3042, + // "alarmCount": 0, + // "dealAlarmCount": 0 + // }, + // { + // "name": "大香沟水库", + // "id": 3043, + // "alarmCount": 0, + // "dealAlarmCount": 0 + // }, + // { + // "name": "小香沟水库", + // "id": 3044, + // "alarmCount": 0, + // "dealAlarmCount": 0 + // }, + // { + // "name": "芦湾墩下库", + // "id": 3045, + // "alarmCount": 0, + // "dealAlarmCount": 0 + // }, + // { + // "name": "刘家深湖水库", + // "id": 3047, + // "alarmCount": 0, + // "dealAlarmCount": 0 + // }, + // { + // "name": "古城水库", + // "id": 3048, + // "alarmCount": 0, + // "dealAlarmCount": 0 + // }, + // { + // "name": "水关河水库", + // "id": 3049, + // "alarmCount": 0, + // "dealAlarmCount": 0 + // }, + // ] useEffect(() => { const overview = document.getElementById("alarmRank"); if (overview) { @@ -87,6 +268,7 @@ const Bigscreen = ({ dispatch, actions, user, match, history, clientHeight, grou interrupt.update(); } }) + useEffect(() => { const maxCombinedValue = mockData?.reduce((max, item) => { const combinedMax = Math.max(item.alarmCount, item.dealAlarmCount); @@ -95,7 +277,6 @@ const Bigscreen = ({ dispatch, actions, user, match, history, clientHeight, grou } return max; }, -Infinity) - console.log('setAlarmData4',maxCombinedValue) const bigD= Math.ceil(maxCombinedValue/50)*50 if(bigD==0){ setXData([5,4,3,2,1,0,1,2,3,4,5])//最大值为0,默认横坐标 @@ -103,7 +284,16 @@ const Bigscreen = ({ dispatch, actions, user, match, history, clientHeight, grou setXData([bigD,(bigD-bigD/5),(bigD-bigD*2/5),(bigD-bigD*3/5),(bigD-bigD*4/5),0,(bigD-bigD*4/5),(bigD-bigD*3/5),(bigD-bigD*2/5),(bigD-bigD/5),bigD]) } setBiggest(bigD) - },[]) + if (mockData && mockData.length > 3 && mockData.length < 21) { + const newArray = mockData.slice(3) + setAlarmData(newArray) + } + if (mockData && mockData.length > 21) { + //数据大于20的话,取前20 + const newArray = mockData.slice(3, 20) + setAlarmData(newArray) + } + },[mockData]) // const mockData=[ // {id: 1,name: '测试结构物测试结构物',alarmCount: 200,dealAlarmCount: 23}, @@ -130,20 +320,6 @@ const Bigscreen = ({ dispatch, actions, user, match, history, clientHeight, grou // {id: 22,name: '测试结构物22',alarmCount: 27,dealAlarmCount: 22}, // {id: 23,name: '测试结构物23',alarmCount: 26,dealAlarmCount: 21}, // ] - useEffect(() => { - if (mockData && mockData.length > 3 && mockData.length < 21) { - const newArray = mockData.slice(3) - setAlarmData(newArray) - } - if (mockData && mockData.length > 21) { - //数据大于20的话,取前20 - const newArray = mockData.slice(3, 20) - setAlarmData(newArray) - } - - }, []) - - let statisticOnline = (groupId) => { dispatch(actions.projectGroup.groupStatisticOnline({ groupId })).then(res => { @@ -246,10 +422,6 @@ const Bigscreen = ({ dispatch, actions, user, match, history, clientHeight, grou }; }, [proportion]); - -console.log('setAlarmData3',alarmData) - console.log(groupStatisticOnline); - return (
@@ -444,6 +616,7 @@ console.log('setAlarmData3',alarmData)
+ {mockData && mockData[0] ? (
From 72724047afd43a79ee4632687928107d41bd92b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?zhaobing=E2=80=99?= Date: Fri, 1 Sep 2023 14:27:21 +0800 Subject: [PATCH 3/5] =?UTF-8?q?feat:=E5=91=8A=E8=AD=A6=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/app/lib/controllers/project/group.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/app/lib/controllers/project/group.js b/api/app/lib/controllers/project/group.js index 63a12ee..24b89f3 100644 --- a/api/app/lib/controllers/project/group.js +++ b/api/app/lib/controllers/project/group.js @@ -360,7 +360,7 @@ async function groupStatisticAlarm (ctx) { ).toPromise() : [] // 查一周内超阈值告警的个数 - strucIdArr = [1] + // strucIdArr = [1] const alarmRes = strucIdArr.length ? await clickHouse.dataAlarm.query( ` SELECT StructureId,count(StructureId) AS alarmCount From 6fe64776d7f3adc195bf733412fbee9f54405ca3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?zhaobing=E2=80=99?= Date: Fri, 1 Sep 2023 15:58:00 +0800 Subject: [PATCH 4/5] feat:console.log( --- api/app/lib/controllers/project/group.js | 1 + 1 file changed, 1 insertion(+) diff --git a/api/app/lib/controllers/project/group.js b/api/app/lib/controllers/project/group.js index 24b89f3..f4bb195 100644 --- a/api/app/lib/controllers/project/group.js +++ b/api/app/lib/controllers/project/group.js @@ -288,6 +288,7 @@ async function groupStatisticOnline (ctx) { ] } }) + console.log('es数据,', onlineRes.hits.hits.length,onlineRes) for (let struc of strucRes) { let curOnline = From 9d0ecf808e33cbe0a20828199501c76a492c96fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?zhaobing=E2=80=99?= Date: Fri, 1 Sep 2023 16:00:53 +0800 Subject: [PATCH 5/5] strucOnlineClient --- api/app/lib/controllers/project/group.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/api/app/lib/controllers/project/group.js b/api/app/lib/controllers/project/group.js index f4bb195..79238a0 100644 --- a/api/app/lib/controllers/project/group.js +++ b/api/app/lib/controllers/project/group.js @@ -255,6 +255,8 @@ async function groupStatisticOnline (ctx) { // 查在线率 const strucOnlineClient = ctx.app.fs.esclient.strucOnline + console.log('es数据,', strucOnlineClient) + const onlineRes = await strucOnlineClient.search({ index: strucOnlineClient.config.index, type: strucOnlineClient.config.type,