Prechádzať zdrojové kódy

Merge branch 'master' of http://git.cc-lotus.info/new_train/service-center

cheny 4 rokov pred
rodič
commit
0d30089e2d
2 zmenil súbory, kde vykonal 30 pridanie a 0 odobranie
  1. 7 0
      app/model/trainplan.js
  2. 23 0
      app/service/class.js

+ 7 - 0
app/model/trainplan.js

@@ -52,6 +52,12 @@ const festivalInfo = new Schema({
   name: { type: String, required: false, maxLength: 200 }, // 名称
 });
 
+// 备注信息表
+const remarkInfo = new Schema({
+  month: { type: String, required: false, maxLength: 20 }, // 月份
+  class: { type: String, required: false, maxLength: 200 }, // 班级
+  number: { type: String, required: false, maxLength: 200 }, // 数量
+});
 
 // 培训计划表
 const TrainplanSchema = {
@@ -60,6 +66,7 @@ const TrainplanSchema = {
   title: { type: String, required: true, maxLength: 500 }, // 标题
   status: { type: String, required: false, maxLength: 200, default: '0' }, // 状态,0-筹备中,1-发布,2-结束
   termnum: { type: [ termInfo ], select: true }, // 期
+  remark: { type: [ remarkInfo ], select: true }, // 备注
   school: { type: [ schInfo ], select: true }, // 学校
   festivals: { type: [ festivalInfo ], select: true }, // 节假日
 };

+ 23 - 0
app/service/class.js

@@ -52,6 +52,29 @@ class ClassService extends CrudService {
       // 取出的学生数据从原数据中删除
       _students = _.difference(_students, beforestu);
     }
+    //  判断学生是否有剩余
+    const stulen_ = _students.length;
+    if (stulen_ > 0) {
+      // 判断共有多少班级
+      // 判断学生数与班级数,当小于或等于班级数 将班级直接分配给学生
+      const classlength = newclass.length;
+      // 循环取得学生id并分配班级
+      let cindex_ = 0;
+      for (const stuid of _students) {
+        const student = await this.stumodel.findById(stuid);
+        if (student) {
+          const cla_ = newclass[cindex_];
+          student.classid = cla_.classid;
+          student.batchid = cla_.batchid;
+          await student.save();
+          cindex_ = cindex_ + 1;
+          if (cindex_ === classlength - 1) {
+            cindex_ = 0;
+          }
+        }
+      }
+
+    }
   }
 
   // 取得同样类型的学生