|
@@ -100,10 +100,37 @@ class ClassService extends CrudService {
|
|
|
}
|
|
|
// 循环出所有班级进行添加操作
|
|
|
const term = await res.termnum.id(termid);
|
|
|
+ let yclocationid = ''; // 用餐地点
|
|
|
+ let kzjhlocationid = ''; // 拓展计划地点
|
|
|
+ let kbyslocationid = ''; // 开班仪式地点
|
|
|
+ let jslocationid = ''; // 教室位置
|
|
|
+ const locations = await this.locamodel.find();
|
|
|
+ const jslocationids = _.filter(locations, { type: '0' });
|
|
|
+ const kbyslocationids = _.filter(locations, { type: '1' });
|
|
|
+ const kzjhlocationids = _.filter(locations, { type: '2' });
|
|
|
+ const yclocationids = _.filter(locations, { type: '3' });
|
|
|
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 };
|
|
|
+ // 取得班级各个地点
|
|
|
+ // 同一地点同期只能使用一次
|
|
|
+ if (jslocationids.length > 0) {
|
|
|
+ jslocationid = jslocationids[0].id;
|
|
|
+ _.remove(jslocationids, { id: jslocationid });
|
|
|
+ }
|
|
|
+ if (kbyslocationids.length > 0) {
|
|
|
+ kbyslocationid = kbyslocationids[0].id;
|
|
|
+ _.remove(kbyslocationids, { id: kbyslocationid });
|
|
|
+ }
|
|
|
+ if (kzjhlocationids.length > 0) {
|
|
|
+ kzjhlocationid = kzjhlocationids[0].id;
|
|
|
+ _.remove(kzjhlocationids, { id: kzjhlocationid });
|
|
|
+ }
|
|
|
+ if (yclocationids.length > 0) {
|
|
|
+ yclocationid = yclocationids[0].id;
|
|
|
+ _.remove(yclocationids, { id: yclocationid });
|
|
|
+ }
|
|
|
+ const newdata = { name: cla.name, number: cla.number, batchid: batch.id, termid: term.id, planid: res.id, type: cla.type, headteacherid: cla.headteacherid, jslocationid, kbyslocationid, kzjhlocationid, yclocationid };
|
|
|
await this.model.create(newdata);
|
|
|
}
|
|
|
}
|