Browse Source

项目集类型

dev
CODE 1 year ago
parent
commit
8e35db39d5
  1. 62
      api/app/lib/controllers/project/group.js
  2. 2
      api/app/lib/schedule/alarms_push.js
  3. 4
      web/client/src/sections/projectGroup/containers/statistic.jsx

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

@ -158,12 +158,31 @@ async function groupStatistic (ctx) {
// 获取所有的 安心云项目id
let anxinProjectIds = new Set()
let pepmProjectIds = new Set()
for (let project of groupProjectRes) {
for (let projectId of project.anxinProjectId) {
anxinProjectIds.add(projectId)
}
if (project.pepProjectId) {
pepmProjectIds.add(project.pepProjectId)
}
}
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(
@ -260,6 +279,7 @@ async function groupStatistic (ctx) {
todayAlarms,
maxOffLineTime,
anxinProjectCount,
level: pepmCustomerLevelRes.length ? pepmCustomerLevelRes[0] : null
})
}
@ -587,16 +607,16 @@ async function groupProject (ctx) {
}
async function getProjectWorkOrders(ctx){
try{
async function getProjectWorkOrders (ctx) {
try {
// 计算一个月前的日期
const oneMonthAgo = moment().subtract(1, 'months').toDate()
const { models } = ctx.fs.dc
const sequelize = ctx.fs.dc.ORM
const { projectIds } = ctx.query
if(projectIds&&projectIds.length){
const projectIdsArr=projectIds.split(',').map(Number)
const res= await models.FormDataTable.findAll({
if (projectIds && projectIds.length) {
const projectIdsArr = projectIds.split(',').map(Number)
const res = await models.FormDataTable.findAll({
attributes: [
'projectId',
[sequelize.fn('COUNT', sequelize.col('id')), 'count'],
@ -612,14 +632,14 @@ async function getProjectWorkOrders(ctx){
group: ['projectId'],
order: [[sequelize.fn('COUNT', sequelize.col('id')), 'DESC']],
})
ctx.body=res
ctx.status=200
}else{
ctx.body='没有查询到数据'
ctx.status=204
ctx.body = res
ctx.status = 200
} else {
ctx.body = '没有查询到数据'
ctx.status = 204
}
}catch(error){
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400;
ctx.body = {
@ -628,15 +648,15 @@ async function getProjectWorkOrders(ctx){
}
}
async function getWorkOrdersRepairRank(ctx){
try{
async function getWorkOrdersRepairRank (ctx) {
try {
const oneMonthAgo = moment().subtract(1, 'months').toDate()
const { models } = ctx.fs.dc
const sequelize = ctx.fs.dc.ORM
const { projectIds } = ctx.query
if(projectIds&&projectIds.length){
const res= await models.FormDataTable.findAll({
if (projectIds && projectIds.length) {
const res = await models.FormDataTable.findAll({
where: {
projectId: {
$in: projectIds.split(',').map(Number)
@ -649,11 +669,11 @@ async function getWorkOrdersRepairRank(ctx){
[sequelize.literal('(EXTRACT(EPOCH FROM "end_time" - "start_time"))'), 'DESC']
]
})
ctx.body=res
ctx.status=200
}else{
ctx.body='没有查询到信息'
ctx.status=204
ctx.body = res
ctx.status = 200
} else {
ctx.body = '没有查询到信息'
ctx.status = 204
}
@ -661,7 +681,7 @@ async function getWorkOrdersRepairRank(ctx){
}catch(error){
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400;
ctx.body = {

2
api/app/lib/schedule/alarms_push.js

@ -1191,7 +1191,7 @@ module.exports = function (app, opts) {
alarms.AlarmCode AS AlarmCode,
alarms.SourceTypeId AS SourceTypeId,
alarms.StructureId AS StructureId,
alarms.subStations AS subStations,
alarms.subStations AS subStations
FROM
alarms
WHERE

4
web/client/src/sections/projectGroup/containers/statistic.jsx

@ -64,7 +64,9 @@ const Statistic = (props) => {
title: '项目集类型',
dataIndex: "name",
key: 'name',
render: (_, row) => '--'
render: (_, row) => {
return row?.level ? row?.level?.name + ' 级' : '--'
}
}, {
title: '项目个数',
dataIndex: "pomsProjectIds",

Loading…
Cancel
Save