明树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 errorMessage = require("../utils/errorMessage");
const _ = require("lodash"); const _ = require("lodash");
const { Op } = require('sequelize'); const { Op } = require('sequelize');
const projectModule = require('../module/projectModule');
// ---------------- 信息报送 RcXxbs ---------------- // ---------------- 信息报送 RcXxbs ----------------
...@@ -119,7 +120,7 @@ async function updateTzgh(req, res, next) { ...@@ -119,7 +120,7 @@ async function updateTzgh(req, res, next) {
async function getTzgh(req, res, next) { async function getTzgh(req, res, next) {
try { try {
if (!req.body.id) return res.sendError(errorMessage.paramsError); 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); if (!(info && info.id)) return res.sendError(errorMessage.resourceNotFound);
return res.sendData(info); return res.sendData(info);
} catch (error) { } catch (error) {
...@@ -144,9 +145,6 @@ async function getTzghList(req, res, next) { ...@@ -144,9 +145,6 @@ async function getTzghList(req, res, next) {
if (req.body.planYear) { if (req.body.planYear) {
where.planYear = req.body.planYear; where.planYear = req.body.planYear;
} }
if (req.body.projectId) {
where.projectId = req.body.projectId;
}
search.where = where; search.where = where;
if (req.body.attributes && req.body.attributes.length) { if (req.body.attributes && req.body.attributes.length) {
search.attributes = req.body.attributes; search.attributes = req.body.attributes;
...@@ -239,7 +237,17 @@ async function getTxjsList(req, res, next) { ...@@ -239,7 +237,17 @@ async function getTxjsList(req, res, next) {
if (req.body.attributes && req.body.attributes.length) { if (req.body.attributes && req.body.attributes.length) {
search.attributes = req.body.attributes; 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); 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); return res.sendData(ret);
} catch (error) { } catch (error) {
next(error); next(error);
...@@ -349,7 +357,7 @@ async function getCgqyglList(req, res, next) { ...@@ -349,7 +357,7 @@ async function getCgqyglList(req, res, next) {
if (req.body.attributes && req.body.attributes.length) search.attributes = req.body.attributes; if (req.body.attributes && req.body.attributes.length) search.attributes = req.body.attributes;
let ret = await DB.RcCgqygl.findAndCountAll(search); 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; }); ret.rows.map(o => { o.xmscjd = risMap[o.xmscjd] || o.xmscjd; return o; });
return res.sendData(ret); return res.sendData(ret);
} catch (error) { } catch (error) {
......
...@@ -38,14 +38,14 @@ const RcXxbs = sequelize.define('RcXxbs', { ...@@ -38,14 +38,14 @@ const RcXxbs = sequelize.define('RcXxbs', {
}, },
sourceId: { // sourceId: {
type: DataTypes.INTEGER, // type: DataTypes.INTEGER,
comment: "所属主表id" // comment: "所属主表id"
}, // },
projectId: { // projectId: {
type: DataTypes.INTEGER, // type: DataTypes.INTEGER,
comment: "所属项目ID", // comment: "所属项目ID",
}, // },
del: { del: {
type: DataTypes.INTEGER, type: DataTypes.INTEGER,
defaultValue: 0, defaultValue: 0,
......
...@@ -91,14 +91,16 @@ async function getResourceInfoByIds(resouInfoIds) { ...@@ -91,14 +91,16 @@ async function getResourceInfoByIds(resouInfoIds) {
// console.log(risMap) // console.log(risMap)
return risMap; return risMap;
} }
async function getResourceInfoMapByKeys(keys) { async function getResourceInfoMapByKey(key) {
let ris = await DB.Resources.findAll({ let ris = await DB.Resources.findOne({
where: { key: { [Op.in]: keys } }, where: { key},
raw: true, raw: true,
}); });
let rids = ris.map(o => { return o.id }); if(!(ris && ris.id)) {
return {};
}
let risinfos = await DB.ResourcesInfo.findAll({ let risinfos = await DB.ResourcesInfo.findAll({
where: { resourceId: { [Op.in]: rids } }, where: { resourceId: ris.id },
raw: true, raw: true,
}); });
let risMap = {}; let risMap = {};
...@@ -343,5 +345,5 @@ module.exports = { ...@@ -343,5 +345,5 @@ module.exports = {
handleProjectData, handleProjectData,
getProjectInfo, getProjectInfo,
getProjectInfoByLixiang, 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