Browse Source

随结构物返回监测因素

dev
巴林闲侠 2 years ago
parent
commit
4dde555dc5
  1. 26
      api/app/lib/controllers/project/index.js

26
api/app/lib/controllers/project/index.js

@ -231,7 +231,9 @@ async function strucWithPomsProject (ctx) {
`
SELECT
t_structure.id AS strucId,
t_structure.name AS strucName
t_structure.name AS strucName,
t_factor.id AS factorId,
t_factor.name AS factorName
FROM
t_project
LEFT JOIN
@ -254,6 +256,10 @@ async function strucWithPomsProject (ctx) {
ON t_structure.id = t_project_structure.structure
OR t_structure.id = t_structuregroup_structure.structure
OR t_structure.id = t_structure_site.structid
LEFT JOIN t_structure_factor
ON t_structure_factor.structure = t_structure.id
LEFT JOIN t_factor
ON t_structure_factor.factor = t_factor.id
WHERE
project_state != -1
AND
@ -263,11 +269,27 @@ async function strucWithPomsProject (ctx) {
).toPromise() :
[]
for (let s of undelStrucRes) {
if (!undelStruc.some(us => us.id == s.strucId)) {
let corStrut = undelStruc.find(us => us.id == s.strucId)
if (!corStrut) {
let nextFacor = []
if (s.factorId) {
nextFacor.push({
id: s.factorId,
name: s.factorName
})
}
undelStruc.push({
id: s.strucId,
name: s.strucName,
factor: nextFacor
})
} else {
if (s.factorId) {
corStrut.factor.push({
id: s.factorId,
name: s.factorName
})
}
}
}
}

Loading…
Cancel
Save