|
@@ -17,7 +17,6 @@ class BedroomService extends CrudService {
|
|
|
this.umodel = this.ctx.model.User;
|
|
|
this.ctmodel = this.ctx.model.Classtype;
|
|
|
this.nmodel = this.ctx.model.Notice;
|
|
|
-
|
|
|
}
|
|
|
|
|
|
// 根据班级id查找班级下所有寝室列表并查询出寝室下学生信息
|
|
@@ -69,7 +68,9 @@ class BedroomService extends CrudService {
|
|
|
// 根据批次id查询批次信息
|
|
|
const _batch = term.batchnum.find(p => p.id === batchid);
|
|
|
// 查询所有寝室列表
|
|
|
- const bedroomList = await this.model.find({ batch: _batch.batch, status: '0' }).sort({ floor: -1 });
|
|
|
+ const bedroomList = await this.model
|
|
|
+ .find({ batch: _batch.batch, status: '0' })
|
|
|
+ .sort({ floor: -1 });
|
|
|
// 循环所有当前批次下的寝室列表进行分寝处理
|
|
|
const studentList = await this.getstudents(termid, batchid);
|
|
|
console.log('stulen-->' + studentList.length);
|
|
@@ -124,21 +125,41 @@ class BedroomService extends CrudService {
|
|
|
// 取得当前批次的所有班级
|
|
|
const classes = await this.cmodel.find({ batchid });
|
|
|
const detail = '班级学生名单与寝室安排已确认,请及时查收';
|
|
|
- const nres = await this.nmodel.create({ planyearid: trainplan.planyearid, planid: trainplanid, termid, noticeid: 'system', content: detail, type: '5' });
|
|
|
+ const nres = await this.nmodel.create({
|
|
|
+ planyearid: trainplan.planyearid,
|
|
|
+ planid: trainplanid,
|
|
|
+ termid,
|
|
|
+ noticeid: 'system',
|
|
|
+ content: detail,
|
|
|
+ type: '5',
|
|
|
+ });
|
|
|
|
|
|
for (const _class of classes) {
|
|
|
// 取得每个班级的班主任id
|
|
|
const headteacherid = _class.headteacherid;
|
|
|
- const headteacher = await this.umodel.findOne({ uid: headteacherid, type: '1' });
|
|
|
+ const headteacher = await this.umodel.findOne({
|
|
|
+ uid: headteacherid,
|
|
|
+ type: '1',
|
|
|
+ });
|
|
|
if (headteacher && headteacher.openid) {
|
|
|
const openid = headteacher.openid;
|
|
|
const remark = '感谢您的使用';
|
|
|
const date = await this.ctx.service.util.updatedate();
|
|
|
- this.ctx.service.weixin.sendTemplateMsg(this.ctx.app.config.REVIEW_TEMPLATE_ID, openid, '您有一个新的通知', detail, date, remark, _class.id);
|
|
|
- nres.notified.push({ notifiedid: headteacher.uid, username: headteacher.name });
|
|
|
+ this.ctx.service.weixin.sendTemplateMsg(
|
|
|
+ this.ctx.app.config.REVIEW_TEMPLATE_ID,
|
|
|
+ openid,
|
|
|
+ '您有一个新的通知',
|
|
|
+ detail,
|
|
|
+ date,
|
|
|
+ remark,
|
|
|
+ _class.id
|
|
|
+ );
|
|
|
+ nres.notified.push({
|
|
|
+ notifiedid: headteacher.uid,
|
|
|
+ username: headteacher.name,
|
|
|
+ });
|
|
|
}
|
|
|
await nres.save();
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -150,7 +171,9 @@ class BedroomService extends CrudService {
|
|
|
console.log('-----types-start--');
|
|
|
console.log(types);
|
|
|
console.log('-----types-end--');
|
|
|
- const studentList = await this.smodel.find({ termid, batchid, type: { $in: types } }).sort({ gender: -1 });
|
|
|
+ const studentList = await this.smodel
|
|
|
+ .find({ termid, batchid, type: { $in: types } })
|
|
|
+ .sort({ gender: -1 });
|
|
|
return studentList;
|
|
|
}
|
|
|
|
|
@@ -160,6 +183,17 @@ class BedroomService extends CrudService {
|
|
|
const studentList = await this.smodel.find({ termid, batchid, bedroom });
|
|
|
return studentList;
|
|
|
}
|
|
|
+
|
|
|
+ // 批量修改学生寝室(新)
|
|
|
+ async updateStudent(data, body) {
|
|
|
+ const { code, ids, bedroomid } = body;
|
|
|
+ for (const id of ids) {
|
|
|
+ const r = await this.ctx.model.Student.findById(id);
|
|
|
+ r.bedroom = code;
|
|
|
+ r.bedroomid = bedroomid;
|
|
|
+ await r.save();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
module.exports = BedroomService;
|