wenlele 2 years ago
parent
commit
d2dacf7ad8
  1. 1
      api/app/lib/controllers/alarm/data.js
  2. 50
      api/app/lib/schedule/alarms_push.js

1
api/app/lib/controllers/alarm/data.js

@ -149,7 +149,6 @@ async function list (ctx) {
`).toPromise(); `).toPromise();
const confirmedAlarm = alarmRes const confirmedAlarm = alarmRes
// TODO: 开发临时注释
.filter(ar => ar.State && ar.State > 2) .filter(ar => ar.State && ar.State > 2)
.map(ar => "'" + ar.AlarmId + "'") .map(ar => "'" + ar.AlarmId + "'")
const confirmedAlarmDetailMax = confirmedAlarm.length ? const confirmedAlarmDetailMax = confirmedAlarm.length ?

50
api/app/lib/schedule/alarms_push.js

@ -60,7 +60,7 @@ module.exports = function (app, opts) {
for (let { dataValues: c } of configListRes) { for (let { dataValues: c } of configListRes) {
if (c.tacticsParams && c.tactics) { if (c.tacticsParams && c.tactics) {
// pomsProjectId 是个数组 [] // pomsProjectId 是个数组 []
const { strucId, pomsProjectId, } = c const { strucId, pomsProjectId, pomsStrucFactorId } = c
const { interval, deviceProportion } = c.tacticsParams const { interval, deviceProportion } = c.tacticsParams
if ( if (
@ -274,6 +274,7 @@ module.exports = function (app, opts) {
anxinIpc.t_video_ipc.name AS anxinIpcPosition, anxinIpc.t_video_ipc.name AS anxinIpcPosition,
anxinStation.id AS anxinStationId, anxinStation.id AS anxinStationId,
anxinStation.name AS anxinStationName, anxinStation.name AS anxinStationName,
anxinStation.factor AS anxinStationFactorId,
anxinStruc.name AS strucName, anxinStruc.name AS strucName,
anxinStruc.id AS strucId anxinStruc.id AS strucId
FROM ( FROM (
@ -348,6 +349,20 @@ module.exports = function (app, opts) {
}) })
} }
} else { } else {
if (pomsStrucFactorId) {
if (!a.strucId || !a.anxinStationFactorId) {
// 当前告警没有绑定结构物或者摄像头没有绑定测点
continue
} else if (!pomsStrucFactorId[a.strucId]) {
// 推送配置没配置这个结构物
continue
} else if (!pomsStrucFactorId[a.strucId].includes(a.anxinStationFactorId)) {
// 不包含这个监测因素
continue
}
}
let d = { let d = {
cameraId: a.cameraId, cameraId: a.cameraId,
cameraName: a.cameraName, cameraName: a.cameraName,
@ -363,6 +378,7 @@ module.exports = function (app, opts) {
confirmContent: a.confirmContent, confirmContent: a.confirmContent,
confirmTime: a.confirmTime, confirmTime: a.confirmTime,
cameraKind: a.cameraKind, cameraKind: a.cameraKind,
factorId: a.anxinStationFactorId,
struc: [], struc: [],
station: [] station: []
} }
@ -387,14 +403,14 @@ module.exports = function (app, opts) {
} }
} }
} }
let p = 1
videoAlarms = returnD videoAlarms = returnD
} }
if (c.alarmType.includes('app_exception')) { if (c.alarmType.includes('app_exception')) {
if (c.alarmSubType) { if (c.alarmSubType) {
appAlarmWhereOption.type = { $in: c.alarmSubType['app_exception'] || [] } appAlarmWhereOption.type = { $in: c.alarmSubType['app_exception'] || [] }
} }
appAlarms = c.alarmSubType && c.alarmSubType['app_exception'].length ? await models.AppAlarm.findAll({ appAlarms = c.alarmSubType && c.alarmSubType['app_exception'].length ?
await models.AppAlarm.findAll({
where: appAlarmWhereOption, where: appAlarmWhereOption,
order: [['createTime', 'DESC']], order: [['createTime', 'DESC']],
include: [{ include: [{
@ -424,15 +440,20 @@ module.exports = function (app, opts) {
dataAlarmSubType.push(-1) dataAlarmSubType.push(-1)
dataAlarmOption.push(`AlarmGroupUnit IN (${dataAlarmSubType.join(',')})`) dataAlarmOption.push(`AlarmGroupUnit IN (${dataAlarmSubType.join(',')})`)
} }
dataAlarms = (!c.alarmSubType || dataAlarmSubType.length) ? await clickHouse.dataAlarm.query(` dataAlarms =
!c.alarmSubType || dataAlarmSubType.length ?
await clickHouse.dataAlarm.query(`
SELECT * FROM alarms SELECT * FROM alarms
LEFT JOIN ${anxinyun}.t_sensor
AS anxinStation
ON toString(anxinStation.id) = alarms.SourceId
AND alarms.SourceTypeId = 2
WHERE WHERE
${`State NOT IN (3, 4) AND `} ${`State NOT IN (3, 4) AND `}
StructureId IN (${searchStrucIds.join(',')}) StructureId IN (${searchStrucIds.join(',')})
${dataAlarmOption.length ? ' AND ' + dataAlarmOption.join(' AND ') : ''} ${dataAlarmOption.length ? ' AND ' + dataAlarmOption.join(' AND ') : ''}
ORDER BY StartTime DESC ORDER BY StartTime DESC
`).toPromise() : [] `).toPromise() : []
console.log(dataAlarms);
} }
let dataAlarmTitle = [{ let dataAlarmTitle = [{
@ -640,6 +661,24 @@ module.exports = function (app, opts) {
let dataAlarmG45 = []; let dataAlarmG45 = [];
let deviceStatistic = new Set() let deviceStatistic = new Set()
for (let d of dataAlarms) { for (let d of dataAlarms) {
if (pomsStrucFactorId && d.SourceTypeId == 2) {
// 做了监测因素筛选 且当前告警有监测因素
if (!d.factor || d.factor == 0) {
// 监测因素不对劲
continue
} else if (!d.StructureId) {
// 当前告警没有绑定结构物
continue
} else if (!pomsStrucFactorId[d.StructureId]) {
// 推送配置没配置这个结构物
continue
} else if (!pomsStrucFactorId[d.StructureId].includes(d.factor)) {
// 不包含这个监测因素
continue
}
}
if (d.AlarmGroup == 1) { if (d.AlarmGroup == 1) {
dataAlarmG1.push(d) dataAlarmG1.push(d)
} else if (d.AlarmGroup == 2) { } else if (d.AlarmGroup == 2) {
@ -655,6 +694,7 @@ module.exports = function (app, opts) {
let rate = ((deviceStatistic.size + videoAlarms.length) / (parseInt(deviceCount) + parseInt(cameraCount))); let rate = ((deviceStatistic.size + videoAlarms.length) / (parseInt(deviceCount) + parseInt(cameraCount)));
if (rate < parseFloat(deviceProportion)) { if (rate < parseFloat(deviceProportion)) {
// 设备异常率低于设定值
continue continue
} }

Loading…
Cancel
Save