Browse Source

异常率低于设置值则不推

dev
巴林闲侠 2 years ago
parent
commit
f050679c6d
  1. 14
      api/app/lib/schedule/alarms_push.js

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

@ -120,7 +120,8 @@ module.exports = function (app, opts) {
return s.id return s.id
}) })
searchStrucIds = searchStrucIds.concat([991, 1052, 700]) // 开发测试用的数据
// searchStrucIds = searchStrucIds.concat([991, 1052, 700])
if (searchStrucIds.length) { if (searchStrucIds.length) {
searchStrucIds.unshift(-1) searchStrucIds.unshift(-1)
@ -377,7 +378,7 @@ module.exports = function (app, opts) {
dataAlarms = await clickHouse.dataAlarm.query(` dataAlarms = await clickHouse.dataAlarm.query(`
SELECT * FROM alarms SELECT * FROM alarms
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
@ -602,8 +603,13 @@ module.exports = function (app, opts) {
deviceStatistic.add(d.SourceId) deviceStatistic.add(d.SourceId)
} }
if (c.tactics == 'abnormal_rate') { if (c.tactics == 'abnormal_rate') {
let a = ((deviceStatistic.size + videoAlarms.length) / (parseInt(deviceCount) + parseInt(cameraCount))).toFixed(1) + '%' let rate = ((deviceStatistic.size + videoAlarms.length) / (parseInt(deviceCount) + parseInt(cameraCount)));
emailSubTitle = emailSubTitle.replace('--%', ((deviceStatistic.size + videoAlarms.length) / (parseInt(deviceCount) + parseInt(cameraCount))).toFixed(1) + '%')
if (rate < parseFloat(deviceProportion)) {
continue
}
emailSubTitle = emailSubTitle.replace('--%', rate.toFixed(1) + '%')
} }
let html = ` let html = `
<html> <html>

Loading…
Cancel
Save