From 1b2b2975ae6be20410f1db011715b8d9d7448330 Mon Sep 17 00:00:00 2001 From: CODE <1650192445@qq.com> Date: Mon, 11 Sep 2023 15:46:59 +0800 Subject: [PATCH] alarm push debug --- api/app/lib/schedule/alarms_push.js | 52 ++++++++++++++++------------- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/api/app/lib/schedule/alarms_push.js b/api/app/lib/schedule/alarms_push.js index 0dc6264..0e56f7e 100644 --- a/api/app/lib/schedule/alarms_push.js +++ b/api/app/lib/schedule/alarms_push.js @@ -97,8 +97,7 @@ module.exports = function (app, opts) { return title } - pLog('EM推送列表',); - pLog(configListRes) + pLog('EM推送列表_' + configListRes.length,); for (let { dataValues: c } of configListRes) { @@ -109,37 +108,44 @@ module.exports = function (app, opts) { const { interval, deviceProportion } = c.tacticsParams if (curMinOfYear % parseInt(interval) == 0 || isDev) { - + pLog(`符合时间断点`) const corPomsProject = pomsProjectRes.filter(poms => pomsProjectId.includes(poms.id)) let curAnxinProjectId = new Set() let pepProjectName_ = [] let pepProject_name = [] //当前有关联的项目,后面往对应项目里面插入对应的结构物-监测因素-告警源 - for (let { dataValues: poms } of corPomsProject) { - if (poms.pepProjectId) { - // 找对应的项企项目 - const corPepProject = - pepProjectRes.find(p => p.id == poms.pepProjectId) - if (corPepProject && c.timeType.some(ct => ct == corPepProject.construction_status_id)) { - pepProjectName_.push(corPepProject.project_name) - pepProject_name.push({ id: poms.id, anxinProjectId: poms.anxinProjectId, name: corPepProject.project_name }) + + try { + for (let { dataValues: poms } of corPomsProject) { + if (poms.pepProjectId) { + // 找对应的项企项目 + const corPepProject = + pepProjectRes.find(p => p.id == poms.pepProjectId) + if (corPepProject && c.timeType.some(ct => ct == corPepProject.construction_status_id)) { + pepProjectName_.push(corPepProject.project_name) + pepProject_name.push({ id: poms.id, anxinProjectId: poms.anxinProjectId, name: corPepProject.project_name }) + } else { + // 不符合当前项目的时间节点 + continue + } } else { - // 不符合当前项目的时间节点 - continue + // 是自定义项目 + if (poms.name) { + pepProjectName_.push(poms.name) + pepProject_name.push({ id: poms.id, anxinProjectId: poms.anxinProjectId, name: poms.name }) + } + } - } else { - // 是自定义项目 - if (poms.name) { - pepProjectName_.push(poms.name) - pepProject_name.push({ id: poms.id, anxinProjectId: poms.anxinProjectId, name: poms.name }) + // 筛选全部的 anxinProjectId pepProjectId + for (let axId of poms.anxinProjectId) { + curAnxinProjectId.add(axId) } - - } - // 筛选全部的 anxinProjectId pepProjectId - for (let axId of poms.anxinProjectId) { - curAnxinProjectId.add(axId) } + } catch (error) { + console.error(error); + throw error } + const anxinProjectId = [...curAnxinProjectId] // 查当前 poms 下的结构物 并把不包含的去掉 // 可能有结构物已解绑