明树Git Lab

Commit 565e33e9 authored by zfp1's avatar zfp1

update

parent 9f80b93c
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 b = _.groupBy(o, '_mark');
console.log(b);
\ No newline at end of file
......@@ -5,6 +5,7 @@
"storagePath": "/uploadfiles"
},
"cron": {
"excel": true
},
"mysql": {
"host": "localhost",
......
......@@ -5,6 +5,8 @@
"storagePath": "/mnt/vdb1/uploadfiles"
},
"cron": {
"excel": true
}
}
\ No newline at end of file
const errorMessage = require("../utils/errorMessage");
const userModule = require('../module/userModule');
const { Op } = require('sequelize');
async function createPosition(req, res, next) {
try {
......
const errorMessage = require("../utils/errorMessage");
const _ = require("lodash");
const { Op } = require('sequelize');
async function getProjectFields(req, res, next) {
try {
let rawAttributes = DB.Project.rawAttributes;
let obj = {
xmjbxx: '项目基本信息',
jcpfxx: '决策及批复信息',
xmgslspfxx: '项目公司落实批复信息',
xmfhhgxffj: '项目合法合规性附件',
qshmkchw: '全生命周期策划文件',
xmjxxpj: '项目绩效评价',
mbzrskh: '目标责任书考核',
hpj: '后评价',
zdsxsb: '重大事项上报',
tzfx: '投资分析',
tzjc: '投资检查',
tzhs: '投资核算',
system: '系统字段',
glfsj: '管理费上缴',
pppzgfa: 'PPP资格认定方案',
xmjs: '项目结束/暂停(备案资料)',
};
for (const key in rawAttributes) {
let element =_.pick(rawAttributes[key],['comment','_mark', 'fieldName']);
rawAttributes[key] = element;
}
let attributes = _.groupBy(rawAttributes, '_mark');
let ret = [];
for (const key in attributes) {
let element = attributes[key];
ret.push({
key: key,
name: obj[key] || key,
attributes: element,
})
}
return res.sendData(ret);
} catch (error) {
next(error);
}
}
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();
} 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 } });
return res.sendData(ret);
} catch (error) {
next(error);
}
}
async function deleteProject(req, res, next) {
try {
if (!req.body.id) {
return res.sendError(errorMessage.resourceNotFound);
}
const ret = await DB.Project.update({ del: 1 }, { where: { id: req.body.id } });
return res.sendData(ret);
} catch (error) {
next(error);
}
}
async function listProject(req, res, next) {
try {
let search = {where: {del: 0}};
let page = req.body.page || 1;
let limit = req.body.pageSize || 10;
let offset = (page - 1) * limit;
if (req.body.name) {
search.where = {
[Op.or]: [
{ name: { [Op.like]: `%${req.body.name}%` } }
],
del: 0,
}
}
search.limit = limit;
search.offset = offset;
search.attributes = req.body.attributes || [];
let ret = await DB.Project.findAndCountAll(search);
return res.sendData(ret);
} catch (error) {
next(error);
}
}
async function exportExcel(req, res, next) {
try {
let search = {}; //根据参数情况处理search
let obj = {
creator: req.user.id,
type: 2,
modelName: 'project',
status: 1,
search: JSON.stringify(search),
}
await DB.ExcelRecord.create(obj);
return res.sendData();
} catch (error) {
next(error);
}
}
module.exports = {
getProjectFields,
createProject,
listProject,
deleteProject,
updateProject,
exportExcel,
}
\ No newline at end of file
// 气象
const httpRequest = require('../utils/httpRequest');
const deviceModule = require('../module/deviceModule');
const collectIPSModule = require('../module/collectIPSModule');
const _ = require('lodash');
const moment = require('moment');
const ExcelJS = require('exceljs');
const fs = require('fs');
// exportExcel()
async function exportExcel() {
let info = await DB.ExcelRecord.findOne({ type: 2, status: 1, del: 0 });
console.log(info);
// if (info && info._id && info.modleName) {
// let workbook = new ExcelJS.Workbook();
// let name = `${info._id}`
// let worksheet = workbook.addWorksheet(name);
// let columns = [];
// if (!_.isEmpty(DB[info.modleName] && DB[info.modleName].schema && DB[info.modleName].schema.obj)) {
// for (const key in DB[info.modleName].schema.obj) {
// const element = DB[info.modleName].schema.obj[key];
// if (element && element.comment) {
// // 有comment的导出,其他需要标注 不需要导出的用comment1
// columns.push({ header: element.comment, key });
// }
// }
// }
// console.log(columns.length, "-=-=-", name);
// if (columns.length > 0) {
// // TODO: 可以优化根据count翻页 暂时
// worksheet.columns = columns;
// let list = await DB[info.modleName].find(info.search || { del: 0 });
// for (let index = 0; index < list.length; index++) {
// const element = list[index];
// worksheet.addRow(element);
// }
// console.log("-----------------------------------",list.length,"---------------------------------------------")
// if (list.length > 0) {
// let path = sysConfig.file.storagePath + '/' + moment().format('YYYYMMDD');
// if (!fs.existsSync(path)) {
// fs.mkdirSync(path, { recursive: true });
// }
// let excelUrl = path + '/' + name + '.xlsx'
// // 1. 写入数据到存储位置
// await workbook.xlsx.writeFile(excelUrl);
// // 2. 创建文件信息
// let fileInfo = await DB.File.create({
// originalname: name + '.xlsx',
// mimetype: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
// filename: name + '.xlsx',
// path: excelUrl,
// nginxpath: _.last(String(path).split('/mnt/vdb1')),
// type: 2,
// });
// // 3. 更新任务结果
// await DB.ExcelRecord.findOneAndUpdate({_id: info._id}, {status: 2, excelUrl: fileInfo._id})
// } else {
// await DB.ExcelRecord.findOneAndUpdate({_id: info._id}, {status: 3});
// }
// }
// }
// let workbook = new Excel.Workbook();
// // 添加一个工作表
// let worksheet = workbook.addWorksheet('我的工作表');
// // 添加表头
// worksheet.columns = [
// { header: '姓名', key: 'name' },
// { header: '年龄', key: 'age' },
// { header: '职业', key: 'occupation' }
// ];
// // 添加数据行
// worksheet.addRow({ name: '张三', age: 30, occupation: '软件工程师' });
// worksheet.addRow({ name: '李四', age: 25, occupation: '产品经理' });
// // 写入文件到磁盘
// await workbook.xlsx.writeFile('我的Excel.xlsx');
}
module.exports = {
exportExcel,
}
......@@ -15,16 +15,14 @@ const config = require('../config');
TODO:需要处理 多个server启动时,定时任务启动多次问题。
*/
const cron = () => {
/*-----------------------------采集设备信息-------------------------------------*/
// 1 土壤温湿度、土壤氮磷钾, 2 土壤ph、土壤电导率, 3 气象站
// if (sysConfig && sysConfig.cron && sysConfig.cron.getDeviceList) {
// console.log("getDeviceList:", new Date());
// // 每天10点30分 处理 1 30 10 * * *
// // new nodeCron.schedule('1 30 10 * * *', async () => {
// new nodeCron.schedule('1 * * * * *', async () => {
// await deviceCron.getDeviceList();
// }, { timezone: "Asia/Shanghai" });
// }
if (sysConfig && sysConfig.cron && sysConfig.cron.excel) {
console.log("excel:", new Date());
new nodeCron.schedule('1 */1 * * * *', async () => {
console.log(new Date().getTime())
await excelCron.exportExcel();
}, { timezone: "Asia/Shanghai" });
}
}
......
......@@ -11,6 +11,9 @@ const RequestLog = require("./model/system/requestLog");
const File = require("./model/system/file");
const Position = require("./model/system/position");
// 业务模型
const Project = require("./model/project/project");
/**
* 业务表
*/
......@@ -28,6 +31,7 @@ global.DB = {
UserDepart,
File,
Position,
Project,
}
......
......@@ -5,4 +5,25 @@ Contract (合同信息表)
InvestmentApproval (投资评价及批复信息表)
Investor (投资主体单位落实信息表)
CompanyApproval (项目公司落实批复信息表)
Compliance (项目合法合规性信息表)
\ No newline at end of file
Compliance (项目合法合规性信息表)
// models/Project.js
const { DataTypes } = require('sequelize');
const sequelize = require('../index');
const { create } = require('lodash');
const Project = sequelize.define('Project', {
// 定义字段
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true
autoIncrement: true,
_mark: 'system',
},
name: {
/**
* 项目基本信息
*/
projectName: {
type: DataTypes.STRING(500),
comment: "名字"
comment: "项目名称",
_mark: 'xmjbxx',
},
code: {
projectShortName: {
type: DataTypes.STRING(500),
comment: "项目简称",
_mark: 'xmjbxx',
},
projectCode: {
type: DataTypes.STRING(100),
comment: "项目监管代码",
_mark: 'xmjbxx',
},
amount: {
type: DataTypes.DECIMAL(20,2), //TODO:
comment: "项目总投资",
_mark: 'xmjbxx',
},
projectState: {
type: DataTypes.STRING(100),
comment: "项目状态",
_mark: 'xmjbxx',
},
projectCategory: {
type: DataTypes.STRING(100),
comment: "项目类别" ,
_mark: 'xmjbxx',
},
investCategory: {
type: DataTypes.STRING(100),
comment: "投资类别",
_mark: 'xmjbxx',
},
projectStage: {
type: DataTypes.STRING(100),
comment: "项目工程阶段",
_mark: 'xmjbxx',
},
projectTrackState: {
type: DataTypes.STRING(100),
comment: "项目跟踪状态",
_mark: 'xmjbxx',
},
roadGrade: {
type: DataTypes.STRING(100),
comment: "道路等级",
_mark: 'xmjbxx',
},
projectTotalMileage: {
type: DataTypes.DECIMAL(10,2), //TODO: 公里数确定位数
comment: "项目总里程(公里)",
_mark: 'xmjbxx',
},
investmentModel: {
type: DataTypes.STRING(100),
comment: "投融资模式",
_mark: 'xmjbxx',
},
returnModel: {
type: DataTypes.STRING(100),
comment: "回报模式",
_mark: 'xmjbxx',
},
constructionModel : {
type: DataTypes.STRING(100),
comment: "项目代码"
comment: "施工模式",
_mark: 'xmjbxx',
},
contractStartTime: {
type: DataTypes.DATE,
comment: "合同开工时间" ,
_mark: 'xmjbxx',
},
contractEndTime: {
type: DataTypes.DATE,
comment: "合同竣工时间",
_mark: 'xmjbxx',
},
realStartTime: {
type: DataTypes.DATE,
comment: "实际开工时间",
_mark: 'xmjbxx',
},
realEndTime: {
type: DataTypes.DATE,
comment: "实际竣工时间",
_mark: 'xmjbxx',
},
decisionRate: {
type: DataTypes.DECIMAL(5,2), //TODO:
comment: "决策收益率",
_mark: 'xmjbxx',
},
benchmarkRate: {
type: DataTypes.DECIMAL(5,2),//TODO:
comment: "基准收益率" ,
_mark: 'xmjbxx',
},
realRate: {
type: DataTypes.DECIMAL(5,2),//TODO:
comment: "实际收益率" ,
_mark: 'xmjbxx',
},
/**
* 决策及批复信息
*/
a1: {
type: DataTypes.STRING(500),
comment: "决策及批复信息",
_mark: 'jcpfxx',
},
/**
* 项目公司落实批复信息
*/
a2: {
type: DataTypes.STRING(500),
comment: "项目公司落实批复信息",
_mark: 'xmgslspfxx',
},
/**
* 项目合法合规性附件
*/
a3: {
type: DataTypes.STRING(500),
comment: "项目合法合规性附件",
_mark: 'xmfhhgxffj',
},
/**
* 全生命周期策划文件
*/
a4: {
type: DataTypes.STRING(500),
comment: "全生命周期策划文件",
_mark: 'qshmkchw',
},
/**
* 项目绩效评价
*/
a5: {
type: DataTypes.STRING(500),
comment: "项目绩效评价",
_mark: 'xmjxxpj',
},
/**
* 目标责任书考核
*/
a6: {
type: DataTypes.STRING(500),
comment: "目标责任书考核",
_mark: 'mbzrskh',
},
/**
* 后评价
*/
a7: {
type: DataTypes.STRING(500),
comment: "后评价",
_mark: 'hpj',
},
/**
* 重大事项上报
*/
a8: {
type: DataTypes.STRING(500),
comment: "重大事项上报",
_mark: 'zdsxsb',
},
/**
* 投资分析
*/
a9: {
type: DataTypes.STRING(500),
comment: "投资分析",
_mark: 'tzfx',
},
/**
* 投资检查
*/
a10: {
type: DataTypes.STRING(500),
comment: "投资检查",
_mark: 'tzjc',
},
/**
* 投资回收
*/
invtRetcompletionRate: {
type: DataTypes.DECIMAL(5,2),//TODO:
comment: "投资回收完成率" ,
_mark: 'tzhs',
},
/**
* 管理费上缴
*/
a11: {
type: DataTypes.STRING(500),
comment: "管理费上缴",
_mark: 'glfsj',
},
/**
* PPP整改方案
*/
a12: {
type: DataTypes.STRING(500),
comment: "PPP整改方案",
_mark: 'pppzgfa',
},
/**
* 项目结束/暂停(备案资料)
*/
a13: {
type: DataTypes.STRING(500),
comment: "项目结束/暂停(备案资料)",
_mark: 'xmjs',
},
del: {
type: DataTypes.INTEGER,
defaultValue: 0,
comment: "0 正常 1 删除"
comment: "0 正常 1 删除",
},
}, {
tableName: 'system_project', // 指定表名(如果与模型名不同)
......@@ -32,7 +251,7 @@ const Project = sequelize.define('Project', {
Project.sync({
// force: false,
// force: true ,//会删除已存在表并重新创建
alter: true
// alter: true
})
.then(() => {
console.log('Project 表同步成功');
......
// models/ExcelRecord.js
const { DataTypes } = require('sequelize');
const sequelize = require('../index');
const ExcelRecord = sequelize.define('ExcelRecord', {
// 定义字段
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true
},
creator: {
type: DataTypes.INTEGER,
allowNull: true,
references: {
model: DB.User, // 关联的表名
key: 'id' // 关联的字段
},
comment: "创建人",
},
type: {
type: DataTypes.INTEGER,
comment: "1. 导入 2. 导出"
},
excelUrl: {
type: DataTypes.INTEGER,
allowNull: true,
references: {
model: DB.File, // 关联的表名
key: 'id' // 关联的字段
},
comment: "导出文件地址",
},
modleName: {
type: DataTypes.STRING,
allowNull: true,
comment: "模块名称"
},
search: {
type: DataTypes.TEXT,
allowNull: true,
comment: "查询条件"
},
status: {
type: DataTypes.INTEGER,
comment: "1.未完成 2. 完成"
},
del: {
type: DataTypes.INTEGER,
defaultValue: 0,
comment: "0 正常 1 删除"
},
}, {
tableName: 'system_excel_record', // 指定表名(如果与模型名不同)
timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
});
// 同步模型到数据库(创建表)
ExcelRecord.sync({
// force: false,
// force: true ,//会删除已存在表并重新创建
// alter: true
})
.then(() => {
console.log('ExcelRecord 表同步成功');
});
module.exports = ExcelRecord;
\ No newline at end of file
......@@ -7,7 +7,9 @@ const fileRouter = require("./fileRouter");
router.use('/user', userRouter); // 用户 角色 菜单
router.use('/file', fileRouter); //
router.use('/file', fileRouter); // 文件上传下载
router.use('/project', require('./projectRouter.js')); // 项目管理
......
const express = require('express');
const router = express.Router();
const projectController = require('../controller/projectController');
/**
* 项目相关
*/
router.post('/createProject', projectController.createProject);
router.post('/updateProject', projectController.updateProject);
// router.post('/deleteProject', projectController.deleteProject);
router.post('/listProject', projectController.listProject);
// router.post('/getProject', projectController.getProject);
router.post('/getProjectFields', projectController.getProjectFields);
router.post('/exportExcel', projectController.exportExcel);
module.exports = router;
\ 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