diff --git a/api/app/lib/schedule/alarms_push.js b/api/app/lib/schedule/alarms_push.js index 4a844cf..e55aaa1 100644 --- a/api/app/lib/schedule/alarms_push.js +++ b/api/app/lib/schedule/alarms_push.js @@ -1,10 +1,10 @@ const moment = require('moment') let isDev = false -// isDev = true +isDev = true let proDebug = false -proDebug = true +// proDebug = true module.exports = function (app, opts) { const alarmsPush = app.fs.scheduleInit( @@ -102,6 +102,10 @@ module.exports = function (app, opts) { pLog(`curMinOfYear / ${curMinOfYear}`) for (let { dataValues: c } of configListRes) { + if (c.id != 94) { + continue + } + if (c.tacticsParams && c.tactics) { pLog(`当前运行EM配置:id=${c.id} name=${c.name}`); // pomsProjectId 是个数组 [] @@ -545,17 +549,17 @@ module.exports = function (app, opts) { //本地化 const dataAlarmsLocal = !c.alarmSubType || dataAlarmSubType_.length ? await clickHouse.dataAlarm.query(` - SELECT * FROM alarms - LEFT JOIN sensors - AS anxinStation - ON anxinStation.ID= alarms.SourceId - AND alarms.SourceTypeId = 2 - WHERE - ${`State NOT IN (3, 4) AND `} - StructureId IN (${searchStrucIds.join(',')}) - ${dataAlarmOption.length ? ' AND ' + dataAlarmOption.join(' AND ') : ''} - ORDER BY StartTime DESC - `).toPromise() : [] + SELECT * FROM alarms + LEFT JOIN sensors + AS anxinStation + ON anxinStation.ID= alarms.SourceId + AND alarms.SourceTypeId = 2 + WHERE + ${`State NOT IN (3, 4) AND `} + StructureId IN (${searchStrucIds.join(',')}) + ${dataAlarmOption.length ? ' AND ' + dataAlarmOption.join(' AND ') : ''} + ORDER BY StartTime DESC + `).toPromise() : [] //合并本地化和安心云的告警 dataAlarms = [...dataAlarms, ...dataAlarmsLocal] pLog('合并的告警列表(安心云+本地)', dataAlarms.length) @@ -1092,9 +1096,6 @@ module.exports = function (app, opts) { } } } - if (proDebug) { - console.log(`符合条件的策略命中 + 1`, d); - } dataAlarmG3.push(d) } else if (d.AlarmGroup == 4 || d.AlarmGroup == 5) { dataAlarmG45.push(d) @@ -1166,7 +1167,7 @@ module.exports = function (app, opts) { pLog('安心云项目结构物id', dataAlarmG1StructureId) pLog('本地化项目结构物id', dataAlarmStructureId) //查询结构物的监测因素(安心云) - let factorData = dataAlarmStructureId.size ? await clickHouse.anxinyun.query( + let factorData = dataAlarmG1StructureId.size ? await clickHouse.anxinyun.query( ` SELECT t_structure_factor.structure AS structureId, @@ -1676,7 +1677,7 @@ module.exports = function (app, opts) { if (isDev) { // !开发测试用的数据 - emails = ['1650192445@qq.com'] + emails = ['gao.zhiyuan@free-sun.com.cn'] // emails=['zhao.bin@free-sun.com.cn'] // emails = ['wen.lele@free-sun.com.cn'] } @@ -1690,6 +1691,9 @@ module.exports = function (app, opts) { html: html }) + if (isDev) { + continue + } // //存日志 存动态 socket到前端 let dataToSave = { time: moment().format(), diff --git a/api/app/lib/service/clickHouseClient.js b/api/app/lib/service/clickHouseClient.js index f688681..ecae84a 100644 --- a/api/app/lib/service/clickHouseClient.js +++ b/api/app/lib/service/clickHouseClient.js @@ -13,6 +13,7 @@ function factory (app, opts) { port: port, debug: opts.dev, format: "json", + usePost: true, basicAuth: user && password ? { username: user, password: password,