|
@@ -112,9 +112,9 @@ class TeaplanService extends CrudService {
|
|
|
}
|
|
|
}
|
|
|
const headteacherInfo = _.filter(headteacherList, item => item.id === teaplan.headteacherid);
|
|
|
- // 如果班主任信息列表中班主任没有上报了班主任全年计划,将其加入班主任全年计划
|
|
|
- if (headteacherInfo.length < 1) {
|
|
|
- teaplanList.push(headteacherInfo[0]);
|
|
|
+ // 如果班主任信息列表中班主任上报了班主任全年计划,将其移除
|
|
|
+ if (headteacherInfo.length >= 1) {
|
|
|
+ _.remove(headteacherList, item => item.id === teaplan.headteacherid);
|
|
|
}
|
|
|
// 过滤出已分配的数据中该班主任的数据
|
|
|
const teaInfo = _.filter(data, item => item.headteacherid === teaplan.headteacherid);
|
|
@@ -135,10 +135,32 @@ class TeaplanService extends CrudService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ for (const headteacher of headteacherList) {
|
|
|
+ headteacher.headteacherid = headteacher.id;
|
|
|
+ // 过滤出已分配的数据中该班主任的数据
|
|
|
+ const teaInfo = _.filter(data, item => item.headteacherid === headteacher.id);
|
|
|
+ // 计算出每个班主任担任过班主任的次数
|
|
|
+ headteacher.teacount = await this.cmodel.count({ headteacherid: headteacher.id }) + teaInfo.length;
|
|
|
+ // 如果已分配的数据中该班主任的数据长度大于0
|
|
|
+ if (teaInfo.length > 0) {
|
|
|
+ // 遍历已分配的数据中该班主任的数据
|
|
|
+ for (const _teaInfo of teaInfo) {
|
|
|
+ // 查询该班主任已分配的数据中的班级信息
|
|
|
+ const _class = await this.cmodel.findById(_teaInfo.classid);
|
|
|
+ // 根据班级的批次id查出该班级的开始时间和结束时间
|
|
|
+ const batchInfo = _.filter(batchList, item => item.id === _class.batchid);
|
|
|
+ // 如果该班级的开始时间和结束时间于当前遍历批次的开始时间和结束时间有重合部分,将该班主任加入不能上课的班主任数组中
|
|
|
+ if (await this.isrepeat(batchInfo.startdate, batchInfo.enddate, _batch.startdate, _batch.enddate)) {
|
|
|
+ _.remove(headteacherList, item => item.id === headteacher.id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
// 将数组去重
|
|
|
noteaList = _.uniqWith(noteaList, _.isEqual);
|
|
|
// 将班主任全年计划表过滤,去除在不能上课的班主任数组中已存在的数据
|
|
|
let teaList = _.difference(teaplanList, noteaList);
|
|
|
+ teaList = _.concat(teaList, headteacherList);
|
|
|
// 将不能上课的班主任数组清空
|
|
|
noteaList = [];
|
|
|
const departmentList = await this.departmentcount(teaList);
|