Browse Source

fix 13020 数据大屏-数据不展示

dev
CODE 2 years ago
parent
commit
4f839cd984
  1. 25
      api/app/lib/controllers/project/group.js

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

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

Loading…
Cancel
Save