diff --git a/api/app/lib/schedule/alarms_push.js b/api/app/lib/schedule/alarms_push.js index c6a1a37..9b2c556 100644 --- a/api/app/lib/schedule/alarms_push.js +++ b/api/app/lib/schedule/alarms_push.js @@ -120,7 +120,8 @@ module.exports = function (app, opts) { return s.id }) - searchStrucIds = searchStrucIds.concat([991, 1052, 700]) + // 开发测试用的数据 + // searchStrucIds = searchStrucIds.concat([991, 1052, 700]) if (searchStrucIds.length) { searchStrucIds.unshift(-1) @@ -377,7 +378,7 @@ module.exports = function (app, opts) { dataAlarms = await clickHouse.dataAlarm.query(` SELECT * FROM alarms WHERE - ${`'State NOT IN (3, 4) AND '`} + ${`State NOT IN (3, 4) AND `} StructureId IN (${searchStrucIds.join(',')}) ${dataAlarmOption.length ? ' AND ' + dataAlarmOption.join(' AND ') : ''} ORDER BY StartTime DESC @@ -602,8 +603,13 @@ module.exports = function (app, opts) { deviceStatistic.add(d.SourceId) } if (c.tactics == 'abnormal_rate') { - let a = ((deviceStatistic.size + videoAlarms.length) / (parseInt(deviceCount) + parseInt(cameraCount))).toFixed(1) + '%' - emailSubTitle = emailSubTitle.replace('--%', ((deviceStatistic.size + videoAlarms.length) / (parseInt(deviceCount) + parseInt(cameraCount))).toFixed(1) + '%') + let rate = ((deviceStatistic.size + videoAlarms.length) / (parseInt(deviceCount) + parseInt(cameraCount))); + + if (rate < parseFloat(deviceProportion)) { + continue + } + + emailSubTitle = emailSubTitle.replace('--%', rate.toFixed(1) + '%') } let html = `