|
|
@ -53,7 +53,7 @@ module.exports = function (app, opts) { |
|
|
|
|
|
|
|
for (let { dataValues: c } of configListRes) { |
|
|
|
if (c.tacticsParams && c.tactics) { |
|
|
|
const { projectCorrelation, strucId } = c |
|
|
|
const { projectCorrelation, strucId, pomsProjectId } = c |
|
|
|
const { interval, deviceProportion } = c.tacticsParams |
|
|
|
|
|
|
|
if ( |
|
|
@ -70,7 +70,7 @@ module.exports = function (app, opts) { |
|
|
|
) |
|
|
|
) { |
|
|
|
// TODO 查当前 poms 下的结构物 并把不包含的去掉
|
|
|
|
|
|
|
|
|
|
|
|
const strucListRes = strucId.length ? await clickHouse.anxinyun.query(` |
|
|
|
SELECT id, iota_thing_id, name |
|
|
|
FROM t_structure |
|
|
@ -83,14 +83,21 @@ module.exports = function (app, opts) { |
|
|
|
|
|
|
|
let videoAlarms = [] |
|
|
|
|
|
|
|
let appAlarmWhereOption = { |
|
|
|
confirmTime: null, |
|
|
|
} |
|
|
|
let appAlarms = [] |
|
|
|
|
|
|
|
let deviceCount = 0 |
|
|
|
let cameraCount = 0 |
|
|
|
// 判断推送策略
|
|
|
|
let pointTime = moment().subtract(interval, 'minute').format('YYYY-MM-DD HH:mm:ss') |
|
|
|
if (c.tactics == 'immediately') { |
|
|
|
dataAlarmOption.push(`StartTime >= '${pointTime}'`); |
|
|
|
appAlarmWhereOption.createTime = { $gte: pointTime } |
|
|
|
} else if (c.tactics == 'continue') { |
|
|
|
dataAlarmOption.push(`StartTime <= '${pointTime}'`); |
|
|
|
appAlarmWhereOption.createTime = { $lte: pointTime } |
|
|
|
} else if (c.tactics == 'abnormal_rate') { |
|
|
|
dataAlarmOption.push(`StartTime <= '${pointTime}'`); |
|
|
|
if (c.alarmType.includes('data_outages') || c.alarmType.includes('data_exception')) { |
|
|
@ -110,6 +117,7 @@ module.exports = function (app, opts) { |
|
|
|
`).toPromise())[0].count
|
|
|
|
: 0 |
|
|
|
} |
|
|
|
appAlarmWhereOption.createTime = { $lte: pointTime } |
|
|
|
} |
|
|
|
|
|
|
|
// 判断告警数据范围
|
|
|
@ -135,9 +143,7 @@ module.exports = function (app, opts) { |
|
|
|
cameraAlarm.confirmContent AS confirmContent, |
|
|
|
cameraAlarm.confirmTime AS confirmTime, |
|
|
|
cameraAlarm.autoRestore AS autoRestore, |
|
|
|
camera_status_resolve.id AS resolveId, |
|
|
|
camera_status.describe AS statusDescribe, |
|
|
|
camera_status_resolve.resolve AS resolve, |
|
|
|
"gbCamera".online AS cameraOnline, |
|
|
|
anxinIpc.t_video_ipc.name AS anxinIpcPosition, |
|
|
|
anxinStation.id AS anxinStationId, |
|
|
@ -155,7 +161,7 @@ module.exports = function (app, opts) { |
|
|
|
camera_status_alarm.serial_no AS cameraSerialNo, |
|
|
|
camera_status_alarm.channel_no AS cameraChannelNo, |
|
|
|
camera_status_alarm.confirm AS confirmContent, |
|
|
|
${'camera_status_alarm.auto_restore AS autoRestore,'} |
|
|
|
camera_status_alarm.auto_restore AS autoRestore, |
|
|
|
camera_status_alarm.confirm_time AS confirmTime |
|
|
|
FROM camera_status_alarm |
|
|
|
INNER JOIN ${anxinyun}.t_video_ipc |
|
|
@ -165,15 +171,13 @@ module.exports = function (app, opts) { |
|
|
|
INNER JOIN camera |
|
|
|
ON camera.serial_no = camera_status_alarm.serial_no |
|
|
|
AND camera.channel_no = camera_status_alarm.channel_no |
|
|
|
WHERE |
|
|
|
camera.delete = false |
|
|
|
AND camera.delete = false |
|
|
|
AND camera.recycle_time is null |
|
|
|
WHERE camera_status_alarm.confirm_time IS null |
|
|
|
) AS cameraAlarm |
|
|
|
LEFT JOIN camera_status |
|
|
|
ON cameraAlarm.platform = camera_status.platform |
|
|
|
AND cameraAlarm.statusId = camera_status.id |
|
|
|
LEFT JOIN camera_status_resolve |
|
|
|
ON camera_status_resolve.status_id = camera_status.id |
|
|
|
LEFT JOIN "gbCamera" |
|
|
|
ON "gbCamera".id = cameraAlarm.gbId |
|
|
|
|
|
|
@ -196,12 +200,7 @@ module.exports = function (app, opts) { |
|
|
|
for (let a of videoAlarms) { |
|
|
|
if (positionD[a.cameraId]) { |
|
|
|
let curD = returnD[positionD[a.cameraId].positionReturnD] |
|
|
|
if (a.resolveId && !curD.resolve.some(r => r.id == a.resolveId)) { |
|
|
|
curD.resolve.push({ |
|
|
|
id: a.resolveId, |
|
|
|
resolve: a.resolve |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
if (a.strucId && !curD.struc.some(s => s.id == a.strucId)) { |
|
|
|
curD.struc.push({ |
|
|
|
id: a.strucId, |
|
|
@ -231,32 +230,10 @@ module.exports = function (app, opts) { |
|
|
|
alarmId: a.alarmId, |
|
|
|
confirmContent: a.confirmContent, |
|
|
|
confirmTime: a.confirmTime, |
|
|
|
|
|
|
|
venderId: a.venderId, |
|
|
|
venderName: a.venderName, |
|
|
|
cameraKindId: a.cameraKindId, |
|
|
|
|
|
|
|
resolve: [], |
|
|
|
struc: [], |
|
|
|
station: [] |
|
|
|
} |
|
|
|
|
|
|
|
// pep 项目
|
|
|
|
// d.pomsProject = (
|
|
|
|
// anxinStruc.find(as => as.strucId == a.strucId) ||
|
|
|
|
// {
|
|
|
|
// pomsProject: [
|
|
|
|
|
|
|
|
// ]
|
|
|
|
// }
|
|
|
|
// ).pomsProject
|
|
|
|
|
|
|
|
if (a.resolveId) { |
|
|
|
d.resolve.push({ |
|
|
|
id: a.resolveId, |
|
|
|
resolve: a.resolve |
|
|
|
}) |
|
|
|
} |
|
|
|
if (a.strucId) { |
|
|
|
d.struc.push({ |
|
|
|
id: a.strucId, |
|
|
@ -280,7 +257,19 @@ module.exports = function (app, opts) { |
|
|
|
let p = 1 |
|
|
|
} |
|
|
|
if (c.alarmType.includes('app_exception')) { |
|
|
|
|
|
|
|
appAlarms = await models.AppAlarm.findAll({ |
|
|
|
where: appAlarmWhereOption, |
|
|
|
include: [{ |
|
|
|
model: models.App, |
|
|
|
include: [{ |
|
|
|
model: models.ProjectApp, |
|
|
|
where: { |
|
|
|
projectId: pomsProjectId |
|
|
|
}, |
|
|
|
}] |
|
|
|
}] |
|
|
|
}) |
|
|
|
let a = 2 |
|
|
|
} |
|
|
|
if (c.alarmType.includes('device_exception')) { |
|
|
|
dataAlarmGroupOption.push(4) |
|
|
|