明树Git Lab

Commit d0e25964 authored by zfp1's avatar zfp1

update

parent 49f1585a
Pipeline #105220 passed with stage
in 4 seconds
......@@ -551,6 +551,202 @@ async function getJsqtzhsList(req, res, next) {
async function createJsqtzjc(req, res, next) {
try {
if (!req.body.projectId) {
return res.sendError(errorMessage.paramsError);
}
//日常自查 投资(成本)分析会
let jsqtzjcTzfxs = req.body.jsqtzjcTzfxs || [];
let newjsqtzjcTzfxs = [];
for (let index = 0; index < jsqtzjcTzfxs.length; index++) {
let element = jsqtzjcTzfxs[index];
element.projectId = req.body.projectId;
element.tzcbfxhzl = (element.tzcbfxhzl || []).map(o => { return o && o.id || o });
newjsqtzjcTzfxs.push(element);
}
delete req.body.jsqtzjcTzfxs;
//日常检查
let jsqtzjcrcjcs = req.body.jsqtzjcrcjcs || [];
let newjsqtzjcrcjcs = [];
for (let index = 0; index < jsqtzjcrcjcs.length; index++) {
let element = jsqtzjcrcjcs[index];
element.projectId = req.body.projectId;
element.fxcl = (element.fxcl || []).map(o => { return o && o.id || o });
newjsqtzjcrcjcs.push(element);
}
delete req.body.jsqtzjcrcjcs;
//专项检查
let jsqtzjcZxjcs = req.body.jsqtzjcZxjcs || [];
let newjsqtzjcZxjcs = [];
for (let index = 0; index < jsqtzjcZxjcs.length; index++) {
let element = jsqtzjcZxjcs[index];
element.projectId = req.body.projectId;
element.fjcl = (element.fjcl || []).map(o => { return o && o.id || o });
newjsqtzjcZxjcs.push(element);
}
delete req.body.jsqtzjcZxjcs;
//创建
await DB.TzJsqtzjcTzfx.bulkCreate(jsqtzjcTzfxs);
await DB.TzJsqtzjcrcjc.bulkCreate(jsqtzjcrcjcs);
await DB.TzJsqtzjcZxjc.bulkCreate(jsqtzjcZxjcs);
let ret = await DB.TzJsqtzjc.create(req.body);
return res.sendData(ret);
} catch (error) {
next(error);
}
}
async function getJsqtzjcInfo (req, res, next) {
try {
let search = {};
if (req.body.id) {
search.id = req.body.id;
}
if (req.body.projectId) {
search.projectId = req.body.projectId;
}
if (_.isEmpty(search)) {
return res.sendError(errorMessage.paramsError);
}
let jsqtzjc = await DB.TzJsqtzjc.findOne({where: search, raw: true});
if(!(jsqtzjc && jsqtzjc.id && jsqtzjc.projectId)) {
return res.sendError(errorMessage.resourceNotFound);
}
let newjsqtzjcTzfxs = [], newjsqtzjcrcjcs = [], newjsqtzjcZxjcs = [];
let jsqtzjcTzfxs = await DB.TzJsqtzjcTzfx.findAll({where: {projectId: jsqtzjc.projectId}, raw: true});
for (let index = 0; index < jsqtzjcTzfxs.length; index++) {
let element = jsqtzjcTzfxs[index];
// fileids.concat(element.tzcbfxhzl || []);
element.tzcbfxhzl = await DB.File.findAll({where: {id: {[Op.in]: element.tzcbfxhzl}}});
newjsqtzjcTzfxs.push(element);
}
let jsqtzjcrcjcs = await DB.TzJsqtzjcrcjc.findAll({where: {projectId: jsqtzjc.projectId}, raw: true});
for (let index = 0; index < jsqtzjcrcjcs.length; index++) {
const element = jsqtzjcrcjcs[index];
// fileids.concat(element.fxcl || []);
element.fxcl = await DB.File.findAll({where: {id: {[Op.in]: element.fxcl}}});
newjsqtzjcrcjcs.push(element);
}
let jsqtzjcZxjcs = await DB.TzJsqtzjcZxjc.findAll({where: {projectId: jsqtzjc.projectId}, raw: true});
for (let index = 0; index < jsqtzjcZxjcs.length; index++) {
const element = jsqtzjcZxjcs[index];
// fileids.concat(element.fjcl || []);
element.fjcl = await DB.File.findAll({where: {id: {[Op.in]: element.fjcl}}});
newjsqtzjcZxjcs.push(element);
}
jsqtzjc.jsqtzjcTzfxs = newjsqtzjcTzfxs;
jsqtzjc.jsqtzjcrcjcs = newjsqtzjcrcjcs;
jsqtzjc.jsqtzjcZxjcs = newjsqtzjcZxjcs;
return res.sendData(jsqtzjc);
} catch (error) {
next(error);
}
}
async function updateJsqtzjc(req, res, next) {
try {
if (!req.body.projectId) {
return res.sendError(errorMessage.paramsError);
}
let jsqtzjcTzfxs = req.body.jsqtzjcTzfxs || [];
let ids = [], newArr = [], info = [];
for (let index = 0; index < jsqtzjcTzfxs.length; index++) {
let element = jsqtzjcTzfxs[index];
element.projectId = req.body.projectId;
element.tzcbfxhzl = (element.tzcbfxhzl || []).map(o => {return o && o.id || o});
if(element.id) {
ids.push(element.id);
info.push(element);
} else {
newArr.push(element);
}
}
await DB.TzJsqtzjcTzfx.destroy({ where: { projectId: req.body.projectId, id: { [Op.notIn]: ids } } }); // 删除id不在传入id数组里面的(用户在界面删除的)
await DB.TzJsqtzjcTzfx.bulkCreate(newArr);//创建新的 没有id的
await Promise.all(info.map(item => { DB.TzJsqtzjcTzfx.update(item, { where: { id: item.id } }) }));
delete req.body.jsqtzjcTzfxs;
let jsqtzjcrcjcs = req.body.jsqtzjcrcjcs || [];
let ids1 = [], newArr1 = [], info1 = [];
for (let index = 0; index < jsqtzjcrcjcs.length; index++) {
let element = jsqtzjcrcjcs[index];
element.projectId = req.body.projectId;
element.fxcl = (element.fxcl || []).map(o => {return o && o.id || o});
if(element.id) {
ids1.push(element.id);
info1.push(element);
} else {
newArr1.push(element);
}
}
await DB.TzJsqtzjcrcjc.destroy({ where: { projectId: req.body.projectId, id: { [Op.notIn]: ids1 } } }); // 删除id不在传入id数组里面的(用户在界面删除的)
await DB.TzJsqtzjcrcjc.bulkCreate(newArr1);//创建新的 没有id的
await Promise.all(info1.map(item => { DB.TzJsqtzjcrcjc.update(item, { where: { id: item.id } }) }));
delete req.body.jsqtzjcrcjcs;
let jsqtzjcZxjcs = req.body.jsqtzjcZxjcs || [];
let ids2 = [], newArr2 = [], info2 = [];
for (let index = 0; index < jsqtzjcZxjcs.length; index++) {
let element = jsqtzjcZxjcs[index];
element.projectId = req.body.projectId;
element.fjcl = (element.fjcl || []).map(o => {return o && o.id || o});
if(element.id) {
ids2.push(element.id);
info2.push(element);
} else {
newArr2.push(element);
}
}
await DB.TzJsqtzjcZxjc.destroy({ where: { projectId: req.body.projectId, id: { [Op.notIn]: ids2 } } }); // 删除id不在传入id数组里面的(用户在界面删除的)
await DB.TzJsqtzjcZxjc.bulkCreate(newArr2);//创建新的 没有id的
await Promise.all(info2.map(item => { DB.TzJsqtzjcZxjc.update(item, { where: { id: item.id } }) }));
delete req.body.jsqtzjcZxjcs;
await DB.TzJsqtzjc.update(req.body, { where: { id: req.body.id } });
return res.sendData({});
} catch (error) {
next(error);
}
}
async function getJsqtzjcList (req, res, next) {
try {
let page = req.body.page || 1;
let limit = req.body.pagesize || req.body.pageSize || 10;
let offset = (page - 1) * limit;
let search = {};
search.order = [['createdAt', 'DESC']];
search.limit = limit;
search.offset = offset;
let where = { del: 0 };
if (req.body.projectName) {
where = {
[Op.or]: [
{ projectName: { [Op.like]: `%${req.body.projectName}%` } },
],
del: 0
}
}
search.where = where;
if (req.body.attributes && req.body.attributes.length) {
search.attributes = req.body.attributes;
}
let ret = await DB.TzJsqtzhs.findAndCountAll(search);
return res.sendData(ret);
} catch (error) {
next(error);
}
}
module.exports = {
createTzmbzrs,
updateTzmbzrs,
......@@ -568,4 +764,8 @@ module.exports = {
updateJsqtzhs,
getJsqtzhsList,
getJsqtzhsInfo,
createJsqtzjc,
updateJsqtzjc,
getJsqtzjcList,
getJsqtzjcInfo,
}
\ No newline at end of file
......@@ -38,7 +38,7 @@ const ProjectZqrz = require('./model/jt/projectZqrz')
const ProjectSpyjjc = require('./model/jt/projectSpyjjc')
//投中
const TzTzmbzrs = require("./model/jt/tzTzmbzrs");
const TzTzmbzrs = require("./model/jt/tzTzmbzrs");
const TzTzmbzrsZb = require("./model/jt/tzTzmbzrsZb");
const TzTzkz = require("./model/jt/tzTzkz");
......@@ -52,6 +52,10 @@ const TzZdfxcz = require("./model/jt/tzZdfxcz");
const TzZdfxcwzb = require("./model/jt/tzZdfxcwzb");
const TzZdfxqk = require("./model/jt/tzZdfxqk");
const TzJsqtzjc = require("./model/jt/tzJsqtzjc");
const TzJsqtzjcTzfx = require("./model/jt/tzJsqtzjcTzfx");
const TzJsqtzjcrcjc = require("./model/jt/tzJsqtzjcrcjc");
const TzJsqtzjcZxjc = require("./model/jt/tzJsqtzjcZxjc");
/**
* 业务表
*/
......@@ -75,7 +79,7 @@ global.DB = {
Resources,
ResourcesInfo,
ProjectBjtj,
ProjectFile,
ProjectFile,
ProjectGdxx,
ProjectJsgm,
ProjectSpyj,
......@@ -103,6 +107,11 @@ global.DB = {
TzZdfxcz,
TzZdfxcwzb,
TzZdfxqk,
TzJsqtzjc,
TzJsqtzjcTzfx,
TzJsqtzjcrcjc,
TzJsqtzjcZxjc,
}
......@@ -200,7 +209,7 @@ Project.hasMany(ProjectJczt, { foreignKey: 'projectId', as: 'projectJczts' });
ProjectJczt.belongsTo(Project, { foreignKey: 'projectId' });
/**项目-建设规模 1:n */
Project.hasMany(ProjectJsgm, { foreignKey: 'projectId', as: 'projectJsgms' });
ProjectJsgm.belongsTo(Project, { foreignKey: 'projectId' });
ProjectJsgm.belongsTo(Project, { foreignKey: 'projectId' });
/**项目-里程碑节点 1:n */
Project.hasMany(ProjectLcbjd, { foreignKey: 'projectId', as: 'projectLcbjds' });
ProjectLcbjd.belongsTo(Project, { foreignKey: 'projectId' });
......
const { DataTypes } = require('sequelize');
const sequelize = require('../index');
const moment = require('moment');
//投中管理- 建设期投资检查
const TzJsqtzjc = sequelize.define('TzJsqtzjc', {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true
},
jcztz: {
type: DataTypes.DECIMAL(20, 2),
comment: "决策总投资 一次填报锁定"
},
zbjnbsyl: {
type: DataTypes.DECIMAL(5, 2),
comment: "资本金内部收益率(%) 一次填报锁定"
},
ycztz: {
type: DataTypes.DECIMAL(20, 2),
comment: "预测总投资"
},
qrztz: {
type: DataTypes.DECIMAL(20, 2),
comment: "确认总投资"
},
// zbjnbsyl: { // 重复了 应该是文档有错误
// type: DataTypes.DECIMAL(5, 2),
// 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('updatedAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
}
}, {
tableName: 'jt_tz_jsqtzjc', // 指定表名(如果与模型名不同)
timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
});
// 同步模型到数据库(创建表)
TzJsqtzjc.sync({
force: false,
// force: true ,//会删除已存在表并重新创建
// alter: true
})
.then(() => {
console.log('TzJsqtzjc 表同步成功');
});
module.exports = TzJsqtzjc;
\ No newline at end of file
const { DataTypes } = require('sequelize');
const sequelize = require('../index');
const moment = require('moment');
//投中管理- 建设期投资检查 ---投资(成本)分析会资料
const TzJsqtzjcTzfx = sequelize.define('TzJsqtzjcTzfx', {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true
},
jd: {
type: DataTypes.STRING,
comment: "季度",
},
ycztz: {
type: DataTypes.DECIMAL(20, 2),
comment: "当期预测总投资"
},
zbjnbsyl: {
type: DataTypes.DECIMAL(5, 2),
comment: "当期资本金内部收益率"
},
tzcbfxhzl: {
type: DataTypes.JSON,
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('updatedAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
}
}, {
tableName: 'jt_tz_jsqtzjcTzfx', // 指定表名(如果与模型名不同)
timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
});
// 同步模型到数据库(创建表)
TzJsqtzjcTzfx.sync({
force: false,
// force: true ,//会删除已存在表并重新创建
// alter: true
})
.then(() => {
console.log('TzJsqtzjcTzfx 表同步成功');
});
module.exports = TzJsqtzjcTzfx;
\ No newline at end of file
const { DataTypes } = require('sequelize');
const sequelize = require('../index');
const moment = require('moment');
//投中管理- 建设期投资检查 ---日常检查 对投资目标偏差每半年进行一次系统盘点,上传分析材料
const TzJsqtzjcZxjc = sequelize.define('TzJsqtzjcZxjc', {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true
},
zxjcfl: {
type: DataTypes.INTEGER,
comment: "专项检查分类 1 能建投资检查、2 葛洲坝集团投资检查、3 公司投资检查、4 其他投资检查"
},
kssj: {
type: DataTypes.DATE,
comment: "开始时间",
get() {
const rawValue = this.getDataValue('kssj');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
},
jssj: {
type: DataTypes.DATE,
comment: "结束时间",
get() {
const rawValue = this.getDataValue('jssj');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
},
fjcl: {
type: DataTypes.JSON,
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('updatedAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
}
}, {
tableName: 'jt_tz_jsqtzjcZxjc', // 指定表名(如果与模型名不同)
timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
});
// 同步模型到数据库(创建表)
TzJsqtzjcZxjc.sync({
// force: false,
// force: true ,//会删除已存在表并重新创建
alter: true
})
.then(() => {
console.log('TzJsqtzjcZxjc 表同步成功');
});
module.exports = TzJsqtzjcZxjc;
\ No newline at end of file
const { DataTypes } = require('sequelize');
const sequelize = require('../index');
const moment = require('moment');
//投中管理- 建设期投资检查 ---日常检查 对投资目标偏差每半年进行一次系统盘点,上传分析材料
const TzJsqtzjcrcjc = sequelize.define('TzJsqtzjcrcjc', {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true
},
kssj: {
type: DataTypes.DATE,
comment: "开始时间",
get() {
const rawValue = this.getDataValue('kssj');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
},
jssj: {
type: DataTypes.DATE,
comment: "结束时间",
get() {
const rawValue = this.getDataValue('jssj');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
},
pdnrsm: {
type: DataTypes.TEXT,
comment: "盘点内容说明"
},
fxcl: {
type: DataTypes.JSON,
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('updatedAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
}
}, {
tableName: 'jt_tz_jsqtzjcrcjc', // 指定表名(如果与模型名不同)
timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
});
// 同步模型到数据库(创建表)
TzJsqtzjcrcjc.sync({
// force: false,
// force: true ,//会删除已存在表并重新创建
alter: true
})
.then(() => {
console.log('TzJsqtzjcrcjc 表同步成功');
});
module.exports = TzJsqtzjcrcjc;
\ No newline at end of file
......@@ -73,5 +73,11 @@ router.post('/updateJsqtzhs', projectTzController.updateJsqtzhs);
router.post('/getJsqtzhsList', projectTzController.getJsqtzhsList);
router.post('/getJsqtzhsInfo', projectTzController.getJsqtzhsInfo);
//建设期投资检查
router.post('/createJsqtzjc', projectTzController.createJsqtzjc);
router.post('/updateJsqtzjc', projectTzController.updateJsqtzjc);
router.post('/getJsqtzjcList', projectTzController.getJsqtzjcList);
router.post('/getJsqtzjcInfo', projectTzController.getJsqtzjcInfo);
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