|
@ -272,20 +272,13 @@ async function groupStatisticOnline (ctx) { |
|
|
anxinProjectIds.add(pid) |
|
|
anxinProjectIds.add(pid) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const strucIdRes = await clickHouse.anxinyun.query( |
|
|
|
|
|
` |
|
|
|
|
|
SELECT * |
|
|
|
|
|
FROM t_project_structure |
|
|
|
|
|
WHERE project IN (${[...anxinProjectIds].join(',')}, -1) |
|
|
|
|
|
` |
|
|
|
|
|
).toPromise() |
|
|
|
|
|
// 统计安心云项目下的结构物
|
|
|
// 统计安心云项目下的结构物
|
|
|
const strucRes = anxinProjectIds.length ? await clickHouse.anxinyun.query( |
|
|
const strucRes = anxinProjectIds.length ? await clickHouse.anxinyun.query( |
|
|
` |
|
|
` |
|
|
SELECT |
|
|
SELECT |
|
|
t_project.id AS projectId, |
|
|
t_project.id AS projectId, |
|
|
t_structure.id AS strucId, |
|
|
t_structure.id AS id, |
|
|
t_structure.name AS strucName, |
|
|
t_structure.name AS name, |
|
|
project_state |
|
|
project_state |
|
|
FROM |
|
|
FROM |
|
|
t_project |
|
|
t_project |
|
@ -318,16 +311,10 @@ async function groupStatisticOnline (ctx) { |
|
|
|
|
|
|
|
|
let strucIds = new Set() |
|
|
let strucIds = new Set() |
|
|
for (let struc of strucRes) { |
|
|
for (let struc of strucRes) { |
|
|
strucIds.add(struc.strucId) |
|
|
strucIds.add(struc.id) |
|
|
} |
|
|
} |
|
|
let strucIdArr = Array.from(strucIds) |
|
|
let strucIdArr = Array.from(strucIds) |
|
|
|
|
|
|
|
|
// const strucRes = strucIdArr.length ? await clickHouse.anxinyun.query(
|
|
|
|
|
|
// `
|
|
|
|
|
|
// SELECT name, id FROM t_structure WHERE id IN (${[...strucIdArr].join(',')});
|
|
|
|
|
|
// `
|
|
|
|
|
|
// ).toPromise() : []
|
|
|
|
|
|
|
|
|
|
|
|
// 查中断时间
|
|
|
// 查中断时间
|
|
|
const maxOfflineTimeRes = strucIdArr.length ? await models.StructureOff.findAll({ |
|
|
const maxOfflineTimeRes = strucIdArr.length ? await models.StructureOff.findAll({ |
|
|
where: { |
|
|
where: { |
|
@ -373,7 +360,6 @@ async function groupStatisticOnline (ctx) { |
|
|
"size": 10000 |
|
|
"size": 10000 |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
console.log('es数据,', onlineRes.hits.hits.length, onlineRes.hits.hits) |
|
|
|
|
|
|
|
|
|
|
|
for (let struc of strucRes) { |
|
|
for (let struc of strucRes) { |
|
|
let curOnline = |
|
|
let curOnline = |
|
@ -426,27 +412,50 @@ async function groupStatisticAlarm (ctx) { |
|
|
anxinProjectIds.add(pid) |
|
|
anxinProjectIds.add(pid) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const strucIdRes = anxinProjectIds.size ? await clickHouse.anxinyun.query( |
|
|
// 统计安心云项目下的结构物
|
|
|
|
|
|
const strucRes = anxinProjectIds.length ? await clickHouse.anxinyun.query( |
|
|
` |
|
|
` |
|
|
SELECT * |
|
|
SELECT |
|
|
FROM t_project_structure |
|
|
t_project.id AS projectId, |
|
|
WHERE project IN (${[...anxinProjectIds].join(',')}, -1) |
|
|
t_structure.id AS id, |
|
|
|
|
|
t_structure.name AS name, |
|
|
|
|
|
project_state |
|
|
|
|
|
FROM |
|
|
|
|
|
t_project |
|
|
|
|
|
LEFT JOIN |
|
|
|
|
|
t_project_structure |
|
|
|
|
|
ON t_project_structure.project = t_project.id |
|
|
|
|
|
LEFT JOIN |
|
|
|
|
|
t_project_structuregroup |
|
|
|
|
|
ON t_project_structuregroup.project = t_project.id |
|
|
|
|
|
LEFT JOIN |
|
|
|
|
|
t_structuregroup_structure |
|
|
|
|
|
ON t_structuregroup_structure.structuregroup = t_project_structuregroup.structuregroup |
|
|
|
|
|
LEFT JOIN |
|
|
|
|
|
t_project_construction |
|
|
|
|
|
ON t_project_construction.project = t_project.id |
|
|
|
|
|
LEFT JOIN |
|
|
|
|
|
t_structure_site |
|
|
|
|
|
ON t_structure_site.siteid = t_project_construction.construction |
|
|
|
|
|
RIGHT JOIN |
|
|
|
|
|
t_structure |
|
|
|
|
|
ON t_structure.id = t_project_structure.structure |
|
|
|
|
|
OR t_structure.id = t_structuregroup_structure.structure |
|
|
|
|
|
OR t_structure.id = t_structure_site.structid |
|
|
|
|
|
WHERE |
|
|
|
|
|
project_state != -1 |
|
|
|
|
|
AND |
|
|
|
|
|
t_project.id IN (${anxinProjectIds.join(',')},-1) |
|
|
` |
|
|
` |
|
|
).toPromise() : [] |
|
|
).toPromise() : [] |
|
|
|
|
|
|
|
|
let strucIds = new Set() |
|
|
let strucIds = new Set() |
|
|
for (let struc of strucIdRes) { |
|
|
for (let struc of strucRes) { |
|
|
strucIds.add(struc.structure) |
|
|
strucIds.add(struc.id) |
|
|
} |
|
|
} |
|
|
let strucIdArr = Array.from(strucIds) |
|
|
let strucIdArr = Array.from(strucIds) |
|
|
|
|
|
|
|
|
const strucRes = strucIdArr.length ? await clickHouse.anxinyun.query( |
|
|
|
|
|
` |
|
|
|
|
|
SELECT name, id FROM t_structure WHERE id IN (${[...strucIdArr].join(',')}); |
|
|
|
|
|
` |
|
|
|
|
|
).toPromise() : [] |
|
|
|
|
|
|
|
|
|
|
|
// 查一周内超阈值告警的个数
|
|
|
// 查一周内超阈值告警的个数
|
|
|
// strucIdArr = [1]
|
|
|
|
|
|
const alarmRes = strucIdArr.length ? await clickHouse.dataAlarm.query( |
|
|
const alarmRes = strucIdArr.length ? await clickHouse.dataAlarm.query( |
|
|
` |
|
|
` |
|
|
SELECT StructureId,count(StructureId) AS alarmCount |
|
|
SELECT StructureId,count(StructureId) AS alarmCount |
|
|