|
@@ -66,7 +66,8 @@ class TrainplanService extends CrudService {
|
|
|
if (res) {
|
|
|
if (status === '1') {
|
|
|
// 自动生成班级
|
|
|
- await this.autoclass(res, trainplanold);
|
|
|
+ // await this.autoclass(res, trainplanold);
|
|
|
+ await this.autoclassNew(res, trainplanold);
|
|
|
// 将生成的班级重新将班级排班名
|
|
|
// await this.autoclassname(res);
|
|
|
// 发送培训计划信息通知给相应人员
|
|
@@ -99,6 +100,22 @@ class TrainplanService extends CrudService {
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
+ // 自动生成班级私有方法
|
|
|
+ async autoclassNew(res) {
|
|
|
+ // 删除所有计划下的班级
|
|
|
+ await this.clamodel.deleteMany({ planid: res.id });
|
|
|
+ // 循环出所有班级进行添加操作
|
|
|
+ for (const term of res.termnum) {
|
|
|
+ for (const batch of term.batchnum) {
|
|
|
+ const classs = await batch.class;
|
|
|
+ for (const cla of classs) {
|
|
|
+ const newdata = { name: cla.name, number: cla.number, batchid: batch.id, termid: term.id, planid: res.id, type: cla.type, headteacherid: cla.headteacherid };
|
|
|
+ await this.clamodel.create(newdata);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// 自动生成班级私有方法
|
|
|
async autoclass(res, trainplanold) {
|
|
|
// 首先比较当前数据和原数据的值是否有不同
|