|
|
@ -282,6 +282,7 @@ async function strucWithPomsProject (ctx) { |
|
|
|
SELECT |
|
|
|
t_structure.id AS strucId, |
|
|
|
t_structure.name AS strucName, |
|
|
|
t_structure.external_platform AS externalPlatform, |
|
|
|
t_factor.id AS factorId, |
|
|
|
t_factor.name AS factorName, |
|
|
|
t_factor.proto AS factorProto, |
|
|
@ -323,8 +324,46 @@ async function strucWithPomsProject (ctx) { |
|
|
|
` |
|
|
|
).toPromise() : |
|
|
|
[] |
|
|
|
for (let s of undelStrucRes) { |
|
|
|
for await (let s of undelStrucRes) { |
|
|
|
let corStrut = undelStruc.find(us => us.id == s.strucId) |
|
|
|
if (s.externalPlatform) { |
|
|
|
if (!corStrut) { |
|
|
|
const factorList = await clickHouse.dataAlarm |
|
|
|
.query(`select SafetyFactorTypeId, SafetyFactorTypeName from sensors where PlatformStructureId = ${s.strucId}`) |
|
|
|
.toPromise() |
|
|
|
const project = await clickHouse.dataAlarm |
|
|
|
.query(`select Project from sensors where PlatformStructureId =${s.strucId} limit 1 `) |
|
|
|
.toPromise() |
|
|
|
|
|
|
|
let fList = factorList.map(m => m.SafetyFactorTypeId) |
|
|
|
let list = await clickHouse.dataAlarm |
|
|
|
.query( |
|
|
|
`select distinct FactorID, Name,Items,ItemNames from factors
|
|
|
|
where FactorID in (${[...fList, -1].join(',')}) |
|
|
|
and Project = '${[...project, 0][0].Project}' |
|
|
|
` |
|
|
|
) |
|
|
|
.toPromise() || [] |
|
|
|
|
|
|
|
let nextFacor = [] |
|
|
|
list.map(d => { |
|
|
|
if (d.Name) { |
|
|
|
nextFacor.push({ |
|
|
|
id: d.FactorID, |
|
|
|
name: d.Name, |
|
|
|
// proto: s.factorProto,
|
|
|
|
item: d.ItemNames && d.ItemNames.split(',').map(item => ({ id: item, name: item })) || [], |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
undelStruc.push({ |
|
|
|
id: s.strucId, |
|
|
|
name: s.strucName, |
|
|
|
factor: nextFacor |
|
|
|
}) |
|
|
|
} |
|
|
|
} else { |
|
|
|
|
|
|
|
if (!corStrut) { |
|
|
|
let nextFacor = [] |
|
|
|
if (s.factorId) { |
|
|
@ -375,6 +414,8 @@ async function strucWithPomsProject (ctx) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
ctx.status = 200; |
|
|
|