Browse Source

在离线取消

dev
wenlele 2 years ago
parent
commit
8ac96e8ec4
  1. 99
      api/app/lib/controllers/control/toolLink.js
  2. 5
      web/client/src/sections/problem/containers/dataAlarm.jsx

99
api/app/lib/controllers/control/toolLink.js

@ -1,4 +1,5 @@
'use strict';
const moment = require('moment');
async function list (ctx) {
try {
@ -118,16 +119,108 @@ async function del (ctx) {
async function count (ctx) {
try {
const { models } = ctx.fs.dc;
const { userId, pepUserId , userInfo} = ctx.fs.api
const { userId, pepUserId, userInfo = {}, pepUserInfo } = ctx.fs.api
const { clickHouse } = ctx.app.fs
const { utils: { judgeSuper, anxinStrucIdRange } } = ctx.app.fs
const { database: anxinyun } = clickHouse.anxinyun.opts.config
const { pepProjectId } = ctx.request.body
let anxinStruc = await anxinStrucIdRange({
ctx, pepProjectId
})
if (anxinStruc.length) {
const anxinStrucIds = anxinStruc.map(a => a.strucId) || []
const dataAlarm = await clickHouse.dataAlarm.query(`
SELECT
AlarmId,State,StartTime
FROM
alarms
WHERE
alarms.StructureId IN (${anxinStrucIds.join(",")})
`).toPromise();
//数据告警总数
const alarm = await clickHouse.dataAlarm.query(`
SELECT
count(alarms.AlarmId) AS count
FROM
alarms
WHERE
alarms.StructureId IN (${anxinStrucIds.join(",")})
`).toPromise();
const confirmedAlarm = dataAlarm
// TODO: 开发临时注释
.filter(ar => ar.State && ar.State > 2)
.map(ar => "'" + ar.AlarmId + "'")
//剩余数据告警
const alarmSurplus = dataAlarm.filter(ar => ar.State && ar.State < 3).length || 0
//今日新增数据告警
const alarmNewAdd = await clickHouse.dataAlarm.query(`
SELECT
count(alarms.StartTime) AS count
FROM
alarms
WHERE
alarms.StructureId IN (${anxinStrucIds.join(",")})
AND
alarms.StartTime >= '${moment().startOf('day').format('YYYY-MM-DD HH:mm:ss')}'
AND
alarms.StartTime <= '${moment().endOf('day').format('YYYY-MM-DD HH:mm:ss')}'
`).toPromise();
//今日确认数据告警
const confirmedAlarmDetailMax = confirmedAlarm.length ?
await clickHouse.dataAlarm.query(`
SELECT
max(Time) AS Time, AlarmId , max(Content) AS Content
FROM
alarm_details
WHERE
AlarmId IN (${confirmedAlarm.join(',')})
AND
alarm_details.Time >= '${moment().startOf('day').format('YYYY-MM-DD HH:mm:ss')}'
AND
alarm_details.Time <= '${moment().endOf('day').format('YYYY-MM-DD HH:mm:ss')}'
GROUP BY AlarmId
`).toPromise() :
[];
ctx.status = 200;
ctx.body = {
dataAlarm: {
alarm: alarm[0].count || 0,
alarmSurplus: alarmSurplus,
alarmNewAdd: alarmNewAdd[0].count || 0,
confirmedAlarmDetailMax: confirmedAlarmDetailMax.length || 0,
},
videoAlarm:{
}
}
} else {
ctx.body = {
dataAlarm: 0,
}
}
ctx.status = 200;
ctx.body = {}
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400;
@ -139,8 +232,6 @@ async function count (ctx) {
module.exports = {
list, edit, del, count
};

5
web/client/src/sections/problem/containers/dataAlarm.jsx

@ -161,9 +161,9 @@ const DataAlarm = ({ match, dispatch, actions, user, loading, socket, iotVcmpWeb
//
const tableList = {
dataLnterrupt: ['index', 'projectName', 'StructureName', 'SourceName', 'AlarmGroupUnit', 'AlarmCodeName', 'sustainTime', 'createTime', 'AlarmContent', 'CurrentLevel', 'updateTime', 'detailCount', 'confirm', 'confirmTime',],
dataAbnormal: ['index', 'projectName', 'StructureName', 'SourceName', 'type', 'createTime', 'sustainTime', 'AlarmContent', 'CurrentLevel', 'updateTime', 'detailCount', 'confirm', 'confirmTime'],
dataAbnormal: ['index', 'projectName', 'StructureName', 'SourceName', 'type', 'createTime', 'sustainTime', 'AlarmContent', 'CurrentLevel', 'updateTime', 'detailCount', 'confirm', 'confirmTime'],
strategyHit: ['index', 'projectName', 'StructureName', 'SourceName', 'Strategy', 'State', 'createTime', 'sustainTime', 'AlarmContent', 'CurrentLevel', 'updateTime', 'detailCount', 'confirm', 'confirmTime'],
videoAbnormal: ['index', 'projectName', 'StructureName', 'SourceName', 'station', 'cameraKindId', 'sustainTime', 'venderName', 'point', 'cameraSerialNo', 'cameraChannelNo', 'platform', 'AlarmContent', 'resolve', 'createTime', 'updateTime', 'confirm', 'confirmTime', 'camerOnline'],
videoAbnormal: ['index', 'projectName', 'StructureName', 'SourceName', 'station', 'cameraKindId', 'sustainTime', 'venderName', 'point', 'cameraSerialNo', 'cameraChannelNo', 'platform', 'AlarmContent', 'resolve', 'createTime', 'updateTime', 'confirm', 'confirmTime',],
useAbnormal: ['index', 'projectName', 'appName', 'url', 'type', 'alarmContent', 'createTime', 'sustainTime', 'updateTime', 'confirm', 'confirmTime'],
deviceAbnormal: ['index', 'projectName', 'StructureName', 'SourceName', 'station', 'type', 'cameraKindId', 'sustainTime', 'venderName', 'AlarmContent', 'AlarmCodeName', 'createTime', 'updateTime', 'confirm', 'confirmTime'],
}
@ -524,6 +524,7 @@ const DataAlarm = ({ match, dispatch, actions, user, loading, socket, iotVcmpWeb
</div>
</Modal> : ""}
{/* 视频的播放 */}
{videoModal ? <Modal
visible={true}
header={null}

Loading…
Cancel
Save