Browse Source

告警->项目阶段

dev
巴林闲侠 2 years ago
parent
commit
6122455ad6
  1. 4
      api/app/lib/controllers/alarm/data.js
  2. 14
      api/app/lib/utils/dataRange.js

4
api/app/lib/controllers/alarm/data.js

@ -125,8 +125,10 @@ async function list (ctx) {
// TODO: 开发临时添加 // TODO: 开发临时添加
{ {
id: 999, id: 999,
name: '这是假的开发の数据,看到请拨打110', projectName: '这是假的开发の数据,看到请拨打110',
isdelete: 0, isdelete: 0,
constructionStatusId: 1,
constructionStatus: '建设中',
} }
] ]
}).pepProject }).pepProject

14
api/app/lib/utils/dataRange.js

@ -38,8 +38,8 @@ module.exports = function (app, opts) {
// 根据 poms 的项目绑定关系查相关联的项企项目、安心云项目id信息 // 根据 poms 的项目绑定关系查相关联的项企项目、安心云项目id信息
const bindRes = await models.ProjectCorrelation.findAll(findOption) const bindRes = await models.ProjectCorrelation.findAll(findOption)
// 获取不重复的 安心云项目id // 获取不重复的 安心云项目id
let pepProjectIds = bindRes.map(b => b.pepProjectId) let pepProjectIds = bindRes.map(b => b.pepProjectId)
// 查询项企项目的信息 // 查询项企项目的信息
let pepProjectWhereOptions = [] let pepProjectWhereOptions = []
@ -50,9 +50,17 @@ module.exports = function (app, opts) {
await clickHouse.projectManage.query( await clickHouse.projectManage.query(
` `
SELECT SELECT
id, project_name AS name, isdelete t_pim_project.id AS id,
t_pim_project.project_name AS projectName,
t_pim_project.isdelete AS isdelete,
t_pim_project_construction.construction_status_id AS constructionStatusId,
t_pim_project_state.construction_status AS constructionStatus
FROM FROM
t_pim_project t_pim_project
LEFT JOIN t_pim_project_construction
ON t_pim_project.id = t_pim_project_construction.project_id
LEFT JOIN t_pim_project_state
ON t_pim_project_construction.construction_status_id = t_pim_project_state.id
WHERE WHERE
id IN (${pepProjectIds.join(',')}) id IN (${pepProjectIds.join(',')})
${pepProjectWhereOptions.length ? `AND ${pepProjectWhereOptions.join(' AND ')}` ${pepProjectWhereOptions.length ? `AND ${pepProjectWhereOptions.join(' AND ')}`

Loading…
Cancel
Save