|
@@ -18,28 +18,69 @@ class TeaplanService extends CrudService {
|
|
|
this.dmodel = this.ctx.model.Department;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+ async findteacher({ planid, termid, batchid }) {
|
|
|
+
|
|
|
+ const headteachers = await this.hmodel.find();
|
|
|
+
|
|
|
+ const trainplan = await this.tmodel.findById(planid);
|
|
|
+ if (!trainplan) {
|
|
|
+ throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '全年计划信息不存在');
|
|
|
+ }
|
|
|
+ const term = await trainplan.termnum.id(termid);
|
|
|
+ if (!term) {
|
|
|
+ throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '全年计划内期信息不存在');
|
|
|
+ }
|
|
|
+ const batch = await term.batchnum.id(batchid);
|
|
|
+ if (!batch) {
|
|
|
+ throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '全年计划内批次信息不存在');
|
|
|
+ }
|
|
|
+ const newheadteachers = [];
|
|
|
+
|
|
|
+ for (const headteacher of headteachers) {
|
|
|
+
|
|
|
+ const teaplan = await this.model.findOne({ headteacherid: headteacher.id });
|
|
|
+ if (teaplan) {
|
|
|
+
|
|
|
+ const nodates = teaplan.nodate;
|
|
|
+ const iswork = await this.teacheriswork(nodates, batch.startdate, batch.enddate);
|
|
|
+ if (iswork) {
|
|
|
+ newheadteachers.push(headteacher);
|
|
|
+ } else {
|
|
|
+ newheadteachers.push({ ...JSON.parse(JSON.stringify(headteacher)), disabled: true });
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ newheadteachers.push(headteacher);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return newheadteachers;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ async betweendate(curdate, startdate, enddate) {
|
|
|
+
|
|
|
+
|
|
|
+ const sres = moment(curdate).diff(moment(startdate), 'days');
|
|
|
+ const eres = moment(curdate).diff(moment(enddate), 'days');
|
|
|
+ let result = true;
|
|
|
+ if (sres < 0 || eres > 0) {
|
|
|
+ result = false;
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ async teacheriswork(nodates, startdate, enddate) {
|
|
|
+ let result = true;
|
|
|
+ for (const nodate of nodates) {
|
|
|
+ const res = this.betweendate(nodate, startdate, enddate);
|
|
|
+ if (res) {
|
|
|
+ result = false;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
|
|
|
async divide({ trainplanid }) {
|
|
|
const data = [];
|