|
@@ -62,6 +62,8 @@ class ApplyService extends CrudService {
|
|
|
// 排课
|
|
|
for (const l of arr) {
|
|
|
const { termid, subid, day: date, teaid, status, batchid } = l;
|
|
|
+ // 本期超过2次的教师列表,如果没有人就用这里分最高的排
|
|
|
+ let outTwoTimesList = [];
|
|
|
if (status && `${status}` === '1') {
|
|
|
afterList.push(l);
|
|
|
continue;
|
|
@@ -76,7 +78,6 @@ class ApplyService extends CrudService {
|
|
|
let applyList = teaplanList.filter(
|
|
|
f => f.date === date && f.subid === subid
|
|
|
);
|
|
|
- // console.log(applyList.length);
|
|
|
applyList = applyList.map(i => {
|
|
|
let obj = { ...JSON.parse(JSON.stringify(i)) };
|
|
|
const r = teacherList.find(f => i.teacherid === f._id);
|
|
@@ -92,8 +93,6 @@ class ApplyService extends CrudService {
|
|
|
applyList = applyList.filter(f => f.score);
|
|
|
// 按成绩排序
|
|
|
applyList = _.orderBy(applyList, [ 'score' ], [ 'desc' ]);
|
|
|
- // 本期超过2次的教师列表,如果没有人就用这里分最高的排
|
|
|
- const outTwoTimesList = [];
|
|
|
// 依次循环申请的教师列表,往这个课程安排中放教师
|
|
|
for (const atea of applyList) {
|
|
|
// 先查询,该教师,是否在今天有安排
|
|
@@ -105,8 +104,9 @@ class ApplyService extends CrudService {
|
|
|
const r = afterList.filter(
|
|
|
f => f.termid === termid && f.teaid === atea.teacherid
|
|
|
);
|
|
|
+
|
|
|
if (r.length >= 2) {
|
|
|
- outTwoTimesList.push(atea);
|
|
|
+ outTwoTimesList = [ ...outTwoTimesList, atea ];
|
|
|
continue;
|
|
|
} else {
|
|
|
l.teaid = atea.teacherid;
|
|
@@ -115,14 +115,9 @@ class ApplyService extends CrudService {
|
|
|
}
|
|
|
}
|
|
|
// 检查,该天,该科的课是否有教师
|
|
|
- const has_teaid = _.has(l, 'teaid');
|
|
|
+ const has_teaid = _.get(l, 'teaid');
|
|
|
if (!has_teaid) {
|
|
|
- // 如果没有教师,就需要在outTowTimesList列表中找分最高的教师
|
|
|
- // const head = _.head();
|
|
|
- // if (head) {
|
|
|
- // l.teaid = head.teacherid;
|
|
|
- // l.teaname = head.teaname;
|
|
|
- // }
|
|
|
+ // // 如果没有教师,就需要在outTowTimesList列表中找分最高的教师
|
|
|
const list = _.orderBy(outTwoTimesList, [ 'score' ], [ 'desc' ]);
|
|
|
for (const i of list) {
|
|
|
const tr = afterList.find(
|
|
@@ -132,6 +127,7 @@ class ApplyService extends CrudService {
|
|
|
else {
|
|
|
l.teaid = i.teacherid;
|
|
|
l.teaname = i.teaname;
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -143,6 +139,41 @@ class ApplyService extends CrudService {
|
|
|
trainplan.termnum = newTermnum;
|
|
|
await trainplan.save();
|
|
|
}
|
|
|
+ // 确认计划安排
|
|
|
+ async arrangeConfirm({ planid, ids }) {
|
|
|
+ console.log(planid, ids);
|
|
|
+ const trainplan = await this.trainmodel.findById(planid);
|
|
|
+ if (!trainplan) {
|
|
|
+ throw new BusinessError(ErrorCode.DATA_EXISTED, '年度计划不存在');
|
|
|
+ }
|
|
|
+ const plan = _.cloneDeep(trainplan);
|
|
|
+ let { termnum } = plan;
|
|
|
+ if (!termnum) return;
|
|
|
+ termnum = JSON.parse(JSON.stringify(termnum));
|
|
|
+ // 过滤出确认的期,TODO:没有做通知
|
|
|
+ termnum = termnum.filter(f => ids.includes(f._id));
|
|
|
+ // 找到每个教师的位置,然后把状态(status)改成1=>已确认
|
|
|
+ for (const t of termnum) {
|
|
|
+ const { term } = t;
|
|
|
+ if (!(t.batchnum && _.isArray(t.batchnum))) continue;
|
|
|
+ for (const b of t.batchnum) {
|
|
|
+ const { batch } = b;
|
|
|
+ if (!(b.class && _.isArray(b.class))) continue;
|
|
|
+ for (const c of b.class) {
|
|
|
+ if (!(c.lessons && _.isArray(c.lessons))) continue;
|
|
|
+ for (const l of c.lessons) {
|
|
|
+ l.status = '1';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ trainplan.termnum = termnum;
|
|
|
+ await trainplan.save();
|
|
|
+ }
|
|
|
+
|
|
|
+ arrangeLesson() {
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 拍平了的课表=>termnum
|
|
@@ -203,14 +234,14 @@ class ApplyService extends CrudService {
|
|
|
* @param {Array} termnum 计划的termnum
|
|
|
*/
|
|
|
setLessonList(termnum) {
|
|
|
- const arr = [];
|
|
|
+ let arr = [];
|
|
|
for (const t of termnum) {
|
|
|
const { batchnum, term, _id: termid } = t;
|
|
|
// 班级和课程一一匹
|
|
|
for (const b of batchnum) {
|
|
|
const { class: classes, lessons, _id: batchid } = b;
|
|
|
const claslesList = this.setList(
|
|
|
- term,
|
|
|
+ term * 1,
|
|
|
termid,
|
|
|
batchid,
|
|
|
classes,
|
|
@@ -219,6 +250,7 @@ class ApplyService extends CrudService {
|
|
|
arr.push(...claslesList);
|
|
|
}
|
|
|
}
|
|
|
+ arr = _.orderBy(arr, [ 'term', 'day' ], [ 'asc', 'asc' ]);
|
|
|
return arr;
|
|
|
}
|
|
|
/**
|
|
@@ -279,7 +311,6 @@ class ApplyService extends CrudService {
|
|
|
const { teaid, term, name, day, subname } = l;
|
|
|
const tea = teaList.find(f => f._id === teaid);
|
|
|
const teauser = teauserList.find(f => f.uid === teaid);
|
|
|
- console.log(teauser);
|
|
|
// 文案
|
|
|
const msg = `${_.get(tea, 'name', '')}老师您好:
|
|
|
吉林省高等学校毕业生就业指导中心-双困生培训系统提醒您:
|
|
@@ -289,11 +320,11 @@ class ApplyService extends CrudService {
|
|
|
// 邮箱与微信都发送
|
|
|
const { email } = tea;
|
|
|
if (email) {
|
|
|
- // this.toSendEmail(email, msg, tea.name);
|
|
|
+ this.toSendEmail(email, msg, tea.name);
|
|
|
}
|
|
|
const { openid } = teauser;
|
|
|
if (openid) {
|
|
|
- this.toSendWxMsg('ocPqjswkUejZHq2ANriNrFFC7A3I', msg, tea.name);
|
|
|
+ this.toSendWxMsg(openid, msg, tea.name);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -324,7 +355,6 @@ class ApplyService extends CrudService {
|
|
|
}
|
|
|
// TODO or notTODO 发送微信推送记录
|
|
|
// const tourl = this.ctx.app.config.baseUrl + '/msgconfirm/?userid=' + teacherUser.uid + '¬iceid=' + nresid;
|
|
|
- console.log('in function:');
|
|
|
await this.ctx.service.weixin.sendTemplateDesign(
|
|
|
this.ctx.app.config.REVIEW_TEMPLATE_ID,
|
|
|
openid,
|