明树Git Lab

Commit 3bac3f4a authored by zfp1's avatar zfp1

update

parent 10030282
......@@ -48,6 +48,9 @@ async function getYyqtzhsInfo(req, res, next) {
if (req.body.id) {
search.id = req.body.id;
}
if (req.body.projectId) {
search.projectId = req.body.projectId;
}
if (req.body.nd) {
ndYear = Number(req.body.nd);
search.nd = sequelize.where(
......
......@@ -84,7 +84,7 @@ async function updateTzmbzrs(req, res, next) {
tzmbzrsPfyjs.map(o => { if (!o.id) { if (!_.isEmpty(o)) { o.projectId = req.body.projectId; o.sourceId = ret.id; newtzmbzrsPfyjs.push(o); } } else { ids1.push(o.id); infos1.push(o); } return o });
await DB.TzTzmbzrsPfyj.destroy({ where: { projectId: req.body.projectId, sourceId: ret.id, id: { [Op.notIn]: ids1 } } }); // 删除id不在传入id数组里面的(用户在界面删除的)
await DB.TzTzmbzrsPfyj.bulkCreate(newtzmbzrsPfyjs);//创建新的 没有id的
await Promise.all(infos1.map(item => {console.log(item, "----"); return DB.TzTzmbzrsPfyj.update(item, { where: { id: item.id } }) }));
await Promise.all(infos1.map(item => { console.log(item, "----"); return 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; o.sourceId = ret.id; newtzmbzrsNds.push(o); } } else { ids2.push(o.id); infos2.push(o); } return o });
......@@ -140,7 +140,7 @@ async function getTzmbzrsInfo(req, res, next) {
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)) {
......@@ -217,7 +217,7 @@ async function createTzkz(req, res, next) {
//处理财务评价指标
// let tzkzcwpjs = (req.body.tzkzcwpjs || []).map(o => { o.projectId = req.body.projectId; o.sourceId = ret.id; return o; });
// delete req.body.tzkzcwpjs;
let flattenArrCwpjs = [];
let flattenArrCwpjs = [];
let tzkzcwpjs = req.body.tzkzcwpjs || [[]]; //二维数组 多次上报
delete req.body.tzkzcwpjs;
for (let index = 0; index < tzkzcwpjs.length; index++) {
......@@ -295,7 +295,7 @@ async function updateTzkz(req, res, next) {
// await DB.TzTzkzCwpj.bulkCreate(newtzkzcwpjs);//创建新的 没有id的
// await Promise.all(infos.map(item => { return DB.TzTzkzCwpj.update(item, { where: { id: item.id } }) }));
// delete req.body.tzkzcwpjs;
let tzkzcwpjs = req.body.tzkzcwpjs || []; //二维数组 多次上报
let tzkzcwpjs = req.body.tzkzcwpjs || []; //二维数组 多次上报
let ids = [], infos = [], newtzkzcwpjss = [];
for (let index = 0; index < tzkzcwpjs.length; index++) {
const element = tzkzcwpjs[index];
......@@ -443,7 +443,7 @@ async function getTzkzInfo(req, res, next) {
where: { projectId: tzkz.projectId, sourceId: tzkz.id },
raw: true,
});
let tzkzcwpjsGroupByObj = _.groupBy(tzkzcwpjs, 'groupBy');
let tzkzcwpjsGroupByObj = _.groupBy(tzkzcwpjs, 'groupBy');
let keyindexs1 = _.keys(tzkzcwpjsGroupByObj);
let newtzkzcwpjs = [];
for (let index = 0; index < keyindexs1.length; index++) {
......@@ -670,16 +670,28 @@ async function getJsqtzhsInfo(req, res, next) {
if (req.body.id) {
search.id = req.body.id;
}
if(req.body.projectId) {
if (req.body.projectId) {
search.projectId = req.body.projectId;
}
if (req.body.nd) {
ndYear = Number(req.body.nd);
search.nd = sequelize.where(
sequelize.fn('YEAR', sequelize.col('nd')), // 调用SQL的YEAR函数取nd字段的年份
ndYear
);
}
if (_.isEmpty(search)) {
return res.sendError(errorMessage.paramsError);
}
let tzhs = await DB.TzJsqtzhs.findOne({ where: search, raw: true });
let tzhs = await DB.TzJsqtzhs.findOne({ where: search });
if (!(tzhs && tzhs.id && tzhs.projectId)) {
return res.sendError(errorMessage.resourceNotFound);
}
tzhs = tzhs.toJSON();
let lastyear = moment(tzhs.nd).subtract(1, 'year').format('YYYY');
console.log(lastyear, "=========")
let lastyeartzhs = await DB.TzJsqtzhs.findOne({ where: { projectId: tzhs.projectId, nd: sequelize.where(sequelize.fn('YEAR', sequelize.col('nd')), lastyear) } });
tzhs.lastyeartzhs = lastyeartzhs || null;
// 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);
......@@ -959,8 +971,8 @@ async function getJsqtzjcList(req, res, next) {
let ret = await DB.TzJsqtzjc.findAndCountAll(search);
let tzjcIds = [];
ret.rows.map(o => { tzjcIds.push(o.id); });
let jsqtzjcTzfxs = await DB.TzJsqtzjcTzfx.findAll({ where: { sourceId: {[Op.in]: tzjcIds} }, raw: true });
let jsqtzjcZxjcs = await DB.TzJsqtzjcZxjc.findAll({ where: { sourceId: {[Op.in]: tzjcIds} }, raw: true });
let jsqtzjcTzfxs = await DB.TzJsqtzjcTzfx.findAll({ where: { sourceId: { [Op.in]: tzjcIds } }, raw: true });
let jsqtzjcZxjcs = await DB.TzJsqtzjcZxjc.findAll({ where: { sourceId: { [Op.in]: tzjcIds } }, raw: true });
let tzfxsmap = _.groupBy(jsqtzjcTzfxs, 'sourceId');
let tzzxjcmap = _.groupBy(jsqtzjcZxjcs, 'sourceId');
// console.log(tzfxsmap, "===")
......@@ -1035,7 +1047,7 @@ async function updateZdsxsp(req, res, next) {
if (!req.body.projectId) {
return res.sendError(errorMessage.paramsError);
}
let zdsxsp = await DB.TzZdsxsp.findOne({ where: {id: req.body.id}, raw: true });
let zdsxsp = await DB.TzZdsxsp.findOne({ where: { id: req.body.id }, raw: true });
if (!(zdsxsp && zdsxsp.id)) {
return res.sendError(errorMessage.resourceNotFound);
}
......
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