运维服务中台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

93 lines
2.6 KiB

'use strict';
const moment = require('moment')
async function getEnabledWorkflowProcess (ctx) {
try {
const { models } = ctx.fs.dc;
2 years ago
const { clickHouse } = ctx.app.fs
const listRes = await clickHouse.pepEmis.query(`
SELECT
workflow_process.id AS id,
workflow_process.name AS name,
workflow_process.create_time AS createTime,
workflow_process.update_time AS updateTime,
workflow_group.name AS group
FROM
workflow_process
RIGHT JOIN workflow_group
ON workflow_process.group_id = workflow_group.id
AND workflow_group.name = '运维中台表单'
2 years ago
WHERE
workflow_process.deleted = 0
AND workflow_process.is_enable = 1
order by workflow_process.update_time desc
2 years ago
`).toPromise()
ctx.status = 200;
2 years ago
ctx.body = listRes
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: error`);
ctx.status = 400;
ctx.body = {
message: typeof error == 'string' ? error : undefined
}
}
}
async function basicDataAllProject (ctx) {
try {
const { models } = ctx.fs.dc;
const { clickHouse } = ctx.app.fs
const proRes = await models.ProjectCorrelation.findAll({
where: {
del: false,
},
order: [['updateTime', 'desc']],
})
let pepProjectIds = new Set()
for (let p of proRes) {
if (p.pepProjectId) {
pepProjectIds.add(p.pepProjectId)
}
}
const pepProjectRes = pepProjectIds.size ?
await clickHouse.projectManage.query(
`
SELECT
t_pim_project.id AS id,
t_pim_project.project_name AS project_name,
t_pim_project.isdelete AS isdelete
FROM t_pim_project
WHERE id IN (${[...pepProjectIds].join(',')}, -1)
`
).toPromise() || [] :
[]
const list = proRes.map(p => {
const corPro = pepProjectRes.find(pp => pp.id == p.pepProjectId) || {}
return {
value: p.id,
label: corPro.project_name || p.name,
disabled: corPro.isdelete == 1
}
})
ctx.status = 200;
ctx.body = list
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400;
ctx.body = {
message: typeof error == 'string' ? error : undefined
}
}
}
module.exports = {
getEnabledWorkflowProcess,
basicDataAllProject
};