Browse Source

fix 项目集等级信息

dev
CODE 1 year ago
parent
commit
d054a70ae8
  1. 28
      api/app/lib/controllers/project/group.js

28
api/app/lib/controllers/project/group.js

@ -174,16 +174,17 @@ async function groupStatistic (ctx) {
console.log(`查询pepm项目`, pepmProjectIdArr.join(',')); console.log(`查询pepm项目`, pepmProjectIdArr.join(','));
let pepmCustomerLevelRes = pepmProjectIdArr.length ? await clickHouse.projectManage.query( let pepmCustomerLevelRes = pepmProjectIdArr.length ? await clickHouse.projectManage.query(
` `
SELECT DISTINCT t_rpm_customer_level.id AS id, t_rpm_customer_level.name AS name FROM t_pim_project SELECT t_rpm_customer_level.id AS id, t_rpm_customer_level.name AS name, t_pim_project.id AS projectId
LEFT JOIN t_rpm_customer FROM t_pim_project
ON t_rpm_customer.id = t_pim_project.related_customers_id LEFT JOIN t_rpm_customer
LEFT JOIN t_rpm_customer_level ON t_rpm_customer.id = t_pim_project.related_customers_id
ON t_rpm_customer_level.id = t_rpm_customer.level LEFT JOIN t_rpm_customer_level
ON t_rpm_customer_level.id = t_rpm_customer.level
WHERE t_pim_project.id IN (${pepmProjectIdArr.join(',')},-1) WHERE t_pim_project.id IN (${pepmProjectIdArr.join(',')},-1)
` `
).toPromise() : [] ).toPromise() : []
console.log(pepmCustomerLevelRes); console.log(pepmCustomerLevelRes);
pepmCustomerLevelRes.sort((a, b) => a.id - b.id) // pepmCustomerLevelRes = pepmCustomerLevelRes.filter(item => item && item.id > 0)
// 统计安心云项目下的结构物 // 统计安心云项目下的结构物
const strucRes = anxinProjectIdArr.length ? await clickHouse.anxinyun.query( const strucRes = anxinProjectIdArr.length ? await clickHouse.anxinyun.query(
@ -245,10 +246,14 @@ async function groupStatistic (ctx) {
).toPromise() : [] ).toPromise() : []
let rslt = [] let rslt = []
// progectGroupList 是自定义分组信息
for (let pg of progectGroupList) { for (let pg of progectGroupList) {
let strucCount = 0 let strucCount = 0
let maxOffLineTime = 0 let maxOffLineTime = 0
let todayAlarms = 0 let todayAlarms = 0
let pepmCustomerLevels = []
// groupProjectRes 是poms项目信息
let anxinProjectCount = groupProjectRes.reduce((count, gp) => { let anxinProjectCount = groupProjectRes.reduce((count, gp) => {
if (pg.pomsProjectIds.some(id => gp.id == id)) { if (pg.pomsProjectIds.some(id => gp.id == id)) {
// 如果 pg 分组信息 存储的 pomsProjectIds 运维项目id 和 真正的 groupProjectRes 运维项目id 相等 // 如果 pg 分组信息 存储的 pomsProjectIds 运维项目id 和 真正的 groupProjectRes 运维项目id 相等
@ -264,6 +269,13 @@ async function groupStatistic (ctx) {
return p + c.alarmCount return p + c.alarmCount
}, 0) }, 0)
// //
if (gp.pepProjectId) {
let corLevel = pepmCustomerLevelRes.find(p => p.projectId == gp.pepProjectId)
if (corLevel) {
pepmCustomerLevels.push(corLevel)
}
}
//
for (let { dataValues: off } of deviceOffTimeRes) { for (let { dataValues: off } of deviceOffTimeRes) {
if (strucIdArr_.some((s) => s.strucId == off.structure)) { if (strucIdArr_.some((s) => s.strucId == off.structure)) {
if (off.offline > maxOffLineTime) { if (off.offline > maxOffLineTime) {
@ -274,13 +286,15 @@ async function groupStatistic (ctx) {
} }
return count return count
}, 0) }, 0)
console.log(pg.id, pepmCustomerLevels);
pepmCustomerLevels.sort((a, b) => a.id - b.id)
rslt.unshift({ rslt.unshift({
...pg.dataValues, ...pg.dataValues,
strucCount, strucCount,
todayAlarms, todayAlarms,
maxOffLineTime, maxOffLineTime,
anxinProjectCount, anxinProjectCount,
level: pepmCustomerLevelRes.length ? pepmCustomerLevelRes[0] : null level: pepmCustomerLevels.length ? pepmCustomerLevels[0] : null
}) })
} }

Loading…
Cancel
Save