|
@@ -95,11 +95,27 @@ class TeaplanService extends CrudService {
|
|
|
}
|
|
|
// 查询本培训计划中班主任全年计划表的全部信息
|
|
|
const teaplanList = await this.model.find({ trainplanid });
|
|
|
+ // 查询所有班主任信息
|
|
|
+ const headteacherList = await this.hmodel.find();
|
|
|
let noteaList = [];
|
|
|
// 遍历所有批次信息
|
|
|
for (const _batch of batchList) {
|
|
|
// 遍历班主任全年计划表
|
|
|
for (const teaplan of teaplanList) {
|
|
|
+ if ((teaplan.nodate).length > 0) {
|
|
|
+ // 遍历班主任全年计划表中的不能上课的日期
|
|
|
+ for (const nodate of teaplan.nodate) {
|
|
|
+ // 如果不能上课的日期在该批次的开始时间和结束时间中,将该班主任加入不能上课的班主任数组中
|
|
|
+ if (moment(nodate).isBetween(_batch.startdate, _batch.enddate, null, '[]')) {
|
|
|
+ noteaList.push(teaplan);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ const headteacherInfo = _.filter(headteacherList, item => item.id === teaplan.headteacherid);
|
|
|
+ // 如果班主任信息列表中班主任没有上报了班主任全年计划,将其加入班主任全年计划
|
|
|
+ if (headteacherInfo.length < 1) {
|
|
|
+ teaplanList.push(headteacherInfo[0]);
|
|
|
+ }
|
|
|
// 过滤出已分配的数据中该班主任的数据
|
|
|
const teaInfo = _.filter(data, item => item.headteacherid === teaplan.headteacherid);
|
|
|
// 计算出每个班主任担任过班主任的次数
|
|
@@ -118,13 +134,6 @@ class TeaplanService extends CrudService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- // 遍历班主任全年计划表中的不能上课的日期
|
|
|
- for (const nodate of teaplan.nodate) {
|
|
|
- // 如果不能上课的日期在该批次的开始时间和结束时间中,将该班主任加入不能上课的班主任数组中
|
|
|
- if (moment(nodate).isBetween(_batch.startdate, _batch.enddate, null, '[]')) {
|
|
|
- noteaList.push(teaplan);
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
// 将数组去重
|
|
|
noteaList = _.uniqWith(noteaList, _.isEqual);
|
|
@@ -177,10 +186,14 @@ class TeaplanService extends CrudService {
|
|
|
let departmentList = [];
|
|
|
for (const teaplan of teaList) {
|
|
|
// 将班主任的部门放到一个数组中
|
|
|
- const headteacher = await this.hmodel.findById(teaplan.headteacherid);
|
|
|
- departmentList.push({ deparmentid: headteacher.department });
|
|
|
- teaplan.deparmentid = headteacher.department;
|
|
|
-
|
|
|
+ if (!teaplan.department) {
|
|
|
+ const headteacher = await this.hmodel.findById(teaplan.headteacherid);
|
|
|
+ departmentList.push({ deparmentid: headteacher.department });
|
|
|
+ teaplan.deparmentid = headteacher.department;
|
|
|
+ } else {
|
|
|
+ departmentList.push({ deparmentid: teaplan.department });
|
|
|
+ teaplan.deparmentid = teaplan.department;
|
|
|
+ }
|
|
|
}
|
|
|
// 将数组去重
|
|
|
departmentList = _.uniqWith(departmentList, _.isEqual);
|