明树Git Lab

Commit f1a2410c authored by zhangqi's avatar zhangqi
parents 436b3d6b ff46a73d
let o = {
id: {
_mark: 'system',
fieldName: 'id',
_modelAttribute: true,
field: 'id'
},
projectName: {
comment: '项目名称',
_mark: 'xmjbxx',
fieldName: 'projectName',
_modelAttribute: true,
field: 'projectName'
},
projectShortName: {
comment: '项目简称',
_mark: 'xmjbxx',
fieldName: 'projectShortName',
_modelAttribute: true,
field: 'projectShortName'
},
returnModel: {
comment: '回报模式',
_mark: 'xmjbxx',
fieldName: 'returnModel',
_modelAttribute: true,
field: 'returnModel'
},
a1: {
comment: '决策及批复信息',
_mark: 'jcpfxx',
fieldName: 'a1',
_modelAttribute: true,
field: 'a1'
},
a2: {
comment: '项目公司落实批复信息',
_mark: 'xmgslspfxx',
fieldName: 'a2',
_modelAttribute: true,
field: 'a2'
},
a3: {
comment: '项目合法合规性附件',
_mark: 'xmfhhgxffj',
fieldName: 'a3',
_modelAttribute: true,
field: 'a3'
},
a4: {
comment: '全生命周期策划文件',
_mark: 'qshmkchw',
fieldName: 'a4',
_modelAttribute: true,
field: 'a4'
},
a5: {
comment: '项目绩效评价',
_mark: 'xmjxxpj',
fieldName: 'a5',
_modelAttribute: true,
field: 'a5'
},
a6: {
comment: '目标责任书考核',
_mark: 'mbzrskh',
fieldName: 'a6',
_modelAttribute: true,
field: 'a6'
},
a7: {
comment: '后评价',
_mark: 'hpj',
fieldName: 'a7',
_modelAttribute: true,
field: 'a7'
},
a8: {
comment: '重大事项上报',
_mark: 'zdsxsb',
fieldName: 'a8',
_modelAttribute: true,
field: 'a8'
},
a9: {
comment: '投资分析',
_mark: 'tzfx',
fieldName: 'a9',
_modelAttribute: true,
field: 'a9'
},
a10: {
comment: '投资检查',
_mark: 'tzjc',
fieldName: 'a10',
_modelAttribute: true,
field: 'a10'
},
invtRetcompletionRate: {
comment: '投资回收完成率',
_mark: 'tzhs',
fieldName: 'invtRetcompletionRate',
_modelAttribute: true,
field: 'invtRetcompletionRate'
},
a11: {
comment: '管理费上缴',
_mark: 'glfsj',
fieldName: 'a11',
_modelAttribute: true,
field: 'a11'
},
a12: {
comment: 'PPP整改方案',
_mark: 'pppzgfa',
fieldName: 'a12',
_modelAttribute: true,
field: 'a12'
},
a13: {
comment: '项目结束/暂停(备案资料)',
_mark: 'xmjs/zt',
fieldName: 'a13',
_modelAttribute: true,
field: 'a13'
const _ = require('lodash');
let a = [
{
xjlr: 100,
xjlc: 200,
sdsqjxjll: 300,
tzsds: 400,
sdshjxjll: 500,
year: "合计",
},
{
xjlr: 100,
xjlc: 200,
sdsqjxjll: 300,
tzsds: 400,
sdshjxjll: 500,
year: 2022,
},
{
xjlr: 101,
xjlc: 201,
sdsqjxjll: 301,
tzsds: 401,
sdshjxjll: 501,
year: 2023,
},
{
xjlr: 1003,
xjlc: 2003,
sdsqjxjll: 3003,
tzsds: 4003,
sdshjxjll: 5003,
year: "2024",
},
{
xjlr: 1004,
xjlc: 2004,
sdsqjxjll: 3004,
tzsds: 4004,
sdshjxjll: 5004,
year: "2025",
}
]
const b = _.sortBy(a, 'year');
console.log(b);
function thvc(a) {
let xjlr = [], xjlc = [], sdsqjxjll = [], tzsds = [], sdshjxjll =[];
let retArr = [];
for (let index = 0; index < a.length; index++) {
const element = a[index];
xjlr.push(element.xjlr);
xjlc.push(element.xjlc);
sdsqjxjll.push(element.sdsqjxjll);
tzsds.push(element.tzsds);
sdshjxjll.push(element.sdshjxjll);
year.push(element.year);
}
return {xjlr, xjlc, sdsqjxjll, tzsds, sdshjxjll};
}
function cvht(obj) {
for (const key in obj) {
const element = obj[key];
const _ = require('lodash');
let b = _.groupBy(o, '_mark');
}
}
function reverseTransform(transformedData) {
// 获取第一个字段的数组长度作为对象数量
const field = Object.keys(transformedData)[0];
const itemCount = transformedData[field].length;
console.log(b);
\ No newline at end of file
const result = [];
// 遍历每个索引位置构建对象
for (let i = 0; i < itemCount; i++) {
const item = {};
// 为每个字段赋值
for (const key in transformedData) {
if (transformedData.hasOwnProperty(key)) {
item[key] = transformedData[key][i];
}
}
result.push(item);
}
return result;
}
// 使用示例
const transformed = {
xjlr: [100, 100, 101, 1003, 1004],
xjlc: [200, 200, 201, 2003, 2004],
sdsqjxjll: [300, 300, 301, 3003, 3004],
tzsds: [400, 400, 401, 4003, 4004],
sdshjxjll: [500, 500, 501, 5003, 5004]
};
console.log(reverseTransform(transformed));
// console.log(thvc(a));
\ No newline at end of file
......@@ -11,7 +11,7 @@
"host": "localhost",
"port": 3306,
"username": "root",
"password": "zhangqi1997.",
"password": "123456",
"database": "gzbjt",
"logging": true
},
......
{
"tokenEx": 86400,
"dbURI": "mongodb://root:letian2024.@127.0.0.1:27017/letian?authSource=admin",
"tokenEx": 86400000000,
"userDefaultPassword": "GZB123JT.",
"file": {
"storagePath": "/mnt/vdb1/uploadfiles"
"storagePath": "/uploadfiles"
},
"cron": {
"excel": true
},
"mysql": {
"host": "localhost",
"port": 3306,
"username": "root",
"password": "123456",
"database": "gzbjt",
"logging": true
},
"redis": {
"host": "localhost",
"port": 6379,
"password": "",
"db": 0
}
}
\ No newline at end of file
const ExcelJS = require('exceljs');
const _ = require('lodash');
const errorMessage = require('../utils/errorMessage');
const Path = require('path');
const fs = require('fs');
async function upload(req, res, next) {
try {
......@@ -20,6 +22,7 @@ async function upload(req, res, next) {
next(error);
}
}
async function batchUpload(req, res, next) {
try {
let ret = [];
......@@ -42,6 +45,87 @@ async function batchUpload(req, res, next) {
}
}
/**
*
*/
async function downloadFileById(req, res, next) {
try {
let fileId = req.params.fileId;
let fileinfo = await DB.File.findOne({ where: {id: fileId}, raw: true });
if (!(fileinfo && fileinfo.id)) {
return res.sendError(errorMessage.resourceNotFound)
}
let {
originalname,
filename,
size,
mimetype,
url,
path,
nginxpath,
} = fileinfo;
//TODO:path处理
const filePath = Path.join(__dirname, '../../../', path);
if (!fs.existsSync(filePath)) {
return res.sendError(errorMessage.resourceNotFound)
}
// 3. 设置强制下载响应头
res.setHeader('Content-Type', 'application/octet-stream');
res.setHeader('Content-Disposition', `attachment; filename="${encodeURIComponent(originalname)}"`);
// 4. 创建文件流并传输
const fileStream = fs.createReadStream(filePath);
fileStream.pipe(res);
// 错误处理
fileStream.on('error', (err) => {
console.error(`File stream error: ${err}`);
if (!res.headersSent) res.status(500).send('File streaming error');
});
} catch (error) {
next(error);
}
}
async function showFileById(req, res, next) {
try {
// ----------
let fileId = req.params.fileId;
let fileinfo = await DB.File.findOne({ where: {id: fileId}, raw: true });
if (!(fileinfo && fileinfo.id)) {
return res.sendError(errorMessage.resourceNotFound)
}
let {
originalname,
filename,
size,
mimetype,
url,
path,
nginxpath,
} = fileinfo;
//TODO:path处理
const filePath = Path.join(__dirname, '../../../', path);
if (!fs.existsSync(filePath)) {
return res.sendError(errorMessage.resourceNotFound)
}
// 3. 设置强制下载响应头
res.setHeader('Content-Type', mimetype);
res.setHeader('Content-Disposition', `inline; filename="${encodeURIComponent(filename)}"`);
// 4. 创建文件流并传输
const fileStream = fs.createReadStream(filePath);
fileStream.pipe(res);
// 错误处理
fileStream.on('error', (err) => {
console.error(`File stream error: ${err}`);
if (!res.headersSent) res.status(500).send('File streaming error');
});
} catch (error) {
next(error);
}
}
......@@ -53,5 +137,7 @@ async function batchUpload(req, res, next) {
module.exports = {
upload,
batchUpload
batchUpload,
downloadFileById,
showFileById,
}
\ No newline at end of file
const errorMessage = require("../utils/errorMessage");
const _ = require("lodash");
const { Op } = require('sequelize');
const { Op, where } = require('sequelize');
async function getProjectFields(req, res, next) {
try {
......@@ -47,27 +47,295 @@ async function getProjectFields(req, res, next) {
async function createProject(req, res, next) {
try {
const body = req.body;
console.log(DB.Project.rawAttributes);
const ret = await DB.Project.create(body);
return res.sendData();
/*
1.处理特殊字段:
projectJsgms :关联建设规模表
projectGdxxs : 关联股东信息表
projectXmtzzes :关联项目投资额表
projectBjtjs :关联项目核心边界条件表
projectSpyjs :关联审批意见表
projectFxgl: 关联 风险管理
projectTzzt: 关联 投资主体审核
ProjectJczt: 关联 决策主体审核
projectZqrz: 关联 债权融资
projectCwpjzb: 关联 财务评价指标
ProjectLcbjd: 关联 里程碑节点
lxzl :关联projectFiles-File文件表
lxpfwj :关联projectFiles-File文件表
xgshcl :关联projectFiles-File文件表
*/
// 1. 先创建项目
let projectInfo = _.omit(body, ['projectJsgms', 'projectGdxxs', 'projectXmtzzes', 'projectBjtjs', 'projectSpyjs', 'lxzl', 'lxpfwj', 'xgshcl']);
let project = await DB.Project.create(projectInfo);
// 处理 projectJsgms
let projectJsgms = body.projectJsgms || [];
projectJsgms = projectJsgms.map(o => { o.projectId = project.id; return o });
await DB.ProjectJsgm.bulkCreate(projectJsgms);
// 处理 projectGdxxs
let projectGdxxs = body.projectGdxxs || [];
projectGdxxs = projectGdxxs.map(o => { o.projectId = project.id; return o });
await DB.ProjectGdxx.bulkCreate(projectGdxxs);
// 处理 projectXmtzzes
let projectXmtzzes = body.projectXmtzzes || [];
projectXmtzzes = projectXmtzzes.map(o => { o.projectId = project.id; return o });
await DB.ProjectXmtzze.bulkCreate(projectXmtzzes);
// 处理 projectBjtjs
let projectBjtjs = body.projectBjtjs || [];
projectBjtjs = projectBjtjs.map(o => { o.projectId = project.id; return o });
await DB.ProjectBjtj.bulkCreate(projectBjtjs);
// 处理 projectFxgl
let projectFxgls = body.projectFxgls || [];
projectFxgls = projectFxgls.map(o => { o.projectId = project.id; return o });
await DB.ProjectFxgl.bulkCreate(projectFxgls);
// 处理 ProjectTzzt
let projectTzzts = body.projectTzzts || [];
projectTzzts = projectTzzts.map(o => { o.projectId = project.id; return o });
await DB.ProjectTzzt.bulkCreate(projectTzzts);
// 处理 ProjectJczt
let projectJczts = body.projectJczts || [];
projectJczts = projectJczts.map(o => { o.projectId = project.id; return o });
await DB.ProjectJczt.bulkCreate(projectJczts);
// 处理 projectZqrz
let projectZqrzs = body.projectZqrzs || [];
projectZqrzs = projectZqrzs.map(o => { o.projectId = project.id; return o });
await DB.ProjectZqrz.bulkCreate(projectZqrzs);
// 处理 projectSpyjs
let projectSpyjs = body.projectSpyjs || [];
projectSpyjs = projectSpyjs.map(o => { o.projectId = project.id; return o });
await DB.ProjectSpyj.bulkCreate(projectSpyjs);
// 处理 projectCwpjzb
let projectCwpjzbs = body.projectCwpjzbs || [];
projectCwpjzbs = projectCwpjzbs.map(o => { o.projectId = project.id; return o });
await DB.ProjectCwpjzb.bulkCreate(projectCwpjzbs);
// 处理 ProjectLcbjd
let projectLcbjds = body.projectLcbjds || [];
projectLcbjds = projectLcbjds.map(o => { o.projectId = project.id; return o });
await DB.ProjectLcbjd.bulkCreate(projectLcbjds);
// 处理 projectTzzjll-----
// 立项资料
let lxzl = body.lxzl || [];
lxzl = lxzl.map(o => { return { fileId: o.id, projectId: project.id, proFieldKey: 'lxzl' } });
// 立项批复文件
let lxpfwj = body.lxpfwj || [];
lxpfwj = lxpfwj.map(o => { return { fileId: o.id, projectId: project.id, proFieldKey: 'lxpfwj' } });
// 相关上会材料
let xgshcl = body.xgshcl || [];
xgshcl = xgshcl.map(o => { return { fileId: o.id, projectId: project.id, proFieldKey: 'xgshcl' } });
// 处理文件
let proFiles = _.concat(lxzl, lxpfwj, xgshcl);
await DB.ProjectFile.bulkCreate(proFiles);
/**
* 处理项目审批及消息 依靠项目状态流转
* 1. 发起人角色为项目公司项目发起人 xmgs_xmfqr;
* 2. 流转状态为 1待处理
* 3. 消息发送给 项目公司项目审批人 xmgs_xmspr,需要写一个审批接口 :项目基本信息不变,状态需要改为 2 项目公司初审:通过则变为3,不通过则变为1;
* 4. 若是投管部门自主创建项目,则项目状态直接到 5 待投管审核---退回则到1
* 5. 投管后续立项推送、决策推送状态再行处理
*/
//B. 找到本公司审批人员发送消息-- 如果找不到人 则提示项目已保存,联系管理员添加【项目公司项目审批人】角色
//A. 创建发起记录
return res.sendData(project);
} catch (error) {
next(error);
}
}
async function updateProject(req, res, next) {
try {
let body = req.body;
if (!body.id) {
return res.sendError(errorMessage.resourceNotFound)
}
const ret = await DB.Project.update(body, { where: { id: body.id } });
/*
1.处理特殊字段:
projectJsgms :关联建设规模表
projectGdxxs : 关联股东信息表
projectXmtzzes :关联项目投资额表
projectBjtjs :关联项目核心边界条件表
projectSpyjs :关联审批意见表
lxzl :关联projectFiles-File文件表
lxpfwj :关联projectFiles-File文件表
xgshcl :关联projectFiles-File文件表
*/
// 1. 先创建项目
let project = body;
let projectInfo = _.omit(body, ['projectJsgms', 'projectGdxxs', 'projectXmtzzes', 'projectBjtjs', 'projectSpyjs', 'lxzl', 'lxpfwj', 'xgshcl']);
// 处理 projectJsgms
let projectJsgms = body.projectJsgms || [];
let pnids1 = [], newprojectJsgms = [];
projectJsgms.map(o => { if(!o.id) {o.projectId = project.id; newprojectJsgms.push(o);} else{pnids1.push(o.id)} return o });
await DB.ProjectJsgm.destroy({ where: { projectId: project.id, id: { [Op.notIn]: pnids1 } } });
await DB.ProjectJsgm.bulkCreate(newprojectJsgms);
// 处理 projectGdxxs
let projectGdxxs = body.projectGdxxs || [];
let pnids2 = [], newprojectGdxxs = [];
projectGdxxs.map(o => { if(!o.id) {o.projectId = project.id; newprojectGdxxs.push(o);} else{pnids2.push(o.id)} return o });
await DB.ProjectGdxx.destroy({ where: { projectId: project.id, id: { [Op.notIn]: pnids2 } } });
await DB.ProjectGdxx.bulkCreate(newprojectGdxxs);
// 处理 projectXmtzzes
let projectXmtzzes = body.projectXmtzzes || [];
let pnids3 = [], newprojectXmtzzes = [];
projectXmtzzes.map(o => { if(!o.id) {o.projectId = project.id; newprojectXmtzzes.push(o);} else{pnids3.push(o.id)} return o });
await DB.ProjectXmtzze.bulkCreate(newprojectXmtzzes);
// 处理 projectBjtjs
let projectBjtjs = body.projectBjtjs || [];
let pnids4 = [], newprojectBjtjs = [];
projectBjtjs.map(o => { if(!o.id) {o.projectId = project.id; newprojectBjtjs.push(o);} else{pnids4.push(o.id)} return o });
await DB.ProjectBjtj.destroy({ where: { projectId: project.id, id: { [Op.notIn]: pnids4 } } });
await DB.ProjectBjtj.bulkCreate(newprojectBjtjs);
// 处理 projectFxgl
let projectFxgls = body.projectFxgls || [];
let pnids5 = [], newprojectFxgls = [];
projectFxgls.map(o => { if(!o.id) {o.projectId = project.id; newprojectFxgls.push(o);} else{pnids5.push(o.id)} return o });
await DB.ProjectFxgl.destroy({ where: { projectId: project.id, id: { [Op.notIn]: pnids5 } } });
await DB.ProjectFxgl.bulkCreate(newprojectFxgls);
// 处理 ProjectTzzt
let projectTzzts = body.projectTzzts || [];
let pnids6 = [], newprojectTzzts = [];
projectTzzts.map(o => { if(!o.id) {o.projectId = project.id; newprojectTzzts.push(o);} else{pnids6.push(o.id)} return o });
await DB.ProjectTzzt.destroy({ where: { projectId: project.id, id: { [Op.notIn]: pnids6 } } });
await DB.ProjectTzzt.bulkCreate(newprojectTzzts);
// 处理 ProjectJczt
let projectJczts = body.projectJczts || [];
let pnids7 = [], newprojectJczts = [];
projectJczts.map(o => { if(!o.id) {o.projectId = project.id; newprojectJczts.push(o);} else{pnids7.push(o.id)} return o });
await DB.ProjectJczt.destroy({ where: { projectId: project.id, id: { [Op.notIn]: pnids7 } } });
await DB.ProjectJczt.bulkCreate(newprojectJczts);
// 处理 projectZqrz
let projectZqrzs = body.projectZqrzs || [];
let pnids8 = [], newprojectZqrzs = [];
projectZqrzs.map(o => { if(!o.id) {o.projectId = project.id; newprojectZqrzs.push(o);} else{pnids8.push(o.id)} return o });
await DB.ProjectZqrz.destroy({ where: { projectId: project.id, id: { [Op.notIn]: pnids8 } } });
await DB.ProjectZqrz.bulkCreate(newprojectZqrzs);
// 处理 projectSpyjs
let projectSpyjs = body.projectSpyjs || [];
let pnids9 = [], newprojectSpyjs = [];
projectSpyjs.map(o => { if(!o.id) {o.projectId = project.id; newprojectSpyjs.push(o);} else{pnids9.push(o.id)} return o });
await DB.ProjectSpyj.destroy({ where: { projectId: project.id, id: { [Op.notIn]: pnids9 } } });
await DB.ProjectSpyj.bulkCreate(newprojectSpyjs);
// 处理 projectCwpjzb
let projectCwpjzbs = body.projectCwpjzbs || [];
let pnids10 = [], newprojectCwpjzbs = [];
projectCwpjzbs.map(o => { if(!o.id) {o.projectId = project.id; newprojectCwpjzbs.push(o);} else{pnids10.push(o.id)} return o });
await DB.ProjectCwpjzb.destroy({ where: { projectId: project.id, id: { [Op.notIn]: pnids10 } } });
await DB.ProjectCwpjzb.bulkCreate(newprojectCwpjzbs);
// 处理 ProjectLcbjd
let projectLcbjds = body.projectLcbjds || [];
let pnids11 = [], newprojectLcbjds = [];
projectLcbjds.map(o => { if(!o.id) {o.projectId = project.id; newprojectLcbjds.push(o);} else{pnids11.push(o.id)} return o });
await DB.ProjectLcbjd.destroy({ where: { projectId: project.id, id: { [Op.notIn]: pnids11 } } });
await DB.ProjectLcbjd.bulkCreate(newprojectLcbjds);
// 处理 projectTzzjll-----
// 立项资料
let lxzl = body.lxzl || [];
let needIds = []; let createIds = [];
lxzl.map(o => { if (!o.proFieldKey) { createIds.push({id: o.id, proFieldKey: 'lxzl'}) } else { needIds.push(o.id) }; return { fileId: o.id, projectId: project.id, proFieldKey: 'lxzl' } });
// 立项批复文件
let lxpfwj = body.lxpfwj || [];
lxpfwj.map(o => { if (!o.proFieldKey) { createIds.push({id: o.id, proFieldKey: 'lxpfwj'}) } else { needIds.push(o.id) }; return { fileId: o.id, projectId: project.id, proFieldKey: 'lxpfwj' } });
// 相关上会材料
let xgshcl = body.xgshcl || [];
xgshcl.map(o => { if (!o.proFieldKey) { createIds.push({id: o.id, proFieldKey: 'xgshcl'}) } else { needIds.push(o.id) }; return { fileId: o.id, projectId: project.id, proFieldKey: 'xgshcl' } });
// 处理文件
//1. 删除
await DB.ProjectFile.destroy({
where: {
projectId: project.id,
fileId: { [Op.notIn]: needIds }
}
});
//2. 创建
if(createIds.length) {
let creProFiles = createIds.map(o=> {return {projectId: project.id, fileId: o.id, proFieldKey: o.proFieldKey}});
await DB.ProjectFile.bulkCreate(creProFiles);
}
const ret = await DB.Project.update(projectInfo, { where: { id: body.id } });
/**
* 根据前端加入的参数区分按钮 更新草稿并提交 更新草稿
*/
return res.sendData(ret);
} catch (error) {
next(error);
}
}
async function getProjectInfo(req, res, next) {
try {
if (!req.body.id) {
return res.sendError(errorMessage.resourceNotFound);
}
let project = await DB.Project.findOne({
where: { id: req.body.id },
// raw: true,
include: [
{
model: DB.ProjectJsgm,
as: 'projectJsgms',
// where: { del: 0 },
// attributes: [],
},
{
model: DB.ProjectGdxx,
as: 'projectGdxxs',
// where: { del: 0 },
// attributes: [],
},
{
model: DB.ProjectXmtzze,
as: 'projectXmtzzes',
// where: { del: 0 },
// attributes: [],
},
{
model: DB.ProjectBjtj,
as: 'projectBjtjs',
// where: { del: 0 },
// attributes: [],
},
{
model: DB.ProjectSpyj,
as: 'projectSpyjs',
// where: { del: 0 },
// attributes: [],
},
{
model: DB.File,
as: 'files',
// where: { del: 0 },
// attributes: [],
through: { attributes: ['proFieldKey'] },
}
],
// raw: true
});
project = project.toJSON();
//处理 projectXmtzzes 树结构
let projectXmtzzes = project.projectXmtzzes || [];
project.projectXmtzzes = utils.buildTree(projectXmtzzes, 'kid');
//处理文件 还原成项目各个字段拥有的文件
let files = project.files || [];
files = files.map(o => { o.proFieldKey = o.jt_project_file && o.jt_project_file.proFieldKey; delete o.jt_project_file; return o; });
let keyFiles = _.groupBy(files, 'proFieldKey');
delete project.files;
let ret = {
...project,
...keyFiles
}
return res.sendData(ret);
} catch (error) {
next(error);
}
}
async function deleteProject(req, res, next) {
try {
if (!req.body.id) {
......@@ -177,11 +445,21 @@ async function exportExcel(req, res, next) {
}
}
async function getExcelTemplate(req, res, next) {
try {
//
} catch (error) {
next(error);
}
}
module.exports = {
getProjectFields,
createProject,
getProjectInfo,
listProject,
deleteProject,
updateProject,
exportExcel,
getExcelTemplate,
}
\ No newline at end of file
......@@ -275,6 +275,7 @@ module.exports = {
deleteResource,
listResource,
createResourceInfo,
updateResourceInfo,
deleteResourceInfo,
......
......@@ -15,6 +15,12 @@ const Position = require("./model/system/position");
const Project = require("./model/jt/project");
const Resources = require("./model/jt/resources");
const ResourcesInfo = require("./model/jt/resourcesInfo");
const ProjectBjtj = require("./model/jt/projectBjtj");
const ProjectFile = require("./model/jt/projectFile");
const ProjectGdxx = require("./model/jt/projectGdxx");
const ProjectJsgm = require("./model/jt/projectJsgm");
const ProjectSpyj = require("./model/jt/projectSpyj");
/**
* 业务表
......@@ -36,6 +42,11 @@ global.DB = {
Project,
Resources,
ResourcesInfo,
ProjectBjtj,
ProjectFile,
ProjectGdxx,
ProjectJsgm,
ProjectSpyj,
}
......@@ -44,17 +55,17 @@ global.DB = {
/**
* 关联关系定义
*/
/**用户-请求日志 1:n */
User.hasMany(RequestLog, { foreignKey: 'userId' });
RequestLog.belongsTo(User, { foreignKey: 'userId' });
/**用户-角色 n:n */
User.belongsToMany(Role, {
through: 'system_user_role', // 中间表名
foreignKey: 'userId', // 用户ID外键
otherKey: 'roleId', // 角色ID外键
as: 'roles',
});
Role.belongsToMany(User, {
through: 'system_user_role',
foreignKey: 'roleId',
......@@ -62,26 +73,26 @@ Role.belongsToMany(User, {
as: 'users'
});
/**角色-菜单 n:n */
Role.belongsToMany(Menu, {
through: 'system_role_menu',
foreignKey: 'roleId',
otherKey: 'menuId',
as: 'menus'
});
Menu.belongsToMany(Role, {
through: 'system_role_menu',
foreignKey: 'menuId',
otherKey: 'roleId'
});
/**用户-部门 n:n */
User.belongsToMany(Depart, {
through: 'system_user_depart', // 中间表名
foreignKey: 'userId', // 用户ID外键
otherKey: 'departId', // 角色ID外键
as: 'departs',
});
Depart.belongsToMany(User, {
through: 'system_user_depart',
foreignKey: 'departId',
......@@ -89,6 +100,7 @@ Depart.belongsToMany(User, {
as: 'users'
});
/**用户-职位 n:n */
User.belongsToMany(Position, {
through: 'system_user_position', // 中间表名
foreignKey: 'userId', // 用户ID外键
......@@ -103,7 +115,27 @@ Position.belongsToMany(User, {
as: 'users'
});
/**用户-项目 1:n */
User.hasMany(Project, { foreignKey: 'projectCreator', as: 'createdProjects' });
Project.belongsTo(User, { foreignKey: 'projectCreator', as: 'creator' });
/**项目-资源信息 1:n */
Resources.hasMany(ResourcesInfo, { foreignKey: 'resourceId', as: 'resourcesInfos' });
ResourcesInfo.belongsTo(Resources, { foreignKey: 'resourceId' });
/**项目-核心边界条件 1:n */
Project.hasMany(ProjectBjtj, { foreignKey: 'projectId', as: 'projectBjtjs' });
ProjectBjtj.belongsTo(Project, { foreignKey: 'projectId' });
/**项目-项目附件 1:n */
Project.belongsToMany(File, { through: 'jt_project_file', foreignKey: 'projectId', as: 'files', otherKey: 'fileId' });
File.belongsToMany(Project, { through: 'jt_project_file', foreignKey: 'fileId', otherKey: 'projectId', as: 'pros' });
/**项目-股东信息 1:n */
Project.hasMany(ProjectGdxx, { foreignKey: 'projectId', as: 'projectGdxxs' });
ProjectGdxx.belongsTo(Project, { foreignKey: 'projectId' });
/**项目-建设规模 1:n */
Project.hasMany(ProjectJsgm, { foreignKey: 'projectId', as: 'projectJsgms' });
ProjectJsgm.belongsTo(Project, { foreignKey: 'projectId' });
/**项目-审批意见 1:n */
Project.hasMany(ProjectSpyj, { foreignKey: 'projectId', as: 'projectSpyjs' });
ProjectSpyj.belongsTo(Project, { foreignKey: 'projectId' });
\ No newline at end of file
https://tz747a.ceec.net.cn/invest2/storage/getObject?storeFileName=%2F2025%2F11%2F22%2Fanoy_CB7136ED1D700001546FA46014AC119F%E6%B4%AA%E6%B4%AA%E8%AF%BB%E4%B9%A6%E8%87%AA%E6%88%91%E7%AE%A1%E7%90%86%E8%A1%A8.pdf&realFileName=%E6%B4%AA%E6%B4%AA%E8%AF%BB%E4%B9%A6%E8%87%AA%E6%88%91%E7%AE%A1%E7%90%86%E8%A1%A8.pdf&operateType=download&fullfilename=%E6%B4%AA%E6%B4%AA%E8%AF%BB%E4%B9%A6%E8%87%AA%E6%88%91%E7%AE%A1%E7%90%86%E8%A1%A8.pdf
https://tz747a.ceec.net.cn/invest2/storage/postObject
//年度投资计划---项目基本信息
lxr: { type: DataTypes.STRING, allowNull: true, comment: "联系人" },
lxdh: { type: DataTypes.STRING, allowNull: true, comment: "联系电话" },
jchcx: { type: DataTypes.STRING, allowNull: true, comment: "建成后成效" },
ssejqy: { type: DataTypes.STRING, allowNull: true, comment: "所属二级企业" },
projectCompanyName: { type: DataTypes.STRING, allowNull: true, comment: "项目公司名称" },
xmjd: { type: DataTypes.STRING, allowNull: true, comment: "项目阶段" },
//国资委中央企业投资信息
sfgjzcqghzdxma1: { type: DataTypes.INTEGER, allowNull: true, comment: "是否国家中长期规划重大项目(A1)" }, //是否
sfgjygbmxddzdxma2: { type: DataTypes.INTEGER, allowNull: true, comment: "是否国家有关部门下达的重点项目(A2)" },//是否
dgmsbgxa3: { type: DataTypes.INTEGER, allowNull: true, comment: "大规模设备更新(A3)" },//是否
zlxxxcybdgca4: { type: DataTypes.INTEGER, allowNull: true, comment: "战略性新兴产业百大工程(A4)" },//是否
lryqcyhxhwlcyqhxddxma3: { type: DataTypes.INTEGER, allowNull: true, comment: "列入央企产业焕新和未来产业启航行动的项目(A5)" },//是否
qlblzdxma5: { type: DataTypes.INTEGER, allowNull: true, comment: "强链补链重点项目(A6)" },//是否
dyzdhzdxmmlmc: { type: DataTypes.STRING, allowNull: true, comment: "对应重大或重点项目名录名称" },
lrqyfzzlxxxcygzfadxma4: { type: DataTypes.INTEGER, allowNull: true, comment: "列入企业发展战略性新兴产业工作方案的项目(A4)" },//是否
lsnykczybzxmb2: { type: DataTypes.INTEGER, allowNull: true, comment: "粮食、能源、矿产资源保障项目(B2)" },//是否
ctcygdhznhlshzxsjxmb3: { type: DataTypes.INTEGER, allowNull: true, comment: "传统产业高端化、智能化、绿色化转型升级项目(B3)" },//是否
zcqyfzdzdxmb4: { type: DataTypes.INTEGER, allowNull: true, comment: "支撑企业发展的重点项目(B4)" },//是否
zzyjsgzxmb1: { type: DataTypes.INTEGER, allowNull: true, comment: "制造业技术改造项目(B1)" },//是否
dwbgltzxmc1: { type: DataTypes.INTEGER, allowNull: true, comment: "对外并购类投资项目(C1)" },//是否
tbjglxmc2: { type: DataTypes.INTEGER, allowNull: true, comment: "特别监管类项目(C2)" },//是否
jwtbgzlxmc3: { type: DataTypes.INTEGER, allowNull: true, comment: "境外特别关注类项目(C3)" },//是否
dwcgltzxmc4: { type: DataTypes.INTEGER, allowNull: true, comment: "对外参股类投资项目(C4)" },//是否
fdctzxmc5: { type: DataTypes.INTEGER, allowNull: true, comment: "房地产投资项目(C5)" },//是否
ppptzxmc6: { type: DataTypes.INTEGER, allowNull: true, comment: "PPP投资项目(C6)" },//是否
lgxmc7: { type: DataTypes.INTEGER, allowNull: true, comment: "两高项目(C7)" },//是否
fzytzxmd1: { type: DataTypes.INTEGER, allowNull: true, comment: "非主业投资项目(D1)" },//是否
cpjrjgd2: { type: DataTypes.INTEGER, allowNull: true, comment: "持牌金融机构(D2)" },//是否
ljrjgd3: { type: DataTypes.INTEGER, allowNull: true, comment: "类金融机构(D3)" },//是否
qtjrjgd4: { type: DataTypes.INTEGER, allowNull: true, comment: "其他金融机构(D4)" },//是否
jjjjjglgsd5: { type: DataTypes.INTEGER, allowNull: true, comment: "基金及基金管理公司(D5)" },//是否
cytzjjd6: { type: DataTypes.INTEGER, allowNull: true, comment: "创业投资基金(D6)" },//是否
zzflqk: { type: DataTypes.TEXT, allowNull: true, comment: "最终分类情况" },
----------------
// xmzbjgqrz: { type: DataTypes.DECIMAL(19, 8), allowNull: true, comment: " 项目资本金(股权融资)" },
// njf: { type: DataTypes.DECIMAL(19, 8), allowNull: true, comment: "  能建方" },
// qtshzbf: { type: DataTypes.DECIMAL(19, 8), allowNull: true, comment: "  其他社会资本方" },
// jkzqrz: { type: DataTypes.DECIMAL(19, 8), allowNull: true, comment: " 借款(债权融资)" },
// yhdk2: { type: DataTypes.DECIMAL(19, 8), allowNull: true, comment: "  银行贷款" },
// qzfbbxmnjfdkdbe: { type: DataTypes.DECIMAL(19, 8), allowNull: true, comment: "   其中:非并表项目能建方贷款/担保额" },
// qtcz: { type: DataTypes.DECIMAL(19, 8), allowNull: true, comment: "其他出资" },
// qznjfcz: { type: DataTypes.DECIMAL(19, 8), allowNull: true, comment: " 其中:能建方出资" },
// czze111213: { type: DataTypes.DECIMAL(19, 8), allowNull: true, comment: "筹资总额(1.1+1.2+1.3)" },
// jsqlxrzfy: { type: DataTypes.DECIMAL(19, 8), allowNull: true, comment: "建设期利息(融资费用)" },
// yyzsr2: { type: DataTypes.DECIMAL(19, 8), allowNull: true, comment: " 营业总收入" },
// yyzcb: { type: DataTypes.DECIMAL(19, 8), allowNull: true, comment: " 营业总成本" },
// qzjycb: { type: DataTypes.DECIMAL(19, 8), allowNull: true, comment: "  其中:经营成本" },
// qzzjjtx: { type: DataTypes.DECIMAL(19, 8), allowNull: true, comment: "  其中:折旧及摊销" },
// lrze3: { type: DataTypes.DECIMAL(19, 8), allowNull: true, comment: " 利润总额" },
// sds: { type: DataTypes.DECIMAL(19, 8), allowNull: true, comment: " 所得税" },
// netProfit3: { type: DataTypes.DECIMAL(19, 8), allowNull: true, comment: " 净利润" },
// njffhsq2: { type: DataTypes.DECIMAL(19, 8), allowNull: true, comment: " 能建方分红(税前)" },
// njffhsh: { type: DataTypes.DECIMAL(19, 8), allowNull: true, comment: " 能建方分红(税后)" },
// wfplr: { type: DataTypes.DECIMAL(19, 8), allowNull: true, comment: "未分配利润" },
// xmd: { type: DataTypes.DECIMAL(19, 8), allowNull: true, comment: " 项目贷" },
// xmdlx: { type: DataTypes.DECIMAL(19, 8), allowNull: true, comment: " 项目贷利息" },
// qtzjbj: { type: DataTypes.DECIMAL(19, 8), allowNull: true, comment: " 其他资金本金" },
// qtzjlxrzfy: { type: DataTypes.DECIMAL(19, 8), allowNull: true, comment: " 其他资金利息(融资费用)" },
// zczeqmz: { type: DataTypes.DECIMAL(19, 8), allowNull: true, comment: " 资产总额(期末值)" },
// fzzeqmz: { type: DataTypes.DECIMAL(19, 8), allowNull: true, comment: " 负债总额(期末值)" },
// jyhdcsjxjl: { type: DataTypes.DECIMAL(19, 8), allowNull: true, comment: "经营活动产生净现金流" },
// tzhdcsjxjl: { type: DataTypes.DECIMAL(19, 8), allowNull: true, comment: "投资活动产生净现金流" },
// jyhdcsdxjlr: { type: DataTypes.DECIMAL(19, 8), allowNull: true, comment: "  经营活动产生的现金流入" },
// jyhdcsdxjlc: { type: DataTypes.DECIMAL(19, 8), allowNull: true, comment: "  经营活动产生的现金流出" },
// tzhdcsdxjlr: { type: DataTypes.DECIMAL(19, 8), allowNull: true, comment: "  投资活动产生的现金流入" },
// tzhdcsdxjlc: { type: DataTypes.DECIMAL(19, 8), allowNull: true, comment: "  投资活动产生的现金流出" },
// czhdcsdxjlr: { type: DataTypes.DECIMAL(19, 8), allowNull: true, comment: "  筹资活动产生的现金流入" },
// czhdcsdxjlc: { type: DataTypes.DECIMAL(19, 8), allowNull: true, comment: "  筹资活动产生的现金流出" },
// tzhdcsdxjlje: { type: DataTypes.DECIMAL(19, 8), allowNull: true, comment: "投资活动产生的现金流净额" },
// czhdcsdxjlje: { type: DataTypes.DECIMAL(19, 8), allowNull: true, comment: "筹资活动产生的现金流净额" },
// jyhdcsdxjlje: { type: DataTypes.DECIMAL(19, 8), allowNull: true, comment: "经营活动产生的现金流净额" },
// lxbfl: { type: DataTypes.DECIMAL(3, 2), allowNull: true, comment: "利息备付率" },
// czbfl: { type: DataTypes.DECIMAL(3, 2), allowNull: true, comment: "偿债备付率" },
----
// jyhdcsdxjlje2: { type: DataTypes.DECIMAL(19, 8), allowNull: true, comment: " 经营活动产生的现金流净额" },
// tzhdcsdxjlje2: { type: DataTypes.DECIMAL(19, 8), allowNull: true, comment: " 投资活动产生的现金流净额" },
项目名称
项目编号
投资分类
......
This source diff could not be displayed because it is too large. You can view the blob instead.
1. 项目提交(项目公司、投管) 只能靠角色
1.1 项目公司新建项目人员---项目公司项目审批人员 --- 投管项目审批人员
项目公司人员 -- 看见本公司所有项目
投管项目审批人员 -- 看见所有项目公司人员
1.2 投管新建项目 --- 投管
同步发起 一个startFlow 流程记录 发起人 发起时间 项目状态(待审批-已审批)
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
const { DataTypes } = require('sequelize');
const sequelize = require('../index');
// 建设规模
const Project = require('./project');
// 核心边界条件
const projectBjtj = sequelize.define('projectBjtj', {
// 定义字段
id: {
type: DataTypes.INTEGER,
primaryKey: true,
......@@ -35,8 +34,7 @@ const projectBjtj = sequelize.define('projectBjtj', {
},
njfhlDw: {
type: DataTypes.STRING,
comment: "年均负荷率单位",
defaultValue: "%"
comment: "年均负荷率单位"
},
dwscfwzcbSz: {
type: DataTypes.DECIMAL(20, 4),
......@@ -44,8 +42,7 @@ const projectBjtj = sequelize.define('projectBjtj', {
},
dwscfwzcbDw: {
type: DataTypes.STRING,
comment: "单位生产服务总成本单位",
defaultValue: "%"
comment: "单位生产服务总成本单位"
},
dwsjSz: {
type: DataTypes.DECIMAL(20, 4),
......@@ -65,8 +62,7 @@ const projectBjtj = sequelize.define('projectBjtj', {
},
ykphddw: {
type: DataTypes.STRING,
comment: "盈亏平衡点单位",
defaultValue: "%"
comment: "盈亏平衡点单位"
},
bcsm: {
type: DataTypes.STRING,
......@@ -76,6 +72,10 @@ const projectBjtj = sequelize.define('projectBjtj', {
projectId: {
type: DataTypes.INTEGER,
comment: "所属项目ID",
references: {
model: Project, // 关联的表名
key: 'id', // 关联的字段
}
},
del: {
......@@ -84,13 +84,13 @@ const projectBjtj = sequelize.define('projectBjtj', {
comment: "0 正常 1 删除"
},
}, {
tableName: 'jt_project_gdxx', // 指定表名(如果与模型名不同)
tableName: 'jt_project_bjtj', // 指定表名(如果与模型名不同)
timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
});
// 同步模型到数据库(创建表)
projectBjtj.sync({
// force: false,
force: false,
// force: true ,//会删除已存在表并重新创建
// alter: true
})
......
const { DataTypes } = require('sequelize');
const sequelize = require('../index');
// 建设规模
// 财务评价指标
const projectCwpjzb = sequelize.define('projectCwpjzb', {
// 定义字段
id: {
type: DataTypes.INTEGER,
primaryKey: true,
......
// models/User.js
const { DataTypes } = require('sequelize');
const sequelize = require('../index');
const File = require('./file');
const File = require('../system/file');
const Project = require('./project');
const projectFile = sequelize.define('projectFile', {
const ProjectFile = sequelize.define('ProjectFile', {
// 定义字段
id: {
type: DataTypes.INTEGER,
......@@ -19,7 +19,7 @@ const projectFile = sequelize.define('projectFile', {
type: DataTypes.INTEGER,
references: { model: Project, key: 'id' }
},
projectKey: {
proFieldKey: {
type: DataTypes.STRING, //项目表中文件字段key
}
}, {
......@@ -28,13 +28,14 @@ const projectFile = sequelize.define('projectFile', {
});
// 同步模型到数据库(创建表)
projectFile.sync({
// force: false, // force: true 会删除已存在表并重新创建
alter: true
ProjectFile.sync({
force: false, //
// force: true //会删除已存在表并重新创建
// alter: true
})
.then(() => {
console.log('projectFile 表同步成功');
console.log('ProjectFile 表同步成功');
});
module.exports = projectFile;
\ No newline at end of file
module.exports = ProjectFile;
\ No newline at end of file
const { DataTypes } = require('sequelize');
const sequelize = require('../index');
const ProjectStage = sequelize.define('ProjectStage', {
// 定义字段
// 风险管理
const ProjectFxgl = sequelize.define('ProjectFxgl', {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true
},
fxlb: {
type: DataTypes.STRING,
comment: "风险类别"
},
fxms: {
type: DataTypes.TEXT,
comment: "风险描述"
},
ydcs: {
type: DataTypes.TEXT,
comment: "应对措施"
},
projectId: {
type: DataTypes.INTEGER,
comment: "所属项目ID",
},
del: {
type: DataTypes.INTEGER,
defaultValue: 0,
comment: "0 正常 1 删除"
},
}, {
tableName: 'system_project', // 指定表名(如果与模型名不同)
tableName: 'jt_project_fxgl', // 指定表名(如果与模型名不同)
timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
});
// 同步模型到数据库(创建表)
ProjectStage.sync({
// force: false,
ProjectFxgl.sync({
force: false,
// force: true ,//会删除已存在表并重新创建
// alter: true
})
.then(() => {
console.log('ProjectStage 表同步成功');
console.log('ProjectFxgl 表同步成功');
});
module.exports = ProjectStage;
\ No newline at end of file
module.exports = ProjectFxgl;
\ No newline at end of file
const { DataTypes } = require('sequelize');
const sequelize = require('../index');
// 建设规模
const projectGdxx = sequelize.define('projectGdxx', {
// 定义字段
// 股东信息
const ProjectGdxx = sequelize.define('ProjectGdxx', {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true
},
type: {
gdlx: {
type: DataTypes.STRING,
comment: "股东类型"
},
name: {
gdmc: {
type: DataTypes.STRING,
comment: "股东名称"
},
......@@ -57,14 +56,14 @@ const projectGdxx = sequelize.define('projectGdxx', {
});
// 同步模型到数据库(创建表)
projectGdxx.sync({
// force: false,
ProjectGdxx.sync({
force: false,
// force: true ,//会删除已存在表并重新创建
// alter: true
})
.then(() => {
console.log('projectGdxx 表同步成功');
console.log('ProjectGdxx 表同步成功');
});
module.exports = projectGdxx;
\ No newline at end of file
module.exports = ProjectGdxx;
\ No newline at end of file
const { DataTypes } = require('sequelize');
const sequelize = require('../index');
//决策主体审核情况
const ProjectJczt = sequelize.define('ProjectJczt', {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true
},
hylx: { type: DataTypes.STRING, allowNull: true, comment: "会议类型" },
hylx: { type: DataTypes.STRING, allowNull: true, comment: "会议名称" },
jc: { type: DataTypes.STRING, allowNull: true, comment: "届次" },
zkrq: { type: DataTypes.DATE, allowNull: true, comment: "召开日期" },
jl: { type: DataTypes.STRING, allowNull: true, comment: "结论" },
qtsm: { type: DataTypes.TEXT, allowNull: true, comment: "决策结论" },
qtsm: { type: DataTypes.TEXT, allowNull: true, comment: "其他说明" },
projectId: {
type: DataTypes.INTEGER,
comment: "所属项目ID",
},
del: {
type: DataTypes.INTEGER,
defaultValue: 0,
comment: "0 正常 1 删除"
},
}, {
tableName: 'jt_project_jczt', // 指定表名(如果与模型名不同)
timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
});
// 同步模型到数据库(创建表)
ProjectJczt.sync({
force: false,
// force: true ,//会删除已存在表并重新创建
// alter: true
})
.then(() => {
console.log('ProjectJczt 表同步成功');
});
module.exports = ProjectJczt;
\ No newline at end of file
......@@ -2,8 +2,7 @@ const { DataTypes } = require('sequelize');
const sequelize = require('../index');
// 建设规模
const projectJsgm = sequelize.define('projectJsgm', {
// 定义字段
const ProjectJsgm = sequelize.define('ProjectJsgm', {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
......@@ -40,14 +39,14 @@ const projectJsgm = sequelize.define('projectJsgm', {
});
// 同步模型到数据库(创建表)
projectJsgm.sync({
// force: false,
ProjectJsgm.sync({
force: false,
// force: true ,//会删除已存在表并重新创建
// alter: true
})
.then(() => {
console.log('projectJsgm 表同步成功');
console.log('ProjectJsgm 表同步成功');
});
module.exports = projectJsgm;
\ No newline at end of file
module.exports = ProjectJsgm;
\ No newline at end of file
const { DataTypes } = require('sequelize');
const sequelize = require('../index');
const File = require('../system/file');
// yjlx: { type: DataTypes.STRING, allowNull: true, comment: "意见类型" },
// pfyj: { type: DataTypes.STRING, allowNull: true, comment: "批复意见" },
// pfyjsj: { type: DataTypes.DATE, allowNull: true, comment: "批复意见时间" },
// zxhf: { type: DataTypes.STRING, allowNull: true, comment: "执行回复" },
// zxhfsj: { type: DataTypes.DATE, allowNull: true, comment: "执行回复时间" },
// zxhffj: { type: DataTypes.STRING, allowNull: true, comment: "执行回复附件" },
// wlsqksm: { type: DataTypes.STRING, allowNull: true, comment: "未落实情况说明" },
//里程碑节点
const ProjectLcbjd = sequelize.define('ProjectLcbjd', {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true
},
lcbjdmc: {
type: DataTypes.STRING,
comment: "里程碑节点名称"
},
jdwcms: {
type: DataTypes.TEXT,
comment: "节点完成描述"
},
yjwcsj: {
type: DataTypes.DATE,
comment: "预计完成时间"
},
projectId: {
type: DataTypes.INTEGER,
comment: "所属项目ID",
},
del: {
type: DataTypes.INTEGER,
defaultValue: 0,
comment: "0 正常 1 删除"
},
}, {
tableName: 'jt_project_lcbjd', // 指定表名(如果与模型名不同)
timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
});
// 同步模型到数据库(创建表)
ProjectLcbjd.sync({
force: false,
// force: true ,//会删除已存在表并重新创建
// alter: true
})
.then(() => {
console.log('ProjectLcbjd 表同步成功');
});
module.exports = ProjectLcbjd;
\ No newline at end of file
const { DataTypes } = require('sequelize');
const sequelize = require('../index');
const File = require('../system/file');
// yjlx: { type: DataTypes.STRING, allowNull: true, comment: "意见类型" },
// pfyj: { type: DataTypes.STRING, allowNull: true, comment: "批复意见" },
// pfyjsj: { type: DataTypes.DATE, allowNull: true, comment: "批复意见时间" },
// zxhf: { type: DataTypes.STRING, allowNull: true, comment: "执行回复" },
// zxhfsj: { type: DataTypes.DATE, allowNull: true, comment: "执行回复时间" },
// zxhffj: { type: DataTypes.STRING, allowNull: true, comment: "执行回复附件" },
// wlsqksm: { type: DataTypes.STRING, allowNull: true, comment: "未落实情况说明" },
// 审批意见
const ProjectSpyj = sequelize.define('ProjectSpyj', {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true
},
lx: {
type: DataTypes.STRING,
comment: "指标名称"
},
pfyj: {
type: DataTypes.TEXT,
comment: "批复意见"
},
pfyjsj: {
type: DataTypes.DATE,
comment: "批复意见时间"
},
zxhf: { type: DataTypes.TEXT, allowNull: true, comment: "执行回复" },
zxhfsj: { type: DataTypes.DATE, allowNull: true, comment: "执行回复时间" },
zxhffj: { type: DataTypes.INTEGER, references: {
model: File,
key: 'id'
}, allowNull: true, comment: "执行回复附件" },
wlsqksm: { type: DataTypes.TEXT, allowNull: true, comment: "未落实情况说明" },
projectId: {
type: DataTypes.INTEGER,
comment: "所属项目ID",
},
del: {
type: DataTypes.INTEGER,
defaultValue: 0,
comment: "0 正常 1 删除"
},
}, {
tableName: 'jt_project_spyj', // 指定表名(如果与模型名不同)
timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
});
// 同步模型到数据库(创建表)
ProjectSpyj.sync({
force: false,
// force: true ,//会删除已存在表并重新创建
// alter: true
})
.then(() => {
console.log('ProjectSpyj 表同步成功');
});
module.exports = ProjectSpyj;
\ No newline at end of file
const { DataTypes } = require('sequelize');
const sequelize = require('../index');
//项目投资资金流量表-excel
const ProjectTzzjll = sequelize.define('ProjectTzzjll', {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true
},
xjlr: { type: DataTypes.DECIMAL(19, 8), allowNull: true, comment: "现金流入" },
xjlc: { type: DataTypes.DECIMAL(19, 8), allowNull: true, comment: "现金流出" },
sdsqjxjll: { type: DataTypes.DECIMAL(19, 8), allowNull: true, comment: "所得税前净现金流量" },
tzsds: { type: DataTypes.DECIMAL(19, 8), allowNull: true, comment: "调整所得税" },
sdshjxjll: { type: DataTypes.DECIMAL(19, 8), allowNull: true, comment: "所得税后净现金流量" },
year: { type: DataTypes.STRING, allowNull: true, comment: "年份"},
projectId: {
type: DataTypes.INTEGER,
comment: "所属项目ID",
},
del: {
type: DataTypes.INTEGER,
defaultValue: 0,
comment: "0 正常 1 删除"
},
}, {
tableName: 'jt_project_tzzjll', // 指定表名(如果与模型名不同)
timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
});
// 同步模型到数据库(创建表)
ProjectTzzjll.sync({
force: false,
// force: true ,//会删除已存在表并重新创建
// alter: true
})
.then(() => {
console.log('ProjectTzzjll 表同步成功');
});
module.exports = ProjectTzzjll;
\ No newline at end of file
const { DataTypes } = require('sequelize');
const sequelize = require('../index');
//投资主体审核情况
const ProjectTzzt = sequelize.define('ProjectTzzt', {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true
},
hylx: { type: DataTypes.STRING, allowNull: true, comment: "会议类型" },
jc: { type: DataTypes.STRING, allowNull: true, comment: "届次" },
zkrq: { type: DataTypes.DATE, allowNull: true, comment: "召开日期" },
jl: { type: DataTypes.STRING, allowNull: true, comment: "结论" },
qtsm: { type: DataTypes.TEXT, allowNull: true, comment: "其他说明" },
projectId: {
type: DataTypes.INTEGER,
comment: "所属项目ID",
},
del: {
type: DataTypes.INTEGER,
defaultValue: 0,
comment: "0 正常 1 删除"
},
}, {
tableName: 'jt_project_tzzt', // 指定表名(如果与模型名不同)
timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
});
// 同步模型到数据库(创建表)
ProjectTzzt.sync({
force: false,
// force: true ,//会删除已存在表并重新创建
// alter: true
})
.then(() => {
console.log('ProjectTzzt 表同步成功');
});
module.exports = ProjectTzzt;
\ No newline at end of file
const { DataTypes } = require('sequelize');
const sequelize = require('../index');
// 建设规模
const projectXmtzze = sequelize.define('projectXmtzze', {
// 定义字段
// 项目总投资总额(全口径)
const ProjectXmtzze = sequelize.define('ProjectXmtzze', {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true
},
// kid: {
// type: DataTypes.INTEGER,
// comment: "表格行ID"
// },
xh: {
type: DataTypes.STRING,
comment: ""
comment: "序号"
},
zb: {
type: DataTypes.STRING,
......@@ -26,11 +29,10 @@ const projectXmtzze = sequelize.define('projectXmtzze', {
type: DataTypes.DECIMAL(20, 4),
comment: "人民币计价"
},
parentId: {
type: DataTypes.INTEGER,
comment: "上级ID",
defaultValue: 0
},
// parentId: {
// type: DataTypes.INTEGER,
// comment: "上级ID"
// },
projectId: {
type: DataTypes.INTEGER,
......@@ -48,14 +50,14 @@ const projectXmtzze = sequelize.define('projectXmtzze', {
});
// 同步模型到数据库(创建表)
projectXmtzze.sync({
// force: false,
ProjectXmtzze.sync({
force: false,
// force: true ,//会删除已存在表并重新创建
// alter: true
})
.then(() => {
console.log('projectXmtzze 表同步成功');
console.log('ProjectXmtzze 表同步成功');
});
module.exports = projectXmtzze;
\ No newline at end of file
module.exports = ProjectXmtzze;
\ No newline at end of file
// const { DataTypes } = require('sequelize');
// const sequelize = require('../index');
// // 债权融资
// const ProjectZqrz = sequelize.define('ProjectZqrz', {
// id: {
// type: DataTypes.INTEGER,
// primaryKey: true,
// autoIncrement: true
// },
// wffzdzqrzjewy: { type: DataTypes.DECIMAL(19, 8), allowNull: true, comment: "我方负责的债权融资金额(万元)" },
// rzcbzq: { type: DataTypes.DECIMAL(19, 8), allowNull: true, comment: "融资成本债权" },
// qxzq: { type: DataTypes.INTEGER, allowNull: true, comment: "期限债权" },
// yjldsjzq: { type: DataTypes.DATE, allowNull: true, comment: "预计落地时间债权" },
// projectId: {
// type: DataTypes.INTEGER,
// comment: "所属项目ID",
// },
// del: {
// type: DataTypes.INTEGER,
// defaultValue: 0,
// comment: "0 正常 1 删除"
// },
// }, {
// tableName: 'jt_project_zqrz', // 指定表名(如果与模型名不同)
// timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
// });
// // 同步模型到数据库(创建表)
// ProjectZqrz.sync({
// force: false,
// // force: true ,//会删除已存在表并重新创建
// // alter: true
// })
// .then(() => {
// console.log('ProjectZqrz 表同步成功');
// });
// module.exports = ProjectZqrz;
\ No newline at end of file
// models/Message.js
const { DataTypes } = require('sequelize');
const sequelize = require('../index');
const Message = sequelize.define('Message', {
// 定义字段
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true
},
creator: {
type: DataTypes.INTEGER,
comment: "创建人ID"
},
receivers: {
type: DataTypes.JSON,
comment: "接收人ID"
},
alreadyRead: {
type: DataTypes.JSON,
comment: "已经阅读人ID"
},
title: {
type: DataTypes.TEXT,
allowNull: false,
comment: "消息标题"
},
content: {
type: DataTypes.TEXT,
allowNull: false,
comment: "消息内容"
},
/**
* 其他待存字段
*/
type: {
type: DataTypes.INTEGER,
allowNull: true,
comment: "消息类型 1 系统消息 2 项目初步审核 3.项目终审"
},
status: {
type: DataTypes.INTEGER,
defaultValue: 0,
comment: "0 未读 1 已读"
},
del: {
type: DataTypes.INTEGER,
defaultValue: 0,
comment: "0 正常 1 删除"
},
}, {
tableName: 'system_message', // 指定表名(如果与模型名不同)
timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
});
// 同步模型到数据库(创建表)
Message.sync({
// force: false,
// force: true ,//会删除已存在表并重新创建
// alter: true
})
.then(() => {
console.log('Message 表同步成功');
});
module.exports = Message;
\ No newline at end of file
......@@ -27,6 +27,10 @@ const User = sequelize.define('User', {
allowNull: true
},
avatar: DataTypes.STRING(500), //头像
type: {
type: DataTypes.INTEGER,
comment: "用户类型 1 葛洲坝用户 2 外部项目公司用户 3 能建用户"
},
enable: {
type: DataTypes.INTEGER,
defaultValue: 0,
......
......@@ -13,7 +13,7 @@ module.exports = async (req, res, next) => {
}
req.headers.authorization = req.headers.authorization || req.headers.Authorization;
const userStr = await ioRedis.get(`token:${req.headers.authorization}`);
console.log(userStr)
// console.log("middleware request文件:", userStr)
if (userStr) {
try {
req.user = JSON.parse(userStr);
......@@ -46,10 +46,25 @@ module.exports = async (req, res, next) => {
next();
}
// function checkPath(path) {
// console.log(path, "===============")
// if (['/user/login', '/user/regist',].includes(path)) {
// return true;
// } else {
// return false;
// }
// }
function checkPath(path) {
if (['/user/login', '/user/regist',].includes(path)) {
return true;
} else {
return false;
}
console.log(path, "===============");
// 允许的路径模式数组
const allowedPatterns = [
/^\/user\/login$/,
/^\/user\/regist$/,
/^\/file\/download\/\d+$/,
/^\/file\/show\/\d+$/,
];
return allowedPatterns.some(pattern => pattern.test(path));
}
\ No newline at end of file
module.exports = {
}
\ No newline at end of file
......@@ -35,5 +35,7 @@ router.post('/upload', upload.single('file'), fileController.upload);
router.post('/batch/upload', upload.array('files'), fileController.batchUpload);
router.get('/download/:fileId', fileController.downloadFileById);
router.get('/show/:fileId', fileController.showFileById);
module.exports = router;
\ No newline at end of file
......@@ -10,11 +10,13 @@ const projectController = require('../controller/projectController');
*/
router.post('/createProject', projectController.createProject);
router.post('/updateProject', projectController.updateProject);
// router.post('/deleteProject', projectController.deleteProject);
router.post('/deleteProject', projectController.deleteProject);
router.post('/listProject', projectController.listProject);
// router.post('/getProject', projectController.getProject);
router.post('/getProjectInfo', projectController.getProjectInfo);
router.post('/getProjectFields', projectController.getProjectFields);
router.post('/exportExcel', projectController.exportExcel);
router.post('/getExcelTemplate', projectController.getExcelTemplate);
module.exports = router;
\ No newline at end of file
......@@ -28,9 +28,9 @@ function checkUserPassword({ reqPw, salt, userPw }) {
}
}
function buildTree(nodes) {
function buildTree(nodes, keyid = 'id') {
// 创建一个映射,将节点ID映射到节点对象
const nodeMap = new Map(nodes.map(node => [String(node.id), { ...node, children: [] }]));
const nodeMap = new Map(nodes.map(node => [String(node[keyid]), { ...node, children: [] }]));
// 遍历所有节点,并将它们添加到对应父节点的children数组中
nodes.forEach(node => {
......@@ -39,7 +39,7 @@ function buildTree(nodes) {
// 确保父节点在映射中存在
if (nodeMap.has(parentId)) {
// 将当前节点添加到父节点的children数组中
nodeMap.get(parentId).children.push(nodeMap.get(String(node.id)));
nodeMap.get(parentId).children.push(nodeMap.get(String(node[keyid])));
nodeMap.get(parentId).children = _.orderBy(nodeMap.get(parentId).children, 'order')
}
}
......
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