明树Git Lab

Commit 5bd58252 authored by zfp1's avatar zfp1

update

parent 5fe27de9
Pipeline #105116 passed with stage
in 3 seconds
......@@ -75,8 +75,8 @@ async function getTzmbzrsList(req, res, next) {
if (req.body.projectName) {
where = {
[Op.or]: [
{projectName: { [Op.like]: `%${req.body.projectName}%` }},
{tzzt: { [Op.like]: `%${req.body.tzzt}%` }}
{ projectName: { [Op.like]: `%${req.body.projectName}%` } },
{ tzzt: { [Op.like]: `%${req.body.tzzt}%` } }
],
del: 0
}
......@@ -96,34 +96,34 @@ async function getTzmbzrsList(req, res, next) {
async function getTzmbzrsInfo(req, res, next) {
try {
let sewhere = {};
if(req.body.id) {
if (req.body.id) {
sewhere.id = req.body.id;
}
if(req.body.projectId) {
if (req.body.projectId) {
sewhere.projectId = req.body.projectId;
}
if(_.isEmpty(sewhere)) {
if (_.isEmpty(sewhere)) {
return res.sendError(errorMessage.paramsError);
}
let zrs = await DB.TzTzmbzrs.findOne({where: {...sewhere, del: 0}, raw: true});
if(!(zrs && zrs.id && zrs.projectId)) {
let zrs = await DB.TzTzmbzrs.findOne({ where: { ...sewhere, del: 0 }, raw: true });
if (!(zrs && zrs.id && zrs.projectId)) {
return res.sendError(errorMessage.resourceNotFound);
}
let tzmbzrsZbs = await DB.TzTzmbzrsZb.findAll({
where: {projectId: zrs.projectId},
where: { projectId: zrs.projectId },
raw: true,
});
// console.log(tzmbzrsZbs, "============", zrs)
//文件处理
let fileIds = [...(zrs.zrswj || []), ...(zrs.chwj || []), ...(zrs.jyglzrs || [])];
let files = await DB.File.findAll({where: {id: {[Op.in]: fileIds}}, raw: true});
let files = await DB.File.findAll({ where: { id: { [Op.in]: fileIds } }, raw: true });
let fileMap = {};
files.map(o => {fileMap[o.id] = o});
files.map(o => { fileMap[o.id] = o });
zrs.zrswj = (zrs.zrswj || []).map(o => {return fileMap[o]});
zrs.chwj = (zrs.chwj || []).map(o => {return fileMap[o]});
zrs.jyglzrs = (zrs.jyglzrs || []).map(o => {return fileMap[o]});
zrs.zrswj = (zrs.zrswj || []).map(o => { return fileMap[o] });
zrs.chwj = (zrs.chwj || []).map(o => { return fileMap[o] });
zrs.jyglzrs = (zrs.jyglzrs || []).map(o => { return fileMap[o] });
zrs.tzmbzrsZbs = tzmbzrsZbs;
return res.sendData(zrs);
......@@ -134,19 +134,19 @@ async function getTzmbzrsInfo(req, res, next) {
async function createTzkz(req, res, next) {
try {
if(!req.body.projectId) {
if (!req.body.projectId) {
return res.sendError(errorMessage.paramsError);
}
//处理文件
req.body.qtjsmbzdpc = (req.body.qtjsmbzdpc || []).map(o => {return o && o.id || o});
req.body.qtjsmbzdpc = (req.body.qtjsmbzdpc || []).map(o => { return o && o.id || o });
//处理财务评价指标
let tzkzcwpjs = (req.body.tzkzcwpjs || []).map(o => {o.projectId = req.body.projectId; return o;});
let tzkzcwpjs = (req.body.tzkzcwpjs || []).map(o => { o.projectId = req.body.projectId; return o; });
delete req.body.tzkzcwpjs;
//处理决策批复意见
let tzkzjcpfyjs = (req.body.tzkzjcpfyjs || []).map(o => {o.projectId = req.body.projectId; return o;});;
let tzkzjcpfyjs = (req.body.tzkzjcpfyjs || []).map(o => { o.projectId = req.body.projectId; return o; });;
delete req.body.tzkzjcpfyjs;
//处理投资收益
let tzkztzsys = (req.body.tzkztzsys || []).map(o => {o.projectId = req.body.projectId; return o;});;
let tzkztzsys = (req.body.tzkztzsys || []).map(o => { o.projectId = req.body.projectId; return o; });;
delete req.body.tzkztzsys;
//处理投资额控制
let flattenArr = [];
......@@ -174,21 +174,132 @@ async function createTzkz(req, res, next) {
}
async function updateTzkz(req, res, next) {
try {
//
if (!req.body.projectId) {
return res.sendError(errorMessage.paramsError);
}
//处理文件
req.body.qtjsmbzdpc = (req.body.qtjsmbzdpc || []).map(o => { return o && o.id || o });
//处理财务评价指标
let ids = [], infos = [], newtzkzcwpjs = [];
req.body.tzkzcwpjs.map(o => { if (!o.id) { if (!_.isEmpty(o)) { o.projectId = req.body.projectId; newtzkzcwpjs.push(o); } } else { ids.push(o.id); infos.push(o); } return o });
await DB.TzTzkzCwpj.destroy({ where: { projectId: req.body.projectId, id: { [Op.notIn]: ids } } }); // 删除id不在传入id数组里面的(用户在界面删除的)
await DB.TzTzkzCwpj.bulkCreate(newtzkzcwpjs);//创建新的 没有id的
await Promise.all(infos.map(item => { DB.TzTzkzCwpj.update(item, { where: { id: item.id } }) }));
delete req.body.tzkzcwpjs;
//处理决策批复意见
let ids1 = [], infos1 = [], newtzkzjcpfyjs = [];
req.body.tzkzjcpfyjs.map(o => { if (!o.id) { if (!_.isEmpty(o)) { o.projectId = req.body.projectId; newtzkzjcpfyjs.push(o); } } else { ids1.push(o.id); infos1.push(o); } return o });
await DB.TzTzkzJcpfyj.destroy({ where: { projectId: req.body.projectId, id: { [Op.notIn]: ids1 } } }); // 删除id不在传入id数组里面的(用户在界面删除的)
await DB.TzTzkzJcpfyj.bulkCreate(newtzkzjcpfyjs);//创建新的 没有id的
await Promise.all(infos1.map(item => { DB.TzTzkzJcpfyj.update(item, { where: { id: item.id } }) }));
delete req.body.tzkzjcpfyjs;
//处理投资收益
let ids2 = [], infos2 = [], newtzkztzsys = [];
req.body.tzkztzsys.map(o => { if (!o.id) { if (!_.isEmpty(o)) { o.projectId = req.body.projectId; newtzkztzsys.push(o); } } else { ids2.push(o.id); infos2.push(o); } return o });
await DB.TzTzkzTzsy.destroy({ where: { projectId: req.body.projectId, id: { [Op.notIn]: ids2 } } }); // 删除id不在传入id数组里面的(用户在界面删除的)
await DB.TzTzkzTzsy.bulkCreate(newtzkztzsys);//创建新的 没有id的
await Promise.all(infos2.map(item => { DB.TzTzkzTzsy.update(item, { where: { id: item.id } }) }));
delete req.body.tzkztzsys;
//处理投资额控制
let tzkztzekzs = req.body.tzkztzekzs || [[]]; //二维数组 多次上报
let ids3 = [], infos3 = [], newtzkztzekzs = [];
for (let index = 0; index < tzkztzekzs.length; index++) {
const element = tzkztzekzs[index];
for (let i = 0; i < element.length; i++) {
let ei = element[i];
ei.groupBy = index;
ei.projectId = req.body.projectId;
if (!ei.id) {
if (!_.isEmpty(ei)) {
newtzkztzekzs.push(ei);
}
} else {
ids3.push(ei.id); infos3.push(ei);
}
}
}
await DB.TzTzkzTzekz.destroy({ where: { projectId: req.body.projectId, id: { [Op.notIn]: ids3 } } }); // 删除id不在传入id数组里面的(用户在界面删除的)
await DB.TzTzkzTzekz.bulkCreate(newtzkztzekzs);//创建新的 没有id的
await Promise.all(infos3.map(item => { DB.TzTzkzTzekz.update(item, { where: { id: item.id } }) }));
delete req.body.tzkztzekzs;
await DB.TzTzkz.update(req.body, {where: {id: req.body.id}});
return res.sendData();
} catch (error) {
next(error);
}
}
async function getTzkzList(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}%` } },
{ tzglzt: { [Op.like]: `%${req.body.tzglzt}%` } },
{ jcdw: { [Op.like]: `%${req.body.jcdw}%` } },
],
del: 0
}
}
search.where = where;
if (req.body.attributes && req.body.attributes.length) {
search.attributes = req.body.attributes;
}
let ret = await DB.TzTzkz.findAndCountAll(search);
return res.sendData(ret);
} catch (error) {
next(error);
}
}
async function getTzkzInfo(req, res, next) {
try {
let tzkz = await DB.TzTzkz.findOne({ where: { id: req.body.id }, raw: true });
if (!(tzkz && tzkz.id)) {
return res.sendError(errorMessage.resourceNotFound);
}
// 文件
if (tzkz.qtjsmbzdpc && tzkz.qtjsmbzdpc.length > 0) {
let files = await DB.File.findAll({ where: { id: { [Op.in]: tzkz.qtjsmbzdpc } }, raw: true });
tzkz.qtjsmbzdpc = files;
}
//
let tzkzcwpjs = await DB.TzTzkzCwpj.findAll({
where: { projectId: tzkz.projectId },
raw: true,
});
tzkz.tzkzcwpjs = tzkzcwpjs || [];
let tzkzjcpfyjs = await DB.TzTzkzJcpfyj.findAll({
where: { projectId: tzkz.projectId },
raw: true
});
tzkz.tzkzjcpfyjs = tzkzjcpfyjs || [];
let tzkztzsys = await DB.TzTzkzTzsy.findAll({
where: { projectId: tzkz.projectId },
raw: true
});
tzkz.tzkztzsys = tzkztzsys || [];
let tzkztzekzs = await DB.TzTzkzTzekz.findAll({
where: { projectId: tzkz.projectId },
raw: true
});
tzkz.tzkztzekzs = _.values(_.groupBy(tzkztzekzs, 'groupBy')) || [[]]
return res.sendData(tzkz);
} catch (error) {
next(error);
}
......
......@@ -308,7 +308,7 @@ const Project = sequelize.define('Project', {
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
const rawValue = this.getDataValue('updatedAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
}
......
......@@ -96,7 +96,7 @@ const projectBjtj = sequelize.define('projectBjtj', {
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
const rawValue = this.getDataValue('updatedAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
}
......
......@@ -41,7 +41,7 @@ const projectCwpjbjtj = sequelize.define('projectCwpjbjtj', {
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
const rawValue = this.getDataValue('updatedAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
}
......
......@@ -44,7 +44,7 @@ const projectCwpjzb = sequelize.define('projectCwpjzb', {
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
const rawValue = this.getDataValue('updatedAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
}
......
......@@ -34,7 +34,7 @@ const ProjectFile = sequelize.define('ProjectFile', {
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
const rawValue = this.getDataValue('updatedAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
}
......
......@@ -41,7 +41,7 @@ const ProjectFxgl = sequelize.define('ProjectFxgl', {
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
const rawValue = this.getDataValue('updatedAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
}
......
......@@ -79,7 +79,7 @@ const ProjectGdxx = sequelize.define('ProjectGdxx', {
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
const rawValue = this.getDataValue('updatedAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
}
......
......@@ -45,7 +45,7 @@ const ProjectJczt = sequelize.define('ProjectJczt', {
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
const rawValue = this.getDataValue('updatedAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
}
......
......@@ -45,7 +45,7 @@ const ProjectJsgm = sequelize.define('ProjectJsgm', {
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
const rawValue = this.getDataValue('updatedAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
}
......
......@@ -44,7 +44,7 @@ const ProjectLcbjd = sequelize.define('ProjectLcbjd', {
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
const rawValue = this.getDataValue('updatedAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
}
......
......@@ -56,7 +56,7 @@ const ProjectSpyj = sequelize.define('ProjectSpyj', {
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
const rawValue = this.getDataValue('updatedAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
}
......
......@@ -55,7 +55,7 @@ const ProjectSpyjjc = sequelize.define('ProjectSpyjjc', {
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
const rawValue = this.getDataValue('updatedAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
}
......
......@@ -33,7 +33,7 @@ const ProjectTzsyzb = sequelize.define('ProjectTzsyzb', {
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
const rawValue = this.getDataValue('updatedAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
}
......
......@@ -35,7 +35,7 @@ const ProjectTzzjll = sequelize.define('ProjectTzzjll', {
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
const rawValue = this.getDataValue('updatedAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
}
......
......@@ -41,7 +41,7 @@ const ProjectTzzt = sequelize.define('ProjectTzzt', {
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
const rawValue = this.getDataValue('updatedAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
}
......
......@@ -60,7 +60,7 @@ const ProjectXmtzze = sequelize.define('ProjectXmtzze', {
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
const rawValue = this.getDataValue('updatedAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
}
......
......@@ -48,7 +48,7 @@ const Resources = sequelize.define('Resources', {
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
const rawValue = this.getDataValue('updatedAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
}
......
......@@ -55,7 +55,7 @@ const TzTzkz = sequelize.define('TzTzkz', {
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
const rawValue = this.getDataValue('updatedAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
}
......
......@@ -47,7 +47,7 @@ const TzTzkzCwpj = sequelize.define('TzTzkzCwpj', {
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
const rawValue = this.getDataValue('updatedAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
}
......
......@@ -62,7 +62,7 @@ const TzTzkzJcpfyj = sequelize.define('TzTzkzJcpfyj', {
type: DataTypes.DATE,
comment: "预计完成时间",
get() {
const rawValue = this.getDataValue('createdAt');
const rawValue = this.getDataValue('yjwcsj');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
},
......@@ -108,7 +108,7 @@ const TzTzkzJcpfyj = sequelize.define('TzTzkzJcpfyj', {
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
const rawValue = this.getDataValue('updatedAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
}
......
......@@ -100,7 +100,7 @@ const TzTzkzTzekz = sequelize.define('TzTzkzTzekz', {
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
const rawValue = this.getDataValue('updatedAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
}
......
......@@ -41,7 +41,7 @@ const TzTzkzTzsy = sequelize.define('TzTzkzTzsy', {
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
const rawValue = this.getDataValue('updatedAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
}
......
......@@ -76,7 +76,7 @@ const TzTzmbzrs = sequelize.define('TzTzmbzrs', {
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
const rawValue = this.getDataValue('updatedAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
}
......
......@@ -60,7 +60,7 @@ const TzTzmbzrsZb = sequelize.define('TzTzmbzrsZb', {
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
const rawValue = this.getDataValue('updatedAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
}
......
......@@ -37,7 +37,7 @@ const Depart = sequelize.define('Depart', {
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
const rawValue = this.getDataValue('updatedAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
}
......
......@@ -66,7 +66,7 @@ const ExcelRecord = sequelize.define('ExcelRecord', {
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
const rawValue = this.getDataValue('updatedAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
}
......
......@@ -49,7 +49,7 @@ const File = sequelize.define('File', {
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
const rawValue = this.getDataValue('updatedAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
}
......
......@@ -64,7 +64,7 @@ const Menu = sequelize.define('Menu', {
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
const rawValue = this.getDataValue('updatedAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
}
......
......@@ -38,7 +38,7 @@ const Position = sequelize.define('Position', {
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
const rawValue = this.getDataValue('updatedAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
}
......
......@@ -39,7 +39,7 @@ const Role = sequelize.define('Role', {
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
const rawValue = this.getDataValue('updatedAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
}
......
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