|
|
@ -22,48 +22,48 @@ async function getStructures (ctx) { |
|
|
|
} |
|
|
|
} |
|
|
|
let undelStrucRes=[] |
|
|
|
if (bindRes) { |
|
|
|
undelStrucRes = anxinProjectIds.size ? |
|
|
|
await clickHouse.anxinyun.query( |
|
|
|
`
|
|
|
|
SELECT |
|
|
|
t_structure.id AS strucId, |
|
|
|
t_structure.name AS strucName |
|
|
|
FROM |
|
|
|
t_project |
|
|
|
LEFT JOIN |
|
|
|
t_project_structure |
|
|
|
ON t_project_structure.project = t_project.id |
|
|
|
LEFT JOIN |
|
|
|
t_project_structuregroup |
|
|
|
ON t_project_structuregroup.project = t_project.id |
|
|
|
LEFT JOIN |
|
|
|
t_structuregroup_structure |
|
|
|
ON t_structuregroup_structure.structuregroup = t_project_structuregroup.structuregroup |
|
|
|
LEFT JOIN |
|
|
|
t_project_construction |
|
|
|
ON t_project_construction.project = t_project.id |
|
|
|
LEFT JOIN |
|
|
|
t_structure_site |
|
|
|
ON t_structure_site.siteid = t_project_construction.construction |
|
|
|
RIGHT JOIN |
|
|
|
t_structure |
|
|
|
ON t_structure.id = t_project_structure.structure |
|
|
|
OR t_structure.id = t_structuregroup_structure.structure |
|
|
|
OR t_structure.id = t_structure_site.structid |
|
|
|
// if (bindRes) {
|
|
|
|
// undelStrucRes = anxinProjectIds.size ?
|
|
|
|
// await clickHouse.anxinyun.query(
|
|
|
|
// `
|
|
|
|
// SELECT
|
|
|
|
// t_structure.id AS strucId,
|
|
|
|
// t_structure.name AS strucName
|
|
|
|
// FROM
|
|
|
|
// t_project
|
|
|
|
// LEFT JOIN
|
|
|
|
// t_project_structure
|
|
|
|
// ON t_project_structure.project = t_project.id
|
|
|
|
// LEFT JOIN
|
|
|
|
// t_project_structuregroup
|
|
|
|
// ON t_project_structuregroup.project = t_project.id
|
|
|
|
// LEFT JOIN
|
|
|
|
// t_structuregroup_structure
|
|
|
|
// ON t_structuregroup_structure.structuregroup = t_project_structuregroup.structuregroup
|
|
|
|
// LEFT JOIN
|
|
|
|
// t_project_construction
|
|
|
|
// ON t_project_construction.project = t_project.id
|
|
|
|
// LEFT JOIN
|
|
|
|
// t_structure_site
|
|
|
|
// ON t_structure_site.siteid = t_project_construction.construction
|
|
|
|
// RIGHT JOIN
|
|
|
|
// t_structure
|
|
|
|
// ON t_structure.id = t_project_structure.structure
|
|
|
|
// OR t_structure.id = t_structuregroup_structure.structure
|
|
|
|
// OR t_structure.id = t_structure_site.structid
|
|
|
|
|
|
|
|
WHERE |
|
|
|
project_state != -1 |
|
|
|
AND |
|
|
|
t_project.id IN (${[...anxinProjectIds].join(',')}, -1) |
|
|
|
AND t_structure.external_platform is not null |
|
|
|
ORDER BY strucId |
|
|
|
` |
|
|
|
).toPromise() : |
|
|
|
[] |
|
|
|
} |
|
|
|
// undelStrucRes.push({strucId:4036,strucName:'象山港大桥'})
|
|
|
|
// undelStrucRes.push({strucId:1,strucName:'象山港大'})
|
|
|
|
// WHERE
|
|
|
|
// project_state != -1
|
|
|
|
// AND
|
|
|
|
// t_project.id IN (${[...anxinProjectIds].join(',')}, -1)
|
|
|
|
// AND t_structure.external_platform is not null
|
|
|
|
// ORDER BY strucId
|
|
|
|
// `
|
|
|
|
// ).toPromise() :
|
|
|
|
// []
|
|
|
|
// }
|
|
|
|
undelStrucRes.push({strucId:4036,strucName:'象山港大桥'}) |
|
|
|
undelStrucRes.push({strucId:1,strucName:'象山港大'}) |
|
|
|
ctx.status = 200; |
|
|
|
ctx.body = undelStrucRes |
|
|
|
} catch (error) { |
|
|
@ -127,14 +127,14 @@ async function getMonitorData (ctx) { |
|
|
|
const factorsList=await clickHouse.alarmLocal.query(`SELECT FactorID,Items,ItemNames,ItemUnits FROM factors
|
|
|
|
WHERE FactorID=${factorId} |
|
|
|
`).toPromise()||[]
|
|
|
|
const id=sensorId&&sensorId.replace('-',':') |
|
|
|
const monitorData=await clickHouse.alarmLocal.query(`SELECT SensorId,CollectTime,Values FROM themes
|
|
|
|
WHERE SensorId in ('${sensorId}') |
|
|
|
WHERE SensorId in ('${id}') |
|
|
|
AND CollectTime >= toDate('${startTime}') |
|
|
|
AND CollectTime <= toDate('${endTime}') |
|
|
|
LIMIT ${limit} OFFSET ${offset} |
|
|
|
`).toPromise()||[]
|
|
|
|
console.log('vmonitorDatamonitorDatamonitorData',monitorData) |
|
|
|
const id=sensorId&&sensorId.replace('-',':') |
|
|
|
const sensor=await clickHouse.alarmLocal.query(`SELECT distinct SensorId,SensorLocationDescription FROM sensors WHERE ID='${id}'`).toPromise() |
|
|
|
//监测项
|
|
|
|
let items={} |
|
|
|