From 75d7ca64ee2022530dc24e13702cca218d424469 Mon Sep 17 00:00:00 2001 From: "gao.zhiyuan" Date: Sun, 6 Nov 2022 22:10:59 +0800 Subject: [PATCH 1/2] pepPojectIds --- api/app/lib/controllers/control/data.js | 8 +++++--- api/app/lib/service/clickHouseClient.js | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/api/app/lib/controllers/control/data.js b/api/app/lib/controllers/control/data.js index 553c28d..4b8b1a1 100644 --- a/api/app/lib/controllers/control/data.js +++ b/api/app/lib/controllers/control/data.js @@ -305,7 +305,9 @@ async function getLatestDynamic(ctx) { //查项目名称 查用户名 let pepPojectIds = new Set(), notedUserIds = new Set(); for (let p of news) { - pepPojectIds.add(p.projectCorrelation.pepProjectId); + if(p.projectCorrelation && p.projectCorrelation.pepProjectId){ + pepPojectIds.add(p.projectCorrelation.pepProjectId); + } if (p.emailSendLog) { p.emailSendLog.toPepUserIds.map(u => { @@ -317,8 +319,8 @@ async function getLatestDynamic(ctx) { } } let pepProjects = pepPojectIds.size ? await clickHouse.projectManage.query(` - SELECT id, project_name FROM t_pim_project WHERE id IN (${[...pepPojectIds].join(',')},-1) - `).toPromise() : []; + SELECT id, project_name FROM t_pim_project WHERE id IN (${[...pepPojectIds].join(',')},-1) + `).toPromise() : []; let userPepRes = notedUserIds.size ? await clickHouse.pepEmis.query( `SELECT DISTINCT user.id AS id, "user"."name" AS name FROM user WHERE user.id IN (${[...notedUserIds].join(',')},-1) diff --git a/api/app/lib/service/clickHouseClient.js b/api/app/lib/service/clickHouseClient.js index 998033a..f688681 100644 --- a/api/app/lib/service/clickHouseClient.js +++ b/api/app/lib/service/clickHouseClient.js @@ -11,7 +11,7 @@ function factory (app, opts) { app.fs.clickHouse[d.name] = new ClickHouse({ url: url, port: port, - debug: true || opts.dev, + debug: opts.dev, format: "json", basicAuth: user && password ? { username: user, From 612a1ed3ce9ba1a7079eaabebef15ca60f062a74 Mon Sep 17 00:00:00 2001 From: "gao.zhiyuan" Date: Sun, 6 Nov 2022 22:21:31 +0800 Subject: [PATCH 2/2] =?UTF-8?q?kafka=20=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/app/lib/service/kafka.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/app/lib/service/kafka.js b/api/app/lib/service/kafka.js index cb6f9d8..5e85899 100644 --- a/api/app/lib/service/kafka.js +++ b/api/app/lib/service/kafka.js @@ -1,6 +1,7 @@ 'use strict'; const moment = require('moment'); const Kafka = require('kafka-node'); + module.exports = async function factory(app, opts) { try { const client = new Kafka.KafkaClient({ kafkaHost: opts.kafka.rootURL, fromOffset: true }); @@ -9,14 +10,13 @@ module.exports = async function factory(app, opts) { app.fs.logger.log('error', "[FS-KAFKA]", err); }); producer.on("ready", function () { - console.log('111111 ready 666666666666') + console.log('Kafka ready') }) let groupId = 'group' + Math.random() let consumer = new Kafka.ConsumerGroup(Object.assign({}, { groupId, fromOffset: 'latest' }, { kafkaHost: opts.kafka.rootURL }), ['anxinyun_alarm']) consumer.on('message', async function (message) { let msg = JSON.parse(message.value) - console.log('kafka consumer----------接收到消息'); await savePullAlarm(msg); })