明树Git Lab

Commit ce2096fc authored by zfp1's avatar zfp1

update

parent 4ffa5160
Pipeline #105972 passed with stage
in 3 seconds
...@@ -22,8 +22,21 @@ async function createTzmbzrs(req, res, next) { ...@@ -22,8 +22,21 @@ async function createTzmbzrs(req, res, next) {
//处理 责任指标 表 //处理 责任指标 表
let tzmbzrsZbs = (req.body.tzmbzrsZbs || []).map(o => { o.projectId = req.body.projectId; return o }); let tzmbzrsZbs = (req.body.tzmbzrsZbs || []).map(o => { o.projectId = req.body.projectId; return o });
delete req.body.tzmbzrsZbs; delete req.body.tzmbzrsZbs;
//1.创建指标表数据 //处理 批复意见
let tzmbzrsPfyjs =(req.body.tzmbzrsPfyjs || []).map(o => { o.projectId = req.body.projectId; return o });
//处理 年度经营责任书
let tzmbzrsNds = (req.body.tzmbzrsPfyjs || []).map(o => {
o.projectId = req.body.projectId;
// o.jyglzrs = o.jyglzrs || [];
// o.jyglzrs = o.jyglzrs.map(j => { return j && j.id || j});
return o
});
//创建指标表数据
await DB.TzTzmbzrsZb.bulkCreate(tzmbzrsZbs); await DB.TzTzmbzrsZb.bulkCreate(tzmbzrsZbs);
await DB.TzTzmbzrsPfyj.bulkCreate(tzmbzrsPfyjs);
await DB.TzTzmbzrsNd.bulkCreate(tzmbzrsNds);
//
//创建投资目标责任书数据 //创建投资目标责任书数据
let ret = await DB.TzTzmbzrs.create(req.body); let ret = await DB.TzTzmbzrs.create(req.body);
return res.sendData(ret); return res.sendData(ret);
...@@ -43,13 +56,28 @@ async function updateTzmbzrs(req, res, next) { ...@@ -43,13 +56,28 @@ async function updateTzmbzrs(req, res, next) {
req.body.jyglzrs = (req.body.jyglzrs || []).map(o => { return o && o.id }); req.body.jyglzrs = (req.body.jyglzrs || []).map(o => { return o && o.id });
//处理 责任指标 表 //处理 责任指标 表
let tzmbzrsZbs = req.body.tzmbzrsZbs || [] let tzmbzrsZbs = req.body.tzmbzrsZbs || []
let tzmbzrsPfyjs = req.body.tzmbzrsPfyjs || []
let tzmbzrsNds = req.body.tzmbzrsNds || []
delete req.body.tzmbzrsZbs; delete req.body.tzmbzrsZbs;
delete req.body.tzmbzrsPfyjs;
delete req.body.tzmbzrsNds;
//1.更新责任指标表数据 //1.更新责任指标表数据
let ids = [], infos = [], newtzmbzrsZbs = []; let ids = [], infos = [], newtzmbzrsZbs = [];
tzmbzrsZbs.map(o => { if (!o.id) { if (!_.isEmpty(o)) { o.projectId = req.body.projectId; newtzmbzrsZbs.push(o); } } else { ids.push(o.id); infos.push(o); } return o }); tzmbzrsZbs.map(o => { if (!o.id) { if (!_.isEmpty(o)) { o.projectId = req.body.projectId; newtzmbzrsZbs.push(o); } } else { ids.push(o.id); infos.push(o); } return o });
await DB.TzTzmbzrsZb.destroy({ where: { projectId: req.body.projectId, id: { [Op.notIn]: ids } } }); // 删除id不在传入id数组里面的(用户在界面删除的) await DB.TzTzmbzrsZb.destroy({ where: { projectId: req.body.projectId, id: { [Op.notIn]: ids } } }); // 删除id不在传入id数组里面的(用户在界面删除的)
await DB.TzTzmbzrsZb.bulkCreate(newtzmbzrsZbs);//创建新的 没有id的 await DB.TzTzmbzrsZb.bulkCreate(newtzmbzrsZbs);//创建新的 没有id的
await Promise.all(infos.map(item => { DB.TzTzmbzrsZb.update(item, { where: { id: item.id } }) })); await Promise.all(infos.map(item => { DB.TzTzmbzrsZb.update(item, { where: { id: item.id } }) }));
//1.更新批复意见
let ids1 = [], infos1 = [], newtzmbzrsPfyjs= [];
tzmbzrsPfyjs.map(o => { if (!o.id) { if (!_.isEmpty(o)) { o.projectId = req.body.projectId; newtzmbzrsPfyjs.push(o); } } else { ids1.push(o.id); infos1.push(o); } return o });
await DB.TzTzmbzrsPfyj.destroy({ where: { projectId: req.body.projectId, id: { [Op.notIn]: ids1 } } }); // 删除id不在传入id数组里面的(用户在界面删除的)
await DB.TzTzmbzrsPfyj.bulkCreate(newtzmbzrsPfyjs);//创建新的 没有id的
await Promise.all(infos1.map(item => { DB.TzTzmbzrsPfyj.update(item, { where: { id: item.id } }) }));
let ids2 = [], infos2 = [], newtzmbzrsNds= [];
tzmbzrsNds.map(o => { if (!o.id) { if (!_.isEmpty(o)) { o.projectId = req.body.projectId; newtzmbzrsNds.push(o); } } else { ids2.push(o.id); infos2.push(o); } return o });
await DB.TzTzmbzrsNd.destroy({ where: { projectId: req.body.projectId, id: { [Op.notIn]: ids2 } } }); // 删除id不在传入id数组里面的(用户在界面删除的)
await DB.TzTzmbzrsNd.bulkCreate(newtzmbzrsNds);//创建新的 没有id的
await Promise.all(infos2.map(item => { DB.TzTzmbzrsNd.update(item, { where: { id: item.id } }) }));
//2.更新责任书 //2.更新责任书
let ret = await DB.TzTzmbzrs.update(req.body, { where: { id: req.body.id } }); let ret = await DB.TzTzmbzrs.update(req.body, { where: { id: req.body.id } });
...@@ -113,6 +141,14 @@ async function getTzmbzrsInfo(req, res, next) { ...@@ -113,6 +141,14 @@ async function getTzmbzrsInfo(req, res, next) {
where: { projectId: zrs.projectId }, where: { projectId: zrs.projectId },
raw: true, raw: true,
}); });
let tzmbzrsPfyjs = await DB.TzTzmbzrsPfyj.findAll({
where: { projectId: zrs.projectId },
raw: true,
});
let tzmbzrsNds = await DB.TzTzmbzrsNd.findAll({
where: { projectId: zrs.projectId },
raw: true,
});
// console.log(tzmbzrsZbs, "============", zrs) // console.log(tzmbzrsZbs, "============", zrs)
//文件处理 //文件处理
...@@ -126,6 +162,8 @@ async function getTzmbzrsInfo(req, res, next) { ...@@ -126,6 +162,8 @@ async function getTzmbzrsInfo(req, res, next) {
zrs.jyglzrs = (zrs.jyglzrs || []).map(o => { return fileMap[o] }); zrs.jyglzrs = (zrs.jyglzrs || []).map(o => { return fileMap[o] });
zrs.tzmbzrsZbs = tzmbzrsZbs; zrs.tzmbzrsZbs = tzmbzrsZbs;
zrs.tzmbzrsPfyjs = tzmbzrsPfyjs;
zrs.tzmbzrsNds = tzmbzrsNds;
return res.sendData(zrs); return res.sendData(zrs);
} catch (error) { } catch (error) {
next(error); next(error);
......
...@@ -40,6 +40,8 @@ const ProjectSpyjjc = require('./model/jt/projectSpyjjc') ...@@ -40,6 +40,8 @@ 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 TzTzmbzrsZb = require("./model/jt/tzTzmbzrsZb");
const TzTzmbzrsNd = require("./model/jt/tzTzmbzrsNd");
const TzTzmbzrsPfyj = require("./model/jt/tzTzmbzrsPfyj");
const TzTzkz = require("./model/jt/tzTzkz"); const TzTzkz = require("./model/jt/tzTzkz");
const TzTzkzJcpfyj = require("./model/jt/tzTzkzJcpfyj"); const TzTzkzJcpfyj = require("./model/jt/tzTzkzJcpfyj");
...@@ -115,6 +117,8 @@ global.DB = { ...@@ -115,6 +117,8 @@ global.DB = {
ProjectSpyjjc, ProjectSpyjjc,
TzTzmbzrs, TzTzmbzrs,
TzTzmbzrsZb, TzTzmbzrsZb,
TzTzmbzrsNd,
TzTzmbzrsPfyj,
TzTzkz, TzTzkz,
TzTzkzJcpfyj, TzTzkzJcpfyj,
TzTzkzTzekz, TzTzkzTzekz,
......
const { DataTypes } = require('sequelize');
const sequelize = require('../index');
const moment = require('moment');
//投中管理-投资目标责任书-考核指标
const TzTzmbzrsNd = sequelize.define('TzTzmbzrsNd', {
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') : '';
}
},
jyglzrs: {
type: DataTypes.JSON,
comment: "经营管理责任书",
},
sm: {
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_tzmbzrs_nd', // 指定表名(如果与模型名不同)
timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
});
// 同步模型到数据库(创建表)
TzTzmbzrsNd.sync({
// force: false,
// force: true ,//会删除已存在表并重新创建
alter: true
})
.then(() => {
console.log('TzTzmbzrsNd 表同步成功');
});
module.exports = TzTzmbzrsNd;
\ No newline at end of file
const { DataTypes } = require('sequelize');
const sequelize = require('../index');
const moment = require('moment');
//投中管理-投资目标责任书-考核指标
const TzTzmbzrsPfyj = sequelize.define('TzTzmbzrsPfyj', {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true
},
lx: {
type: DataTypes.INTEGER,
comment: "类型",
},
pfyj: {
type: DataTypes.TEXT,
comment: "批复意见",
},
jzf: {
type: DataTypes.INTEGER,
comment: "基准分",
},
lsqk: {
type: DataTypes.INTEGER,
comment: "落实情况 已落实、未落实、持续落实、部分已落实",
},
lsqkjtsm: {
type: DataTypes.TEXT,
comment: "落实情况具体说明",
},
lssj: {
type: DataTypes.DATE,
comment: "落实时间",
get() {
const rawValue = this.getDataValue('lssj');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
},
khgz: {
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_tzmbzrs_pfyj', // 指定表名(如果与模型名不同)
timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
});
// 同步模型到数据库(创建表)
TzTzmbzrsPfyj.sync({
// force: false,
// force: true ,//会删除已存在表并重新创建
alter: true
})
.then(() => {
console.log('TzTzmbzrsPfyj 表同步成功');
});
module.exports = TzTzmbzrsPfyj;
\ No newline at end of file
...@@ -21,23 +21,30 @@ const TzTzmbzrsZb = sequelize.define('TzTzmbzrsZb', { ...@@ -21,23 +21,30 @@ const TzTzmbzrsZb = sequelize.define('TzTzmbzrsZb', {
type: DataTypes.INTEGER, type: DataTypes.INTEGER,
comment: "指标目标值", comment: "指标目标值",
}, },
zbsjz: { // zbsjz: {
type: DataTypes.INTEGER, // type: DataTypes.INTEGER,
comment: "指标实际值", // comment: "指标实际值",
}, // },
khjzf: { khjzf: {
type: DataTypes.INTEGER, type: DataTypes.INTEGER,
comment: "考核基准分", comment: "考核基准分",
}, },
khkf: { // khkf: {
// type: DataTypes.INTEGER,
// comment: "考核扣分",
// },
// khdf: {
// type: DataTypes.INTEGER,
// comment: "考核得分",
// },
sfsy: {
type: DataTypes.INTEGER, type: DataTypes.INTEGER,
comment: "考核扣分", comment: "是否适用",
}, },
khdf: { khsm: {
type: DataTypes.INTEGER, type: DataTypes.TEXT,
comment: "考核得分", comment: "考核说明",
}, },
projectId: { projectId: {
type: DataTypes.INTEGER, type: DataTypes.INTEGER,
......
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