diff --git a/api/app/lib/schedule/alarms_push.js b/api/app/lib/schedule/alarms_push.js index 24b52e2..6663ab3 100644 --- a/api/app/lib/schedule/alarms_push.js +++ b/api/app/lib/schedule/alarms_push.js @@ -106,7 +106,11 @@ module.exports = function (app, opts) { pLog(`当前运行EM配置:id=${c.id} name=${c.name}`); // pomsProjectId 是个数组 [] const { strucId, pomsProjectId, pomsStrucFactorId } = c - const { interval, deviceProportion } = c.tacticsParams + let { interval, deviceProportion } = c.tacticsParams + if (c.tactics == 'abnormal_rate') { + interval = parseInt(interval) * 60 + } + pLog(`tactics = ${c.tactics}`) pLog(`interval / ${interval} /${curMinOfYear % parseInt(interval)}`) if (curMinOfYear % parseInt(interval) == 0 || isDev) { pLog(`符合时间断点`) @@ -272,7 +276,7 @@ module.exports = function (app, opts) { appAlarmWhereOption.createTime = { $lte: pointTime } videoAlarmWhereOption.push(`camera_status_alarm.create_time <= '${pointTime}'`) // 新增的应该是上一个时间节点到上上个节点之间 - newAddStartTime = moment(pointTime).subtract(parseInt(interval)).format('YYYY-MM-DD HH:mm:ss') + newAddStartTime = moment(pointTime).subtract(parseInt(interval), 'minute').format('YYYY-MM-DD HH:mm:ss') newAddEndTime = pointTime if (c.tactics == 'continue') { @@ -301,7 +305,7 @@ module.exports = function (app, opts) { pLog(`查得安心云当前项目下萤石设备总数量 - ${cameraCount}`) } emailTitle += `异常率推送服务` - emailSubTitle += `持续产生时间超过${interval}分钟的异常设备数量${interval}个,异常率达到项目或结构物内设备总数量${parseInt(deviceCount) + parseInt(cameraCount)}个的 --%,详情如下` // --% 是在下面计算得 + emailSubTitle += `持续产生时间超过${(interval / 60).toFixed(0)}小时的异常设备数量**个,异常率达到项目或结构物内设备总数量${parseInt(deviceCount) + parseInt(cameraCount)}个的 --%,详情如下` // --% ** 是在下面计算得 } } emailTitle += '_POMS飞尚运维中台' @@ -1087,14 +1091,17 @@ module.exports = function (app, opts) { if (c.tactics == 'abnormal_rate') { pLog(`异常设备数量 - ${deviceStatistic.size}`) pLog(`异常视频告警数量 - ${videoAlarms.length}`) - let rate = ((deviceStatistic.size + videoAlarms.length) / (parseInt(deviceCount) + parseInt(cameraCount))) * 100; + let abnormalDeviceCount = deviceStatistic.size + videoAlarms.length + let rate = (abnormalDeviceCount / (parseInt(deviceCount) + parseInt(cameraCount))) * 100; pLog(`异常比率 ${rate} 设定值 ${deviceProportion}`) if (rate < parseFloat(deviceProportion)) { // 设备异常率低于设定值 continue } - emailSubTitle = emailSubTitle.replace('--%', rate.toFixed(1) + '%') + emailSubTitle = emailSubTitle + .replace('--%', rate.toFixed(1) + '%') + .replace('**', abnormalDeviceCount.toFixed(0)) } // 注1 if (apMergeDeVeAnxinProjectId_.length || isDev) {