明树Git Lab

Commit 6588ab91 authored by zfp1's avatar zfp1

update

parent 7912bdfb
Pipeline #104235 passed with stage
in 4 seconds
......@@ -766,6 +766,35 @@ async function finalJugProject(req, res, next) {
}
}
async function getProjectCwpj(req, res, next) {
try {
const projectId = req.body.id;
if (!projectId) {
return res.sendError(errorMessage.resourceNotFound);
}
const sql = `SELECT * FROM (
SELECT
*,
ROW_NUMBER() OVER (
PARTITION BY tampName
ORDER BY updatedAt DESC, id DESC
) AS row_num
FROM jt_project_excel_data
WHERE projectId = :projectId AND del = 0
) AS ranked
WHERE row_num = 1`;
const results = await DB.sequelize.query(sql, {
replacements: { projectId },
type: sequelize.QueryTypes.SELECT,
model: DB.ProjectExcelData, // 替换为实际模型
mapToModel: true
});
return res.sendData(results);
} catch (error) {
next(error);
}
}
async function getProjectInfo(req, res, next) {
try {
if (!req.body.id) {
......@@ -834,8 +863,8 @@ async function listProject(req, res, next) {
projectLzTypes = [5, 7, 8, 9];
break;
}
if(req.body.menuType) {
where.projectLzType = {[Op.in]: projectLzTypes}
if (req.body.menuType) {
where.projectLzType = { [Op.in]: projectLzTypes }
}
console.log(projectLzTypes)
search.where = where;
......@@ -999,4 +1028,5 @@ module.exports = {
saveProjectPreLixiang,
queryLixiangResult,
queryJueceResult,
getProjectCwpj,
}
\ No newline at end of file
This diff is collapsed.
const sequelize = require('./model/index');
// 模型初始化
const User = require("./model/system/user");
const Role = require("./model/system/role");
......@@ -31,6 +33,7 @@ const ProjectTzzjll = require("./model/jt/projectTzzjll");
const ProjectTzzt = require("./model/jt/projectTzzt");
const ProjectXmtzze = require("./model/jt/projectXmtzze");
const ProjectLixiang = require("./model/jt/projectLixiang");
const ProjectExcelData = require("./model/jt/projectExcelData");
/**
......@@ -40,6 +43,7 @@ const ProjectLixiang = require("./model/jt/projectLixiang");
global.DB = {
sequelize,
User,
RequestLog,
Role,
......@@ -69,6 +73,7 @@ global.DB = {
Message,
FlowRecord,
ProjectLixiang,
ProjectExcelData,
}
......
const { DataTypes } = require('sequelize');
const sequelize = require('../index');
const moment = require('moment');
//投决计划---决策信息--财务评价--投决计划
const ProjectExcelData = sequelize.define('ProjectExcelData', {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true
},
tampName: { type: DataTypes.STRING, allowNull: true, comment: "模板名称" },
data: { type: DataTypes.JSON, allowNull: true, comment: "解析数据" }, //原本设计数据横向转纵向存储,再取出来纵向转横向还原,过于复杂,而且数据无其他统计计算要求,只是展示,暂时此方案,后续若改动,清洗数据即可
projectId: {
type: DataTypes.INTEGER,
comment: "所属项目ID",
},
del: {
type: DataTypes.INTEGER,
defaultValue: 0,
comment: "0 正常 1 删除"
},
// createdAt: {
// type: DataTypes.DATE,
// defaultValue: new Date(),
// get() {
// const rawValue = this.getDataValue('createdAt');
// return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
// }
// },
// updatedAt: { // 同样处理 updatedAt
// type: DataTypes.DATE,
// defaultValue: new Date(),
// get() {
// const rawValue = this.getDataValue('createdAt');
// return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
// }
// }
}, {
tableName: 'jt_project_excel_data', // 指定表名(如果与模型名不同)
timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
});
// 同步模型到数据库(创建表)
ProjectExcelData.sync({
force: false,
// force: true ,//会删除已存在表并重新创建
// alter: true
})
.then(() => {
console.log('ProjectExcelData 表同步成功');
});
module.exports = ProjectExcelData;
\ No newline at end of file
......@@ -24,6 +24,7 @@
"exceljs": "4.4.0",
"express": "4.19.2",
"form-data": "4.0.0",
"hyperformula": "^3.1.0",
"ioredis": "5.4.1",
"joi": "17.13.1",
"lodash": "4.17.21",
......
......@@ -25,6 +25,10 @@ router.post('/startJuece', projectController.startJuece); //发起决策
router.post('/queryJueceResult', projectController.queryJueceResult); //查询决策审批结果
// 财务评价
router.post('/getProjectCwpj', projectController.getProjectCwpj);
router.post('/getProjectInfo', projectController.getProjectInfo);
router.post('/updateProject', projectController.updateProject);
......
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