Bladeren bron

首页修改为待办事项

zs 9 maanden geleden
bovenliggende
commit
88f043abe8
2 gewijzigde bestanden met toevoegingen van 24 en 7 verwijderingen
  1. 1 1
      app/model/liveroom.js
  2. 23 6
      app/service/count.js

+ 1 - 1
app/model/liveroom.js

@@ -9,7 +9,7 @@ const LiveroomSchema = {
   subname: { type: String, required: true, maxLength: 200 }, // 科目
   teacher: { type: String, required: true, maxLength: 200 }, // 教师id
   teacherid: { type: String, required: true, maxLength: 200 }, // 教师id
-  status: { type: String, required: false, maxLength: 200, default: "0" }, // 状态:0=>未审核;1=>通过;2=>拒绝
+  status: { type: String, required: false, maxLength: 200, default: '0' }, // 状态:0=>未审核;1=>通过;2=>拒绝
   start: { type: Boolean, required: true, maxLength: 200, default: false }, // true=>开始直播;false=>未开始
   reason: { type: String, required: false, maxLength: 2000 }, // 申请原因
 };

+ 23 - 6
app/service/count.js

@@ -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;
   }
 }