|
@ -158,12 +158,31 @@ async function groupStatistic (ctx) { |
|
|
|
|
|
|
|
|
// 获取所有的 安心云项目id
|
|
|
// 获取所有的 安心云项目id
|
|
|
let anxinProjectIds = new Set() |
|
|
let anxinProjectIds = new Set() |
|
|
|
|
|
let pepmProjectIds = new Set() |
|
|
for (let project of groupProjectRes) { |
|
|
for (let project of groupProjectRes) { |
|
|
for (let projectId of project.anxinProjectId) { |
|
|
for (let projectId of project.anxinProjectId) { |
|
|
anxinProjectIds.add(projectId) |
|
|
anxinProjectIds.add(projectId) |
|
|
} |
|
|
} |
|
|
|
|
|
if (project.pepProjectId) { |
|
|
|
|
|
pepmProjectIds.add(project.pepProjectId) |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
let anxinProjectIdArr = Array.from(anxinProjectIds) |
|
|
let anxinProjectIdArr = Array.from(anxinProjectIds) |
|
|
|
|
|
let pepmProjectIdArr = Array.from(pepmProjectIds) |
|
|
|
|
|
|
|
|
|
|
|
// 查询pepm项目的客户等级
|
|
|
|
|
|
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 |
|
|
|
|
|
RIGHT JOIN t_rpm_customer |
|
|
|
|
|
ON t_rpm_customer.id = t_pim_project.related_customers_id |
|
|
|
|
|
RIGHT JOIN t_rpm_customer_level |
|
|
|
|
|
ON t_rpm_customer_level.id = t_rpm_customer.level |
|
|
|
|
|
WHERE t_pim_project.id IN (${pepmProjectIdArr.join(',')},-1) |
|
|
|
|
|
` |
|
|
|
|
|
).toPromise() : [] |
|
|
|
|
|
|
|
|
|
|
|
pepmCustomerLevelRes.sort((a, b) => a.id - b.id) |
|
|
|
|
|
|
|
|
// 统计安心云项目下的结构物
|
|
|
// 统计安心云项目下的结构物
|
|
|
const strucRes = anxinProjectIdArr.length ? await clickHouse.anxinyun.query( |
|
|
const strucRes = anxinProjectIdArr.length ? await clickHouse.anxinyun.query( |
|
@ -260,6 +279,7 @@ async function groupStatistic (ctx) { |
|
|
todayAlarms, |
|
|
todayAlarms, |
|
|
maxOffLineTime, |
|
|
maxOffLineTime, |
|
|
anxinProjectCount, |
|
|
anxinProjectCount, |
|
|
|
|
|
level: pepmCustomerLevelRes.length ? pepmCustomerLevelRes[0] : null |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|