明树Git Lab

Commit ec07c517 authored by zfp1's avatar zfp1

update

parent 16f9f1e9
Pipeline #109218 passed with stage
in 3 seconds
......@@ -48,16 +48,24 @@ async function getYyqtzhsInfo(req, res, next) {
if (req.body.id) {
search.id = req.body.id;
}
if (_.isEmpty(search)) {
return res.sendError(errorMessage.paramsError);
}
let tzhs = await DB.ThYyqtzhs.findOne({ where: search});
if (req.body.nd) {
ndYear = Number(req.body.nd);
search.nd = sequelize.where(
sequelize.fn('YEAR', sequelize.col('nd')), // 调用SQL的YEAR函数取nd字段的年份
ndYear
);
}
console.log(search, "===")
// if (_.isEmpty(search)) {
// return res.sendError(errorMessage.paramsError);
// }
let tzhs = await DB.ThYyqtzhs.findOne({ where: search });
if (!(tzhs && tzhs.id && tzhs.projectId)) {
return res.sendError(errorMessage.resourceNotFound);
}
tzhs = tzhs.toJSON();
let lastyear = moment().subtract(1, 'year').format('YYYY');
let lastyeartzhs = await DB.ThYyqtzhs.findOne({where: {projectId: tzhs.projectId, nd: lastyear}});
let lastyeartzhs = await DB.ThYyqtzhs.findOne({ where: { projectId: tzhs.projectId, nd: lastyear } });
tzhs.lastyeartzhs = lastyeartzhs || null;
// let yyqtzhss = await DB.ThYyqtzhszb.findAll({ where: { projectId: tzhs.projectId, sourceId: req.body.id }, raw: true });
// tzhs.yyqtzhss = _.values(_.groupBy(yyqtzhss, 'groupBy')) || [[]]
......@@ -424,7 +432,7 @@ async function getTzhpjInfo(req, res, next) {
if (_.isEmpty(search)) {
return res.sendError(errorMessage.paramsError);
}
let tzhpj = await DB.ThTzhpj.findOne({ where: search});
let tzhpj = await DB.ThTzhpj.findOne({ where: search });
if (!(tzhpj && tzhpj.id)) {
return res.sendError(errorMessage.resourceNotFound);
}
......@@ -441,7 +449,7 @@ async function getTzhpjInfo(req, res, next) {
tzhpj.hpjbg = tzhpj.hpjbg.map(o => { return fileMap[o] });
tzhpj.qsmzqpj = tzhpj.qsmzqpj.map(o => { return fileMap[o] });
tzhpj.tzhpjwtzgs = await DB.ThTzhpjwtzg.findAll({ where: { projectId: tzhpj.projectId,sourceId: req.body.id }});
tzhpj.tzhpjwtzgs = await DB.ThTzhpjwtzg.findAll({ where: { projectId: tzhpj.projectId, sourceId: req.body.id } });
return res.sendData(tzhpj);
} catch (error) {
next(error);
......@@ -601,9 +609,9 @@ module.exports = {
updateYjgl,
getYjglList,
getYjglInfo,
deleteYyqtzhs,
deleteYyqtzjc,
deleteTzhpj,
deleteYjgl,
deleteYyqtzhs,
deleteYyqtzjc,
deleteTzhpj,
deleteYjgl,
}
\ 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