明树Git Lab

Commit ccb3856e authored by zfp1's avatar zfp1

update

parent 742f9ba0
Pipeline #105417 passed with stage
in 3 seconds
...@@ -598,7 +598,7 @@ async function createJsqtzjc(req, res, next) { ...@@ -598,7 +598,7 @@ async function createJsqtzjc(req, res, next) {
} }
} }
async function getJsqtzjcInfo (req, res, next) { async function getJsqtzjcInfo(req, res, next) {
try { try {
let search = {}; let search = {};
if (req.body.id) { if (req.body.id) {
...@@ -610,31 +610,31 @@ async function getJsqtzjcInfo (req, res, next) { ...@@ -610,31 +610,31 @@ async function getJsqtzjcInfo (req, res, next) {
if (_.isEmpty(search)) { if (_.isEmpty(search)) {
return res.sendError(errorMessage.paramsError); return res.sendError(errorMessage.paramsError);
} }
let jsqtzjc = await DB.TzJsqtzjc.findOne({where: search, raw: true}); let jsqtzjc = await DB.TzJsqtzjc.findOne({ where: search, raw: true });
if(!(jsqtzjc && jsqtzjc.id && jsqtzjc.projectId)) { if (!(jsqtzjc && jsqtzjc.id && jsqtzjc.projectId)) {
return res.sendError(errorMessage.resourceNotFound); return res.sendError(errorMessage.resourceNotFound);
} }
let newjsqtzjcTzfxs = [], newjsqtzjcrcjcs = [], newjsqtzjcZxjcs = []; let newjsqtzjcTzfxs = [], newjsqtzjcrcjcs = [], newjsqtzjcZxjcs = [];
let jsqtzjcTzfxs = await DB.TzJsqtzjcTzfx.findAll({where: {projectId: jsqtzjc.projectId}, raw: true}); let jsqtzjcTzfxs = await DB.TzJsqtzjcTzfx.findAll({ where: { projectId: jsqtzjc.projectId }, raw: true });
for (let index = 0; index < jsqtzjcTzfxs.length; index++) { for (let index = 0; index < jsqtzjcTzfxs.length; index++) {
let element = jsqtzjcTzfxs[index]; let element = jsqtzjcTzfxs[index];
// fileids.concat(element.tzcbfxhzl || []); // fileids.concat(element.tzcbfxhzl || []);
element.tzcbfxhzl = await DB.File.findAll({where: {id: {[Op.in]: element.tzcbfxhzl}}}); element.tzcbfxhzl = await DB.File.findAll({ where: { id: { [Op.in]: element.tzcbfxhzl } } });
newjsqtzjcTzfxs.push(element); newjsqtzjcTzfxs.push(element);
} }
let jsqtzjcrcjcs = await DB.TzJsqtzjcrcjc.findAll({where: {projectId: jsqtzjc.projectId}, raw: true}); let jsqtzjcrcjcs = await DB.TzJsqtzjcrcjc.findAll({ where: { projectId: jsqtzjc.projectId }, raw: true });
for (let index = 0; index < jsqtzjcrcjcs.length; index++) { for (let index = 0; index < jsqtzjcrcjcs.length; index++) {
const element = jsqtzjcrcjcs[index]; const element = jsqtzjcrcjcs[index];
// fileids.concat(element.fxcl || []); // fileids.concat(element.fxcl || []);
element.fxcl = await DB.File.findAll({where: {id: {[Op.in]: element.fxcl}}}); element.fxcl = await DB.File.findAll({ where: { id: { [Op.in]: element.fxcl } } });
newjsqtzjcrcjcs.push(element); newjsqtzjcrcjcs.push(element);
} }
let jsqtzjcZxjcs = await DB.TzJsqtzjcZxjc.findAll({where: {projectId: jsqtzjc.projectId}, raw: true}); let jsqtzjcZxjcs = await DB.TzJsqtzjcZxjc.findAll({ where: { projectId: jsqtzjc.projectId }, raw: true });
for (let index = 0; index < jsqtzjcZxjcs.length; index++) { for (let index = 0; index < jsqtzjcZxjcs.length; index++) {
const element = jsqtzjcZxjcs[index]; const element = jsqtzjcZxjcs[index];
// fileids.concat(element.fjcl || []); // fileids.concat(element.fjcl || []);
element.fjcl = await DB.File.findAll({where: {id: {[Op.in]: element.fjcl}}}); element.fjcl = await DB.File.findAll({ where: { id: { [Op.in]: element.fjcl } } });
newjsqtzjcZxjcs.push(element); newjsqtzjcZxjcs.push(element);
} }
...@@ -657,8 +657,8 @@ async function updateJsqtzjc(req, res, next) { ...@@ -657,8 +657,8 @@ async function updateJsqtzjc(req, res, next) {
for (let index = 0; index < jsqtzjcTzfxs.length; index++) { for (let index = 0; index < jsqtzjcTzfxs.length; index++) {
let element = jsqtzjcTzfxs[index]; let element = jsqtzjcTzfxs[index];
element.projectId = req.body.projectId; element.projectId = req.body.projectId;
element.tzcbfxhzl = (element.tzcbfxhzl || []).map(o => {return o && o.id || o}); element.tzcbfxhzl = (element.tzcbfxhzl || []).map(o => { return o && o.id || o });
if(element.id) { if (element.id) {
ids.push(element.id); ids.push(element.id);
info.push(element); info.push(element);
} else { } else {
...@@ -675,8 +675,8 @@ async function updateJsqtzjc(req, res, next) { ...@@ -675,8 +675,8 @@ async function updateJsqtzjc(req, res, next) {
for (let index = 0; index < jsqtzjcrcjcs.length; index++) { for (let index = 0; index < jsqtzjcrcjcs.length; index++) {
let element = jsqtzjcrcjcs[index]; let element = jsqtzjcrcjcs[index];
element.projectId = req.body.projectId; element.projectId = req.body.projectId;
element.fxcl = (element.fxcl || []).map(o => {return o && o.id || o}); element.fxcl = (element.fxcl || []).map(o => { return o && o.id || o });
if(element.id) { if (element.id) {
ids1.push(element.id); ids1.push(element.id);
info1.push(element); info1.push(element);
} else { } else {
...@@ -694,8 +694,8 @@ async function updateJsqtzjc(req, res, next) { ...@@ -694,8 +694,8 @@ async function updateJsqtzjc(req, res, next) {
for (let index = 0; index < jsqtzjcZxjcs.length; index++) { for (let index = 0; index < jsqtzjcZxjcs.length; index++) {
let element = jsqtzjcZxjcs[index]; let element = jsqtzjcZxjcs[index];
element.projectId = req.body.projectId; element.projectId = req.body.projectId;
element.fjcl = (element.fjcl || []).map(o => {return o && o.id || o}); element.fjcl = (element.fjcl || []).map(o => { return o && o.id || o });
if(element.id) { if (element.id) {
ids2.push(element.id); ids2.push(element.id);
info2.push(element); info2.push(element);
} else { } else {
...@@ -713,7 +713,7 @@ async function updateJsqtzjc(req, res, next) { ...@@ -713,7 +713,7 @@ async function updateJsqtzjc(req, res, next) {
next(error); next(error);
} }
} }
async function getJsqtzjcList (req, res, next) { async function getJsqtzjcList(req, res, next) {
try { try {
let page = req.body.page || 1; let page = req.body.page || 1;
let limit = req.body.pagesize || req.body.pageSize || 10; let limit = req.body.pagesize || req.body.pageSize || 10;
...@@ -754,8 +754,8 @@ async function createZdsxsp(req, res, next) { ...@@ -754,8 +754,8 @@ async function createZdsxsp(req, res, next) {
let newArr = []; let newArr = [];
for (let index = 0; index < zdsxspfls.length; index++) { for (let index = 0; index < zdsxspfls.length; index++) {
const element = zdsxspfls[index]; const element = zdsxspfls[index];
element.projectId = projectId; element.projectId = req.body.projectId;
element.wj = (element.wj || []).map(o => {return o && o.id || o}); element.wj = (element.wj || []).map(o => { return o && o.id || o });
newArr.push(element); newArr.push(element);
} }
delete req.body.zdsxspfls; delete req.body.zdsxspfls;
...@@ -767,7 +767,7 @@ async function createZdsxsp(req, res, next) { ...@@ -767,7 +767,7 @@ async function createZdsxsp(req, res, next) {
} }
} }
async function getZdsxspInfo (req, res, next) { async function getZdsxspInfo(req, res, next) {
try { try {
let search = {}; let search = {};
if (req.body.id) { if (req.body.id) {
...@@ -779,23 +779,23 @@ async function getZdsxspInfo (req, res, next) { ...@@ -779,23 +779,23 @@ async function getZdsxspInfo (req, res, next) {
if (_.isEmpty(search)) { if (_.isEmpty(search)) {
return res.sendError(errorMessage.paramsError); return res.sendError(errorMessage.paramsError);
} }
let zdsxsp = await DB.TzZdsxsp.findOne({where: search, raw: true}); let zdsxsp = await DB.TzZdsxsp.findOne({ where: search, raw: true });
if(!(zdsxsp && zdsxsp.id && zdsxsp.projectId)) { if (!(zdsxsp && zdsxsp.id && zdsxsp.projectId)) {
return res.sendError(errorMessage.resourceNotFound); return res.sendError(errorMessage.resourceNotFound);
} }
let zdsxspfls = await DB.TzZdsxspfl.findAll({ let zdsxspfls = await DB.TzZdsxspfl.findAll({
where: {projectId: req.body.projectId}, where: { projectId: zdsxsp.projectId },
raw: true, raw: true,
}); });
let newArr = []; let newArr = [];
for (let index = 0; index < zdsxspfls.length; index++) { for (let index = 0; index < zdsxspfls.length; index++) {
const element = zdsxspfls[index]; const element = zdsxspfls[index];
if(element.wj && element.wj.length > 0) { if (element.wj && element.wj.length > 0) {
element.wj = await DB.File.findAll({where: {id: {[Op.in]: element.wj}}, raw: true}); element.wj = await DB.File.findAll({ where: { id: { [Op.in]: element.wj } }, raw: true });
} }
newArr.push(element); newArr.push(element);
} }
zdsxsp.zdsxspfls = zdsxspfls; zdsxsp.zdsxspfls = newArr;
return res.sendData(zdsxsp); return res.sendData(zdsxsp);
} catch (error) { } catch (error) {
next(error); next(error);
...@@ -806,13 +806,31 @@ async function updateZdsxsp(req, res, next) { ...@@ -806,13 +806,31 @@ async function updateZdsxsp(req, res, next) {
if (!req.body.projectId) { if (!req.body.projectId) {
return res.sendError(errorMessage.paramsError); return res.sendError(errorMessage.paramsError);
} }
let zdsxspfls = req.body.zdsxspfls || [];
let ids = [], info = [], newArr = [];
for (let index = 0; index < zdsxspfls.length; index++) {
const element = zdsxspfls[index];
element.projectId = req.body.projectId;
element.wj = (element.wj || []).map(o => { return o && o.id || o });
if (element.id) {
ids.push(element.id);
info.push(element);
} else {
newArr.push(element);
}
}
await DB.TzZdsxspfl.destroy({ where: { projectId: req.body.projectId, id: { [Op.notIn]: ids } } }); // 删除id不在传入id数组里面的(用户在界面删除的)
await DB.TzZdsxspfl.bulkCreate(newArr);//创建新的 没有id的
await Promise.all(info.map(item => { DB.TzZdsxspfl.update(item, { where: { id: item.id } }) }));
delete req.body.zdsxspfls;
await DB.TzZdsxsp.update(req.body, {where: {id: req.body.id}});
return res.sendData({}); return res.sendData({});
} catch (error) { } catch (error) {
next(error); next(error);
} }
} }
async function getZdsxspList (req, res, next) { async function getZdsxspList(req, res, next) {
try { try {
let page = req.body.page || 1; let page = req.body.page || 1;
let limit = req.body.pagesize || req.body.pageSize || 10; let limit = req.body.pagesize || req.body.pageSize || 10;
...@@ -824,20 +842,124 @@ async function getZdsxspList (req, res, next) { ...@@ -824,20 +842,124 @@ async function getZdsxspList (req, res, next) {
search.offset = offset; search.offset = offset;
let where = { del: 0 }; let where = { del: 0 };
// if (req.body.projectName) { if (req.body.projectName) {
// where = { where = {
// [Op.or]: [ [Op.or]: [
// { projectName: { [Op.like]: `%${req.body.projectName}%` } }, { projectName: { [Op.like]: `%${req.body.projectName}%` } },
// ], ],
// del: 0 del: 0
// } }
// } }
search.where = where; search.where = where;
if (req.body.attributes && req.body.attributes.length) { if (req.body.attributes && req.body.attributes.length) {
search.attributes = req.body.attributes; search.attributes = req.body.attributes;
} }
let ret = await DB.TzJsqtzjc.findAndCountAll(search); let ret = await DB.TzZdsxsp.findAndCountAll(search);
return res.sendData(ret);
} catch (error) {
next(error);
}
}
async function createXmtc(req, res, next) {
try {
if (!req.body.projectId) {
return res.sendError(errorMessage.paramsError);
}
// 1. 文件
req.body.tcwj = (req.body.tcwj || []).map(o => { return o && o.id || o});
let tccwzbs = (req.body.tccwzbs || []).map(o => {o.projectId = req.body.projectId; return o;});
delete req.body.tccwzbs;
await DB.TzXmtcCwzb.bulkCreate(tccwzbs);
let ret = await DB.TzXmtc.create(req.body);
return res.sendData(ret);
} catch (error) {
next(error);
}
}
async function getXmtcInfo(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 xmtc = await DB.TzXmtc.findOne({ where: search, raw: true });
if (!(xmtc && xmtc.id && xmtc.projectId)) {
return res.sendError(errorMessage.resourceNotFound);
}
let tccwzbs = await DB.TzXmtcCwzb.findAll({
where: { projectId: xmtc.projectId },
raw: true,
});
xmtc.tccwzbs = tccwzbs;
return res.sendData(xmtc);
} catch (error) {
next(error);
}
}
async function updateXmtc(req, res, next) {
try {
if (!req.body.projectId) {
return res.sendError(errorMessage.paramsError);
}
let tccwzbs = req.body.tccwzbs || [];
let ids = [], info = [], newArr = [];
for (let index = 0; index < tccwzbs.length; index++) {
const element = tccwzbs[index];
element.projectId = req.body.projectId;
element.wj = (element.wj || []).map(o => { return o && o.id || o });
if (element.id) {
ids.push(element.id);
info.push(element);
} else {
newArr.push(element);
}
}
await DB.TzXmtcCwzb.destroy({ where: { projectId: req.body.projectId, id: { [Op.notIn]: ids } } }); // 删除id不在传入id数组里面的(用户在界面删除的)
await DB.TzXmtcCwzb.bulkCreate(newArr);//创建新的 没有id的
await Promise.all(info.map(item => { DB.TzXmtcCwzb.update(item, { where: { id: item.id } }) }));
delete req.body.tccwzbs;
await DB.TzXmtc.update(req.body, {where: {id: req.body.id}});
return res.sendData({});
} catch (error) {
next(error);
}
}
async function getXmtcList(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.TzXmtc.findAndCountAll(search);
return res.sendData(ret); return res.sendData(ret);
} catch (error) { } catch (error) {
next(error); next(error);
...@@ -871,4 +993,8 @@ module.exports = { ...@@ -871,4 +993,8 @@ module.exports = {
getZdsxspInfo, getZdsxspInfo,
updateZdsxsp, updateZdsxsp,
getZdsxspList, getZdsxspList,
createXmtc,
getXmtcInfo,
updateXmtc,
getXmtcList,
} }
\ No newline at end of file
...@@ -61,6 +61,8 @@ const TzJsqtzjcZxjc = require("./model/jt/tzJsqtzjcZxjc"); ...@@ -61,6 +61,8 @@ const TzJsqtzjcZxjc = require("./model/jt/tzJsqtzjcZxjc");
const TzZdsxsp = require("./model/jt/tzZdsxsp"); const TzZdsxsp = require("./model/jt/tzZdsxsp");
const TzZdsxspfl = require("./model/jt/tzZdsxspfl"); const TzZdsxspfl = require("./model/jt/tzZdsxspfl");
const TzXmtc = require("./model/jt/tzXmtc");
const TzXmtcCwzb = require("./model/jt/tzXmtcCwzb");
/** /**
* 业务表 * 业务表
...@@ -120,6 +122,8 @@ global.DB = { ...@@ -120,6 +122,8 @@ global.DB = {
TzJsqtzjcZxjc, TzJsqtzjcZxjc,
TzZdsxsp, TzZdsxsp,
TzZdsxspfl, TzZdsxspfl,
TzXmtc,
TzXmtcCwzb,
} }
......
...@@ -9,6 +9,11 @@ const TzJsqtzjc = sequelize.define('TzJsqtzjc', { ...@@ -9,6 +9,11 @@ const TzJsqtzjc = sequelize.define('TzJsqtzjc', {
primaryKey: true, primaryKey: true,
autoIncrement: true autoIncrement: true
}, },
projectName: {
type: DataTypes.STRING,
comment: "项目名称",
},
jcztz: { jcztz: {
type: DataTypes.DECIMAL(20, 2), type: DataTypes.DECIMAL(20, 2),
comment: "决策总投资 一次填报锁定" comment: "决策总投资 一次填报锁定"
......
const { DataTypes } = require('sequelize');
const sequelize = require('../index');
const moment = require('moment');
//投中管理- 重大事项审批
const TzXmtc = sequelize.define('TzXmtc', {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true
},
/* -------------------TODO: 缺少内容------------------------------------- */
projectName: {
type: DataTypes.STRING,
comment: "项目名称",
},
tcfs: {
type: DataTypes.STRING,
comment: "退出方式"
},
sjtcrq: {
type: DataTypes.DATE,
comment: "实际退出日期"
},
tcwj: {
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_xmtc', // 指定表名(如果与模型名不同)
timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
});
// 同步模型到数据库(创建表)
TzXmtc.sync({
// force: false,
// force: true ,//会删除已存在表并重新创建
alter: true
})
.then(() => {
console.log('TzXmtc 表同步成功');
});
module.exports = TzXmtc;
\ No newline at end of file
const { DataTypes } = require('sequelize');
const sequelize = require('../index');
const moment = require('moment');
//投中管理- 重大事项审批
const TzXmtcCwzb = sequelize.define('TzXmtcCwzb', {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true
},
/* -------------------TODO: 缺少内容------------------------------------- */
zbmc: {
type: DataTypes.STRING,
comment: "指标名称",
},
zbsz: {
type: DataTypes.INTEGER,
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_xmtccwzb', // 指定表名(如果与模型名不同)
timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
});
// 同步模型到数据库(创建表)
TzXmtcCwzb.sync({
// force: false,
// force: true ,//会删除已存在表并重新创建
alter: true
})
.then(() => {
console.log('TzXmtcCwzb 表同步成功');
});
module.exports = TzXmtcCwzb;
\ No newline at end of file
...@@ -9,8 +9,12 @@ const TzZdsxsp = sequelize.define('TzZdsxsp', { ...@@ -9,8 +9,12 @@ const TzZdsxsp = sequelize.define('TzZdsxsp', {
primaryKey: true, primaryKey: true,
autoIncrement: true autoIncrement: true
}, },
/* -------------------------------------------------------- */ /* -------------------TODO: 缺少内容------------------------------------- */
projectName: {
type: DataTypes.STRING,
comment: "项目名称",
},
projectId: { projectId: {
type: DataTypes.INTEGER, type: DataTypes.INTEGER,
......
...@@ -85,4 +85,11 @@ router.post('/getZdsxspList', projectTzController.getZdsxspList); ...@@ -85,4 +85,11 @@ router.post('/getZdsxspList', projectTzController.getZdsxspList);
router.post('/getZdsxspInfo', projectTzController.getZdsxspInfo); router.post('/getZdsxspInfo', projectTzController.getZdsxspInfo);
//项目退出
router.post('/createXmtc', projectTzController.createXmtc);
router.post('/updateXmtc', projectTzController.updateXmtc);
router.post('/getXmtcList', projectTzController.getXmtcList);
router.post('/getXmtcInfo', projectTzController.getXmtcInfo);
module.exports = router; 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