|
|
@ -4,7 +4,7 @@ module.exports = function (app, opts) { |
|
|
|
const alarmsPush = app.fs.scheduleInit( |
|
|
|
{ |
|
|
|
interval: '12 */1 * * * *', |
|
|
|
immediate: true, // dev
|
|
|
|
// immediate: true, // dev
|
|
|
|
proRun: true, |
|
|
|
}, |
|
|
|
async () => { |
|
|
@ -112,7 +112,13 @@ module.exports = function (app, opts) { |
|
|
|
` |
|
|
|
).toPromise() : |
|
|
|
[] |
|
|
|
let searchStrucIds = strucListRes.map(s => s.id) |
|
|
|
let strucThingId = [] |
|
|
|
let searchStrucIds = strucListRes.map(s => { |
|
|
|
if (s.iotaThingId) { |
|
|
|
strucThingId.push(s.iotaThingId) |
|
|
|
} |
|
|
|
return s.id |
|
|
|
}) |
|
|
|
|
|
|
|
searchStrucIds = searchStrucIds.concat([991, 1052, 700]) |
|
|
|
|
|
|
@ -177,11 +183,13 @@ module.exports = function (app, opts) { |
|
|
|
} else { |
|
|
|
if (c.alarmType.includes('data_outages') || c.alarmType.includes('data_exception')) { |
|
|
|
// 查了设备异常率 去安心云查当前项目下的设备数量
|
|
|
|
// TODO 等同步以太数据再查
|
|
|
|
deviceCount = 9999 |
|
|
|
// await clickHouse.anxinyun.query(`
|
|
|
|
// SELECT count(*) FROM
|
|
|
|
// `).toPromise()
|
|
|
|
let deviceCountRes = |
|
|
|
strucThingId.length ? |
|
|
|
await clickHouse.iot.query(` |
|
|
|
SELECT count(DeviceId) AS count FROM device WHERE ThingId IN (${strucThingId.map(t => `'${t}'`).join(',')}, '-1') |
|
|
|
`).toPromise()
|
|
|
|
: [] |
|
|
|
deviceCount = deviceCountRes.length ? deviceCountRes[0].count : 0 |
|
|
|
} |
|
|
|
if (c.alarmType.includes('video_exception')) { |
|
|
|
// 查了视频异常 去安心云查 接入的 萤石 设备数量
|
|
|
@ -675,9 +683,9 @@ module.exports = function (app, opts) { |
|
|
|
} |
|
|
|
return arr |
|
|
|
}, []) |
|
|
|
if (emails.length || 1) { |
|
|
|
if (emails.length) { |
|
|
|
await pushByEmail({ |
|
|
|
email: ['1650192445@qq.com', '777y'], |
|
|
|
email: emails, |
|
|
|
title: emailTitle, |
|
|
|
text: '', |
|
|
|
html: html |
|
|
|