|
@@ -64,11 +64,7 @@ class CountService extends CrudService {
|
|
|
data.levelexit = levelexit || 0;
|
|
|
|
|
|
// 参加培训的学生
|
|
|
- const trainstuRes = await this.ctx.model.Student.aggregate([
|
|
|
- { $match: { planid } },
|
|
|
- { $match: { openid: { $exists: true } } },
|
|
|
- { $count: 'total' },
|
|
|
- ]);
|
|
|
+ const trainstuRes = await this.ctx.model.Student.aggregate([{ $match: { planid } }, { $match: { openid: { $exists: true } } }, { $count: 'total' }]);
|
|
|
const h = _.head(trainstuRes);
|
|
|
if (h) {
|
|
|
let { total: trainstu } = h;
|
|
@@ -116,12 +112,15 @@ class CountService extends CrudService {
|
|
|
// schstu:上传名单人数 该年度计划下,的student.total √
|
|
|
// trainstu:已参加培训人数 user(type==4&&openid).total √
|
|
|
// planstu:年度计划人数(重算) 根据年度计划学校的分配计算 √
|
|
|
+ // leaveNum:请假人数未处理 √
|
|
|
+ // uploadNum:计划上报未处理 √
|
|
|
+
|
|
|
// 取得当前年份计划信息
|
|
|
const setting = await this.setmodel.findOne();
|
|
|
if (!setting) {
|
|
|
throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '没有找到默认设置');
|
|
|
}
|
|
|
- const { planid } = setting;
|
|
|
+ const { planid, termid } = setting;
|
|
|
if (!planid) {
|
|
|
throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '没有找到默认年度计划');
|
|
|
}
|
|
@@ -187,6 +186,24 @@ class CountService extends CrudService {
|
|
|
const mid = await this.ctx.model.Schtime.find({ planid, schid: id });
|
|
|
const planstu = mid.reduce((p, n) => p + n.arrange.reduce((np, nn) => np + (nn.number * 1 || 0), 0), 0);
|
|
|
data.planstu = planstu;
|
|
|
+ // 请假或退出人数未处理
|
|
|
+ const leaveNum = await this.ctx.model.Leave.count({
|
|
|
+ termid,
|
|
|
+ schid: id,
|
|
|
+ status: '0',
|
|
|
+ });
|
|
|
+ data.leaveNum = leaveNum || 0;
|
|
|
+ // 计划上报学校上传学生名单
|
|
|
+ const schtime = await this.ctx.model.Schtime.findOne({ planid, schid: id }).lean();
|
|
|
+ const uploadNum = 0;
|
|
|
+ if (schtime && schtime.arrange) {
|
|
|
+ for (const val of schtime.arrange) {
|
|
|
+ const { termid, batchid } = val;
|
|
|
+ const studentTotal = await this.ctx.model.Student.count({ termid, batchid, schid: id });
|
|
|
+ if (studentTotal === 0) uploadNum + 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ data.uploadNum = uploadNum;
|
|
|
return data;
|
|
|
}
|
|
|
}
|