|
@ -195,7 +195,7 @@ async function groupStatistic (ctx) { |
|
|
` |
|
|
` |
|
|
SELECT StructureId,count(StructureId) AS alarmCount |
|
|
SELECT StructureId,count(StructureId) AS alarmCount |
|
|
FROM alarms |
|
|
FROM alarms |
|
|
WHERE StructureId IN (${[...strucIdArr].join(',')}) |
|
|
WHERE StructureId IN (${strucIdArr.join(',')}, -1) |
|
|
AND AlarmGroupUnit = 8 |
|
|
AND AlarmGroupUnit = 8 |
|
|
AND StartTime >= '${moment().subtract(1, 'days').format('YYYY-MM-DD HH:mm:ss')}' |
|
|
AND StartTime >= '${moment().subtract(1, 'days').format('YYYY-MM-DD HH:mm:ss')}' |
|
|
group by StructureId |
|
|
group by StructureId |
|
@ -278,9 +278,9 @@ async function groupStatisticOnline (ctx) { |
|
|
const strucRes = anxinProjectIds.size ? await clickHouse.anxinyun.query( |
|
|
const strucRes = anxinProjectIds.size ? await clickHouse.anxinyun.query( |
|
|
` |
|
|
` |
|
|
SELECT |
|
|
SELECT |
|
|
DISTINCT t_structure.id AS strucId, |
|
|
DISTINCT t_structure.id AS id, |
|
|
t_project.id AS projectId, |
|
|
t_project.id AS projectId, |
|
|
t_structure.name AS strucName, |
|
|
t_structure.name AS name, |
|
|
project_state |
|
|
project_state |
|
|
FROM |
|
|
FROM |
|
|
t_project |
|
|
t_project |
|
@ -318,7 +318,8 @@ async function groupStatisticOnline (ctx) { |
|
|
let strucIdArr = Array.from(strucIds) |
|
|
let strucIdArr = Array.from(strucIds) |
|
|
|
|
|
|
|
|
// 查中断时间
|
|
|
// 查中断时间
|
|
|
const maxOfflineTimeRes = strucIdArr.length ? await models.StructureOff.findAll({ |
|
|
const maxOfflineTimeRes = strucIdArr.length ? |
|
|
|
|
|
await models.StructureOff.findAll({ |
|
|
where: { |
|
|
where: { |
|
|
structure: { $in: strucIdArr }, |
|
|
structure: { $in: strucIdArr }, |
|
|
state: 0, |
|
|
state: 0, |
|
@ -329,7 +330,8 @@ async function groupStatisticOnline (ctx) { |
|
|
// 查在线率
|
|
|
// 查在线率
|
|
|
const strucOnlineClient = ctx.app.fs.esclient.strucOnline |
|
|
const strucOnlineClient = ctx.app.fs.esclient.strucOnline |
|
|
|
|
|
|
|
|
const onlineRes = await strucOnlineClient.search({ |
|
|
const onlineRes = strucIdArr.length ? |
|
|
|
|
|
await strucOnlineClient.search({ |
|
|
index: strucOnlineClient.config.index, |
|
|
index: strucOnlineClient.config.index, |
|
|
type: strucOnlineClient.config.type, |
|
|
type: strucOnlineClient.config.type, |
|
|
body: { |
|
|
body: { |
|
@ -363,6 +365,11 @@ async function groupStatisticOnline (ctx) { |
|
|
"size": 10000 |
|
|
"size": 10000 |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
|
|
|
: { |
|
|
|
|
|
hits: { |
|
|
|
|
|
hits: [] |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
for (let struc of strucRes) { |
|
|
for (let struc of strucRes) { |
|
|
let curOnline = |
|
|
let curOnline = |
|
@ -419,9 +426,9 @@ async function groupStatisticAlarm (ctx) { |
|
|
const strucRes = anxinProjectIds.size ? await clickHouse.anxinyun.query( |
|
|
const strucRes = anxinProjectIds.size ? await clickHouse.anxinyun.query( |
|
|
` |
|
|
` |
|
|
SELECT |
|
|
SELECT |
|
|
DISTINCT t_structure.id AS strucId, |
|
|
DISTINCT t_structure.id AS id, |
|
|
t_project.id AS projectId, |
|
|
t_project.id AS projectId, |
|
|
t_structure.name AS strucName, |
|
|
t_structure.name AS name, |
|
|
project_state |
|
|
project_state |
|
|
FROM |
|
|
FROM |
|
|
t_project |
|
|
t_project |
|
@ -463,7 +470,7 @@ async function groupStatisticAlarm (ctx) { |
|
|
` |
|
|
` |
|
|
SELECT StructureId,count(StructureId) AS alarmCount |
|
|
SELECT StructureId,count(StructureId) AS alarmCount |
|
|
FROM alarms |
|
|
FROM alarms |
|
|
WHERE StructureId IN (${[...strucIdArr].join(',')}) |
|
|
WHERE StructureId IN (${strucIdArr.join(',')}, -1) |
|
|
AND AlarmGroupUnit = 8 |
|
|
AND AlarmGroupUnit = 8 |
|
|
AND StartTime >= '${moment().subtract(7, 'days').format('YYYY-MM-DD HH:mm:ss')}' |
|
|
AND StartTime >= '${moment().subtract(7, 'days').format('YYYY-MM-DD HH:mm:ss')}' |
|
|
group by StructureId |
|
|
group by StructureId |
|
@ -474,7 +481,7 @@ async function groupStatisticAlarm (ctx) { |
|
|
` |
|
|
` |
|
|
SELECT StructureId,count(StructureId) AS alarmCount |
|
|
SELECT StructureId,count(StructureId) AS alarmCount |
|
|
FROM alarms |
|
|
FROM alarms |
|
|
WHERE StructureId IN (${[...strucIdArr].join(',')}) |
|
|
WHERE StructureId IN (${strucIdArr.join(',')}, -1) |
|
|
AND AlarmGroupUnit = 8 |
|
|
AND AlarmGroupUnit = 8 |
|
|
AND State = 4 |
|
|
AND State = 4 |
|
|
AND StartTime >= '${moment().subtract(30, 'days').format('YYYY-MM-DD HH:mm:ss')}' |
|
|
AND StartTime >= '${moment().subtract(30, 'days').format('YYYY-MM-DD HH:mm:ss')}' |
|
|