|
@@ -313,7 +313,12 @@ class LessonService extends CrudService {
|
|
|
type: '4',
|
|
|
});
|
|
|
console.log(nres);
|
|
|
- if (nres) is_update = true;
|
|
|
+ let alreadyList = [];
|
|
|
+ if (nres) {
|
|
|
+ const { notified } = nres;
|
|
|
+ alreadyList = notified.filter(i => i.status === '1');
|
|
|
+ is_update = true;
|
|
|
+ }
|
|
|
if (!is_update) {
|
|
|
nres = await this.nmodel.create({
|
|
|
planyearid: planRes.planyearid,
|
|
@@ -329,7 +334,7 @@ class LessonService extends CrudService {
|
|
|
const { headteacherid, lyteacherid } = classInfo;
|
|
|
const headteacher = await this.headteamodel.findById(headteacherid);
|
|
|
if (headteacher) {
|
|
|
- const r = await this.toSendMsg(headteacher, 'headteacher', termnum, nres._id, content);
|
|
|
+ const r = await this.toSendMsg(headteacher, 'headteacher', termnum, nres._id, content, alreadyList);
|
|
|
if (r && !is_update) nres.notified.push(r);
|
|
|
else if (r && is_update) {
|
|
|
const dr = nres.notified.find(f => f.notifiedid === r.notifiedid);
|
|
@@ -340,7 +345,7 @@ class LessonService extends CrudService {
|
|
|
if (lyteacherid !== headteacherid) {
|
|
|
let lyTeacher = await this.headteamodel.findById(lyteacherid);
|
|
|
if (lyTeacher) {
|
|
|
- const r = await this.toSendMsg(lyTeacher, 'headteacher', termnum, nres._id, content);
|
|
|
+ const r = await this.toSendMsg(lyTeacher, 'headteacher', termnum, nres._id, content, alreadyList);
|
|
|
if (r && !is_update) nres.notified.push(r);
|
|
|
else if (r && is_update) {
|
|
|
const dr = nres.notified.find(f => f.notifiedid === r.notifiedid);
|
|
@@ -349,7 +354,7 @@ class LessonService extends CrudService {
|
|
|
} else {
|
|
|
lyTeacher = await this.teamodel.findById(lyteacherid);
|
|
|
if (lyTeacher) {
|
|
|
- const r = await this.toSendMsg(lyTeacher, 'teacher', termnum, nres._id, content);
|
|
|
+ const r = await this.toSendMsg(lyTeacher, 'teacher', termnum, nres._id, content, alreadyList);
|
|
|
if (r && !is_update) nres.notified.push(r);
|
|
|
else if (r && is_update) {
|
|
|
const dr = nres.notified.find(f => f.notifiedid === r.notifiedid);
|
|
@@ -364,7 +369,7 @@ class LessonService extends CrudService {
|
|
|
for (const tea of teacherList) {
|
|
|
const teacher = await this.teamodel.findById(tea);
|
|
|
if (!teacher) continue;
|
|
|
- const r = await this.toSendMsg(teacher, 'teacher', termnum, nres._id, content);
|
|
|
+ const r = await this.toSendMsg(teacher, 'teacher', termnum, nres._id, content, alreadyList);
|
|
|
if (r && !is_update) nres.notified.push(r);
|
|
|
else if (r && is_update) {
|
|
|
const dr = nres.notified.find(f => f.notifiedid === r.notifiedid);
|
|
@@ -376,7 +381,9 @@ class LessonService extends CrudService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- async toSendMsg(teacherInfo, type, term, nresid, content) {
|
|
|
+ async toSendMsg(teacherInfo, type, term, nresid, content, alreadyList) {
|
|
|
+ const r = alreadyList.find(f => ObjectId(f.notifiedid).equals(teacherInfo._id));
|
|
|
+ if (r) return;
|
|
|
let person = null;
|
|
|
if (teacherInfo) {
|
|
|
let email;
|