lrf402788946 4 years ago
parent
commit
548cc423d0
1 changed files with 6 additions and 1 deletions
  1. 6 1
      app/service/count.js

+ 6 - 1
app/service/count.js

@@ -15,13 +15,18 @@ class CountService extends CrudService {
     this.tmodel = this.ctx.model.Trainplan;
     this.lmodel = this.ctx.model.Leave;
     this.schmodel = this.ctx.model.School;
+    this.setmodel = this.ctx.model.Setting;
   }
 
   // 查询
   async countstudent() {
     // 取得当前年份计划信息
+    const setting = await this.setmodel.findOne();
+    if (!setting) {
+      throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '没有找到默认设置');
+    }
     console.log(moment().format('YYYY'));
-    const plan = await this.tmodel.findOne({ year: moment().format('YYYY') });
+    const plan = await this.tmodel.findById(setting.planid);
     if (!plan) {
       throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '当前全年计划不存在');
     }