明树Git Lab

Commit f195e92c authored by zfp1's avatar zfp1

update

parent 5bd58252
Pipeline #105174 passed with stage
in 3 seconds
...@@ -210,12 +210,12 @@ async function updateTzkz(req, res, next) { ...@@ -210,12 +210,12 @@ async function updateTzkz(req, res, next) {
let ei = element[i]; let ei = element[i];
ei.groupBy = index; ei.groupBy = index;
ei.projectId = req.body.projectId; ei.projectId = req.body.projectId;
if (!ei.id) { if (!ei.id) {
if (!_.isEmpty(ei)) { if (!_.isEmpty(ei)) {
newtzkztzekzs.push(ei); newtzkztzekzs.push(ei);
} }
} else { } else {
ids3.push(ei.id); infos3.push(ei); ids3.push(ei.id); infos3.push(ei);
} }
} }
} }
...@@ -224,7 +224,7 @@ async function updateTzkz(req, res, next) { ...@@ -224,7 +224,7 @@ async function updateTzkz(req, res, next) {
await Promise.all(infos3.map(item => { DB.TzTzkzTzekz.update(item, { where: { id: item.id } }) })); await Promise.all(infos3.map(item => { DB.TzTzkzTzekz.update(item, { where: { id: item.id } }) }));
delete req.body.tzkztzekzs; delete req.body.tzkztzekzs;
await DB.TzTzkz.update(req.body, {where: {id: req.body.id}}); await DB.TzTzkz.update(req.body, { where: { id: req.body.id } });
return res.sendData(); return res.sendData();
} catch (error) { } catch (error) {
next(error); next(error);
...@@ -265,7 +265,17 @@ async function getTzkzList(req, res, next) { ...@@ -265,7 +265,17 @@ async function getTzkzList(req, res, next) {
} }
async function getTzkzInfo(req, res, next) { async function getTzkzInfo(req, res, next) {
try { try {
let tzkz = await DB.TzTzkz.findOne({ where: { id: req.body.id }, raw: true }); 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 tzkz = await DB.TzTzkz.findOne({ where: search, raw: true });
if (!(tzkz && tzkz.id)) { if (!(tzkz && tzkz.id)) {
return res.sendError(errorMessage.resourceNotFound); return res.sendError(errorMessage.resourceNotFound);
} }
...@@ -305,6 +315,126 @@ async function getTzkzInfo(req, res, next) { ...@@ -305,6 +315,126 @@ async function getTzkzInfo(req, res, next) {
} }
} }
async function createZdfx(req, res, next) {
try {
if (!req.body.projectId) {
return res.sendError(errorMessage.paramsError);
}
//处理财务指标
let zdfxcwzbs = (req.body.zdfxcwzbs || []).map(o => { o.projectId = req.body.projectId; return o; });
delete req.body.zdfxcwzbs;
//处理风险处置
let zdfxczs = (req.body.zdfxczs || []).map(o => { o.projectId = req.body.projectId; return o; });
delete req.body.zdfxczs;
//处理风险情况
let zdfxqks = (req.body.zdfxqks || []).map(o => { o.projectId = req.body.projectId; return o; });
delete req.body.zdfxqks;
await DB.TzZdfxcwzb.bulkCreate(zdfxcwzbs);
await DB.TzZdfxcz.bulkCreate(zdfxczs);
await DB.TzZdfxqk.bulkCreate(zdfxqks);
let ret = await DB.TzZdfx.create(req.body);
return res.sendData(ret);
} catch (error) {
next(error);
}
}
async function getZdfxInfo(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 zdfx = await DB.TzZdfx.findOne({ where: search, raw: true });
if (!(zdfx && zdfx.id && zdfx.projectId)) {
return res.sendError(errorMessage.resourceNotFound);
}
let zdfxcwzbs = await DB.TzZdfxcwzb.findAll({ where: { projectId: zdfx.projectId }, raw: true });
let zdfxczs = await DB.TzZdfxcz.findAll({ where: { projectId: zdfx.projectId }, raw: true });
let zdfxqks = await DB.TzZdfxqk.findAll({ where: { projectId: zdfx.projectId }, raw: true });
zdfx.zdfxcwzbs = zdfxcwzbs;
zdfx.zdfxczs = zdfxczs;
zdfx.zdfxqks = zdfxqks;
return res.sendData(zdfx);
} catch (error) {
next(error);
}
}
async function updateZdfx(req, res, next) {
try {
if (!req.body.projectId) {
return res.sendError(errorMessage.paramsError);
}
//处理财务指标
let ids = [], infos = [], newzdfxcwzbs = [];
req.body.zdfxcwzbs.map(o => { if (!o.id) { if (!_.isEmpty(o)) { o.projectId = req.body.projectId; newzdfxcwzbs.push(o); } } else { ids.push(o.id); infos.push(o); } return o });
await DB.TzZdfxcwzb.destroy({ where: { projectId: req.body.projectId, id: { [Op.notIn]: ids } } }); // 删除id不在传入id数组里面的(用户在界面删除的)
await DB.TzZdfxcwzb.bulkCreate(newzdfxcwzbs);//创建新的 没有id的
await Promise.all(infos.map(item => { DB.TzZdfxcwzb.update(item, { where: { id: item.id } }) }));
delete req.body.zdfxcwzbs;
//处理风险处置
let ids1 = [], infos1 = [], newzdfxczs = [];
req.body.zdfxczs.map(o => { if (!o.id) { if (!_.isEmpty(o)) { o.projectId = req.body.projectId; newzdfxczs.push(o); } } else { ids1.push(o.id); infos1.push(o); } return o });
await DB.TzZdfxcwzb.destroy({ where: { projectId: req.body.projectId, id: { [Op.notIn]: ids1 } } }); // 删除id不在传入id数组里面的(用户在界面删除的)
await DB.TzZdfxcwzb.bulkCreate(newzdfxczs);//创建新的 没有id的
await Promise.all(infos1.map(item => { DB.TzZdfxcwzb.update(item, { where: { id: item.id } }) }));
delete req.body.zdfxczs;
//处理风险情况
let ids2 = [], infos2 = [], newzdfxqks = [];
req.body.zdfxqks.map(o => { if (!o.id) { if (!_.isEmpty(o)) { o.projectId = req.body.projectId; newzdfxqks.push(o); } } else { ids2.push(o.id); infos2.push(o); } return o });
await DB.TzZdfxcwzb.destroy({ where: { projectId: req.body.projectId, id: { [Op.notIn]: ids2 } } }); // 删除id不在传入id数组里面的(用户在界面删除的)
await DB.TzZdfxcwzb.bulkCreate(newzdfxqks);//创建新的 没有id的
await Promise.all(infos2.map(item => { DB.TzZdfxcwzb.update(item, { where: { id: item.id } }) }));
delete req.body.zdfxqks;
let ret = await DB.TzZdfx.update(req.body, { where: { id: req.body.id } });
return res.sendData(ret);
} catch (error) {
next(error);
}
}
async function getZdfxList(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}%` } },
{ xmgsqc: { [Op.like]: `%${req.body.xmgsqc}%` } },
{ zsqy: { [Op.like]: `%${req.body.zsqy}%` } },
],
del: 0
}
}
search.where = where;
if (req.body.attributes && req.body.attributes.length) {
search.attributes = req.body.attributes;
}
let ret = await DB.TzZdfx.findAndCountAll(search);
return res.sendData(ret);
} catch (error) {
next(error);
}
}
module.exports = { module.exports = {
createTzmbzrs, createTzmbzrs,
...@@ -315,4 +445,8 @@ module.exports = { ...@@ -315,4 +445,8 @@ module.exports = {
getTzkzInfo, getTzkzInfo,
getTzkzList, getTzkzList,
updateTzkz, updateTzkz,
createZdfx,
updateZdfx,
getZdfxList,
getZdfxInfo,
} }
\ No newline at end of file
...@@ -46,6 +46,12 @@ const TzTzkzJcpfyj = require("./model/jt/tzTzkzJcpfyj"); ...@@ -46,6 +46,12 @@ const TzTzkzJcpfyj = require("./model/jt/tzTzkzJcpfyj");
const TzTzkzTzekz = require("./model/jt/tzTzkzTzekz"); const TzTzkzTzekz = require("./model/jt/tzTzkzTzekz");
const TzTzkzCwpj = require("./model/jt/tzTzkzCwpj"); const TzTzkzCwpj = require("./model/jt/tzTzkzCwpj");
const TzTzkzTzsy = require('./model/jt/tzTzkzTzsy'); const TzTzkzTzsy = require('./model/jt/tzTzkzTzsy');
const TzZdfx = require("./model/jt/tzZdfx");
const TzZdfxcz = require("./model/jt/tzZdfxcz");
const TzZdfxcwzb = require("./model/jt/tzZdfxcwzb");
const TzZdfxqk = require("./model/jt/tzZdfxqk");
/** /**
* 业务表 * 业务表
*/ */
...@@ -93,6 +99,10 @@ global.DB = { ...@@ -93,6 +99,10 @@ global.DB = {
TzTzkzTzekz, TzTzkzTzekz,
TzTzkzCwpj, TzTzkzCwpj,
TzTzkzTzsy, TzTzkzTzsy,
TzZdfx,
TzZdfxcz,
TzZdfxcwzb,
TzZdfxqk,
} }
......
This diff is collapsed.
const { DataTypes } = require('sequelize');
const sequelize = require('../index');
const moment = require('moment');
//投中管理-重大风险防控
const TzZdfx = sequelize.define('TzZdfx', {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true
},
zsqy: {
type: DataTypes.STRING,
comment: "直属企业",
},
projectName: {
type: DataTypes.STRING,
comment: "项目名称",
},
xmgsqc: {
type: DataTypes.STRING,
comment: "项目公司全称",
},
jnw: { type: DataTypes.INTEGER, allowNull: true, comment: "境内/外", zjType: 'danxuan', _mark: "lixiang" },
sjnzjjw: { type: DataTypes.INTEGER, allowNull: true, comment: "省(境内)/洲际(境外)", zjType: 'danxuan', _mark: "lixiang" },
dsjngjjw: { type: DataTypes.INTEGER, allowNull: true, comment: "地市(境内)/国家(境外)", zjType: 'danxuan', _mark: "lixiang" },
tzbk: { type: DataTypes.INTEGER, allowNull: true, comment: "投资板块", zjType: 'danxuan', _mark: "lixiang" },
xmlx: { type: DataTypes.INTEGER, allowNull: true, comment: "项目类型 1控股/2参股/3平股", zjType: 'danxuan', },
bjtgb: {
type: DataTypes.DECIMAL(5, 2),
comment: "本集团股比(%)"
},
xmyjztz: {
type: DataTypes.DECIMAL(20, 2),
comment: "项目(预计)总投资"
},
ljwctz: {
type: DataTypes.DECIMAL(20, 2),
comment: "累计完成投资"
},
yjkgny: {
type: DataTypes.DATE,
get() {
const rawValue = this.getDataValue('yjkgny');
return rawValue ? moment(rawValue).format('YYYY-MM') : '';
}
},
yjwgny: {
type: DataTypes.DATE,
get() {
const rawValue = this.getDataValue('yjwgny');
return rawValue ? moment(rawValue).format('YYYY-MM') : '';
}
},
yyq: {
type: DataTypes.INTEGER,
comment: "运营期(年)",
},
xmjd: {
type: DataTypes.INTEGER,
comment: "项目阶段 1未开工/2未交割/3在建/4运营",
},
xmqzqyysr: {
type: DataTypes.DECIMAL(20, 2),
comment: "项目全周期-营业收入"
},
xmqzqlrze: {
type: DataTypes.DECIMAL(20, 2),
comment: "项目全周期-利润总额"
},
// cwzbsj: {
// type: DataTypes.DATE,
// comment: "财务指标时间",
// get() {
// const rawValue = this.getDataValue('cwzbsj');
// return rawValue ? moment(rawValue).format('YYYY-MM') : '';
// }
// },
// xmljyysr: {
// type: DataTypes.DECIMAL(20, 2),
// comment: "项目累计营业收入"
// },
// xmljlrze: {
// type: DataTypes.DECIMAL(20, 2),
// comment: "项目累计利润总额"
// },
// xmdnyysr: {
// type: DataTypes.DECIMAL(20, 2),
// comment: "项目当年营业收入"
// },
// xmdnlrze: {
// type: DataTypes.DECIMAL(20, 2),
// comment: "项目当年利润总额"
// },
zrrlxfs: {
type: DataTypes.STRING,
comment: "责任人联系方式",
},
sfdqxz: {
type: DataTypes.INTEGER,
comment: "是否当期新增 1 是 2 否",
},
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_zdfx', // 指定表名(如果与模型名不同)
timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
});
// 同步模型到数据库(创建表)
TzZdfx.sync({
// force: false,
// force: true ,//会删除已存在表并重新创建
alter: true
})
.then(() => {
console.log('TzZdfx 表同步成功');
});
module.exports = TzZdfx;
\ No newline at end of file
const { DataTypes } = require('sequelize');
const sequelize = require('../index');
const moment = require('moment');
//投中管理- 年度 财务指标
const TzZdfxcwzb = sequelize.define('TzZdfxcwzb', {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true
},
cwzbsj: {
type: DataTypes.DATE,
comment: "财务指标时间-年度",
get() {
const rawValue = this.getDataValue('cwzbsj');
return rawValue ? moment(rawValue).format('YYYY-MM') : '';
}
},
xmljyysr: {
type: DataTypes.DECIMAL(20, 2),
comment: "项目累计营业收入"
},
xmljlrze: {
type: DataTypes.DECIMAL(20, 2),
comment: "项目累计利润总额"
},
xmdnyysr: {
type: DataTypes.DECIMAL(20, 2),
comment: "项目当年营业收入"
},
xmdnlrze: {
type: DataTypes.DECIMAL(20, 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_zdfxcwzb', // 指定表名(如果与模型名不同)
timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
});
// 同步模型到数据库(创建表)
TzZdfxcwzb.sync({
// force: false,
// force: true ,//会删除已存在表并重新创建
alter: true
})
.then(() => {
console.log('TzZdfxcwzb 表同步成功');
});
module.exports = TzZdfxcwzb;
\ No newline at end of file
const { DataTypes } = require('sequelize');
const sequelize = require('../index');
const moment = require('moment');
/**
* 投中管理- 风险处置
*/
const TzZdfxcz = sequelize.define('TzZdfxcz', {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true
},
nd: {
type: DataTypes.DATE,
comment: "财务指标时间-年度",
get() {
const rawValue = this.getDataValue('nd');
return rawValue ? moment(rawValue).format('YYYY-MM') : '';
}
},
mbfj: {
type: DataTypes.TEXT,
comment: "目标分解"
},
jzqk: {
type: DataTypes.TEXT,
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_zdfxcz', // 指定表名(如果与模型名不同)
timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
});
// 同步模型到数据库(创建表)
TzZdfxcz.sync({
// force: false,
// force: true ,//会删除已存在表并重新创建
alter: true
})
.then(() => {
console.log('TzZdfxcz 表同步成功');
});
module.exports = TzZdfxcz;
\ No newline at end of file
const { DataTypes } = require('sequelize');
const sequelize = require('../index');
const moment = require('moment');
//投中管理- 已发现或暴露的风险 ---风险情况
const TzZdfxqk = sequelize.define('TzZdfxqk', {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true
},
fxdj: {
type: DataTypes.STRING,
comment: "风险等级"
},
fxfl: {
type: DataTypes.STRING,
comment: "风险分类"
},
fxgk: {
type: DataTypes.TEXT,
comment: "风险概况"
},
kzcs: {
type: DataTypes.TEXT,
comment: "控制措施"
},
czjz: {
type: DataTypes.TEXT,
comment: "处置进展"
},
yjzgwcsj: {
type: DataTypes.DATE,
comment: "预计整改完成时间",
get() {
const rawValue = this.getDataValue('yjzgwcsj');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
},
fxsjje: {
type: DataTypes.DECIMAL(20, 2),
comment: "风险涉及金额"
},
cxgl: {
type: DataTypes.STRING,
comment: "出险概率"
},
fxfxfs: {
type: DataTypes.STRING,
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_zdfxqk', // 指定表名(如果与模型名不同)
timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
});
// 同步模型到数据库(创建表)
TzZdfxqk.sync({
// force: false,
// force: true ,//会删除已存在表并重新创建
alter: true
})
.then(() => {
console.log('TzZdfxqk 表同步成功');
});
module.exports = TzZdfxqk;
\ No newline at end of file
...@@ -61,6 +61,11 @@ router.post('/updateTzkz', projectTzController.updateTzkz); ...@@ -61,6 +61,11 @@ router.post('/updateTzkz', projectTzController.updateTzkz);
router.post('/getTzkzList', projectTzController.getTzkzList); router.post('/getTzkzList', projectTzController.getTzkzList);
router.post('/getTzkzInfo', projectTzController.getTzkzInfo); router.post('/getTzkzInfo', projectTzController.getTzkzInfo);
//重大风险防控
router.post('/createZdfx', projectTzController.createZdfx);
router.post('/updateZdfx', projectTzController.updateZdfx);
router.post('/getZdfxList', projectTzController.getZdfxList);
router.post('/getZdfxInfo', projectTzController.getZdfxInfo);
......
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