|
|
@ -14,7 +14,7 @@ module.exports = function (app, opts) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
async function anxinStrucIdRange ({ ctx, pepProjectId }) { |
|
|
|
async function anxinStrucIdRange ({ ctx, pepProjectId, projectOrStructKeyword }) { |
|
|
|
try { |
|
|
|
const { models } = ctx.fs.dc; |
|
|
|
const { userInfo = {} } = ctx.fs.api || {}; |
|
|
@ -36,9 +36,12 @@ module.exports = function (app, opts) { |
|
|
|
// TODO 这儿也许需要判断传进来的 pepProjectId 在不在当前用户的关注范围内
|
|
|
|
const bindRes = await models.ProjectCorrelation.findAll(findOption) |
|
|
|
|
|
|
|
const anxinStrucIds = [ |
|
|
|
let pepProjectIds = [] |
|
|
|
|
|
|
|
const anxinProjectIds = [ |
|
|
|
...bindRes.reduce( |
|
|
|
(arr, b) => { |
|
|
|
pepProjectIds.push(b.pepProjectId) |
|
|
|
for (let sid of b.anxinProjectId) { |
|
|
|
arr.add(sid); |
|
|
|
} |
|
|
@ -47,22 +50,42 @@ module.exports = function (app, opts) { |
|
|
|
new Set() |
|
|
|
) |
|
|
|
] |
|
|
|
const pepProjectRes = pepProjectIds.length ? |
|
|
|
await clickHouse.projectManage.query( |
|
|
|
` |
|
|
|
SELECT |
|
|
|
id, project_name, isdelete |
|
|
|
FROM |
|
|
|
t_pim_project |
|
|
|
WHERE |
|
|
|
id IN (${pepProjectIds.join(',')}) |
|
|
|
` |
|
|
|
).toPromise() : |
|
|
|
[] |
|
|
|
|
|
|
|
// 查结构物 左联 项目 ,项目 id 在关注的项目里
|
|
|
|
const undelStrucRes = anxinStrucIds.length ? |
|
|
|
await clickHouse.anxinyun.query(` |
|
|
|
const undelStrucRes = anxinProjectIds.length ? |
|
|
|
await clickHouse.anxinyun.query( |
|
|
|
` |
|
|
|
SELECT |
|
|
|
id |
|
|
|
t_project.id, t_structure.id AS strucId, project_state |
|
|
|
FROM |
|
|
|
t_project |
|
|
|
LEFT JOIN |
|
|
|
t_project_structure |
|
|
|
ON t_project_structure.project = t_project.id |
|
|
|
RIGHT JOIN |
|
|
|
t_structure |
|
|
|
ON t_structure.id = t_project_structure.structure |
|
|
|
WHERE |
|
|
|
project_state != -1 |
|
|
|
AND |
|
|
|
id IN (${anxinStrucIds.join(',')}) |
|
|
|
`).toPromise() :
|
|
|
|
t_project.id IN (${anxinProjectIds.join(',')}) |
|
|
|
${projectOrStructKeyword ? `AND (t_project.name LIKE '%${projectOrStructKeyword}%' OR t_structure.name LIKE '%${projectOrStructKeyword}%')` : ''} |
|
|
|
` |
|
|
|
).toPromise() : |
|
|
|
[] |
|
|
|
|
|
|
|
return undelStrucRes.map(s => s.id) |
|
|
|
return [...new Set(...undelStrucRes.map(s => s.strucId))] |
|
|
|
} catch (error) { |
|
|
|
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|
|
|
} |
|
|
|