明树Git Lab

Commit bf539628 authored by zfp1's avatar zfp1

update

parent 22bcd01f
Pipeline #106729 passed with stage
in 3 seconds
const errorMessage = require("../utils/errorMessage");
const _ = require("lodash");
const { Op } = require('sequelize');
const projectModule = require('../module/projectModule');
// ---------------- 信息报送 RcXxbs ----------------
......@@ -119,7 +120,7 @@ async function updateTzgh(req, res, next) {
async function getTzgh(req, res, next) {
try {
if (!req.body.id) return res.sendError(errorMessage.paramsError);
let info = await DB.RcTzgh.findOne({ where: { id: req.body.id, del: 0 }});
let info = await DB.RcTzgh.findOne({ where: { id: req.body.id, del: 0 } });
if (!(info && info.id)) return res.sendError(errorMessage.resourceNotFound);
return res.sendData(info);
} catch (error) {
......@@ -144,9 +145,6 @@ async function getTzghList(req, res, next) {
if (req.body.planYear) {
where.planYear = req.body.planYear;
}
if (req.body.projectId) {
where.projectId = req.body.projectId;
}
search.where = where;
if (req.body.attributes && req.body.attributes.length) {
search.attributes = req.body.attributes;
......@@ -239,7 +237,17 @@ async function getTxjsList(req, res, next) {
if (req.body.attributes && req.body.attributes.length) {
search.attributes = req.body.attributes;
}
// 获取资源库映射
const wjcjMap = await projectModule.getResourceInfoMapByKey('fileHierarchy');
const wjlbMap = await projectModule.getResourceInfoMapByKey('fileType');
// console.log(risMap, "====")
let ret = await DB.RcTxjs.findAndCountAll(search);
// 字典映射
ret.rows = ret.rows.map(row => {
row.wjcj = wjcjMap[row.wjcj] || row.wjcj;
row.wjlb = wjlbMap[row.wjlb] || row.wjlb;
return row;
});
return res.sendData(ret);
} catch (error) {
next(error);
......@@ -349,7 +357,7 @@ 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"]);
let risMap = await projectModule.getResourceInfoMapByKey("xmjd");
ret.rows.map(o => { o.xmscjd = risMap[o.xmscjd] || o.xmscjd; return o; });
return res.sendData(ret);
} catch (error) {
......
......@@ -38,14 +38,14 @@ const RcXxbs = sequelize.define('RcXxbs', {
},
sourceId: {
type: DataTypes.INTEGER,
comment: "所属主表id"
},
projectId: {
type: DataTypes.INTEGER,
comment: "所属项目ID",
},
// sourceId: {
// type: DataTypes.INTEGER,
// comment: "所属主表id"
// },
// projectId: {
// type: DataTypes.INTEGER,
// comment: "所属项目ID",
// },
del: {
type: DataTypes.INTEGER,
defaultValue: 0,
......
......@@ -91,14 +91,16 @@ async function getResourceInfoByIds(resouInfoIds) {
// console.log(risMap)
return risMap;
}
async function getResourceInfoMapByKeys(keys) {
let ris = await DB.Resources.findAll({
where: { key: { [Op.in]: keys } },
async function getResourceInfoMapByKey(key) {
let ris = await DB.Resources.findOne({
where: { key},
raw: true,
});
let rids = ris.map(o => { return o.id });
if(!(ris && ris.id)) {
return {};
}
let risinfos = await DB.ResourcesInfo.findAll({
where: { resourceId: { [Op.in]: rids } },
where: { resourceId: ris.id },
raw: true,
});
let risMap = {};
......@@ -343,5 +345,5 @@ module.exports = {
handleProjectData,
getProjectInfo,
getProjectInfoByLixiang,
getResourceInfoMapByKeys,
getResourceInfoMapByKey,
}
\ 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