明树Git Lab

Commit 1da64ebe authored by zfp1's avatar zfp1

update

parent 529e06a0
let o = { let a = [{a: 1}, {a:2}];
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'); a = a.map(o => {return {id: o.a}});
console.log(a);
let b = _.groupBy(o, '_mark'); \ No newline at end of file
console.log(b);
\ No newline at end of file
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
"host": "localhost", "host": "localhost",
"port": 3306, "port": 3306,
"username": "root", "username": "root",
"password": "zhangqi1997.", "password": "123456",
"database": "gzbjt", "database": "gzbjt",
"logging": true "logging": true
}, },
......
...@@ -47,21 +47,208 @@ async function getProjectFields(req, res, next) { ...@@ -47,21 +47,208 @@ async function getProjectFields(req, res, next) {
async function createProject(req, res, next) { async function createProject(req, res, next) {
try { try {
const body = req.body; const body = req.body;
console.log(DB.Project.rawAttributes); /*
const ret = await DB.Project.create(body); 1.处理特殊字段:
return res.sendData(); projectJsgms :关联建设规模表
projectGdxxs : 关联股东信息表
projectXmtzzes :关联项目投资额表
projectBjtjs :关联项目核心边界条件表
projectSpyjs :关联审批意见表
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)
// 处理 projectBjtjs
let projectBjtjs = body.projectBjtjs || [];
projectBjtjs = projectBjtjs.map(o => { o.projectId = project.id; return o });
await DB.ProjectBjtj.bulkCreate(projectBjtjs);
// 处理 projectXmtzzes
let projectXmtzzes = body.projectXmtzzes || [];
projectXmtzzes = utils.disTree(projectXmtzzes);
projectXmtzzes = projectXmtzzes.map(o => { o.projectId = project.id; return o });
await DB.ProjectXmtzze.bulkCreate(projectXmtzzes);
// 处理 projectSpyjs
let projectSpyjs = body.projectSpyjs || [];
projectSpyjs = utils.disTree(projectSpyjs);
projectSpyjs = projectSpyjs.map(o => { o.projectId = project.id; return o });
await DB.ProjectSpyj.bulkCreate(projectSpyjs);
// 立项资料
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);
return res.sendData(project);
} catch (error) { } catch (error) {
next(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 updateProject(req, res, next) { async function updateProject(req, res, next) {
try { try {
let body = req.body; let body = req.body;
if (!body.id) { if (!body.id) {
return res.sendError(errorMessage.resourceNotFound) 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 || [];
projectJsgms = projectJsgms.map(o => { o.projectId = project.id; delete o.id; return o });
await DB.ProjectJsgm.destroy({ where: { projectId: project.id } });
await DB.ProjectJsgm.bulkCreate(projectJsgms);
// 处理 projectGdxxs
let projectGdxxs = body.projectGdxxs || [];
projectGdxxs = projectGdxxs.map(o => { o.projectId = project.id; delete o.id; return o });
await DB.ProjectGdxx.destroy({ where: { projectId: project.id } });
await DB.ProjectGdxx.bulkCreate(projectGdxxs)
// 处理 projectBjtjs
let projectBjtjs = body.projectBjtjs || [];
projectBjtjs = projectBjtjs.map(o => { o.projectId = project.id; delete o.id; return o });
await DB.ProjectBjtj.destroy({ where: { projectId: project.id } });
await DB.ProjectBjtj.bulkCreate(projectBjtjs);
// 处理 projectXmtzzes
let projectXmtzzes = body.projectXmtzzes || [];
projectXmtzzes = utils.disTree(projectXmtzzes);
projectXmtzzes = projectXmtzzes.map(o => { o.projectId = project.id; delete o.id; return o });
await DB.ProjectXmtzze.destroy({ where: { projectId: project.id } });
await DB.ProjectXmtzze.bulkCreate(projectXmtzzes);
// 处理 projectSpyjs
let projectSpyjs = body.projectSpyjs || [];
projectSpyjs = utils.disTree(projectSpyjs);
projectSpyjs = projectSpyjs.map(o => { o.projectId = project.id; delete o.id; return o });
await DB.ProjectSpyj.destroy({ where: { projectId: project.id } });
await DB.ProjectSpyj.bulkCreate(projectSpyjs);
// 立项资料
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); return res.sendData(ret);
} catch (error) { } catch (error) {
next(error); next(error);
...@@ -180,6 +367,7 @@ async function exportExcel(req, res, next) { ...@@ -180,6 +367,7 @@ async function exportExcel(req, res, next) {
module.exports = { module.exports = {
getProjectFields, getProjectFields,
createProject, createProject,
getProjectInfo,
listProject, listProject,
deleteProject, deleteProject,
updateProject, updateProject,
......
...@@ -128,11 +128,11 @@ ResourcesInfo.belongsTo(Resources, { foreignKey: 'resourceId' }); ...@@ -128,11 +128,11 @@ ResourcesInfo.belongsTo(Resources, { foreignKey: 'resourceId' });
Project.hasMany(ProjectBjtj, { foreignKey: 'projectId', as: 'projectBjtjs' }); Project.hasMany(ProjectBjtj, { foreignKey: 'projectId', as: 'projectBjtjs' });
ProjectBjtj.belongsTo(Project, { foreignKey: 'projectId' }); ProjectBjtj.belongsTo(Project, { foreignKey: 'projectId' });
/**项目-财务评价指标 1:n */ /**项目-财务评价指标 1:n */
Project.hasMany(ProjectCwpjzb, { foreignKey: 'projectId', as: 'projectCwpjzbs' }); // Project.hasMany(ProjectCwpjzb, { foreignKey: 'projectId', as: 'projectCwpjzbs' });
ProjectCwpjzb.belongsTo(Project, { foreignKey: 'projectId' }); // ProjectCwpjzb.belongsTo(Project, { foreignKey: 'projectId' });
/**项目-项目附件 1:n */ /**项目-项目附件 1:n */
Project.belongsToMany(File, { through: 'jt_project_file', foreignKey: 'projectId', as: 'files', otherKey: 'fileId' }); Project.belongsToMany(File, { through: 'jt_project_file', foreignKey: 'projectId', as: 'files', otherKey: 'fileId' });
File.belongsTo(Project, { through: 'jt_project_file', foreignKey: 'fileId', otherKey: 'projectId' }); File.belongsToMany(Project, { through: 'jt_project_file', foreignKey: 'fileId', otherKey: 'projectId', as: 'pros' });
/**项目-股东信息 1:n */ /**项目-股东信息 1:n */
Project.hasMany(ProjectGdxx, { foreignKey: 'projectId', as: 'projectGdxxs' }); Project.hasMany(ProjectGdxx, { foreignKey: 'projectId', as: 'projectGdxxs' });
ProjectGdxx.belongsTo(Project, { foreignKey: 'projectId' }); ProjectGdxx.belongsTo(Project, { foreignKey: 'projectId' });
......
...@@ -84,24 +84,24 @@ const Project = sequelize.define('Project', { ...@@ -84,24 +84,24 @@ const Project = sequelize.define('Project', {
//项目基本信息 //项目基本信息
projectName: { type: DataTypes.STRING, allowNull: true, comment: "项目名称" }, projectName: { type: DataTypes.STRING, allowNull: true, comment: "项目名称" },
projectCode: { type: DataTypes.STRING, allowNull: true, comment: "项目编号" }, projectCode: { type: DataTypes.STRING, allowNull: true, comment: "项目编号" },
isZjc: { type: DataTypes.ENUM('1', '2'), allowNull: true, comment: "是否再决策" }, // 1是 2 否 sfzjc: { type: DataTypes.INTEGER, allowNull: true, comment: "是否再决策" }, // 1是 2 否
projectForeignName: { type: DataTypes.STRING, allowNull: true, comment: "项目外文名称" }, projectForeignName: { type: DataTypes.STRING, allowNull: true, comment: "项目外文名称" },
sfnjlhtxm: { type: DataTypes.ENUM('1', '2'), allowNull: true, comment: "是否能建联合体项目" }, // 1是 2 否 sfnjlhtxm: { type: DataTypes.INTEGER, allowNull: true, comment: "是否能建联合体项目" }, // 1是 2 否
applicationUnit: { type: DataTypes.STRING, allowNull: true, comment: "申报单位" }, applicationUnit: { type: DataTypes.STRING, allowNull: true, comment: "申报单位" },
zyfzy: { type: DataTypes.STRING, allowNull: true, comment: "主业/非主业" }, //TODO:下拉 zyfzy: { type: DataTypes.STRING, allowNull: true, comment: "主业/非主业" }, //TODO:下拉
zsqy: { type: DataTypes.STRING, allowNull: true, comment: "直属企业" }, zsqy: { type: DataTypes.STRING, allowNull: true, comment: "直属企业" },
sfnjzdhzytz: { type: DataTypes.STRING, allowNull: true, comment: "是否能建重大或重要投资" }, sfnjzdhzytz: { type: DataTypes.INTEGER, allowNull: true, comment: "是否能建重大或重要投资" },
sfzzjc: { type: DataTypes.STRING, allowNull: true, comment: "是否自主决策" }, sfzzjc: { type: DataTypes.INTEGER, allowNull: true, comment: "是否自主决策" },
financialStatementType: { type: DataTypes.STRING, allowNull: true, comment: "财务报表类型" }, //TODO:下拉 financialStatementType: { type: DataTypes.STRING, allowNull: true, comment: "财务报表类型" }, //TODO:下拉
zfsphzbajb: { type: DataTypes.STRING, allowNull: true, comment: "政府审批(核准、备案)级别" }, //TODO:下拉 zfsphzbajb: { type: DataTypes.STRING, allowNull: true, comment: "政府审批(核准、备案)级别" }, //TODO:下拉
sflxbqyscx: { type: DataTypes.STRING, allowNull: true, comment: "是否履行标前预审程序" }, sflxbqyscx: { type: DataTypes.INTEGER, allowNull: true, comment: "是否履行标前预审程序" },
//项目所在地 //项目所在地
domesticOrOverseas: { type: DataTypes.STRING, allowNull: true, comment: "境内/外" },//TODO:下拉 domesticOrOverseas: { type: DataTypes.STRING, allowNull: true, comment: "境内/外" },//TODO:下拉
sjnzjjw: { type: DataTypes.STRING, allowNull: true, comment: "省(境内)/洲际(境外)" },//TODO:下拉 sjnzjjw: { type: DataTypes.STRING, allowNull: true, comment: "省(境内)/洲际(境外)" },//TODO:下拉
cityOrCountry: { type: DataTypes.STRING, allowNull: true, comment: "地市(境内)/国家(境外)" },//TODO:下拉 cityOrCountry: { type: DataTypes.STRING, allowNull: true, comment: "地市(境内)/国家(境外)" },//TODO:下拉
qxjngjjw: { type: DataTypes.STRING, allowNull: true, comment: "区县(境内)/国家(境外)" },//TODO:下拉 qxjngjjw: { type: DataTypes.STRING, allowNull: true, comment: "区县(境内)/国家(境外)" },//TODO:下拉
xmqy: { type: DataTypes.STRING, allowNull: true, comment: "项目区域" },//TODO:下拉 xmqy: { type: DataTypes.STRING, allowNull: true, comment: "项目区域" },//TODO:下拉
sfydylyxgj: { type: DataTypes.STRING, allowNull: true, comment: "是否一带一路沿线国家" }, sfydylyxgj: { type: DataTypes.INTEGER, allowNull: true, comment: "是否一带一路沿线国家" },
//计量币种 //计量币种
bizhong: { type: DataTypes.STRING, allowNull: true, comment: "币种" },//TODO:下拉 bizhong: { type: DataTypes.STRING, allowNull: true, comment: "币种" },//TODO:下拉
huilv: { type: DataTypes.DECIMAL(3, 2), allowNull: true, comment: "汇率" }, huilv: { type: DataTypes.DECIMAL(3, 2), allowNull: true, comment: "汇率" },
...@@ -124,9 +124,9 @@ const Project = sequelize.define('Project', { ...@@ -124,9 +124,9 @@ const Project = sequelize.define('Project', {
tzznflgs: { type: DataTypes.STRING, allowNull: true, comment: "投资指南分类概述" }, tzznflgs: { type: DataTypes.STRING, allowNull: true, comment: "投资指南分类概述" },
gmjjhy: { type: DataTypes.STRING, allowNull: true, comment: "国民经济行业" },//TODO:下拉 gmjjhy: { type: DataTypes.STRING, allowNull: true, comment: "国民经济行业" },//TODO:下拉
// 特别关注、特别监管类等信息 // 特别关注、特别监管类等信息
sfxbgjfzggwhswbhz: { type: DataTypes.STRING, allowNull: true, comment: "是否需报国家发展改革委和商务部核准" },//TODO:下拉 sfxbgjfzggwhswbhz: { type: DataTypes.INTEGER, allowNull: true, comment: "是否需报国家发展改革委和商务部核准" },//TODO:下拉
sfgjldjq: { type: DataTypes.STRING, allowNull: true, comment: "是否国家领导见签" },//TODO:下拉 sfgjldjq: { type: DataTypes.INTEGER, allowNull: true, comment: "是否国家领导见签" },//TODO:下拉
sfjntbjgl: { type: DataTypes.STRING, allowNull: true, comment: "是否境内特别监管类" },//TODO:下拉 sfjntbjgl: { type: DataTypes.INTEGER, allowNull: true, comment: "是否境内特别监管类" },//TODO:下拉
//建设规模(实物量指标) //建设规模(实物量指标)
//股东信息 //股东信息
//项目必要性及可行性 //项目必要性及可行性
...@@ -137,7 +137,6 @@ const Project = sequelize.define('Project', { ...@@ -137,7 +137,6 @@ const Project = sequelize.define('Project', {
// 项目投资总额 // 项目投资总额
// xmzbjwy: { type: DataTypes.DECIMAL(19, 8), allowNull: true, comment: "项目资本金(万元)" }, // xmzbjwy: { type: DataTypes.DECIMAL(19, 8), allowNull: true, comment: "项目资本金(万元)" },
// pfztz: { type: DataTypes.DECIMAL(19, 8), allowNull: true, comment: "批复总投资" }, // pfztz: { type: DataTypes.DECIMAL(19, 8), allowNull: true, comment: "批复总投资" },
...@@ -1736,7 +1735,7 @@ const Project = sequelize.define('Project', { ...@@ -1736,7 +1735,7 @@ const Project = sequelize.define('Project', {
// 同步模型到数据库(创建表) // 同步模型到数据库(创建表)
Project.sync({ Project.sync({
// force: false, force: false,
// force: true ,//会删除已存在表并重新创建 // force: true ,//会删除已存在表并重新创建
// alter: true // alter: true
}) })
......
...@@ -34,8 +34,7 @@ const projectBjtj = sequelize.define('projectBjtj', { ...@@ -34,8 +34,7 @@ const projectBjtj = sequelize.define('projectBjtj', {
}, },
njfhlDw: { njfhlDw: {
type: DataTypes.STRING, type: DataTypes.STRING,
comment: "年均负荷率单位", comment: "年均负荷率单位"
defaultValue: "%"
}, },
dwscfwzcbSz: { dwscfwzcbSz: {
type: DataTypes.DECIMAL(20, 4), type: DataTypes.DECIMAL(20, 4),
...@@ -43,8 +42,7 @@ const projectBjtj = sequelize.define('projectBjtj', { ...@@ -43,8 +42,7 @@ const projectBjtj = sequelize.define('projectBjtj', {
}, },
dwscfwzcbDw: { dwscfwzcbDw: {
type: DataTypes.STRING, type: DataTypes.STRING,
comment: "单位生产服务总成本单位", comment: "单位生产服务总成本单位"
defaultValue: "%"
}, },
dwsjSz: { dwsjSz: {
type: DataTypes.DECIMAL(20, 4), type: DataTypes.DECIMAL(20, 4),
...@@ -64,8 +62,7 @@ const projectBjtj = sequelize.define('projectBjtj', { ...@@ -64,8 +62,7 @@ const projectBjtj = sequelize.define('projectBjtj', {
}, },
ykphddw: { ykphddw: {
type: DataTypes.STRING, type: DataTypes.STRING,
comment: "盈亏平衡点单位", comment: "盈亏平衡点单位"
defaultValue: "%"
}, },
bcsm: { bcsm: {
type: DataTypes.STRING, type: DataTypes.STRING,
...@@ -87,13 +84,13 @@ const projectBjtj = sequelize.define('projectBjtj', { ...@@ -87,13 +84,13 @@ const projectBjtj = sequelize.define('projectBjtj', {
comment: "0 正常 1 删除" comment: "0 正常 1 删除"
}, },
}, { }, {
tableName: 'jt_project_gdxx', // 指定表名(如果与模型名不同) tableName: 'jt_project_bjtj', // 指定表名(如果与模型名不同)
timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置) timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
}); });
// 同步模型到数据库(创建表) // 同步模型到数据库(创建表)
projectBjtj.sync({ projectBjtj.sync({
// force: false, force: false,
// force: true ,//会删除已存在表并重新创建 // force: true ,//会删除已存在表并重新创建
// alter: true // alter: true
}) })
......
const { DataTypes } = require('sequelize'); // const { DataTypes } = require('sequelize');
const sequelize = require('../index'); // const sequelize = require('../index');
// 财务评价指标 // // 财务评价指标----废弃
const projectCwpjzb = sequelize.define('projectCwpjzb', { // const projectCwpjzb = sequelize.define('projectCwpjzb', {
id: { // id: {
type: DataTypes.INTEGER, // type: DataTypes.INTEGER,
primaryKey: true, // primaryKey: true,
autoIncrement: true // autoIncrement: true
}, // },
name: { // name: {
type: DataTypes.STRING, // type: DataTypes.STRING,
comment: "指标名称" // comment: "指标名称"
}, // },
num: { // num: {
type: DataTypes.DECIMAL(20, 4), // type: DataTypes.DECIMAL(20, 4),
comment: "数量" // comment: "数量"
}, // },
unit: { // unit: {
type: DataTypes.STRING, // type: DataTypes.STRING,
comment: "单位" // comment: "单位"
}, // },
projectId: { // projectId: {
type: DataTypes.INTEGER, // type: DataTypes.INTEGER,
comment: "所属项目ID", // comment: "所属项目ID",
}, // },
}, { // }, {
tableName: 'jt_project_cwpjzb', // 指定表名(如果与模型名不同) // tableName: 'jt_project_cwpjzb', // 指定表名(如果与模型名不同)
timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置) // timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
}); // });
// 同步模型到数据库(创建表) // // 同步模型到数据库(创建表)
projectCwpjzb.sync({ // projectCwpjzb.sync({
// force: false, // // force: false,
// force: true ,//会删除已存在表并重新创建 // // force: true ,//会删除已存在表并重新创建
// alter: true // // alter: true
}) // })
.then(() => { // .then(() => {
console.log('projectCwpjzb 表同步成功'); // console.log('projectCwpjzb 表同步成功');
}); // });
module.exports = projectCwpjzb; // module.exports = projectCwpjzb;
\ No newline at end of file \ No newline at end of file
...@@ -4,7 +4,7 @@ const sequelize = require('../index'); ...@@ -4,7 +4,7 @@ const sequelize = require('../index');
const File = require('../system/file'); const File = require('../system/file');
const Project = require('./project'); const Project = require('./project');
const projectFile = sequelize.define('projectFile', { const ProjectFile = sequelize.define('ProjectFile', {
// 定义字段 // 定义字段
id: { id: {
type: DataTypes.INTEGER, type: DataTypes.INTEGER,
...@@ -19,7 +19,7 @@ const projectFile = sequelize.define('projectFile', { ...@@ -19,7 +19,7 @@ const projectFile = sequelize.define('projectFile', {
type: DataTypes.INTEGER, type: DataTypes.INTEGER,
references: { model: Project, key: 'id' } references: { model: Project, key: 'id' }
}, },
projectKey: { proFieldKey: {
type: DataTypes.STRING, //项目表中文件字段key type: DataTypes.STRING, //项目表中文件字段key
} }
}, { }, {
...@@ -28,13 +28,14 @@ const projectFile = sequelize.define('projectFile', { ...@@ -28,13 +28,14 @@ const projectFile = sequelize.define('projectFile', {
}); });
// 同步模型到数据库(创建表) // 同步模型到数据库(创建表)
projectFile.sync({ ProjectFile.sync({
// force: false, // force: true 会删除已存在表并重新创建 force: false, //
alter: true // force: true //会删除已存在表并重新创建
// alter: true
}) })
.then(() => { .then(() => {
console.log('projectFile 表同步成功'); console.log('ProjectFile 表同步成功');
}); });
module.exports = projectFile; module.exports = ProjectFile;
\ No newline at end of file \ No newline at end of file
...@@ -2,7 +2,7 @@ const { DataTypes } = require('sequelize'); ...@@ -2,7 +2,7 @@ const { DataTypes } = require('sequelize');
const sequelize = require('../index'); const sequelize = require('../index');
// 股东信息 // 股东信息
const projectGdxx = sequelize.define('projectGdxx', { const ProjectGdxx = sequelize.define('ProjectGdxx', {
id: { id: {
type: DataTypes.INTEGER, type: DataTypes.INTEGER,
primaryKey: true, primaryKey: true,
...@@ -56,14 +56,14 @@ const projectGdxx = sequelize.define('projectGdxx', { ...@@ -56,14 +56,14 @@ const projectGdxx = sequelize.define('projectGdxx', {
}); });
// 同步模型到数据库(创建表) // 同步模型到数据库(创建表)
projectGdxx.sync({ ProjectGdxx.sync({
// force: false, force: false,
// force: true ,//会删除已存在表并重新创建 // force: true ,//会删除已存在表并重新创建
// alter: true // alter: true
}) })
.then(() => { .then(() => {
console.log('projectGdxx 表同步成功'); console.log('ProjectGdxx 表同步成功');
}); });
module.exports = projectGdxx; module.exports = ProjectGdxx;
\ No newline at end of file \ No newline at end of file
...@@ -2,7 +2,7 @@ const { DataTypes } = require('sequelize'); ...@@ -2,7 +2,7 @@ const { DataTypes } = require('sequelize');
const sequelize = require('../index'); const sequelize = require('../index');
// 建设规模 // 建设规模
const projectJsgm = sequelize.define('projectJsgm', { const ProjectJsgm = sequelize.define('ProjectJsgm', {
id: { id: {
type: DataTypes.INTEGER, type: DataTypes.INTEGER,
primaryKey: true, primaryKey: true,
...@@ -39,14 +39,14 @@ const projectJsgm = sequelize.define('projectJsgm', { ...@@ -39,14 +39,14 @@ const projectJsgm = sequelize.define('projectJsgm', {
}); });
// 同步模型到数据库(创建表) // 同步模型到数据库(创建表)
projectJsgm.sync({ ProjectJsgm.sync({
// force: false, force: false,
// force: true ,//会删除已存在表并重新创建 // force: true ,//会删除已存在表并重新创建
// alter: true // alter: true
}) })
.then(() => { .then(() => {
console.log('projectJsgm 表同步成功'); console.log('ProjectJsgm 表同步成功');
}); });
module.exports = projectJsgm; module.exports = ProjectJsgm;
\ No newline at end of file \ No newline at end of file
...@@ -2,7 +2,7 @@ const { DataTypes } = require('sequelize'); ...@@ -2,7 +2,7 @@ const { DataTypes } = require('sequelize');
const sequelize = require('../index'); const sequelize = require('../index');
// 审批意见 // 审批意见
const projectSpyj = sequelize.define('projectSpyj', { const ProjectSpyj = sequelize.define('ProjectSpyj', {
id: { id: {
type: DataTypes.INTEGER, type: DataTypes.INTEGER,
primaryKey: true, primaryKey: true,
...@@ -36,14 +36,14 @@ const projectSpyj = sequelize.define('projectSpyj', { ...@@ -36,14 +36,14 @@ const projectSpyj = sequelize.define('projectSpyj', {
}); });
// 同步模型到数据库(创建表) // 同步模型到数据库(创建表)
projectSpyj.sync({ ProjectSpyj.sync({
// force: false, force: false,
// force: true ,//会删除已存在表并重新创建 // force: true ,//会删除已存在表并重新创建
// alter: true // alter: true
}) })
.then(() => { .then(() => {
console.log('projectSpyj 表同步成功'); console.log('ProjectSpyj 表同步成功');
}); });
module.exports = projectSpyj; module.exports = ProjectSpyj;
\ No newline at end of file \ No newline at end of file
...@@ -2,12 +2,16 @@ const { DataTypes } = require('sequelize'); ...@@ -2,12 +2,16 @@ const { DataTypes } = require('sequelize');
const sequelize = require('../index'); const sequelize = require('../index');
// 项目总投资总额(全口径) // 项目总投资总额(全口径)
const projectXmtzze = sequelize.define('projectXmtzze', { const ProjectXmtzze = sequelize.define('ProjectXmtzze', {
id: { id: {
type: DataTypes.INTEGER, type: DataTypes.INTEGER,
primaryKey: true, primaryKey: true,
autoIncrement: true autoIncrement: true
}, },
kid: {
type: DataTypes.INTEGER,
comment: "表格行ID"
},
xh: { xh: {
type: DataTypes.STRING, type: DataTypes.STRING,
comment: "序号" comment: "序号"
...@@ -27,8 +31,7 @@ const projectXmtzze = sequelize.define('projectXmtzze', { ...@@ -27,8 +31,7 @@ const projectXmtzze = sequelize.define('projectXmtzze', {
}, },
parentId: { parentId: {
type: DataTypes.INTEGER, type: DataTypes.INTEGER,
comment: "上级ID", comment: "上级ID"
defaultValue: 0
}, },
projectId: { projectId: {
...@@ -47,14 +50,14 @@ const projectXmtzze = sequelize.define('projectXmtzze', { ...@@ -47,14 +50,14 @@ const projectXmtzze = sequelize.define('projectXmtzze', {
}); });
// 同步模型到数据库(创建表) // 同步模型到数据库(创建表)
projectXmtzze.sync({ ProjectXmtzze.sync({
// force: false, force: false,
// force: true ,//会删除已存在表并重新创建 // force: true ,//会删除已存在表并重新创建
// alter: true // alter: true
}) })
.then(() => { .then(() => {
console.log('projectXmtzze 表同步成功'); console.log('ProjectXmtzze 表同步成功');
}); });
module.exports = projectXmtzze; module.exports = ProjectXmtzze;
\ No newline at end of file \ No newline at end of file
...@@ -13,7 +13,7 @@ module.exports = async (req, res, next) => { ...@@ -13,7 +13,7 @@ module.exports = async (req, res, next) => {
} }
req.headers.authorization = req.headers.authorization || req.headers.Authorization; req.headers.authorization = req.headers.authorization || req.headers.Authorization;
const userStr = await ioRedis.get(`token:${req.headers.authorization}`); const userStr = await ioRedis.get(`token:${req.headers.authorization}`);
console.log(userStr) // console.log("middleware request文件:", userStr)
if (userStr) { if (userStr) {
try { try {
req.user = JSON.parse(userStr); req.user = JSON.parse(userStr);
......
module.exports = {
}
\ No newline at end of file
...@@ -10,9 +10,9 @@ const projectController = require('../controller/projectController'); ...@@ -10,9 +10,9 @@ const projectController = require('../controller/projectController');
*/ */
router.post('/createProject', projectController.createProject); router.post('/createProject', projectController.createProject);
router.post('/updateProject', projectController.updateProject); router.post('/updateProject', projectController.updateProject);
// router.post('/deleteProject', projectController.deleteProject); router.post('/deleteProject', projectController.deleteProject);
router.post('/listProject', projectController.listProject); router.post('/listProject', projectController.listProject);
// router.post('/getProject', projectController.getProject); router.post('/getProjectInfo', projectController.getProjectInfo);
router.post('/getProjectFields', projectController.getProjectFields); router.post('/getProjectFields', projectController.getProjectFields);
router.post('/exportExcel', projectController.exportExcel); router.post('/exportExcel', projectController.exportExcel);
......
...@@ -28,9 +28,9 @@ function checkUserPassword({ reqPw, salt, userPw }) { ...@@ -28,9 +28,9 @@ function checkUserPassword({ reqPw, salt, userPw }) {
} }
} }
function buildTree(nodes) { function buildTree(nodes, keyid = 'id') {
// 创建一个映射,将节点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数组中 // 遍历所有节点,并将它们添加到对应父节点的children数组中
nodes.forEach(node => { nodes.forEach(node => {
...@@ -39,7 +39,7 @@ function buildTree(nodes) { ...@@ -39,7 +39,7 @@ function buildTree(nodes) {
// 确保父节点在映射中存在 // 确保父节点在映射中存在
if (nodeMap.has(parentId)) { if (nodeMap.has(parentId)) {
// 将当前节点添加到父节点的children数组中 // 将当前节点添加到父节点的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') 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