class.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576
  1. 'use strict';
  2. const assert = require('assert');
  3. const _ = require('lodash');
  4. const { ObjectId } = require('mongoose').Types;
  5. const { CrudService } = require('naf-framework-mongoose/lib/service');
  6. const { BusinessError, ErrorCode } = require('naf-core').Error;
  7. class ClassService extends CrudService {
  8. constructor(ctx) {
  9. super(ctx, 'class');
  10. this.model = this.ctx.model.Class;
  11. this.stumodel = this.ctx.model.Student;
  12. this.lessmodel = this.ctx.model.Lesson;
  13. this.umodel = this.ctx.model.User;
  14. this.tmodel = this.ctx.model.Trainplan;
  15. this.gmodel = this.ctx.model.Group;
  16. this.heamodel = this.ctx.model.Headteacher;
  17. this.teamodel = this.ctx.model.Teacher;
  18. this.locamodel = this.ctx.model.Location;
  19. }
  20. async divide(data) {
  21. const { planid, termid } = data;
  22. assert(planid, '计划id为必填项');
  23. assert(termid, '期id为必填项');
  24. // 先自动生成班级 TODO:之后放开
  25. await this.autoclass(planid, termid);
  26. // 根据计划id与期id查询所有批次下的班级
  27. const newclass = await this.model.find({ planid, termid });
  28. if (!newclass) {
  29. throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '班级信息不存在');
  30. }
  31. // 根据计划和期查询所有上报的学生 并按照学校排序
  32. const newstudent = await this.stumodel.find({ termid }).sort({ schid: 1 });
  33. if (!newstudent) {
  34. throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '学生信息不存在');
  35. }
  36. // 按批次分组,每个批次处理自己的
  37. const claGroup = _.groupBy(newclass, 'batchid');
  38. const keys = Object.keys(claGroup);
  39. const result = {}; // key:班级id;value:学生id数组
  40. for (const bkey of keys) {
  41. const classList = claGroup[bkey]; // 该批次下的班级列表
  42. const batchStudentList = _.shuffle(newstudent.filter(f => f.batchid === bkey)); // shuffle:打乱顺序 该批次下的学生列表
  43. // 分为多个学校 男/女 数组
  44. // 按学校分组
  45. const sgroup = _.groupBy(batchStudentList, 'schid');
  46. // 学校代码key
  47. const schKeys = Object.keys(sgroup);
  48. const studentGroup = {}; // key:学校id-boys/girls;value:对应学校,性别的学生列表
  49. for (const skey of schKeys) {
  50. const schstus = sgroup[skey];
  51. const boys = schstus.filter(f => f.gender.includes('男'));
  52. const girls = schstus.filter(f => f.gender.includes('女'));
  53. studentGroup[`${skey}-boy`] = boys;
  54. studentGroup[`${skey}-girl`] = girls;
  55. }
  56. // 往班级里塞人
  57. for (const cla of classList) {
  58. let { number, _id, name } = cla;
  59. result[_id] = [];
  60. number = parseInt(number);
  61. if (!_.isNumber(number)) throw new BusinessError(ErrorCode.DATA_INVALID, `${name}班的人数设置无法转换成数字处理`);
  62. const ko = { boy: 0, girl: 0 }; // key:学校/性别; value:分配多少人了
  63. // 制作keyList,主要是把学校计数key放进去
  64. for (const skey of schKeys) ko[skey] = 0;
  65. // 循环这个班的坑:目的就是给班级的坑填上
  66. for (let i = 0; i < number; i++) {
  67. // 通过方法,获取备选 学校 性别的选择数组
  68. const selects = this.getSelects(ko);
  69. // 循环优先级结果,依次验证,如果成立,则直接按照schid和gender去找对应学校的对应性别的学生,推进去;删掉学生;计数
  70. for (const s of selects) {
  71. const { schid, gender } = s;
  72. // 获取数组
  73. let stuList = _.cloneDeep(_.get(studentGroup, `${schid}-${gender}`, []));
  74. // 有学生,则为最优解
  75. const head = _.head(stuList);
  76. if (head) {
  77. // 推人,删除,计数
  78. const { _id: studentid } = head;
  79. // 推人
  80. result[_id].push(studentid);
  81. // 删人
  82. stuList = _.drop(stuList);
  83. studentGroup[`${schid}-${gender}`] = stuList;
  84. // 计数
  85. ko[schid]++;
  86. ko[gender]++;
  87. break;
  88. } else {
  89. // 下一个选择验证
  90. continue;
  91. }
  92. }
  93. }
  94. }
  95. }
  96. // 更新学生的班级
  97. const ckeys = Object.keys(result);
  98. for (const classid of ckeys) {
  99. await this.stumodel.updateMany({ _id: result[classid] }, { classid });
  100. }
  101. // 新添,给学生排序号
  102. const claList = await this.model.find({ termid });
  103. for (const cla of claList) {
  104. await this.ctx.service.student.arrangeNumber({ classid: cla._id });
  105. }
  106. }
  107. // 获取选择结果
  108. getSelects(keyObject) {
  109. const keys = Object.keys(keyObject);
  110. const skeys = keys.filter(f => !_.isNaN(parseInt(f))); // 学校计数器的key
  111. const gkeys = keys.filter(f => _.isNaN(parseInt(f))); // 性别计数器的key
  112. // 得到学校计数的升序排列(数最少的在最上面)
  113. let sr = [];
  114. for (const skey of skeys) {
  115. sr.push({ key: skey, value: keyObject[skey] });
  116. }
  117. sr = _.orderBy(sr, [ 'value' ], [ 'asc' ]);
  118. // 同理获得性别计数的升序排列
  119. let gr = [];
  120. for (const gkey of gkeys) {
  121. gr.push({ key: gkey, value: keyObject[gkey] });
  122. }
  123. gr = _.orderBy(gr, [ 'value' ], [ 'asc' ]);
  124. // 最后双循环得到最后学校+性别的优先级结果
  125. const result = [];
  126. // 优先性别
  127. for (const g of gr) {
  128. for (const s of sr) {
  129. result.push({ schid: s.key, gender: g.key });
  130. }
  131. }
  132. return result;
  133. }
  134. // 取得同样类型的学生
  135. async getstutype(_students, type) {
  136. const data = [];
  137. for (const stuid of _students) {
  138. const student = await this.stumodel.findById(stuid);
  139. if (student && student.type === type) {
  140. data.push(stuid);
  141. }
  142. }
  143. return data;
  144. }
  145. // 自动生成班级私有方法
  146. async autoclass(planid, termid) {
  147. // 删除所有计划下的班级
  148. await this.model.deleteMany({ planid, termid });
  149. // 根据批次id取得当前批次具体信息
  150. const res = await this.tmodel.findById(planid);
  151. if (!res) {
  152. throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '全年计划信息不存在');
  153. }
  154. // 循环出所有班级进行添加操作
  155. const term = await res.termnum.id(termid);
  156. for (const batch of term.batchnum) {
  157. const classs = await batch.class;
  158. for (const cla of classs) {
  159. const newdata = { name: cla.name, number: cla.number, batchid: batch.id, termid: term.id, planid: res.id, type: cla.type };
  160. const rescla = await this.model.create(newdata);
  161. await this.toSetClassSetting({ classid: rescla._id });
  162. }
  163. }
  164. }
  165. // 根据传入的学生列表和班级id更新学生信息
  166. async studentup(classid, batchid, beforestu) {
  167. // 循环学生id
  168. for (const stuid of beforestu) {
  169. const student = await this.stumodel.findById(stuid);
  170. if (student) {
  171. student.classid = classid;
  172. student.batchid = batchid;
  173. await student.save();
  174. }
  175. }
  176. }
  177. // 自动分组
  178. async groupcreate(termid, batchid, classid) {
  179. const group = await this.gmodel.find({ termid, batchid, classid });
  180. if (group.length === 0) {
  181. for (let i = 1; i < 8; i++) {
  182. const name = i + '组';
  183. const newdata = { name, termid, batchid, classid };
  184. await this.gmodel.create(newdata);
  185. }
  186. }
  187. }
  188. // 根据传入的学生列表和班级id更新学生信息
  189. async studentupclass({ id }, data) {
  190. assert(id, '班级id为必填项');
  191. // 根据全年计划表id查出对应的全年计划详细信息
  192. const trainplan = await this.tmodel.findOne({ 'termnum.batchnum.class._id': ObjectId(id) });
  193. if (!trainplan) {
  194. throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '全年计划信息不存在');
  195. }
  196. // 取得计划期批次信息
  197. let termid = '';
  198. let batchid = '';
  199. let classname = '';
  200. let class_ = {};
  201. for (const term of trainplan.termnum) {
  202. for (const batch of term.batchnum) {
  203. const _class = await batch.class.id(id);
  204. if (_class) {
  205. termid = term.id;
  206. batchid = batch.id;
  207. classname = _class.name;
  208. class_ = _class;
  209. break;
  210. }
  211. }
  212. }
  213. if (!class_) {
  214. throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '班级信息不存在');
  215. }
  216. let classid_ = '';
  217. if (classname) {
  218. const cla_ = await this.model.findOne({ termid, batchid, name: classname });
  219. if (cla_) {
  220. classid_ = cla_.id;
  221. } else {
  222. const newdata = {
  223. name: class_.name,
  224. number: class_.number,
  225. batchid,
  226. termid,
  227. planid: trainplan.id,
  228. type: class_.type,
  229. headteacherid: class_.headteacherid,
  230. };
  231. const rescla = await this.model.create(newdata);
  232. if (rescla) {
  233. classid_ = rescla.id;
  234. }
  235. }
  236. }
  237. if (classid_) {
  238. // 循环学生id
  239. for (const stuid of data) {
  240. const student = await this.stumodel.findById(stuid);
  241. if (student) {
  242. student.classid = classid_;
  243. await student.save();
  244. }
  245. }
  246. }
  247. // 添加,给学生排序号
  248. await this.ctx.service.student.arrangeNumber({ classid: classid_ });
  249. // TODO 根据模板复制班级信息
  250. await this.toSetClassSetting({ classid: classid_ });
  251. }
  252. async notice(data) {
  253. for (const classid of data.classids) {
  254. // 根据班级id找到需要通知的班级
  255. const _class = await this.model.findById(classid);
  256. const { headteacherid } = _class;
  257. // 根据班级id找到对应的课程表
  258. const lesson = await this.lessmodel.findOne({ classid });
  259. if (lesson) {
  260. const lessons = lesson.lessons;
  261. const remark = '感谢您的使用';
  262. const date = await this.ctx.service.util.updatedate();
  263. const detail = '班级各项信息已确认,请注意查收';
  264. // 遍历班级授课教师发送通知
  265. for (const lessoninfo of lessons) {
  266. const teaid = lessoninfo.teaid;
  267. const _teacher = await this.umodel.findOne({ uid: teaid, type: '3' });
  268. if (_teacher) {
  269. const teaopenid = _teacher.openid;
  270. this.ctx.service.weixin.sendTemplateMsg(this.ctx.app.config.REVIEW_TEMPLATE_ID, teaopenid, '您有一个新的通知', detail, date, remark, classid);
  271. }
  272. }
  273. // 给班主任发送通知
  274. const _headteacher = await this.umodel.findOne({ uid: headteacherid, type: '1' });
  275. if (_headteacher) {
  276. const headteaopenid = _headteacher.openid;
  277. this.ctx.service.weixin.sendTemplateMsg(this.ctx.app.config.REVIEW_TEMPLATE_ID, headteaopenid, '您有一个新的通知', detail, date, remark, classid);
  278. }
  279. // 根据班级的期id查询对应的培训计划
  280. const trainplan = await this.tmodel.findOne({ 'termnum._id': _class.termid });
  281. const term = await trainplan.termnum.id(_class.termid);
  282. const batch = await term.batchnum.id(_class.batchid);
  283. const startdate = batch.startdate;
  284. const classname = _class.name;
  285. // 给班级所有学生发送邮件通知
  286. const students = await this.stumodel.find({ classid });
  287. for (const student of students) {
  288. const { email, name } = student;
  289. const subject = '吉林省高等学校毕业生就业指导中心通知';
  290. const text = name + '您好!\n欢迎参加由吉林省高等学校毕业生就业指导中心举办的“双困生培训会”。\n您所在的班级为:' + classname + '\n班级开课时间为:' + startdate;
  291. this.ctx.service.util.sendMail(email, subject, text);
  292. }
  293. }
  294. }
  295. }
  296. async uptea(data) {
  297. for (const _data of data) {
  298. const classInfo = await this.model.findById(_data.id);
  299. classInfo.headteacherid = _data.headteacherid;
  300. await classInfo.save();
  301. }
  302. }
  303. async query({ skip, limit, ...info }) {
  304. const classes = await this.model
  305. .find(info)
  306. .populate([
  307. {
  308. path: 'yclocationid',
  309. model: 'Location',
  310. select: 'name',
  311. },
  312. {
  313. path: 'kzjhlocationid',
  314. model: 'Location',
  315. select: 'name',
  316. },
  317. {
  318. path: 'kbyslocationid',
  319. model: 'Location',
  320. select: 'name',
  321. },
  322. {
  323. path: 'jslocationid',
  324. model: 'Location',
  325. select: 'name',
  326. },
  327. {
  328. path: 'headteacherid',
  329. model: 'Headteacher',
  330. select: 'name',
  331. },
  332. ])
  333. .skip(Number(skip))
  334. .limit(Number(limit));
  335. const data = [];
  336. let planids = classes.map(i => i.planid);
  337. planids = _.uniq(planids);
  338. const trainplan = await this.tmodel.find({ _id: { $in: planids } });
  339. for (const _class of classes) {
  340. let res = await this.setClassData(_class, trainplan);
  341. if (res) {
  342. res = this.setData(res);
  343. data.push(res);
  344. } else {
  345. data.push(_class);
  346. }
  347. }
  348. return data;
  349. }
  350. async fetch({ id }) {
  351. let classInfo = await this.model.findById(id).populate([
  352. {
  353. path: 'yclocationid',
  354. model: 'Location',
  355. select: 'name',
  356. },
  357. {
  358. path: 'kzjhlocationid',
  359. model: 'Location',
  360. select: 'name',
  361. },
  362. {
  363. path: 'kbyslocationid',
  364. model: 'Location',
  365. select: 'name',
  366. },
  367. {
  368. path: 'jslocationid',
  369. model: 'Location',
  370. select: 'name',
  371. },
  372. {
  373. path: 'headteacherid',
  374. model: 'Headteacher',
  375. select: 'name',
  376. },
  377. ]);
  378. const trainplan = await this.tmodel.findById(classInfo.planid);
  379. classInfo = await this.setClassData(classInfo, [ trainplan ]);
  380. classInfo = this.setData(classInfo);
  381. return classInfo;
  382. }
  383. // 整理数据,找礼仪教师
  384. async setClassData(cla, trainplan) {
  385. const { planid, termid, batchid } = cla;
  386. cla = JSON.parse(JSON.stringify(cla));
  387. const tpRes = trainplan.find(f => ObjectId(planid).equals(f._id));
  388. if (!tpRes) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到班级的计划信息');
  389. const t = tpRes.termnum.id(termid);
  390. if (!t) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到班级的期信息');
  391. const { term, batchnum } = t;
  392. if (!term) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到班级的期信息');
  393. else cla.term = term;
  394. if (!batchnum) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到班级的批次信息');
  395. const b = batchnum.id(batchid);
  396. if (!b) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到班级的批次信息');
  397. const { batch, startdate, enddate } = b;
  398. if (batch)cla.batch = batch;
  399. if (startdate) cla.startdate = startdate;
  400. if (enddate) cla.enddate = enddate;
  401. // 礼仪教师
  402. if (cla.lyteacherid) {
  403. let res = await this.teamodel.findById(cla.lyteacherid);
  404. if (!res) res = await this.heamodel.findById(cla.lyteacherid);
  405. if (res) cla.lyteacher = res.name;
  406. }
  407. return cla;
  408. }
  409. // 整理数据
  410. setData(cla) {
  411. const { headteacherid, yclocationid, kzjhlocationid, kbyslocationid, jslocationid } = cla;
  412. const arr = [];
  413. if (headteacherid && _.isObject(headteacherid)) arr.push({ headteacherid });
  414. if (yclocationid && _.isObject(yclocationid)) arr.push({ yclocationid });
  415. if (kzjhlocationid && _.isObject(kzjhlocationid)) arr.push({ kzjhlocationid });
  416. if (kbyslocationid && _.isObject(kbyslocationid)) arr.push({ kbyslocationid });
  417. if (jslocationid && _.isObject(jslocationid)) arr.push({ jslocationid });
  418. for (const kid of arr) {
  419. for (const key in kid) {
  420. if (kid.hasOwnProperty(key)) {
  421. const obj = kid[key];
  422. const { _id, name } = obj;
  423. const keynoids = key.split('id');
  424. cla[key] = _id;
  425. cla[_.get(keynoids, 0)] = name;
  426. }
  427. }
  428. }
  429. return cla;
  430. }
  431. async upclasses(data) {
  432. for (const _data of data) {
  433. await this.model.findByIdAndUpdate(_data.id, _data);
  434. }
  435. }
  436. async classinfo({ id: classid }) {
  437. const _classes = await this.model.findById(classid);
  438. // 班级信息
  439. const classes = _.cloneDeep(JSON.parse(JSON.stringify(_classes)));
  440. // 学生信息
  441. const students = await this.stumodel.find({ classid });
  442. // 所有用户信息
  443. const users = await this.umodel.find();
  444. if (students) {
  445. for (const stu of students) {
  446. const user = users.find(item => item.uid === stu.id);
  447. if (user && user.openid) {
  448. const _stu = _.cloneDeep(JSON.parse(JSON.stringify(stu)));
  449. _stu.hasuserinfo = '1';
  450. _.remove(students, stu);
  451. students.push(_stu);
  452. }
  453. }
  454. classes.students = students;
  455. }
  456. // 班主任信息
  457. let headteacher;
  458. if (classes.headteacherid) {
  459. headteacher = await this.heamodel.findById(classes.headteacherid);
  460. }
  461. // 礼仪课老师信息
  462. let lyteacher;
  463. if (classes.lyteacherid) {
  464. lyteacher = await this.heamodel.findById(classes.lyteacherid);
  465. if (!lyteacher) {
  466. lyteacher = await this.teamodel.findById(classes.lyteacherid);
  467. }
  468. }
  469. // 教课老师信息
  470. let teachers = [];
  471. const lessones = await this.lessmodel.findOne({ classid });
  472. if (lessones) {
  473. for (const lesson of lessones.lessons) {
  474. if (lesson.teaid) {
  475. const teacher = await this.teamodel.findById(lesson.teaid);
  476. teachers.push(teacher);
  477. }
  478. }
  479. }
  480. teachers.push(lyteacher);
  481. teachers.push(headteacher);
  482. teachers = _.uniq(_.compact(teachers));
  483. for (const tea of teachers) {
  484. const user = users.find(item => item.uid === tea.id);
  485. if (user && user.openid) {
  486. const _tea = _.cloneDeep(JSON.parse(JSON.stringify(tea)));
  487. _tea.hasuserinfo = '1';
  488. _.remove(teachers, tea);
  489. teachers.push(_tea);
  490. }
  491. }
  492. classes.teachers = teachers;
  493. return classes;
  494. }
  495. // 根据模板设置班级信息
  496. async toSetClassSetting({ classid }) {
  497. const setting = await this.ctx.model.Setting.findOne();
  498. if (!setting) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到系统设置');
  499. const { template_term } = setting;
  500. if (!template_term) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到班级模板设置');
  501. const templateList = await this.query({ termid: template_term });
  502. const tClass = await this.model.findById(classid);
  503. if (!tClass) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '班级不存在,无法复制设定的班级设置');
  504. const { name, termid, batchid } = tClass;
  505. const r = templateList.find(f => f.name === name);
  506. // 找到班主任全年计划
  507. const trainPlan = await this.tmodel.findById(tClass.planid);
  508. if (!trainPlan) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到该班所在的年度计划信息');
  509. const tpt = trainPlan.termnum.id(tClass.termid);
  510. if (!tpt) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到该班所在年度计划的期信息');
  511. const tpb = tpt.batchnum.id(tClass.batchid);
  512. if (!tpb) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到该班所在年度计划的批次信息');
  513. if (!tpb.class) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到该班所在年度计划批次下的班级');
  514. const tpc = tpb.class.find(f => f.name === tClass.name);
  515. if (!tpc) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到该班所在年度计划的班级信息');
  516. const { headteacherid } = tpc;
  517. if (r) {
  518. // 说明这个是正常班,且从模板中找得到; 除了礼仪教师外,都复制过来
  519. const { jslocationid, kbyslocationid, kzjhlocationid, yclocationid } = r;
  520. if (!tClass.jslocation && jslocationid) tClass.jslocationid = jslocationid;
  521. if (!tClass.kbyslocationid && kbyslocationid) tClass.kbyslocationid = kbyslocationid;
  522. if (!tClass.kzjhlocationid && kzjhlocationid) tClass.kzjhlocationid = kzjhlocationid;
  523. if (!tClass.yclocationid && yclocationid) tClass.yclocationid = yclocationid;
  524. if (!tClass.headteacherid && headteacherid) {
  525. tClass.headteacherid = headteacherid;
  526. // 默认班主任为礼仪教师
  527. tClass.lyteacherid = headteacherid;
  528. }
  529. await tClass.save();
  530. } else {
  531. // 没找到,有可能是普通班,也有可能是非普通班
  532. // 找这个班级的同批次
  533. const tClassBatch = await this.query({ termid, batchid });
  534. const r = tClassBatch.find(f => ObjectId(tClass._id).equals(f._id));
  535. const ri = tClassBatch.findIndex(f => ObjectId(tClass._id).equals(f._id));
  536. // TODO 特殊班需要判断,如果没有就没有
  537. // if (r) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '无法确定班级批次排序');
  538. if (!r) {
  539. const { batch: tAllClassBatch } = r;
  540. const templateBatchList = templateList.filter(f => f.batch === tAllClassBatch);
  541. // 根据该班级所在批次的顺序,找到对应模板,然后复制
  542. const copyTemplate = templateBatchList[ri];
  543. const { jslocationid, kbyslocationid, kzjhlocationid, yclocationid } = copyTemplate;
  544. if (!tClass.jslocation && jslocationid) tClass.jslocationid = jslocationid;
  545. if (!tClass.kbyslocationid && kbyslocationid) tClass.kbyslocationid = kbyslocationid;
  546. if (!tClass.kzjhlocationid && kzjhlocationid) tClass.kzjhlocationid = kzjhlocationid;
  547. if (!tClass.yclocationid && yclocationid) tClass.yclocationid = yclocationid;
  548. if (!tClass.headteacherid && headteacherid) tClass.headteacherid = headteacherid;
  549. await tClass.save();
  550. }
  551. }
  552. }
  553. }
  554. module.exports = ClassService;