|
|
@ -205,21 +205,15 @@ async function apiErrorList (ctx) { |
|
|
|
try { |
|
|
|
const models = ctx.fs.dc.models; |
|
|
|
const { clickHouse } = ctx.app.fs |
|
|
|
const { keyword, errType, confirmState, sustainTimeStart, sustainTimeEnd, limit, page } = ctx.query |
|
|
|
|
|
|
|
const pepProjectSql = ` |
|
|
|
SELECT |
|
|
|
t_pim_project.id AS id, |
|
|
|
t_pim_project.project_name AS project_name, |
|
|
|
t_pim_project_construction.construction_status_id AS construction_status_id, |
|
|
|
t_pim_project_state.construction_status AS construction_status |
|
|
|
FROM 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 |
|
|
|
` |
|
|
|
const { utils: { anxinStrucIdRange, pomsProjectRange } } = ctx.app.fs |
|
|
|
const { keyword, errType, confirmState, sustainTimeStart, sustainTimeEnd, limit, page, pepProjectId } = ctx.query |
|
|
|
|
|
|
|
let pomsProject = await pomsProjectRange({ |
|
|
|
ctx, pepProjectId, |
|
|
|
keywordTarget: 'pepProject', |
|
|
|
keyword, |
|
|
|
}) |
|
|
|
const pomsProjectIds = pomsProject.map(p => p.id) |
|
|
|
let findOption = { |
|
|
|
where: { |
|
|
|
$or: [] |
|
|
@ -243,16 +237,11 @@ async function apiErrorList (ctx) { |
|
|
|
}] |
|
|
|
}] |
|
|
|
} |
|
|
|
let projectRes = [] |
|
|
|
if (keyword) { |
|
|
|
projectRes = await clickHouse.projectManage.query(` |
|
|
|
${pepProjectSql} |
|
|
|
WHERE project_name LIKE '%${keyword}%'` |
|
|
|
).toPromise() |
|
|
|
findOption.where.$or.push( |
|
|
|
{ |
|
|
|
'$app->projectCorrelations.pep_project_id$': { |
|
|
|
$in: projectRes.map(p => p.id) |
|
|
|
'$app->projectCorrelations.id$': { |
|
|
|
$in: pomsProjectIds |
|
|
|
}, |
|
|
|
} |
|
|
|
) |
|
|
@ -263,17 +252,8 @@ async function apiErrorList (ctx) { |
|
|
|
) |
|
|
|
} |
|
|
|
|
|
|
|
// if (errType) {
|
|
|
|
// if (errType == 'element') {
|
|
|
|
// findOption.where.screenshot = { $ne: null }
|
|
|
|
// } else if (errType == 'timeout') {
|
|
|
|
|
|
|
|
// } else if (errType == 'apiError') {
|
|
|
|
// findOption.where.screenshot = null
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
if (errType) { |
|
|
|
findOption.where.type = errType |
|
|
|
findOption.where.type = errType // element / apiError
|
|
|
|
} |
|
|
|
if (confirmState) { |
|
|
|
if (confirmState == 'confirmd') { |
|
|
@ -306,32 +286,13 @@ async function apiErrorList (ctx) { |
|
|
|
delete findOption.where.$or |
|
|
|
} |
|
|
|
const listRes = await models.AppAlarm.findAndCountAll(findOption) |
|
|
|
if (!keyword) { |
|
|
|
// 没有关键字筛选 查询关联的项目信息
|
|
|
|
let pepProjectIds = new Set() |
|
|
|
for (let lr of listRes.rows) { |
|
|
|
if (lr.app && lr.app.projectCorrelations) { |
|
|
|
for (let p of lr.app.projectCorrelations) { |
|
|
|
if (p.pepProjectId) { |
|
|
|
pepProjectIds.add(p.pepProjectId) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (pepProjectIds.size) { |
|
|
|
projectRes = await clickHouse.projectManage.query(` |
|
|
|
${pepProjectSql} |
|
|
|
WHERE id IN (${[...pepProjectIds].join(',')})` |
|
|
|
).toPromise() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
for (let lr of listRes.rows) { |
|
|
|
if (lr.app && lr.app.projectCorrelations) { |
|
|
|
for (let p of lr.app.projectCorrelations) { |
|
|
|
let corPepProject = projectRes.find(pr => pr.id == p.pepProjectId) |
|
|
|
if (corPepProject) { |
|
|
|
p.dataValues.pepProject = corPepProject |
|
|
|
let corProjectCorrelations = pomsProject.find(pr => pr.id == p.id) |
|
|
|
if (corProjectCorrelations) { |
|
|
|
p.dataValues = corProjectCorrelations |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|