|
@@ -17,6 +17,7 @@ class ApplyService extends CrudService {
|
|
|
this.submodel = this.ctx.model.Subject;
|
|
|
this.trainmodel = this.ctx.model.Trainplan;
|
|
|
this.umodel = this.ctx.model.User;
|
|
|
+ this.nmodel = this.ctx.model.Notice;
|
|
|
this.dayList = [ '日', '一', '二', '三', '四', '五', '六' ];
|
|
|
}
|
|
|
|
|
@@ -270,6 +271,7 @@ class ApplyService extends CrudService {
|
|
|
nobj.term = term;
|
|
|
nobj.termid = termid;
|
|
|
nobj.batchid = batchid;
|
|
|
+ nobj.type = cla.type;
|
|
|
const obj = _.omit(cla, [ 'lessons' ]);
|
|
|
nobj.classid = _.clone(cla._id);
|
|
|
nobj = _.assign(nobj, obj);
|
|
@@ -286,12 +288,14 @@ class ApplyService extends CrudService {
|
|
|
* @param {Object} param planid:年度计划id,ids,发送的期列表;classtype:发送班级类型 undefined 都发,有的话就找指定班级类型发
|
|
|
*/
|
|
|
async arrangeSendMsg({ planid, ids, classtype }) {
|
|
|
+ console.log(classtype);
|
|
|
const trainplan = await this.trainmodel.findById(planid);
|
|
|
if (!trainplan) {
|
|
|
throw new BusinessError(ErrorCode.DATA_EXISTED, '年度计划不存在');
|
|
|
}
|
|
|
+ // 大批次id,年度计划id
|
|
|
const plan = _.cloneDeep(trainplan);
|
|
|
- let { termnum } = plan;
|
|
|
+ let { termnum, planyearid } = plan;
|
|
|
if (!termnum) return;
|
|
|
termnum = JSON.parse(JSON.stringify(termnum));
|
|
|
// 整理出课表
|
|
@@ -309,9 +313,12 @@ class ApplyService extends CrudService {
|
|
|
if (teaList) teaList = JSON.parse(JSON.stringify(teaList));
|
|
|
if (teauserList)teauserList = JSON.parse(JSON.stringify(teauserList));
|
|
|
// 发送,此处是根据安排,给教师发.还有一种方案是根据教师,整理安排一起发送
|
|
|
+ // 查询是否发送过这期的通知
|
|
|
for (const l of arr) {
|
|
|
// 教师id,期数,班级名,上课的日期,课程名
|
|
|
- const { teaid, term, name, day, subname } = l;
|
|
|
+ const { teaid, term, name, day, subname, termid, classid, type } = l;
|
|
|
+ // 判断发送的班级类型
|
|
|
+ if (!(classtype && classtype === type)) continue;
|
|
|
const tea = teaList.find(f => f._id === teaid);
|
|
|
const teauser = teauserList.find(f => f.uid === teaid);
|
|
|
// 文案
|
|
@@ -321,14 +328,36 @@ class ApplyService extends CrudService {
|
|
|
${day}(星期${this.dayList[moment(day).days()]})
|
|
|
有您的课程安排:${subname}`;
|
|
|
msg = `${msg}\n 如果您无法进行授课,请及时联系中心负责人`;
|
|
|
+ const { openid } = teauser;
|
|
|
+
|
|
|
// 邮箱与微信都发送
|
|
|
const { email } = tea;
|
|
|
if (email) {
|
|
|
this.toSendEmail(email, msg, tea.name);
|
|
|
}
|
|
|
- const { openid } = teauser;
|
|
|
if (openid) {
|
|
|
- this.toSendWxMsg(openid, msg, tea.name);
|
|
|
+ let notice = await this.nmodel.findOne({ planid, termid, classid, type: '6' });
|
|
|
+ // 找下是否发过信息
|
|
|
+ if (notice) {
|
|
|
+ // 发过信息,找有没有这个教师
|
|
|
+ const { notified } = notice;
|
|
|
+ if (_.isArray(notified)) {
|
|
|
+ const has_notice = notified.find(f => f.notifiedid === teaid);
|
|
|
+ if (has_notice) msg = has_notice;
|
|
|
+ else {
|
|
|
+ const obj = { notifiedid: teaid, username: _.get(tea, 'name', ''), content: msg };
|
|
|
+ notice.notified.push(obj);
|
|
|
+ await notice.save();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ const notified = [{ notifiedid: teaid, username: _.get(tea, 'name', ''), content: msg }];
|
|
|
+ const noticeObj = { planyearid, planid, termid, classid, noticeid: 'system', type: '6', content: `${term}期-${name.includes('班') ? name : `${name}班`}教师计划初步信息确认`, notified };
|
|
|
+ await this.nmodel.create(noticeObj);
|
|
|
+ notice = await this.nmodel.findOne({ planid, termid, classid, type: '6' });
|
|
|
+ }
|
|
|
+ const tourl = this.ctx.app.config.baseUrl + '/msgconfirm/?userid=' + teaid + '¬iceid=' + notice._id;
|
|
|
+ this.toSendWxMsg(openid, msg, tea.name, tourl);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -344,28 +373,29 @@ class ApplyService extends CrudService {
|
|
|
return;
|
|
|
}
|
|
|
const subject = '吉林省高等学校毕业生就业指导中心通知(系统邮件,请勿回复)'; //
|
|
|
- this.ctx.service.util.sendMail(email, subject, content);
|
|
|
+ this.ctx.service.util.sendMail('2938260457@qq.com', subject, content);
|
|
|
}
|
|
|
/**
|
|
|
* 计划-教师初步课表发送微信推送
|
|
|
* @param {String} openid 微信公众号的openid
|
|
|
* @param {String} content 内容
|
|
|
* @param {String} teaname 教师姓名
|
|
|
+ * @param {String} tourl 确认地址
|
|
|
*/
|
|
|
- async toSendWxMsg(openid, content, teaname) {
|
|
|
+ async toSendWxMsg(openid, content, teaname, tourl) {
|
|
|
if (!openid) {
|
|
|
console.error(`计划教师发送微信推送:${teaname}没有openid`);
|
|
|
return;
|
|
|
}
|
|
|
// TODO or notTODO 发送微信推送记录
|
|
|
- // const tourl = this.ctx.app.config.baseUrl + '/msgconfirm/?userid=' + teacherUser.uid + '¬iceid=' + nresid;
|
|
|
await this.ctx.service.weixin.sendTemplateDesign(
|
|
|
this.ctx.app.config.REVIEW_TEMPLATE_ID,
|
|
|
- openid,
|
|
|
+ 'ocPqjswkUejZHq2ANriNrFFC7A3I',
|
|
|
'您有一个新的通知',
|
|
|
'您有新的安排',
|
|
|
content,
|
|
|
- '感谢您的使用'
|
|
|
+ '感谢您的使用',
|
|
|
+ tourl
|
|
|
);
|
|
|
}
|
|
|
}
|