diff --git a/api/app/lib/schedule/alarms_push.js b/api/app/lib/schedule/alarms_push.js index e55aaa1..8a41ece 100644 --- a/api/app/lib/schedule/alarms_push.js +++ b/api/app/lib/schedule/alarms_push.js @@ -4,7 +4,7 @@ let isDev = false isDev = true let proDebug = false -// proDebug = true +proDebug = true module.exports = function (app, opts) { const alarmsPush = app.fs.scheduleInit( @@ -24,6 +24,7 @@ module.exports = function (app, opts) { const { clickHouse } = app.fs const { database: anxinyun } = clickHouse.anxinyun.opts.config const { database: dataAlarm } = clickHouse.dataAlarm.opts.config + const { database: iota } = clickHouse.iot.opts.config const { pushBySms, pushByEmail, sendNoticeToWeb } = app.fs.utils const curMinOfYear = moment().diff(moment().startOf('year'), 'minutes') @@ -77,6 +78,7 @@ module.exports = function (app, opts) { [] const calcMinute2DHM = (minute) => { + pLog('calcMinute2DHM ', minute) if (!minute && minute != 0) { return minute } @@ -94,6 +96,7 @@ module.exports = function (app, opts) { if (h) { title = title + m + '分' } + pLog('calcMinute2DHM Rslt', title) return title } @@ -102,9 +105,9 @@ module.exports = function (app, opts) { pLog(`curMinOfYear / ${curMinOfYear}`) for (let { dataValues: c } of configListRes) { - if (c.id != 94) { - continue - } + // if (isDev && c.id != 94) { + // continue + // } if (c.tacticsParams && c.tactics) { pLog(`当前运行EM配置:id=${c.id} name=${c.name}`); @@ -558,6 +561,7 @@ module.exports = function (app, opts) { ${`State NOT IN (3, 4) AND `} StructureId IN (${searchStrucIds.join(',')}) ${dataAlarmOption.length ? ' AND ' + dataAlarmOption.join(' AND ') : ''} + AND Project IS NOT null ORDER BY StartTime DESC `).toPromise() : [] //合并本地化和安心云的告警 @@ -623,8 +627,12 @@ module.exports = function (app, opts) { n: '持续时间', k: '', f: (d) => { - return d.StartTime ? - '超过' + calcMinute2DHM(moment().diff(moment(d.StartTime), 'minutes')) : '' + let str = '' + if (d.StartTime) { + str = calcMinute2DHM(moment().diff(moment(d.StartTime), 'minutes')) + } + return str ? + '超过' + str : '' } },] @@ -679,8 +687,12 @@ module.exports = function (app, opts) { n: '持续时间', k: '', f: (d) => { - return d.StartTime ? - '超过' + calcMinute2DHM(moment().diff(moment(d.StartTime), 'minutes')) : '' + let str = '' + if (d.StartTime) { + str = calcMinute2DHM(moment().diff(moment(d.StartTime), 'minutes')) + } + return str ? + '超过' + str : '' } },] @@ -745,8 +757,12 @@ module.exports = function (app, opts) { // n: '持续时间', // k: '', // f: (d) => { - // return d.StartTime ? - // '超过' + calcMinute2DHM(moment().diff(moment(d.StartTime), 'minutes')) : '' + // let str = '' + // if (d.StartTime) { + // str = calcMinute2DHM(moment().diff(moment(d.StartTime), 'minutes')) + // } + // return str ? + // '超过' + str : '' // } // }, // { @@ -832,8 +848,12 @@ module.exports = function (app, opts) { n: '持续时间', k: '', f: (d) => { - return d.createTime ? - '超过' + calcMinute2DHM(moment().diff(moment(d.createTime), 'minutes')) : '' + let str = '' + if (d.createTime) { + str = calcMinute2DHM(moment().diff(moment(d.createTime), 'minutes')) + } + return str ? + '超过' + str : '' } },] @@ -872,8 +892,12 @@ module.exports = function (app, opts) { n: '持续时间', k: '', f: (d) => { - return d.createTime ? - '超过' + calcMinute2DHM(moment().diff(moment(d.createTime), 'minutes')) : '' + let str = '' + if (d.createTime) { + str = calcMinute2DHM(moment().diff(moment(d.createTime), 'minutes')) + } + return str ? + '超过' + str : '' } },] @@ -1150,14 +1174,18 @@ module.exports = function (app, opts) {