|
@@ -157,7 +157,7 @@ class InfoService extends Service {
|
|
|
// });
|
|
|
// }
|
|
|
|
|
|
- this.ctx.logger.info('条件', where);
|
|
|
+ this.ctx.logger.info('条件===============================================', where);
|
|
|
|
|
|
|
|
|
const pop = [
|
|
@@ -1119,27 +1119,68 @@ class InfoService extends Service {
|
|
|
const { model } = this.ctx;
|
|
|
const level = user.dept.level;
|
|
|
const match = {};
|
|
|
- match.time = data.yestday;
|
|
|
+
|
|
|
// admin的dept 存在冲突,所以它不需要结合
|
|
|
if (user.role._id != this.app.config.defaultAdminRoleId) {
|
|
|
- match['dept'+level]= user.dept._id;
|
|
|
+ match['dept'+level]= this.app.mongoose.Types.ObjectId(user.dept._id);
|
|
|
}
|
|
|
- this.ctx.logger.info('条件', match);
|
|
|
- const res = await model.InfoModel.aggregate([
|
|
|
- { $project: { time: { $dateToString: { format: '%Y-%m-%d', date: '$time' } },_id:1,dept1:1,dept2:1,dept3:1,dept4:1,dept5:1,status:1 } },
|
|
|
- { $match: match},
|
|
|
- { $group:
|
|
|
- { _id: '$time', sumnum : {$sum : 1},
|
|
|
- nodone: { $sum: {$cond: [{ $eq: [ '$status', '0' ] }, 1, 0 ]} },
|
|
|
- writenostu: { $sum: {$cond: [{ $eq: [ '$status', '1' ] }, 1, 0 ]} },
|
|
|
- stuing: { $sum: {$cond: [{ $eq: [ '$status', '2' ] }, 1, 0 ]} },
|
|
|
- stued: { $sum: {$cond: [{ $eq: [ '$status', '3' ] }, 1, 0 ]} },
|
|
|
- fullstu: { $sum: {$cond: [{ $eq: [ '$status', '4' ] }, 1, 0 ]} },
|
|
|
- }
|
|
|
- }
|
|
|
- ]);
|
|
|
+ match.time = { $gte: data.yestday + ' 00:00:00', $lt: data.yestday + ' 23:59:59' };
|
|
|
+ this.ctx.logger.info('条件===============================================', match);
|
|
|
+
|
|
|
+ let finalarr = [];
|
|
|
+ let vote = {};
|
|
|
+
|
|
|
+ const nodonem = {};
|
|
|
+ if (user.role._id != this.app.config.defaultAdminRoleId) {
|
|
|
+ nodonem['dept'+level]= this.app.mongoose.Types.ObjectId(user.dept._id);
|
|
|
+ }
|
|
|
+ nodonem.time = { $gte: data.yestday + ' 00:00:00', $lt: data.yestday + ' 23:59:59' };
|
|
|
+ nodonem.status = 0;
|
|
|
+
|
|
|
+ const writenostum = {};
|
|
|
+ if (user.role._id != this.app.config.defaultAdminRoleId) {
|
|
|
+ writenostum['dept'+level]= this.app.mongoose.Types.ObjectId(user.dept._id);
|
|
|
+ }
|
|
|
+ writenostum.time = { $gte: data.yestday + ' 00:00:00', $lt: data.yestday + ' 23:59:59' };
|
|
|
+ writenostum.status = 1;
|
|
|
+
|
|
|
+ const stuingm = {};
|
|
|
+ if (user.role._id != this.app.config.defaultAdminRoleId) {
|
|
|
+ stuingm['dept'+level]= this.app.mongoose.Types.ObjectId(user.dept._id);
|
|
|
+ }
|
|
|
+ stuingm.time = { $gte: data.yestday + ' 00:00:00', $lt: data.yestday + ' 23:59:59' };
|
|
|
+ stuingm.status = 2;
|
|
|
+
|
|
|
+ const stuedm = {};
|
|
|
+ if (user.role._id != this.app.config.defaultAdminRoleId) {
|
|
|
+ stuedm['dept'+level]= this.app.mongoose.Types.ObjectId(user.dept._id);
|
|
|
+ }
|
|
|
+ stuedm.time = { $gte: data.yestday + ' 00:00:00', $lt: data.yestday + ' 23:59:59' };
|
|
|
+ stuedm.status = 3;
|
|
|
+
|
|
|
+ const fullstum = {};
|
|
|
+ if (user.role._id != this.app.config.defaultAdminRoleId) {
|
|
|
+ fullstum['dept'+level]= this.app.mongoose.Types.ObjectId(user.dept._id);
|
|
|
+ }
|
|
|
+ fullstum.time = { $gte: data.yestday + ' 00:00:00', $lt: data.yestday + ' 23:59:59' };
|
|
|
+ fullstum.status = 4;
|
|
|
+
|
|
|
+
|
|
|
+ const sumnum = await model.InfoModel.find(match).countDocuments();
|
|
|
+ const nodone = await model.InfoModel.find(nodonem).countDocuments();
|
|
|
+ const writenostu = await model.InfoModel.find(writenostum).countDocuments();
|
|
|
+ const stuing = await model.InfoModel.find(stuingm).countDocuments();
|
|
|
+ const stued = await model.InfoModel.find(stuedm).countDocuments();
|
|
|
+ const fullstu = await model.InfoModel.find(fullstum).countDocuments();
|
|
|
+ vote.sumnum = sumnum;
|
|
|
+ vote.nodone = nodone;
|
|
|
+ vote.writenostu = writenostu;
|
|
|
+ vote.stuing = stuing;
|
|
|
+ vote.stued = stued;
|
|
|
+ vote.fullstu = fullstu;
|
|
|
+ finalarr.push(vote)
|
|
|
|
|
|
- return res;
|
|
|
+ return finalarr;
|
|
|
}
|
|
|
|
|
|
}
|