|
@@ -20,6 +20,7 @@ class LessonService extends CrudService {
|
|
|
this.schmodel = this.ctx.model.School;
|
|
|
this.headteamodel = this.ctx.model.Headteacher;
|
|
|
this.umodel = this.ctx.model.User;
|
|
|
+ this.nmodel = this.ctx.model.Notice;
|
|
|
}
|
|
|
|
|
|
// 自动排课私有方法
|
|
@@ -292,6 +293,7 @@ class LessonService extends CrudService {
|
|
|
const res = await this.model.updateMany({ _id: { $in: ids } }, { status: '1' });
|
|
|
// 循环课表
|
|
|
for (const lessonInfo of list) {
|
|
|
+ // 一个班下,给每个班创建信息即可
|
|
|
// 获取期数
|
|
|
const { termid, classid, lessons } = lessonInfo;
|
|
|
const planRes = await this.tmodel.findOne({ termnum: { $elemMatch: { _id: termid } } });
|
|
@@ -300,29 +302,50 @@ class LessonService extends CrudService {
|
|
|
if (!term) continue;
|
|
|
const { term: termnum } = term;
|
|
|
const classInfo = await this.clamodel.findById(classid);
|
|
|
+ // TODO创建信息,获取数据
|
|
|
+ const nres = await this.nmodel.create({
|
|
|
+ planyearid: planRes.planyearid,
|
|
|
+ planid: planRes._id,
|
|
|
+ termid,
|
|
|
+ classid,
|
|
|
+ noticeid: 'system',
|
|
|
+ type: '4',
|
|
|
+ content: `欢迎参加由吉林省高等学校毕业生就业指导中心举办的"双困生培训会"第${termnum}期`,
|
|
|
+ });
|
|
|
const { headteacherid, lyteacherid } = classInfo;
|
|
|
const headteacher = await this.headteamodel.findById(headteacherid);
|
|
|
- if (headteacher) await this.toSendMsg(headteacher, 'headteacher', termnum);
|
|
|
+ if (headteacher) {
|
|
|
+ const r = await this.toSendMsg(headteacher, 'headteacher', termnum, nres._id);
|
|
|
+ if (r)nres.notified.push(r);
|
|
|
+ }
|
|
|
// 礼仪教师和班主任不是一个人时查礼仪教师是班主任还是任课教师,然后发消息
|
|
|
if (lyteacherid !== headteacherid) {
|
|
|
let lyTeacher = await this.headteamodel.findById(lyteacherid);
|
|
|
- if (lyTeacher) await this.toSendMsg(lyTeacher, 'headteacher', termnum);
|
|
|
- else {
|
|
|
+ if (lyTeacher) {
|
|
|
+ const r = await this.toSendMsg(lyTeacher, 'headteacher', termnum);
|
|
|
+ if (r)nres.notified.push(r);
|
|
|
+ } else {
|
|
|
lyTeacher = await this.teamodel.findById(lyteacherid);
|
|
|
- if (lyTeacher) await this.toSendMsg(lyTeacher, 'teacher', termnum);
|
|
|
+ if (lyTeacher) {
|
|
|
+ const r = await this.toSendMsg(lyTeacher, 'teacher', termnum);
|
|
|
+ if (r) nres.notified.push(r);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
// 获取所有任课教师ids
|
|
|
const teacherList = _.compact(_.uniq(lessons.map(i => i.teaid)));
|
|
|
if (teacherList) {
|
|
|
for (const tea of teacherList) {
|
|
|
- await this.toSendMsg(tea, 'teacher', termnum);
|
|
|
+ const r = await this.toSendMsg(tea, 'teacher', termnum);
|
|
|
+ if (r) nres.notified.push(r);
|
|
|
}
|
|
|
}
|
|
|
+ nres.save();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- async toSendMsg(teacherInfo, type, term) {
|
|
|
+ async toSendMsg(teacherInfo, type, term, nresid) {
|
|
|
+ let person = null;
|
|
|
if (teacherInfo) {
|
|
|
let email;
|
|
|
if (type === 'headteacher') {
|
|
@@ -345,19 +368,22 @@ class LessonService extends CrudService {
|
|
|
if (teacherUser) {
|
|
|
const { openid } = teacherUser;
|
|
|
if (openid) {
|
|
|
+ const tourl = this.ctx.app.config.baseUrl + '/trainnotice/?userid=' + teacherUser.uid + '¬iceid=' + nresid;
|
|
|
// TODO 推送
|
|
|
await this.ctx.service.weixin.sendTemplateDesign(
|
|
|
this.ctx.app.config.REVIEW_TEMPLATE_ID,
|
|
|
openid,
|
|
|
- '您有一个新的通知',
|
|
|
+ '您有一个新的通知,请点击信息,确认您已收到信息!',
|
|
|
'您有新的安排',
|
|
|
- `欢迎参加由吉林省高等学校毕业生就业指导中心举办的“双困生培训会”第${term}期`,
|
|
|
+ `欢迎参加由吉林省高等学校毕业生就业指导中心举办的"双困生培训会"第${term}期`,
|
|
|
'感谢您的使用',
|
|
|
'http://www.baidu.com'
|
|
|
);
|
|
|
+ person = { notifiedid: teacherUser.uid, username: teacherUser.name };
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ return person;
|
|
|
}
|
|
|
|
|
|
}
|