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

Loading…
Cancel
Save