From b1a4d03bb51ef8f96b3032d8ae3b0697312f33f9 Mon Sep 17 00:00:00 2001 From: "gao.zhiyuan" Date: Wed, 23 Nov 2022 09:18:04 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=91=E5=AE=9A=E9=A1=B9=E7=9B=AE=E7=9A=84?= =?UTF-8?q?=E7=BB=93=E6=9E=84=E7=89=A9=E6=94=AF=E6=8C=81=E5=A4=9Aid?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/app/lib/controllers/project/index.js | 42 +++++++++++-------- .../0.10/schema/1.alter_alarm_push_config.sql | 8 ++++ 2 files changed, 33 insertions(+), 17 deletions(-) diff --git a/api/app/lib/controllers/project/index.js b/api/app/lib/controllers/project/index.js index 2659964..c2807a3 100644 --- a/api/app/lib/controllers/project/index.js +++ b/api/app/lib/controllers/project/index.js @@ -57,7 +57,7 @@ async function pomsProject (ctx) { if (p.pepProjectId) { pepProjectIds.add(p.pepProjectId) } - if(p.createUser){ + if (p.createUser) { createUsers.add(p.createUser) } for (let ap of p.anxinProjectId) { @@ -66,18 +66,18 @@ async function pomsProject (ctx) { } } } - const pomsUser = await models.User.findAll({ - where: { - id: { $in: [...createUsers]} - } - }) - let pepUserIds = new Set() - for (let p of pomsUser) { - if (p.pepUserId) { + const pomsUser = await models.User.findAll({ + where: { + id: { $in: [...createUsers] } + } + }) + let pepUserIds = new Set() + for (let p of pomsUser) { + if (p.pepUserId) { pepUserIds.add(p.pepUserId) - } - } - const pepcaUser = pepUserIds.size ? + } + } + const pepcaUser = pepUserIds.size ? await clickHouse.pepEmis.query( ` SELECT * FROM user @@ -112,7 +112,7 @@ async function pomsProject (ctx) { for (let p of proRes.rows) { const corPro = pepProjectRes.find(pp => pp.id == p.pepProjectId) || {} - const pepUserName = (pepcaUser.find(qq => qq.id == (pomsUser.find(oo => oo.id == p.createUser)||{}).pepUserId)||{}).name ||'' + const pepUserName = (pepcaUser.find(qq => qq.id == (pomsUser.find(oo => oo.id == p.createUser) || {}).pepUserId) || {}).name || '' p.dataValues.pepProjectName = corPro.project_name p.dataValues.pepProjectIsDelete = corPro.isdelete p.dataValues.constructionStatusId = corPro.construction_status_id @@ -210,15 +210,23 @@ async function strucWithPomsProject (ctx) { const { clickHouse } = ctx.app.fs const { pomsProjectId } = ctx.query - const bindRes = await models.ProjectCorrelation.findOne({ + const bindRes = await models.ProjectCorrelation.findAll({ where: { - id: pomsProjectId + id: { $in: pomsProjectId.split(',') } } }) + let anxinProjectIds = new Set() + for (let b of bindRes) { + if (b.anxinProjectId.length) { + for (let aid of b.anxinProjectId) { + anxinProjectIds.add(aid) + } + } + } let undelStruc = [] if (bindRes) { - const undelStrucRes = bindRes.anxinProjectId.length ? + const undelStrucRes = anxinProjectIds.size ? await clickHouse.anxinyun.query( ` SELECT @@ -249,7 +257,7 @@ async function strucWithPomsProject (ctx) { WHERE project_state != -1 AND - t_project.id IN (${bindRes.anxinProjectId.join(',')}) + t_project.id IN (${[...anxinProjectIds].join(',')}, -1) ORDER BY strucId ` ).toPromise() : diff --git a/script/0.10/schema/1.alter_alarm_push_config.sql b/script/0.10/schema/1.alter_alarm_push_config.sql index 08ad5b3..8bf1d54 100644 --- a/script/0.10/schema/1.alter_alarm_push_config.sql +++ b/script/0.10/schema/1.alter_alarm_push_config.sql @@ -6,3 +6,11 @@ comment on column alarm_push_config.alarm_sub_type is '存对应监听模块(ala 视频异常:camera.kind_id, 应用异常:app_alarm.errType )'; + + +ALTER TABLE alarm_push_config ALTER COLUMN poms_project_id TYPE INTEGER [] + USING CASE + WHEN poms_project_id is NULL + then NULL + ELSE array [poms_project_id] + END ::INTEGER []; \ No newline at end of file