From 7af7caa2a32987e615574343c6c536743f78f361 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?zhaobing=E2=80=99?= Date: Tue, 5 Sep 2023 10:55:05 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E4=BB=8A=E6=97=A5=E5=91=8A?= =?UTF-8?q?=E8=AD=A6=E6=95=B0=E6=8D=AE=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 | 19 ++++++++++++++++++- .../projectGroup/containers/statistic.jsx | 6 +++--- .../src/sections/projectGroup/style.less | 2 +- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/api/app/lib/controllers/project/group.js b/api/app/lib/controllers/project/group.js index 9ade271..d2717ab 100644 --- a/api/app/lib/controllers/project/group.js +++ b/api/app/lib/controllers/project/group.js @@ -160,11 +160,22 @@ async function groupStatistic (ctx) { structure: { $in: strucIdArr } } }) : [] - + const alarmRes = strucIdArr.length ? await clickHouse.dataAlarm.query( + ` + SELECT StructureId,count(StructureId) AS alarmCount + FROM alarms + WHERE StructureId IN (${[...strucIdArr].join(',')}) + AND AlarmGroupUnit = 8 + AND StartTime >= '${moment().subtract(1, 'days').format('YYYY-MM-DD HH:mm:ss')}' + group by StructureId + ` + ).toPromise() : [] + // console.log('',) let rslt = [] for (let pg of progectGroupList) { let strucCount = 0 let maxOffLineTime = 0 + let todayAlarms=0 let anxinProjectCount = groupProjectRes.reduce((count, gp) => { if (pg.pomsProjectIds.some(id => gp.id == id)) { // 如果 pg 分组信息 存储的 pomsProjectIds 运维项目id 和 真正的 groupProjectRes 运维项目id 相等 @@ -174,6 +185,11 @@ async function groupStatistic (ctx) { let strucIdArr_ = strucIdRes.filter(s => gp.anxinProjectId.includes(s.project)) strucCount += strucIdArr_.length + //所有结构物的告警 + const ss=alarmRes.filter(p=>strucIdArr_.some(q=>q.structure==p.StructureId)) + todayAlarms= ss.reduce((p,c)=>{ + return p+c.alarmCount + },0) // for (let { dataValues: off } of deviceOffTimeRes) { if (strucIdArr_.some((s) => s.structure == off.structure)) { @@ -188,6 +204,7 @@ async function groupStatistic (ctx) { rslt.unshift({ ...pg.dataValues, strucCount, + todayAlarms, maxOffLineTime, anxinProjectCount, }) diff --git a/web/client/src/sections/projectGroup/containers/statistic.jsx b/web/client/src/sections/projectGroup/containers/statistic.jsx index a560eaa..421bf17 100644 --- a/web/client/src/sections/projectGroup/containers/statistic.jsx +++ b/web/client/src/sections/projectGroup/containers/statistic.jsx @@ -71,9 +71,9 @@ const Statistic = ({ dispatch, actions, user, history, loading, groupStatistic, key: 'maxOffLineTime', }, { title: '今日告警个数', - dataIndex: "name", - key: 'name', - render: (_, row) => Math.floor(Math.random() * 20) + dataIndex: "todayAlarms", + key: 'todayAlarms', + // render: (_, row) => Math.floor(Math.random() * 20) } ] diff --git a/web/client/src/sections/projectGroup/style.less b/web/client/src/sections/projectGroup/style.less index dbb1989..c7f0738 100644 --- a/web/client/src/sections/projectGroup/style.less +++ b/web/client/src/sections/projectGroup/style.less @@ -92,7 +92,7 @@ } .scale{ display: flex; - width: 740px; +// width: 740px; height: 18px; font-family: DIN-Regular; font-weight: 400;