|
@ -282,6 +282,7 @@ async function strucWithPomsProject (ctx) { |
|
|
SELECT |
|
|
SELECT |
|
|
t_structure.id AS strucId, |
|
|
t_structure.id AS strucId, |
|
|
t_structure.name AS strucName, |
|
|
t_structure.name AS strucName, |
|
|
|
|
|
t_structure.external_platform AS externalPlatform, |
|
|
t_factor.id AS factorId, |
|
|
t_factor.id AS factorId, |
|
|
t_factor.name AS factorName, |
|
|
t_factor.name AS factorName, |
|
|
t_factor.proto AS factorProto, |
|
|
t_factor.proto AS factorProto, |
|
@ -323,57 +324,97 @@ async function strucWithPomsProject (ctx) { |
|
|
` |
|
|
` |
|
|
).toPromise() : |
|
|
).toPromise() : |
|
|
[] |
|
|
[] |
|
|
for (let s of undelStrucRes) { |
|
|
for await (let s of undelStrucRes) { |
|
|
let corStrut = undelStruc.find(us => us.id == s.strucId) |
|
|
let corStrut = undelStruc.find(us => us.id == s.strucId) |
|
|
if (!corStrut) { |
|
|
if (s.externalPlatform) { |
|
|
let nextFacor = [] |
|
|
if (!corStrut) { |
|
|
if (s.factorId) { |
|
|
const factorList = await clickHouse.dataAlarm |
|
|
let nextFactorItem = [] |
|
|
.query(`select SafetyFactorTypeId, SafetyFactorTypeName from sensors where PlatformStructureId = ${s.strucId}`) |
|
|
if (s.factorItemId) { |
|
|
.toPromise() |
|
|
nextFactorItem.push({ |
|
|
const project = await clickHouse.dataAlarm |
|
|
id: s.factorItemId, |
|
|
.query(`select Project from sensors where PlatformStructureId =${s.strucId} limit 1 `) |
|
|
name: s.factorItemName, |
|
|
.toPromise() |
|
|
}) |
|
|
|
|
|
} |
|
|
let fList = factorList.map(m => m.SafetyFactorTypeId) |
|
|
nextFacor.push({ |
|
|
let list = await clickHouse.dataAlarm |
|
|
id: s.factorId, |
|
|
.query( |
|
|
name: s.factorName, |
|
|
`select distinct FactorID, Name,Items,ItemNames from factors
|
|
|
proto: s.factorProto, |
|
|
where FactorID in (${[...fList, -1].join(',')}) |
|
|
item: nextFactorItem, |
|
|
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 |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
undelStruc.push({ |
|
|
|
|
|
id: s.strucId, |
|
|
|
|
|
name: s.strucName, |
|
|
|
|
|
factor: nextFacor |
|
|
|
|
|
}) |
|
|
|
|
|
} else { |
|
|
} else { |
|
|
if (s.factorId) { |
|
|
|
|
|
let corFactor = corStrut.factor.find(v => v.id == s.factorId) |
|
|
if (!corStrut) { |
|
|
let nextFactorItem = null |
|
|
let nextFacor = [] |
|
|
if (s.factorItemId) { |
|
|
if (s.factorId) { |
|
|
nextFactorItem = { |
|
|
let nextFactorItem = [] |
|
|
id: s.factorItemId, |
|
|
if (s.factorItemId) { |
|
|
name: s.factorItemName, |
|
|
nextFactorItem.push({ |
|
|
} |
|
|
id: s.factorItemId, |
|
|
} |
|
|
name: s.factorItemName, |
|
|
if (corFactor) { |
|
|
}) |
|
|
if (!corFactor.item.some(fi => fi.id == s.factorItemId) && nextFactorItem) { |
|
|
|
|
|
corFactor.item.push(nextFactorItem) |
|
|
|
|
|
} |
|
|
} |
|
|
} else { |
|
|
nextFacor.push({ |
|
|
corStrut.factor.push({ |
|
|
|
|
|
id: s.factorId, |
|
|
id: s.factorId, |
|
|
name: s.factorName, |
|
|
name: s.factorName, |
|
|
proto: s.factorProto, |
|
|
proto: s.factorProto, |
|
|
item: nextFactorItem ? [{ |
|
|
item: nextFactorItem, |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
undelStruc.push({ |
|
|
|
|
|
id: s.strucId, |
|
|
|
|
|
name: s.strucName, |
|
|
|
|
|
factor: nextFacor |
|
|
|
|
|
}) |
|
|
|
|
|
} else { |
|
|
|
|
|
if (s.factorId) { |
|
|
|
|
|
let corFactor = corStrut.factor.find(v => v.id == s.factorId) |
|
|
|
|
|
let nextFactorItem = null |
|
|
|
|
|
if (s.factorItemId) { |
|
|
|
|
|
nextFactorItem = { |
|
|
id: s.factorItemId, |
|
|
id: s.factorItemId, |
|
|
name: s.factorItemName, |
|
|
name: s.factorItemName, |
|
|
}] : [], |
|
|
} |
|
|
}) |
|
|
} |
|
|
|
|
|
if (corFactor) { |
|
|
|
|
|
if (!corFactor.item.some(fi => fi.id == s.factorItemId) && nextFactorItem) { |
|
|
|
|
|
corFactor.item.push(nextFactorItem) |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
corStrut.factor.push({ |
|
|
|
|
|
id: s.factorId, |
|
|
|
|
|
name: s.factorName, |
|
|
|
|
|
proto: s.factorProto, |
|
|
|
|
|
item: nextFactorItem ? [{ |
|
|
|
|
|
id: s.factorItemId, |
|
|
|
|
|
name: s.factorItemName, |
|
|
|
|
|
}] : [], |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -432,7 +473,7 @@ async function getStructureStation (ctx) { |
|
|
|
|
|
|
|
|
let attention = `AND positionCaseInsensitive(toString(t_sensor.labels), '${trait}') > 0` |
|
|
let attention = `AND positionCaseInsensitive(toString(t_sensor.labels), '${trait}') > 0` |
|
|
console.log(111, trait, attention); |
|
|
console.log(111, trait, attention); |
|
|
|
|
|
|
|
|
const sensor = strucId.length ? |
|
|
const sensor = strucId.length ? |
|
|
await clickHouse.anxinyun.query( |
|
|
await clickHouse.anxinyun.query( |
|
|
`
|
|
|
`
|
|
|