liuyu 4 éve
szülő
commit
090c4d61de
1 módosított fájl, 7 hozzáadás és 2 törlés
  1. 7 2
      app/service/lesson.js

+ 7 - 2
app/service/lesson.js

@@ -60,6 +60,7 @@ class LessonService extends CrudService {
           const newlesson = [];
           for (const day of sedays) {
             // 循环课程模板,将模板信息排入班级课程表中
+            const teachids = [];
             for (const lessm of lessons_) {
               // 循环插入模板信息
               if (lessm['day' + i] !== '--') {
@@ -82,10 +83,11 @@ class LessonService extends CrudService {
                   day: allday,
                 };
                 // 将教师按照分数的综合成绩排序,上报时间,安排教师.
-                const teacher_ = await this.autoteacher(_subid);
+                const teacher_ = await this.autoteacher(_subid, teachids);
                 if (teacher_) {
                   data.teaid = teacher_.id;
                   data.teaname = teacher_.name;
+                  teachids.push(teacher_.id);
                 }
                 newlesson.push(data);
               }
@@ -106,9 +108,12 @@ class LessonService extends CrudService {
   }
 
   // 自动排教师,按照分数的综合成绩排序,上报时间,安排教师
-  async autoteacher(subid) {
+  async autoteacher(subid, teachids) {
     // 按照上报时间取得所有老师,进行正序排列
     const teachers = await this.teamodel.find({ subid, status: '4' }).sort({ zlscore: '-1', msscore: '-1', xsscore: '-1' });
+    for (const teaid of teachids) {
+      _.remove(teachers, item => item.id === teaid);
+    }
     let teacher = {};
     if (teachers.length > 0) {
       teacher = teachers[0];