明树Git Lab

Commit 40ae8d31 authored by zfp1's avatar zfp1

update

parent 05ce7a67
Pipeline #106375 passed with stage
in 3 seconds
......@@ -14,6 +14,7 @@
const errorMessage = require("../utils/errorMessage");
const _ = require("lodash");
const { Op } = require('sequelize');
const projectModule = require('../module/projectModule');
async function createCgqygl(req, res, next) {
try {
......@@ -106,6 +107,8 @@ async function getCgqyglList(req, res, next) {
if (req.body.attributes && req.body.attributes.length) search.attributes = req.body.attributes;
let ret = await DB.RcCgqygl.findAndCountAll(search);
let risMap = await projectModule.getResourceInfoMapByKeys(["xmjd"]);
ret.rows.map(o => {o.xmscjd = risMap[o.xmscjd] || o.xmscjd; return o;});
return res.sendData(ret);
} catch (error) {
next(error);
......
......@@ -80,13 +80,31 @@ async function handleProjectData(ret, queryAttrs) {
async function getResourceInfoByIds(resouInfoIds) {
let ris = await DB.ResourcesInfo.findAll({
where: { id: { [Op.in]: resouInfoIds } },
where: { key: { [Op.in]: resouInfoIds } },
// raw: true,
});
let risMap = {};
for (let index = 0; index < ris.length; index++) {
const element = ris[index];
risMap[element.id] = element.value;
risMap[element.key] = element.value || element.name;
}
// console.log(risMap)
return risMap;
}
async function getResourceInfoMapByKeys(keys) {
let ris = await DB.Resources.findAll({
where: { key: { [Op.in]: keys } },
raw: true,
});
let rids = ris.map(o => { return o.id });
let risinfos = await DB.ResourcesInfo.findAll({
where: { resourceId: { [Op.in]: rids } },
raw: true,
});
let risMap = {};
for (let index = 0; index < risinfos.length; index++) {
const element = risinfos[index];
risMap[element.key] = element.value || element.name;
}
// console.log(risMap)
return risMap;
......@@ -214,7 +232,7 @@ async function getProjectInfo({ id }) {
project.projectTzzjlls = await DB.ProjectTzzjll.findAll({ where: { projectId: id }, raw: true });
project.projectTzzts = await DB.ProjectTzzt.findAll({ where: { projectId: id }, raw: true });
project.projectXmtzzes = await DB.ProjectXmtzze.findAll({ where: { projectId: id }, raw: true });
project.projectZqrzs = await DB.ProjectZqrz.findAll({ where: { projectId: id }, raw: true });
project.projectZqrzs = await DB.ProjectZqrz.findAll({ where: { projectId: id }, raw: true });
project.projectXmtzzes = utils.buildTree2(project.projectXmtzzes, {
keyName: "key",
parentKeyName: 'parentKey',
......@@ -325,4 +343,5 @@ module.exports = {
handleProjectData,
getProjectInfo,
getProjectInfoByLixiang,
getResourceInfoMapByKeys,
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment