apply.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613
  1. 'use strict';
  2. const assert = require('assert');
  3. const { after } = require('lodash');
  4. const _ = require('lodash');
  5. const moment = require('moment');
  6. const { ObjectId } = require('mongoose').Types;
  7. const { CrudService } = require('naf-framework-mongoose/lib/service');
  8. const { BusinessError, ErrorCode } = require('naf-core').Error;
  9. class ApplyService extends CrudService {
  10. constructor(ctx) {
  11. super(ctx, 'apply');
  12. this.model = this.ctx.model.Apply;
  13. this.tmodel = this.ctx.model.Teacher;
  14. this.submodel = this.ctx.model.Subject;
  15. this.trainmodel = this.ctx.model.Trainplan;
  16. this.umodel = this.ctx.model.User;
  17. this.nmodel = this.ctx.model.Notice;
  18. this.dayList = [ '日', '一', '二', '三', '四', '五', '六' ];
  19. }
  20. // 查询
  21. async queryteacher(query) {
  22. const { termid, subid, date } = query;
  23. const data = await this.model
  24. .find({ termid, subid, date })
  25. .sort({ msscore: -1 });
  26. const teachers = [];
  27. for (const _data of data) {
  28. const teacherid = _data.teacherid;
  29. const teacher = await this.tmodel.findById(teacherid);
  30. teachers.push(teacher);
  31. }
  32. return teachers;
  33. }
  34. /**
  35. * 教师计划初步课表安排,可反复使用
  36. * @param {Object} body planid:计划id,ids:期数id列表;classtype:班级类型
  37. */
  38. async arrangeteacher({ planid, ids, classtype }) {
  39. console.log(classtype);
  40. assert(planid, '缺少计划信息');
  41. const trainplan = await this.trainmodel.findById(planid);
  42. if (!trainplan) {
  43. throw new BusinessError(ErrorCode.DATA_EXISTED, '年度计划不存在');
  44. }
  45. // trainplan = JSON.parse(JSON.stringify(trainplan));
  46. // 查找所有教师列表
  47. let teacherList = await this.tmodel.find({ xsscore: { $exists: true } });
  48. teacherList = JSON.parse(JSON.stringify(teacherList));
  49. // 查找所有教师上报列表
  50. let teaplanList = await this.model.find();
  51. teaplanList = JSON.parse(JSON.stringify(teaplanList));
  52. // 课程
  53. let subjectList = await this.submodel.find();
  54. subjectList = JSON.parse(JSON.stringify(subjectList));
  55. const termList = _.cloneDeep(trainplan);
  56. let { termnum } = termList;
  57. if (!termnum) return;
  58. termnum = JSON.parse(JSON.stringify(termnum));
  59. // 整理出课表
  60. const arr = this.setLessonList(termnum);
  61. // 安排后的课表
  62. const afterList = [];
  63. // 排课
  64. for (const l of arr) {
  65. const { termid, subid, day: date, status, type, classid } = l;
  66. // 检验是否在需要安排的期内
  67. if (!ids.includes(termid)) {
  68. // 不在要求安排的期内,就直接放回去
  69. afterList.push(l);
  70. continue;
  71. }
  72. // 检查是否符合要求的班级类型
  73. if (classtype || `${classtype}` === '0') {
  74. // 不符合,放回去,下一个
  75. if (`${classtype}` !== `${type}`) {
  76. afterList.push(l);
  77. continue;
  78. }
  79. }
  80. // 重置教师
  81. l.teaid = null;
  82. l.teaname = null;
  83. if (status && `${status}` === '1') {
  84. afterList.push(l);
  85. continue;
  86. }
  87. const subject = subjectList.find(f => ObjectId(subid).equals(f._id));
  88. if (subject.need_teacher !== '0') {
  89. afterList.push(l);
  90. continue;
  91. }
  92. // 申请该天,该科目的教师,并查出教师的名字,分数;并按分数排序
  93. let applyList = teaplanList.filter(
  94. f => f.date === date && f.subid === subid
  95. );
  96. applyList = applyList.map(i => {
  97. let obj = { ...JSON.parse(JSON.stringify(i)) };
  98. const r = teacherList.find(f => i.teacherid === f._id);
  99. if (r) {
  100. const { name: teaname, xsscore: score } = r;
  101. i.teaname = teaname;
  102. i.score = score * 1;
  103. obj = { ...obj, teaname, score };
  104. }
  105. return obj;
  106. });
  107. // 过滤出没有分数的,不排
  108. applyList = applyList.filter(f => f.score);
  109. // 按成绩排序
  110. applyList = _.orderBy(applyList, [ 'score' ], [ 'desc' ]);
  111. // 本期超过2次的教师列表,如果没有人就用这里分最高的排 + 教过这个班的教师列表,不过内容都一样
  112. let outTwoTimesList = [];
  113. // 依次循环申请的教师列表,往这个课程安排中放教师
  114. for (const atea of applyList) {
  115. // 先查询,该教师,是否在今天有安排 条件1:同一天,一个教师只能有一次,因为一上一天课
  116. const tr = afterList.find(
  117. f => f.teaid === atea.teacherid && f.day === atea.date
  118. );
  119. if (tr) continue;
  120. // 条件2:优先排一期2次以内的教师,超过2次的教师延后排,根据 次数升序,分数降序找合适的;
  121. // 查看这期内,每个申请上课的教师时候超过2天(2条记录),如果超过,则不排,但是如果最后没有人了,就得硬排了
  122. const r = afterList.filter(
  123. f => f.termid === termid && f.teaid === atea.teacherid
  124. );
  125. if (r.length >= 2) {
  126. // 需要记录这个老师已经有几次
  127. const obj = { ...atea, times: r.length };
  128. outTwoTimesList = [ ...outTwoTimesList, obj ];
  129. continue;
  130. } else {
  131. // 条件3:尽量不让一个教师在一个班出现2次及其以上,但是如果没人,之前又排完了,还是会出现一个教师教1个班2天的情况,所以需要最后收尾检查
  132. const alreadyTeach = afterList.find(
  133. f => f.classid === classid && f.teaid === atea.teacherid
  134. );
  135. if (alreadyTeach) {
  136. // 已经教过这个班了,也暂时放到2次以上列表中,将次数记录下来
  137. const obj = { ...atea, times: r.length };
  138. outTwoTimesList = [ ...outTwoTimesList, obj ];
  139. continue;
  140. }
  141. l.teaid = atea.teacherid;
  142. l.teaname = atea.teaname;
  143. break;
  144. }
  145. }
  146. // 检查,该天,该科的课是否有教师
  147. const has_teaid = _.get(l, 'teaid');
  148. if (!has_teaid) {
  149. // 如果没有教师,就需要在outTowTimesList列表中找分最高的教师
  150. // 排序需要根据,次数(后加的),分数排序,优先选次数最少,分数最高的教师
  151. const list = _.orderBy(
  152. outTwoTimesList,
  153. [ 'times', 'score' ],
  154. [ 'asc', 'desc' ]
  155. );
  156. for (const i of list) {
  157. const tr = afterList.find(
  158. f => f.teaid === i.teacherid && f.day === i.date
  159. );
  160. if (tr) continue;
  161. else {
  162. l.teaid = i.teacherid;
  163. l.teaname = i.teaname;
  164. break;
  165. }
  166. }
  167. }
  168. afterList.push(l);
  169. }
  170. // 需要按classid分组,然后查每组下,有没有重复教师,如果有重复教师,提取出这个教师的日期,科目,分2种情况:
  171. // 1)可以和其他班教师换下位置;2)没法换,只能排下个教师
  172. // 查找这天,这科的 课程安排 且 这些课程的教师 没给这个班级上过课 (undefined也算,每排教师)
  173. // =>如果有满足条件的教师, 找到该班, 然后查看,现在需要换的这个教师是否也满足 没给这个班上过课 的条件
  174. // =>满足条件,两个班级的教师对调
  175. // =>不满足条件直至没有教师,需要整理出 applyList,然后将现在这个教师排除掉(放到一个空间),然后找其他满足条件的教师,如果没有,那就只能有他了
  176. const checkList = afterList.filter(f => ids.includes(f.termid) && f.type === classtype && f.teaid);
  177. const groupObj = _.groupBy(checkList, 'classid');
  178. const keys = Object.keys(groupObj);
  179. const exchangeList = [];
  180. for (const key of keys) {
  181. const arr = groupObj[key];
  182. const teaids = arr.map(i => _.pick(i, [ 'day', 'subid', 'teaid' ]));
  183. for (const l of arr) {
  184. const { day, subid, teaid, teaname, termid } = l;
  185. // 找下这个教师在这个班级中,是否教了多科
  186. let findres = teaids.filter(f => f.teaid === teaid);
  187. // 2科以下,跳过不看
  188. if (findres.length < 2) continue;
  189. // 2科以上,需要找到每一天的申请名单,可最多的那天先换
  190. // 先查下同一天,同一科的教师能不能换
  191. const toDaySubjectList = afterList.filter(f => f.subid === subid && f.day === day && f.teaid !== teaid);
  192. let sameSubChange = false;
  193. for (const tdstea of toDaySubjectList) {
  194. // 找一下,这个教师能不能换到这个班和当前重复教一个班的教师能不能带这个教师的班
  195. // 为什么这么找:因为到这里之前,所有需要安排的课程,已经按照1,2原则排完,是最优解,所以尽可能在最优解之间进行调换,
  196. // 如果最优解没有办法调换,那就只能往下找了,对于两个班的情况可能常见,但是对于三个班来说基本就很少了,如果开4个班,基本就不存在这个问题了,
  197. // 循环的教师,需要在teaids中找有没有这个教师
  198. const first = teaids.find(f => f.teaid === tdstea.teaid);
  199. if (first) continue;
  200. else {
  201. // 如果这个教师可以,需要进行反查,查当前有问题的这个教师,在没在要和他换的教师班级里讲过课
  202. const { classid } = tdstea;
  203. const tdsLessonClass = groupObj[classid];
  204. const sec = tdsLessonClass.find(f => f.teaid === teaid);
  205. // 如果这个教师教过要调换教师那个班,就继续找看下个老师
  206. if (sec) continue;
  207. sameSubChange = tdstea;
  208. }
  209. }
  210. // 判断sameSubChange,如果不为false,则说明当天教师可以替换,接着continue就行
  211. if (sameSubChange) {
  212. const { teaid: oteaid, teaname: oteaname } = sameSubChange;
  213. // 要替换的索引
  214. const oindex = afterList.findIndex(f => _.isEqual(f, sameSubChange));
  215. // 重复老师的索引
  216. const tindex = afterList.findIndex(f => _.isEqual(f, l));
  217. // 交换
  218. afterList[oindex].teaid = teaid;
  219. afterList[oindex].teaname = teaname;
  220. afterList[tindex].teaid = oteaid;
  221. afterList[tindex].teaname = oteaname;
  222. continue;
  223. }
  224. // 如果到这里了,也就是说同天同科的教师都替换不了,那就是一点血找也没有了
  225. for (const les of findres) {
  226. // 申请的教师
  227. let applyList = teaplanList.filter(
  228. f => f.date === les.day && f.subid === les.subid && f.teacherid !== les.teaid
  229. );
  230. applyList = applyList.map(i => {
  231. let obj = { ...JSON.parse(JSON.stringify(i)) };
  232. const r = teacherList.find(f => i.teacherid === f._id);
  233. if (r) {
  234. const { name: teaname, xsscore: score } = r;
  235. i.teaname = teaname;
  236. i.score = score * 1;
  237. obj = { ...obj, teaname, score };
  238. }
  239. return obj;
  240. });
  241. // 过滤出没有分数的,不排
  242. applyList = applyList.filter(f => f.score);
  243. // 过滤出当天有课的教师
  244. applyList = applyList.filter(f => !(afterList.find(af => af.day === f.day && af.teaid === f.teaid)));
  245. // 过滤出这期有几次
  246. applyList = applyList.map(i => {
  247. // 找到这个教师在这期有几次
  248. const r = afterList.filter(f => f.termid === termid && f.teaid === i.teaid);
  249. i.times = r.length;
  250. return i;
  251. });
  252. // 按成绩排序
  253. applyList = _.orderBy(applyList, [ 'times', 'score' ], [ 'asc', 'desc' ]);
  254. // 整理出教师教这个班的所有科目的其他可选教师(排除已经排完课的教师)
  255. les.applyList = applyList;
  256. les.applynum = applyList.length;
  257. }
  258. // 按照申请人数排序,然后看看人最多那天是不是这天,如果是这天,就处理
  259. findres = _.orderBy(findres, [ 'applynum' ], [ 'desc' ]);
  260. const head = _.head(findres);
  261. if (head.day === day) {
  262. // 如果当前日期,是申请人数最多的,就处理它
  263. const { applyList } = head;
  264. if (applyList.length >= 0) {
  265. // 将排完序的第一个教师拿出来(一定是符合要求的)
  266. const apply = _.head(applyList);
  267. const { teaid, teaname } = apply;
  268. const tindex = afterList.findIndex(f => _.isEqual(f, l));
  269. afterList[tindex].teaid = teaid;
  270. afterList[tindex].teaname = teaname;
  271. }
  272. }
  273. }
  274. }
  275. // 将afterList还原回正常的termnum;
  276. const newTermnum = this.returnTermnum(afterList, termnum);
  277. // 保存至计划
  278. trainplan.termnum = newTermnum;
  279. await trainplan.save();
  280. }
  281. // 确认计划安排
  282. async arrangeConfirm({ planid, ids, classtype }) {
  283. const trainplan = await this.trainmodel.findById(planid);
  284. if (!trainplan) {
  285. throw new BusinessError(ErrorCode.DATA_EXISTED, '年度计划不存在');
  286. }
  287. const plan = _.cloneDeep(trainplan);
  288. let { termnum } = plan;
  289. if (!termnum) return;
  290. termnum = JSON.parse(JSON.stringify(termnum));
  291. // 过滤出确认的期,TODO:没有做通知
  292. // termnum = termnum.filter(f => );
  293. // 找到每个教师的位置,然后把状态(status)改成1=>已确认
  294. for (const t of termnum) {
  295. if (!ids.includes(t._id)) continue;
  296. const { term } = t;
  297. if (!(t.batchnum && _.isArray(t.batchnum))) continue;
  298. for (const b of t.batchnum) {
  299. const { batch } = b;
  300. if (!(b.class && _.isArray(b.class))) continue;
  301. for (const c of b.class) {
  302. // 检查是否要求班级类型
  303. if (classtype || `${classtype}` === '0') {
  304. // 获取这个班级的班级类型
  305. const { type } = c;
  306. // 判断班级类型与要求的符不符合,不符合就跳过不改
  307. if (`${type}` !== `${classtype}`) continue;
  308. }
  309. if (!(c.lessons && _.isArray(c.lessons))) continue;
  310. for (const l of c.lessons) {
  311. l.status = '1';
  312. }
  313. }
  314. }
  315. }
  316. // console.log(termnum);
  317. trainplan.termnum = termnum;
  318. await trainplan.save();
  319. }
  320. /**
  321. * 拍平了的课表=>termnum
  322. * @param {Array} list 拍平了的课表,详情参考页面的初步课表的数据
  323. * @param {Array} termnum 原termnum
  324. */
  325. returnTermnum(list, termnum) {
  326. let newTermnum = [];
  327. for (const l of list) {
  328. const { termid, batchid, classid, ...info } = l;
  329. const updata = _.pick(info, [
  330. 'day',
  331. 'subid',
  332. 'subname',
  333. 'teaid',
  334. 'teaname',
  335. 'time',
  336. 'status',
  337. ]);
  338. newTermnum = termnum.map(t => {
  339. // 找到期
  340. if (termid === t._id) {
  341. t.batchnum = t.batchnum.map(b => {
  342. if (batchid === b._id) {
  343. // 找到批次
  344. b.class = b.class.map(c => {
  345. if (classid === c._id) {
  346. if (c.lessons) {
  347. // 说明有课程安排,找有没有重复的,没有就推进去,有就更改,subid查
  348. const r = c.lessons.find(f => f.subid === updata.subid);
  349. if (r) {
  350. const rindex = c.lessons.findIndex(
  351. f => f.subid === updata.subid
  352. );
  353. c.lessons[rindex] = updata;
  354. } else {
  355. c.lessons.push(updata);
  356. }
  357. } else {
  358. // 说明没有课程安排,放进去一条保存
  359. c.lessons = [ updata ];
  360. }
  361. }
  362. return c;
  363. });
  364. }
  365. return b;
  366. });
  367. }
  368. return t;
  369. });
  370. }
  371. return newTermnum;
  372. }
  373. /**
  374. * 将课表拍平了,从多维=>一维
  375. * @param {Array} termnum 计划的termnum
  376. */
  377. setLessonList(termnum) {
  378. let arr = [];
  379. for (const t of termnum) {
  380. const { batchnum, term, _id: termid } = t;
  381. // 班级和课程一一匹
  382. for (const b of batchnum) {
  383. const { class: classes, lessons, _id: batchid } = b;
  384. const claslesList = this.setList(
  385. term * 1,
  386. termid,
  387. batchid,
  388. classes,
  389. lessons
  390. );
  391. arr.push(...claslesList);
  392. }
  393. }
  394. arr = _.orderBy(arr, [ 'term', 'day' ], [ 'asc', 'asc' ]);
  395. return arr;
  396. }
  397. /**
  398. * 将课表模板和班级整理成一维数组
  399. * @param {String} term 期数
  400. * @param {String} termid 期id
  401. * @param {String} batchid 批id
  402. * @param {Array} classes 班级列表
  403. * @param {Array} lessonTemplate 课表模板
  404. */
  405. setList(term, termid, batchid, classes, lessonTemplate) {
  406. const arr = [];
  407. // 班级和课程匹配
  408. for (const cla of classes) {
  409. let { lessons } = cla;
  410. if (!lessons) lessons = lessonTemplate;
  411. for (const i of lessons) {
  412. let nobj = {};
  413. nobj.term = term;
  414. nobj.termid = termid;
  415. nobj.batchid = batchid;
  416. nobj.type = cla.type;
  417. const obj = _.omit(cla, [ 'lessons' ]);
  418. nobj.classid = _.clone(cla._id);
  419. nobj = _.assign(nobj, obj);
  420. nobj = _.assign(nobj, i);
  421. arr.push(nobj);
  422. }
  423. }
  424. return arr;
  425. }
  426. /**
  427. * 发送消息
  428. * @param {Object} param planid:年度计划id,ids,发送的期列表;classtype:发送班级类型 undefined 都发,有的话就找指定班级类型发
  429. */
  430. async arrangeSendMsg({ planid, ids, classtype }) {
  431. const trainplan = await this.trainmodel.findById(planid);
  432. if (!trainplan) {
  433. throw new BusinessError(ErrorCode.DATA_EXISTED, '年度计划不存在');
  434. }
  435. // 大批次id,年度计划id
  436. const plan = _.cloneDeep(trainplan);
  437. let { termnum, planyearid } = plan;
  438. if (!termnum) return;
  439. termnum = JSON.parse(JSON.stringify(termnum));
  440. // 整理出课表
  441. let arr = this.setLessonList(termnum);
  442. // 过滤出需要发送的教师
  443. arr = arr.filter(f => ids.find(id => f.termid === id) && f.teaid);
  444. // && f.status !== '1'
  445. // 整理出要发送的教师列表
  446. let teaids = arr.map(i => i.teaid);
  447. teaids = _.uniq(teaids);
  448. // 找到教师信息
  449. let teaList = await this.tmodel.find({ _id: teaids });
  450. // 找到教师用户信息
  451. let teauserList = await this.umodel.find({ uid: teaids });
  452. if (teaList) teaList = JSON.parse(JSON.stringify(teaList));
  453. if (teauserList) teauserList = JSON.parse(JSON.stringify(teauserList));
  454. // 发送,此处是根据安排,给教师发.还有一种方案是根据教师,整理安排一起发送
  455. // 查询是否发送过这期的通知
  456. // 排序
  457. arr = _.orderBy(arr, [ 'day' ], [ 'asc' ]);
  458. for (const l of arr) {
  459. // 教师id,期数,班级名,上课的日期,课程名
  460. const {
  461. teaid,
  462. term,
  463. name,
  464. day,
  465. subname,
  466. termid,
  467. classid,
  468. type,
  469. status,
  470. } = l;
  471. // 已确认的教师不发信息
  472. if (status === '1') continue;
  473. // 判断发送的班级类型
  474. if (!(classtype && classtype === type)) continue;
  475. const tea = teaList.find(f => f._id === teaid);
  476. const teauser = teauserList.find(f => f.uid === teaid);
  477. // 文案
  478. let msg = `${_.get(tea, 'name', '')}老师您好:
  479. 吉林省高等学校毕业生就业指导中心-双困生培训系统提醒您:
  480. ${term}期-${name.includes('班') ? name : `${name}班`}
  481. ${day}(星期${this.dayList[moment(day).days()]})
  482. 有您的课程安排:${subname}`;
  483. msg = `${msg}\n 如果您无法进行授课,请及时联系中心负责人`;
  484. const { openid } = teauser;
  485. let tourl;
  486. let to_send = false;
  487. if (openid) {
  488. let notice = await this.nmodel.findOne({
  489. planid,
  490. termid,
  491. classid,
  492. type: '6',
  493. });
  494. // 找下是否发过信息
  495. if (notice) {
  496. // 发过信息,找有没有这个教师
  497. const { notified } = notice;
  498. if (_.isArray(notified)) {
  499. const has_notice = notified.find(f => f.notifiedid === teaid);
  500. if (has_notice) {
  501. const { status } = has_notice;
  502. if (status !== '1') to_send = true;
  503. } else {
  504. const obj = {
  505. notifiedid: teaid,
  506. username: _.get(tea, 'name', ''),
  507. content: msg,
  508. };
  509. notice.notified.push(obj);
  510. await notice.save();
  511. to_send = true;
  512. }
  513. }
  514. } else {
  515. const notified = [
  516. {
  517. notifiedid: teaid,
  518. username: _.get(tea, 'name', ''),
  519. content: msg,
  520. },
  521. ];
  522. const noticeObj = {
  523. planyearid,
  524. planid,
  525. termid,
  526. classid,
  527. noticeid: 'system',
  528. type: '6',
  529. content: `${term}期-${
  530. name.includes('班') ? name : `${name}班`
  531. }教师计划初步信息确认`,
  532. notified,
  533. };
  534. await this.nmodel.create(noticeObj);
  535. notice = await this.nmodel.findOne({
  536. planid,
  537. termid,
  538. classid,
  539. type: '6',
  540. });
  541. to_send = true;
  542. }
  543. tourl =
  544. this.ctx.app.config.baseUrl +
  545. '/msgconfirm/?userid=' +
  546. teaid +
  547. '&noticeid=' +
  548. notice._id;
  549. }
  550. if (to_send) {
  551. // 邮箱与微信都发送
  552. const { email } = tea;
  553. if (email) {
  554. this.toSendEmail(email, msg, tea.name);
  555. }
  556. if (openid) {
  557. this.toSendWxMsg(openid, msg, tea.name, tourl);
  558. }
  559. }
  560. }
  561. }
  562. /**
  563. * 计划-教师初步课表发送邮件
  564. * @param {String} email 邮件
  565. * @param {String} content 内容
  566. * @param {String} teaname 教师姓名
  567. */
  568. async toSendEmail(email, content, teaname) {
  569. if (!email) {
  570. console.error(`计划教师发送通知:${teaname}没有email`);
  571. return;
  572. }
  573. const subject = '吉林省高等学校毕业生就业指导中心通知(系统邮件,请勿回复)'; //
  574. this.ctx.service.util.sendMail(email, subject, content);
  575. }
  576. /**
  577. * 计划-教师初步课表发送微信推送
  578. * @param {String} openid 微信公众号的openid
  579. * @param {String} content 内容
  580. * @param {String} teaname 教师姓名
  581. * @param {String} tourl 确认地址
  582. */
  583. async toSendWxMsg(openid, content, teaname, tourl) {
  584. if (!openid) {
  585. console.error(`计划教师发送微信推送:${teaname}没有openid`);
  586. return;
  587. }
  588. // TODO or notTODO 发送微信推送记录
  589. await this.ctx.service.weixin.sendTemplateDesign(
  590. this.ctx.app.config.REVIEW_TEMPLATE_ID,
  591. openid,
  592. '您有一个新的通知',
  593. '您有新的安排',
  594. content,
  595. '感谢您的使用',
  596. tourl
  597. );
  598. }
  599. }
  600. module.exports = ApplyService;