明树Git Lab

Commit 9b2d8967 authored by zfp1's avatar zfp1

update

parent 669d51da
Pipeline #106886 passed with stage
in 3 seconds
......@@ -19,23 +19,23 @@ async function createYyqtzhs(req, res, next) {
}
let ret = await DB.ThTzYyqtzhs.create(req.body);
//处理财务指标
let flattenArr = [];
let yyqtzhss = req.body.yyqtzhss || [[]]; //二维数组 多次上报
delete req.body.yyqtzhss;
for (let index = 0; index < yyqtzhss.length; index++) {
const element = yyqtzhss[index];
for (let i = 0; i < element.length; i++) {
let ei = element[i];
ei.groupBy = index;
ei.projectId = req.body.projectId;
ei.sourceId = ret.id;
flattenArr.push(ei);
}
}
delete req.body.yyqtzhss;
// //处理财务指标
// let flattenArr = [];
// let yyqtzhss = req.body.yyqtzhss || [[]]; //二维数组 多次上报
// delete req.body.yyqtzhss;
// for (let index = 0; index < yyqtzhss.length; index++) {
// const element = yyqtzhss[index];
// for (let i = 0; i < element.length; i++) {
// let ei = element[i];
// ei.groupBy = index;
// ei.projectId = req.body.projectId;
// ei.sourceId = ret.id;
// flattenArr.push(ei);
// }
// }
// delete req.body.yyqtzhss;
await DB.ThTzYyqtzhszb.bulkCreate(flattenArr);
// await DB.ThTzYyqtzhszb.bulkCreate(flattenArr);
return res.sendData(ret);
} catch (error) {
next(error);
......@@ -55,8 +55,8 @@ async function getYyqtzhsInfo(req, res, next) {
if (!(tzhs && tzhs.id && tzhs.projectId)) {
return res.sendError(errorMessage.resourceNotFound);
}
let yyqtzhss = await DB.ThTzYyqtzhszb.findAll({ where: { projectId: tzhs.projectId, sourceId: req.body.id }, raw: true });
tzhs.yyqtzhss = _.values(_.groupBy(yyqtzhss, 'groupBy')) || [[]]
// let yyqtzhss = await DB.ThTzYyqtzhszb.findAll({ where: { projectId: tzhs.projectId, sourceId: req.body.id }, raw: true });
// tzhs.yyqtzhss = _.values(_.groupBy(yyqtzhss, 'groupBy')) || [[]]
return res.sendData(tzhs);
} catch (error) {
next(error);
......@@ -67,28 +67,28 @@ async function updateYyqtzhs(req, res, next) {
if (!req.body.projectId) {
return res.sendError(errorMessage.paramsError);
}
let yyqtzhss = req.body.yyqtzhss || [[]]; //二维数组 多次上报
let ids3 = [], infos3 = [], newtyyqtzhss = [];
for (let index = 0; index < yyqtzhss.length; index++) {
const element = yyqtzhss[index];
for (let i = 0; i < element.length; i++) {
let ei = element[i];
ei.groupBy = index;
ei.projectId = req.body.projectId;
ei.sourceId = req.body.id;
if (!ei.id) {
if (!_.isEmpty(ei)) {
newtyyqtzhss.push(ei);
}
} else {
ids3.push(ei.id); infos3.push(ei);
}
}
}
await DB.ThTzYyqtzhszb.destroy({ where: { projectId: req.body.projectId, sourceId: req.body.id, id: { [Op.notIn]: ids3 } } }); // 删除id不在传入id数组里面的(用户在界面删除的)
await DB.ThTzYyqtzhszb.bulkCreate(newtyyqtzhss);//创建新的 没有id的
await Promise.all(infos3.map(item => { DB.ThTzYyqtzhszb.update(item, { where: { id: item.id } }) }));
delete req.body.yyqtzhss;
// let yyqtzhss = req.body.yyqtzhss || [[]]; //二维数组 多次上报
// let ids3 = [], infos3 = [], newtyyqtzhss = [];
// for (let index = 0; index < yyqtzhss.length; index++) {
// const element = yyqtzhss[index];
// for (let i = 0; i < element.length; i++) {
// let ei = element[i];
// ei.groupBy = index;
// ei.projectId = req.body.projectId;
// ei.sourceId = req.body.id;
// if (!ei.id) {
// if (!_.isEmpty(ei)) {
// newtyyqtzhss.push(ei);
// }
// } else {
// ids3.push(ei.id); infos3.push(ei);
// }
// }
// }
// await DB.ThTzYyqtzhszb.destroy({ where: { projectId: req.body.projectId, sourceId: req.body.id, id: { [Op.notIn]: ids3 } } }); // 删除id不在传入id数组里面的(用户在界面删除的)
// await DB.ThTzYyqtzhszb.bulkCreate(newtyyqtzhss);//创建新的 没有id的
// await Promise.all(infos3.map(item => { DB.ThTzYyqtzhszb.update(item, { where: { id: item.id } }) }));
// delete req.body.yyqtzhss;
await DB.ThTzYyqtzhs.update(req.body, { where: { id: req.body.id } });
return res.sendData({});
......
......@@ -580,23 +580,23 @@ async function createJsqtzhs(req, res, next) {
return res.sendError(errorMessage.paramsError);
}
let ret = await DB.TzJsqtzhs.create(req.body);
//处理财务指标
let flattenArr = [];
let jsqtzhss = req.body.jsqtzhss || [[]]; //二维数组 多次上报
delete req.body.jsqtzhss;
for (let index = 0; index < jsqtzhss.length; index++) {
const element = jsqtzhss[index];
for (let i = 0; i < element.length; i++) {
let ei = element[i];
ei.groupBy = index;
ei.projectId = req.body.projectId;
ei.sourceId = ret.id;
flattenArr.push(ei);
}
}
delete req.body.jsqtzhss;
// //处理财务指标
// let flattenArr = [];
// let jsqtzhss = req.body.jsqtzhss || [[]]; //二维数组 多次上报
// delete req.body.jsqtzhss;
// for (let index = 0; index < jsqtzhss.length; index++) {
// const element = jsqtzhss[index];
// for (let i = 0; i < element.length; i++) {
// let ei = element[i];
// ei.groupBy = index;
// ei.projectId = req.body.projectId;
// ei.sourceId = ret.id;
// flattenArr.push(ei);
// }
// }
// delete req.body.jsqtzhss;
await DB.TzJsqtzhszb.bulkCreate(flattenArr);
// await DB.TzJsqtzhszb.bulkCreate(flattenArr);
return res.sendData(ret);
} catch (error) {
next(error);
......@@ -616,8 +616,8 @@ async function getJsqtzhsInfo(req, res, next) {
if (!(tzhs && tzhs.id && tzhs.projectId)) {
return res.sendError(errorMessage.resourceNotFound);
}
let jsqtzhss = await DB.TzJsqtzhszb.findAll({ where: { projectId: tzhs.projectId, sourceId: tzhs.id }, raw: true });
tzhs.jsqtzhss = _.values(_.groupBy(jsqtzhss, 'groupBy')) || [[]]
// let jsqtzhss = await DB.TzJsqtzhszb.findAll({ where: { projectId: tzhs.projectId, sourceId: tzhs.id }, raw: true });
// tzhs.jsqtzhss = _.values(_.groupBy(jsqtzhss, 'groupBy')) || [[]]
return res.sendData(tzhs);
} catch (error) {
next(error);
......@@ -632,28 +632,28 @@ async function updateJsqtzhs(req, res, next) {
if (!(tzhs && tzhs.id)) {
return res.sendError(errorMessage.resourceNotFound)
}
let jsqtzhss = req.body.jsqtzhss || [[]]; //二维数组 多次上报
let ids3 = [], infos3 = [], newtjsqtzhss = [];
for (let index = 0; index < jsqtzhss.length; index++) {
const element = jsqtzhss[index];
for (let i = 0; i < element.length; i++) {
let ei = element[i];
ei.groupBy = index;
ei.projectId = req.body.projectId;
ei.sourceId = tzhs.id;
if (!ei.id) {
if (!_.isEmpty(ei)) {
newtjsqtzhss.push(ei);
}
} else {
ids3.push(ei.id); infos3.push(ei);
}
}
}
await DB.TzJsqtzhszb.destroy({ where: { projectId: req.body.projectId, sourceId: tzhs.id, id: { [Op.notIn]: ids3 } } }); // 删除id不在传入id数组里面的(用户在界面删除的)
await DB.TzJsqtzhszb.bulkCreate(newtjsqtzhss);//创建新的 没有id的
await Promise.all(infos3.map(item => { return DB.TzJsqtzhszb.update(item, { where: { id: item.id } }) }));
delete req.body.jsqtzhss;
// let jsqtzhss = req.body.jsqtzhss || [[]]; //二维数组 多次上报
// let ids3 = [], infos3 = [], newtjsqtzhss = [];
// for (let index = 0; index < jsqtzhss.length; index++) {
// const element = jsqtzhss[index];
// for (let i = 0; i < element.length; i++) {
// let ei = element[i];
// ei.groupBy = index;
// ei.projectId = req.body.projectId;
// ei.sourceId = tzhs.id;
// if (!ei.id) {
// if (!_.isEmpty(ei)) {
// newtjsqtzhss.push(ei);
// }
// } else {
// ids3.push(ei.id); infos3.push(ei);
// }
// }
// }
// await DB.TzJsqtzhszb.destroy({ where: { projectId: req.body.projectId, sourceId: tzhs.id, id: { [Op.notIn]: ids3 } } }); // 删除id不在传入id数组里面的(用户在界面删除的)
// await DB.TzJsqtzhszb.bulkCreate(newtjsqtzhss);//创建新的 没有id的
// await Promise.all(infos3.map(item => { return DB.TzJsqtzhszb.update(item, { where: { id: item.id } }) }));
// delete req.body.jsqtzhss;
await DB.TzJsqtzhs.update(req.body, { where: { id: req.body.id } });
return res.sendData({});
......
const { DataTypes } = require('sequelize');
const sequelize = require('../index');
const moment = require('moment');
// const { DataTypes } = require('sequelize');
// const sequelize = require('../index');
// const moment = require('moment');
/**
* /**
* 投后管理- 运营期投资回收关联表
*/
const ThYyqtzhszb = sequelize.define('ThYyqtzhszb', {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true
},
year: {
type: DataTypes.DATE,
comment: "年份",
},
month: {
type: DataTypes.INTEGER,
comment: "月份",
},
xh: {
type: DataTypes.STRING,
comment: "序号",
},
ndtzhsmb: {
type: DataTypes.DECIMAL(20, 2),
comment: "年度投资回收目标"
},
dyhs: {
type: DataTypes.DECIMAL(20, 2),
comment: "当月回收"
},
dyljhs: {
type: DataTypes.DECIMAL(20, 2),
comment: "当月累计回收"
},
ndjhwcl: {
type: DataTypes.DECIMAL(5, 2),
comment: "年度计划完成率 %"
},
bz: {
type: DataTypes.TEXT,
comment: "备注",
},
// /**
// * /**
// * 投后管理- 运营期投资回收关联表
// */
// const ThYyqtzhszb = sequelize.define('ThYyqtzhszb', {
// id: {
// type: DataTypes.INTEGER,
// primaryKey: true,
// autoIncrement: true
// },
// year: {
// type: DataTypes.DATE,
// comment: "年份",
// },
// month: {
// type: DataTypes.INTEGER,
// comment: "月份",
// },
// xh: {
// type: DataTypes.STRING,
// comment: "序号",
// },
// ndtzhsmb: {
// type: DataTypes.DECIMAL(20, 2),
// comment: "年度投资回收目标"
// },
// dyhs: {
// type: DataTypes.DECIMAL(20, 2),
// comment: "当月回收"
// },
// dyljhs: {
// type: DataTypes.DECIMAL(20, 2),
// comment: "当月累计回收"
// },
// ndjhwcl: {
// type: DataTypes.DECIMAL(5, 2),
// comment: "年度计划完成率 %"
// },
// bz: {
// type: DataTypes.TEXT,
// comment: "备注",
// },
groupBy: {
type: DataTypes.INTEGER,
comment: "分组"
},
sourceId: {
type: DataTypes.INTEGER,
comment: "所属投资控制主表id"
},
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_th_yyqtzhszb', // 指定表名(如果与模型名不同)
timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
});
// groupBy: {
// type: DataTypes.INTEGER,
// comment: "分组"
// },
// sourceId: {
// type: DataTypes.INTEGER,
// comment: "所属投资控制主表id"
// },
// 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_th_yyqtzhszb', // 指定表名(如果与模型名不同)
// timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
// });
// 同步模型到数据库(创建表)
ThYyqtzhszb.sync({
// force: false,
// force: true ,//会删除已存在表并重新创建
alter: true
})
.then(() => {
console.log('ThYyqtzhszb 表同步成功');
});
// // 同步模型到数据库(创建表)
// ThYyqtzhszb.sync({
// // force: false,
// // force: true ,//会删除已存在表并重新创建
// alter: true
// })
// .then(() => {
// console.log('ThYyqtzhszb 表同步成功');
// });
module.exports = ThYyqtzhszb;
\ No newline at end of file
// module.exports = ThYyqtzhszb;
\ No newline at end of file
......@@ -11,10 +11,86 @@ const TzJsqtzhs = sequelize.define('TzJsqtzhs', {
primaryKey: true,
autoIncrement: true
},
//以下 项目信息里面取值
projectName: {
type: DataTypes.STRING,
comment: "项目名称",
},
xmgsmc: {
type: DataTypes.STRING,
comment: "项目公司名称",
},
tbdwmc: {
type: DataTypes.STRING,
comment: "填报单位名称",
},
ssejqy: {
type: DataTypes.STRING,
comment: "所属二级企业",
},
xmjd: {
type: DataTypes.STRING,
comment: "项目阶段",
},
xmlx: {
type: DataTypes.STRING,
comment: "项目类别 同等与 项目类型 xmlx",
},
tzms: {
type: DataTypes.STRING,
comment: "投资模式分类",
},
tzhsfs: {
type: DataTypes.STRING,
comment: "投资回收方式",
},
xnxmjd: {
type: DataTypes.STRING,
comment: "下年项目阶段",
},
projectGdxxs: {
type: DataTypes.JSON,
},
//以下 可能跟项目相关 有可能在项目里面取值,需要项目信息齐全并对应上
tzzejc: { type: DataTypes.DECIMAL(20, 8), allowNull: true, comment: "投资总额-决策值", },
wfzbjczejc: { type: DataTypes.DECIMAL(20, 8), allowNull: true, comment: "我方资本金出资额-决策值", },
tzzesj: { type: DataTypes.DECIMAL(20, 8), allowNull: true, comment: "投资总额-实际值", },
wfzbjczesj: { type: DataTypes.DECIMAL(20, 8), allowNull: true, comment: "我方资本家出资额--实际值", },
tzzejhz: { type: DataTypes.DECIMAL(20, 8), allowNull: true, comment: "投资总额-计划值", },
//以下投资回收相关
bnwc: { type: DataTypes.DECIMAL(20, 8), allowNull: true, comment: "本年完成 投资回收决策目标值", },
jzbnlj: { type: DataTypes.DECIMAL(20, 8), allowNull: true, comment: "截止本年累计", },
xynwcs: { type: DataTypes.DECIMAL(20, 8), allowNull: true, comment: "下一年完成数", },
bnjh: { type: DataTypes.DECIMAL(20, 8), allowNull: true, comment: "本年计划", },
bnwcsjz: { type: DataTypes.DECIMAL(20, 8), allowNull: true, comment: "本年完成--投资回收实际值", },
jzbnljsjz: { type: DataTypes.DECIMAL(20, 8), allowNull: true, comment: "截止本年累计--投资回收实际值", },
sjyjhcysm: { type: DataTypes.TEXT, comment: "实际与计划差异说明" },
ljqs: { type: DataTypes.DECIMAL(20, 8), allowNull: true, comment: "累计欠收", },
wcl: { type: DataTypes.DECIMAL(5, 2), allowNull: true, comment: "完成率", },
czdzywt: { type: DataTypes.TEXT, comment: "存在主要问题" },
cqcsjgzkzqk: { type: DataTypes.TEXT, comment: "采取措施及开展情况" },
bz: { type: DataTypes.TEXT, comment: "备注" },
jhyjcmbcysm: { type: DataTypes.TEXT, comment: "计划与决策目标值差异说明" },
//截至月末累计应收
jzymljys: {
type: DataTypes.JSON,
},
//截至月末累计实收
jzymljsh: {
type: DataTypes.JSON,
},
tzhsjc: {type: DataTypes.JSON,},
tzhsjh: {type: DataTypes.JSON,},
......
const { DataTypes } = require('sequelize');
const sequelize = require('../index');
const moment = require('moment');
// const { DataTypes } = require('sequelize');
// const sequelize = require('../index');
// const moment = require('moment');
/**
* 投中管理- 建设期投资回收关联表
*/
const TzJsqtzhszb = sequelize.define('TzJsqtzhszb', {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true
},
year: {
type: DataTypes.DATE,
comment: "年份",
},
month: {
type: DataTypes.INTEGER,
comment: "月份",
},
xh: {
type: DataTypes.STRING,
comment: "序号",
},
ndtzhsmb: {
type: DataTypes.DECIMAL(20, 2),
comment: "年度投资回收目标"
},
dyhs: {
type: DataTypes.DECIMAL(20, 2),
comment: "当月回收"
},
dyljhs: {
type: DataTypes.DECIMAL(20, 2),
comment: "当月累计回收"
},
ndjhwcl: {
type: DataTypes.DECIMAL(5, 2),
comment: "年度计划完成率 %"
},
bz: {
type: DataTypes.TEXT,
comment: "备注",
},
// /**
// * 投中管理- 建设期投资回收关联表
// */
// const TzJsqtzhszb = sequelize.define('TzJsqtzhszb', {
// id: {
// type: DataTypes.INTEGER,
// primaryKey: true,
// autoIncrement: true
// },
// year: {
// type: DataTypes.DATE,
// comment: "年份",
// },
// month: {
// type: DataTypes.INTEGER,
// comment: "月份",
// },
// xh: {
// type: DataTypes.STRING,
// comment: "序号",
// },
// ndtzhsmb: {
// type: DataTypes.DECIMAL(20, 2),
// comment: "年度投资回收目标"
// },
// dyhs: {
// type: DataTypes.DECIMAL(20, 2),
// comment: "当月回收"
// },
// dyljhs: {
// type: DataTypes.DECIMAL(20, 2),
// comment: "当月累计回收"
// },
// ndjhwcl: {
// type: DataTypes.DECIMAL(5, 2),
// comment: "年度计划完成率 %"
// },
// bz: {
// type: DataTypes.TEXT,
// comment: "备注",
// },
groupBy: {
type: DataTypes.INTEGER,
comment: "分组"
},
sourceId: {
type: DataTypes.INTEGER,
comment: "所属投资控制主表id"
},
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_jsqtzhs', // 指定表名(如果与模型名不同)
timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
});
// groupBy: {
// type: DataTypes.INTEGER,
// comment: "分组"
// },
// sourceId: {
// type: DataTypes.INTEGER,
// comment: "所属投资控制主表id"
// },
// 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_jsqtzhs', // 指定表名(如果与模型名不同)
// timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
// });
// 同步模型到数据库(创建表)
TzJsqtzhszb.sync({
// force: false,
// force: true ,//会删除已存在表并重新创建
alter: true
})
.then(() => {
console.log('TzJsqtzhszb 表同步成功');
});
// // 同步模型到数据库(创建表)
// TzJsqtzhszb.sync({
// // force: false,
// // force: true ,//会删除已存在表并重新创建
// alter: true
// })
// .then(() => {
// console.log('TzJsqtzhszb 表同步成功');
// });
module.exports = TzJsqtzhszb;
\ No newline at end of file
// module.exports = TzJsqtzhszb;
\ 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