|
@@ -16,6 +16,9 @@ class LessonService extends CrudService {
|
|
|
this.clamodel = this.ctx.model.Class;
|
|
|
this.lmodel = this.ctx.model.Lessonmode;
|
|
|
this.teamodel = this.ctx.model.Teacher;
|
|
|
+ this.stumodel = this.ctx.model.Student;
|
|
|
+ this.schmodel = this.ctx.model.School;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
// 自动排课私有方法
|
|
@@ -72,7 +75,11 @@ class LessonService extends CrudService {
|
|
|
}
|
|
|
let allday = 0;
|
|
|
if (i === 6) {
|
|
|
- allday = _lessonmode.allday;
|
|
|
+ // 判断是否有外市的学生有的时候 将其设置为半天
|
|
|
+ const ishalfday = await this.ishalfday(cla.id);
|
|
|
+ if (ishalfday) {
|
|
|
+ allday = 1;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
const data = {
|
|
@@ -121,6 +128,21 @@ class LessonService extends CrudService {
|
|
|
return teacher;
|
|
|
}
|
|
|
|
|
|
+ // 判断是否为半天
|
|
|
+ async ishalfday(classid) {
|
|
|
+ // 通过班级id取得所有学生
|
|
|
+ const students = await this.stumodel.find({ classid });
|
|
|
+ let res = false;
|
|
|
+ for (const stu of students) {
|
|
|
+ const sch = await this.schmodel.findById(stu.schid);
|
|
|
+ if (sch && sch.hascar === '0') {
|
|
|
+ res = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
// 取得日期间所有日期
|
|
|
async getAllDays(begin_date, end_date) {
|
|
|
const errArr = [],
|