CODE 1 year ago
parent
commit
66eb1e5493
  1. 19
      api/app/lib/controllers/project/group.js
  2. 6
      web/client/src/sections/projectGroup/containers/statistic.jsx
  3. 2
      web/client/src/sections/projectGroup/style.less

19
api/app/lib/controllers/project/group.js

@ -189,11 +189,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 相等
@ -203,6 +214,11 @@ async function groupStatistic (ctx) {
let strucIdArr_ =
strucRes.filter(s => gp.anxinProjectId.includes(s.projectId))
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.strucId == off.structure)) {
@ -217,6 +233,7 @@ async function groupStatistic (ctx) {
rslt.unshift({
...pg.dataValues,
strucCount,
todayAlarms,
maxOffLineTime,
anxinProjectCount,
})

6
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)
}
]

2
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;

Loading…
Cancel
Save