|
|
@ -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, |
|
|
|
}) |
|
|
|