lrf 9 months ago
parent
commit
afdea3d92e
6 changed files with 112 additions and 152 deletions
  1. 5 0
      app/controller/.school.js
  2. 6 5
      app/model/trainmodel.js
  3. 13 12
      app/model/trainplan.js
  4. 1 0
      app/router.js
  5. 26 27
      app/service/school.js
  6. 61 108
      app/service/trainplan.js

+ 5 - 0
app/controller/.school.js

@@ -55,4 +55,9 @@ module.exports = {
       count: true,
     },
   },
+  findByCodes:{
+    requestBody: [
+      "code",
+    ],
+  }
 };

+ 6 - 5
app/model/trainmodel.js

@@ -11,27 +11,28 @@ const classInfo = new Schema({
 // 批次信息表
 const batchInfo = new Schema({
   batch: { type: String, required: false, maxLength: 200 }, // 批次
-  classnum: { type: [ classInfo ], required: false, select: true }, // 班级
+  place: { type: String, required: false, maxLength: 200 }, // 培训地点
+  color: { type: String, required: false, maxLength: 200 }, // 计划日历中使用颜色
+  classnum: { type: [classInfo], required: false, select: true }, // 班级
 });
 
 // 全年计划模板表
 const TrainmodelSchema = {
   total: { type: String, required: false, maxLength: 200 }, // 总人数
   day: { type: String, required: false, maxLength: 200 }, // 课程所需天数
-  color: { type: [ String ], required: false }, // 默认颜色
+  color: { type: [String], required: false }, // 默认颜色
   planyearid: { type: String, required: true, maxLength: 200 }, // 大批次id
   planid: { type: String, required: true, maxLength: 200 }, // 计划id
-  batchnum: { type: [ batchInfo ], required: false, select: true }, // 默认期下生成的批次数
+  batchnum: { type: [batchInfo], required: false, select: true }, // 默认期下生成的批次数
   stunum: { type: String, required: false, maxLength: 200 }, // 默认每班学生数
   carpnum: { type: String, required: false, maxLength: 200 }, // 默认每辆车的学生数
 };
 
-
 const schema = new Schema(TrainmodelSchema, { toJSON: { virtuals: true } });
 schema.index({ id: 1 });
 schema.plugin(metaPlugin);
 
-module.exports = app => {
+module.exports = (app) => {
   const { mongoose } = app;
   return mongoose.model('Trainmodel', schema, 'trainmodel');
 };

+ 13 - 12
app/model/trainplan.js

@@ -8,21 +8,23 @@ const classInfo = new Schema({
   number: { type: String, required: false, maxLength: 200 }, // 人数
   type: { type: String, required: false, maxLength: 200 }, // 类型-0正常,1特殊,2,3创业班
   headteacherid: { type: String, required: false, maxLength: 200 }, // 班主任id
-  lessons: { type: [ Object ], required: false }, // 班级课表 => status:0-未发布; 1-已发布
+  lessons: { type: [Object], required: false }, // 班级课表 => status:0-未发布; 1-已发布. 与报课有关
   hasclass: { type: String, required: false, maxLength: 200 }, // 是否生成班级: 0未生成;1已生成
 });
 
 // 批次信息表
 const batchInfo = new Schema({
   batch: { type: String, required: false, maxLength: 200 }, // 批次
-  class: { type: [ classInfo ], required: false, select: true }, // 班级数
+  class: { type: [classInfo], required: false, select: true }, // 班级数
   startdate: { type: String, required: false, maxLength: 200 }, // 开始日期
   enddate: { type: String, required: false, maxLength: 200 }, // 结束日期
-  lessons: { type: [ Object ], required: false }, // 课程表
+  lessons: { type: [Object], required: false }, // 课程表,模板的
   // type: { type: String, required: false, maxLength: 200 }, // 类型:0-正常,1-特殊
   // name: { type: String, required: false, maxLength: 200 }, // 名称
   // number: { type: String, required: false, maxLength: 200 }, // 人数
   color: { type: String, required: false, maxLength: 200 }, // 颜色
+  reteacher: { type: String, required: false, maxLength: 200 }, // 督导教师
+  place: { type: String, required: false, maxLength: 200 }, // 培训场地
 });
 
 // 学校班级人数信息表
@@ -35,7 +37,7 @@ const classNumInfo = new Schema({
 // 学校信息表
 const schInfo = new Schema({
   code: { type: String, required: false, maxLength: 200 }, // 学校code
-  classnum: { type: [ classNumInfo ], select: true }, // 班级人数
+  classnum: { type: [classNumInfo], select: true }, // 班级人数
   num: { type: String, required: false, maxLength: 200 }, // 总人数
 });
 
@@ -43,8 +45,8 @@ const schInfo = new Schema({
 const termInfo = new Schema({
   term: { type: String, required: false, maxLength: 200 }, // 期数
   classnum: { type: String, required: false, maxLength: 200 }, // 班级数
-  batchnum: { type: [ batchInfo ], select: true }, // 批
-  reteacher: { type: String, required: false, maxLength: 2000 }, // 督导教师
+  batchnum: { type: [batchInfo], select: true }, // 批
+  reteacher: { type: String, required: false, maxLength: 2000 }, // 督导教师, 根据地点多人所以这里应该有问题
 });
 
 // 节假日信息表
@@ -67,18 +69,17 @@ const TrainplanSchema = {
   year: { type: String, required: true, maxLength: 200 }, // 年份
   title: { type: String, required: true, maxLength: 500 }, // 标题
   status: { type: String, required: false, maxLength: 200, default: '0' }, // 状态,0-筹备中,1-发布,2-结束
-  termnum: { type: [ termInfo ], select: true }, // 期
-  remark: { type: [ remarkInfo ], select: true }, // 备注
-  school: { type: [ schInfo ], select: true }, // 学校
-  festivals: { type: [ festivalInfo ], select: true }, // 节假日
+  termnum: { type: [termInfo], select: true }, // 期
+  remark: { type: [remarkInfo], select: true }, // 备注
+  school: { type: [schInfo], select: true }, // 学校
+  festivals: { type: [festivalInfo], select: true }, // 节假日
 };
 
-
 const schema = new Schema(TrainplanSchema, { toJSON: { virtuals: true } });
 schema.index({ id: 1 });
 schema.plugin(metaPlugin);
 
-module.exports = app => {
+module.exports = (app) => {
   const { mongoose } = app;
   return mongoose.model('Trainplan', schema, 'trainplan');
 };

+ 1 - 0
app/router.js

@@ -213,6 +213,7 @@ module.exports = app => {
   router.resources('school', '/api/train/school', controller.school); // index、create、show、destroy
   router.post('school', '/api/train/school/update/:id', controller.school.update);
   router.post('/api/train/school/import', controller.school.stuimport); // 名单上传
+  router.post('school', '/api/train/school/findByCodes', controller.school.findByCodes); // 根据编码找学校
 
   // 民族表设置路由
   router.resources('nation', '/api/train/nation', controller.nation); // index、create、show、destroy

+ 26 - 27
app/service/school.js

@@ -1,6 +1,5 @@
 'use strict';
 
-
 const assert = require('assert');
 const _ = require('lodash');
 const { ObjectId } = require('mongoose').Types;
@@ -21,7 +20,11 @@ class SchoolService extends CrudService {
     this.jmodel = this.ctx.model.Job;
     this.schmodel = this.ctx.model.Schtime;
   }
-
+  async findByCodes({ code }) {
+    if (!_.isArray(code) || code.length <= 0) return [];
+    const res = await this.model.find({ code }, { name: 1, code: 1, level: 1, hascar: 1, address: 1 });
+    return res;
+  }
   async create(data) {
     const { code, name } = data;
     assert(code, '缺少学校代码');
@@ -53,10 +56,10 @@ class SchoolService extends CrudService {
     let res = await this.model.find(query).skip(parseInt(skip)).limit(parseInt(limit));
     if (res && res.length > 0) {
       res = JSON.parse(JSON.stringify(res));
-      const ids = res.map(i => i._id);
+      const ids = res.map((i) => i._id);
       const users = await this.umodel.find({ uid: { $in: ids } }, '+passwd');
       for (const tea of res) {
-        const r = users.find(f => f.uid === tea._id);
+        const r = users.find((f) => f.uid === tea._id);
         if (r) {
           const passwd = _.get(r.passwd, 'secret');
           if (passwd) tea.passwd = passwd;
@@ -96,21 +99,17 @@ class SchoolService extends CrudService {
     const res = await this.model.aggregate(AggregateInfo);
     if (res && res.length > 0) {
       data = JSON.parse(JSON.stringify(res));
-      const ids = res.map(i => i._id);
+      const ids = res.map((i) => i._id);
       const users = await this.umodel.find({ uid: { $in: ids } }, '+passwd').lean();
       for (const tea of data) {
-        const r = users.find(f => f.uid === tea._id);
+        const r = users.find((f) => f.uid === tea._id);
         if (r) {
           const passwd = _.get(r.passwd, 'secret');
           if (passwd) tea.passwd = passwd;
         }
       }
     }
-    const count = await this.model.aggregate([
-      { $match: query },
-      { $group: { _id: '$code' } },
-      { $count: 'distinctCount' },
-    ]);
+    const count = await this.model.aggregate([{ $match: query }, { $group: { _id: '$code' } }, { $count: 'distinctCount' }]);
     const total = _.get(count[0], 'distinctCount') || 0;
     return { total, data };
   }
@@ -132,7 +131,7 @@ class SchoolService extends CrudService {
     let dbStuList = await this.ctx.model.Student.find({ termid, batchid, schid });
     if (dbStuList.length > 0) {
       // 查这个学校的这期学生是否修改过班级 或 寝室
-      const is_change = dbStuList.find(f => f.classid || f.bedroomid);
+      const is_change = dbStuList.find((f) => f.classid || f.bedroomid);
       if (is_change) {
         throw new BusinessError(
           ErrorCode.BUSINESS,
@@ -206,7 +205,7 @@ class SchoolService extends CrudService {
       // 复制,删除,添加
       if (dbStuList.length > 0) {
         dbStuList = JSON.parse(JSON.stringify(dbStuList));
-        dbStuList = dbStuList.map(i => {
+        dbStuList = dbStuList.map((i) => {
           delete i.meta;
           i.studentid = _.clone(i._id);
           delete i.id;
@@ -253,7 +252,7 @@ class SchoolService extends CrudService {
   async getschnum(plan, schid, batchid) {
     const schtime = await this.schmodel.findOne({ schid, planid: plan.id });
     const { arrange } = schtime;
-    const r = arrange.find(f => f.batchid === batchid);
+    const r = arrange.find((f) => f.batchid === batchid);
     if (!r) {
       throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '没有找到该学校的计划');
     }
@@ -282,9 +281,9 @@ class SchoolService extends CrudService {
     headRow.eachCell((cell, coli) => {
       console.log(cell.value);
       if (cell.value !== '序号') {
-        const r = cols.find(f => f.key === cell.value);
+        const r = cols.find((f) => f.key === cell.value);
         if (r) {
-          const ri = cols.findIndex(f => f.key === cell.value);
+          const ri = cols.findIndex((f) => f.key === cell.value);
           // 表头符合要求,做上标记
           r.colIndex = coli;
           cols[ri] = r;
@@ -294,14 +293,14 @@ class SchoolService extends CrudService {
       }
     });
     // 检查表头结果,如果有没有 colIndex,说明表头里有不符合要求的,退回去
-    const excelIsRigth = cols.every(f => f.colIndex);
+    const excelIsRigth = cols.every((f) => f.colIndex);
     if (!excelIsRigth) throw new BusinessError(ErrorCode.DATA_INVALID, 'Excel表格格式不正确,请使用系统提供的模板,或重新下载模板!');
     // 删除掉第一行 表头行,这不是数据
     worksheet.spliceRows(0, 1);
     const stuList = [];
-    const noWhite = str => str.replace(/\s*/g, '');
+    const noWhite = (str) => str.replace(/\s*/g, '');
     // 整理数据,根据检查合格的表头行,获取每个格子的数据,制成[object]格式
-    worksheet.eachRow(row => {
+    worksheet.eachRow((row) => {
       const stu = {};
       for (let i = 0; i < cols.length; i++) {
         const col = cols[i];
@@ -357,7 +356,7 @@ class SchoolService extends CrudService {
           //   error = true;
           //   msg = `${msg}学生已存在`;
           // }
-          const have_same = stuList.filter(f => f.id_number === val && f.name !== name);
+          const have_same = stuList.filter((f) => f.id_number === val && f.name !== name);
           if (have_same.length > 0) {
             error = true;
             const h = _.head(have_same);
@@ -381,7 +380,7 @@ class SchoolService extends CrudService {
           //   error = true;
           //   msg = `${msg}学生库中已有该手机号,请检查手机号是否正确,若无误,请联系中心负责人`;
           // }
-          const have_same = stuList.filter(f => f.phone === val && f.name !== name);
+          const have_same = stuList.filter((f) => f.phone === val && f.name !== name);
           if (have_same.length > 0) {
             error = true;
             const h = _.head(have_same);
@@ -446,15 +445,15 @@ class SchoolService extends CrudService {
   // 最后整合数据
   lastSetData(stuList, data) {
     const cols = this.getStucolumn();
-    const needChange = cols.filter(f => f.change);
-    stuList = stuList.map(i => {
+    const needChange = cols.filter((f) => f.change);
+    stuList = stuList.map((i) => {
       const d = { ...i, ...data };
       for (const col of needChange) {
         const { column, change } = col;
         if (!column && change && _.isArray(change)) continue;
         const val = _.get(d, column);
         if (!val) continue;
-        const r = change.find(f => f.key === val);
+        const r = change.find((f) => f.key === val);
         if (!r) continue;
         const { value } = r;
         d[column] = value;
@@ -535,7 +534,7 @@ class SchoolService extends CrudService {
     const path = `${rp}${sep}train${sep}${nowDate}.xlsx`;
     const respath = `${bu}/files/train/${nowDate}.xlsx`;
     const wb = {
-      SheetNames: [ 'sheet0' ],
+      SheetNames: ['sheet0'],
       Sheets: { sheet0: Object.assign({}, output, { '!ref': ref }) },
     };
     // 导出 Excel
@@ -636,9 +635,9 @@ class SchoolService extends CrudService {
         code = code.split('');
         // ∑(ai×Wi)(mod 11)
         // 加权因子
-        const factor = [ 7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2 ];
+        const factor = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2];
         // 校验位
-        const parity = [ 1, 0, 'X', 9, 8, 7, 6, 5, 4, 3, 2 ];
+        const parity = [1, 0, 'X', 9, 8, 7, 6, 5, 4, 3, 2];
         let sum = 0;
         let ai = 0;
         let wi = 0;

+ 61 - 108
app/service/trainplan.js

@@ -1,6 +1,5 @@
 'use strict';
 
-
 const _ = require('lodash');
 const { CrudService } = require('naf-framework-mongoose/lib/service');
 const assert = require('assert');
@@ -37,15 +36,21 @@ class TrainplanService extends CrudService {
     if (res) planid = res._id;
     const schoolList = await this.smodel.find();
     const schtimeArr = [];
+    // 为学校创建不可以培训的数据
     for (const sch of schoolList) {
       const { code } = sch;
+      // 没有学校编码就下一个
+      if (!code) continue;
       const obj = { schid: code, year, planid };
       let schtimeres;
       schtimeres = await this.schmodel.findOne(obj);
-      if (!schtimeres)schtimeres = await this.schmodel.create(obj);
+      if (!schtimeres) schtimeres = await this.schmodel.create(obj);
       if (schtimeres) schtimeArr.push(schtimeres);
     }
-    if (!schtimeArr.every(e => e)) { throw new BusinessError(ErrorCode.DATA_INVALID, '学校计划生成失败'); } else return res;
+    // if (!schtimeArr.every((e) => e)) {
+    //   throw new BusinessError(ErrorCode.DATA_INVALID, '学校计划生成失败');
+    // } else
+    return res;
   }
 
   async update({ id }, data) {
@@ -137,6 +142,8 @@ class TrainplanService extends CrudService {
       for (const school of schoolList) {
         const r = await this.schmodel.findOne({ year: trainplan.year, planid: id, schid: school.code });
         if (r) continue;
+        // 学校没有编码直接跳过
+        if (!school.code) continue;
         const obj = { schid: school.code, year: trainplan.year, planid: id };
         await this.schmodel.create(obj);
       }
@@ -150,24 +157,24 @@ class TrainplanService extends CrudService {
       for (const batch of term.batchnum) {
         const { class: classes, startdate, enddate } = batch;
         // 获取每批次下每个班的班级类型
-        const typeList = _.uniq(classes.map(i => i.type));
+        const typeList = _.uniq(classes.map((i) => i.type));
         const h = _.head(typeList);
         if (!h) continue;
-        const tem = lessonModelList.find(f => f.type === h);
+        const tem = lessonModelList.find((f) => f.type === h);
         if (!tem) continue;
         let { lessons } = tem;
         if (!lessons) continue;
         lessons = JSON.parse(lessons);
         // 过滤出上课的时间段
-        lessons = lessons.filter(f => {
-          const keys = Object.keys(f).filter(f => f.includes('subid'));
+        lessons = lessons.filter((f) => {
+          const keys = Object.keys(f).filter((f) => f.includes('subid'));
           return keys.length > 0;
         });
         // 记录上课的时间
         const times = [];
         // 记录所有的科目
         let subject = [];
-        lessons.map(i => {
+        lessons.map((i) => {
           times.push(i.time);
           const keys = Object.keys(i);
           let arr = [];
@@ -300,10 +307,7 @@ class TrainplanService extends CrudService {
         // 保存后所有期id
         const batchid_res = _.map(el.batchnum, 'id');
         // 保存前所有期id
-        const batchid_old = _.map(
-          trainplanold.termnum.id(el.id).batchnum,
-          'id'
-        );
+        const batchid_old = _.map(trainplanold.termnum.id(el.id).batchnum, 'id');
         // 取得要删除的期id,进行班级中删除已删除期的班级
         const delbatchs = _.difference(batchid_old, batchid_res);
         // 循环删除已经删除期的所有班级
@@ -331,10 +335,7 @@ class TrainplanService extends CrudService {
               await this.clamodel.create(newdata);
             }
           } else {
-            if (
-              batchnum.class ===
-              trainplanold.termnum.id(el.id).batchnum.id(batchnum.id).class
-            ) {
+            if (batchnum.class === trainplanold.termnum.id(el.id).batchnum.id(batchnum.id).class) {
               // 编辑只会针对班级人数进行修改。
               const _class = await this.clamodel.find({
                 termid: el.id,
@@ -421,7 +422,7 @@ class TrainplanService extends CrudService {
         student.isComming = utils.getIsNot(student.isComming);
         student.trainplandName = trainplandName;
         // 期次
-        const term = trainplan.termnum.filter(term => {
+        const term = trainplan.termnum.filter((term) => {
           return term.id === student.termid;
         });
         if (term.length > 0) {
@@ -429,7 +430,7 @@ class TrainplanService extends CrudService {
         }
         // 批次
         if (term.length !== 0) {
-          const batch = term[0].batchnum.filter(batch => {
+          const batch = term[0].batchnum.filter((batch) => {
             return batch.id === student.batchid;
           });
           if (batch.length > 0) {
@@ -473,30 +474,13 @@ class TrainplanService extends CrudService {
       const _data = studentList;
       const headers = _headers
         .map(({ title }) => title)
-        .map((v, i) =>
-          Object.assign({}, { v, position: String.fromCharCode(65 + i) + 1 })
-        )
-        .reduce(
-          (prev, next) =>
-            Object.assign({}, prev, { [next.position]: { v: next.v } }),
-          {}
-        );
+        .map((v, i) => Object.assign({}, { v, position: String.fromCharCode(65 + i) + 1 }))
+        .reduce((prev, next) => Object.assign({}, prev, { [next.position]: { v: next.v } }), {});
 
       const data = _data
-        .map((v, i) =>
-          _headers.map(({ key }, j) =>
-            Object.assign(
-              {},
-              { v: v[key], position: String.fromCharCode(65 + j) + (i + 2) }
-            )
-          )
-        )
+        .map((v, i) => _headers.map(({ key }, j) => Object.assign({}, { v: v[key], position: String.fromCharCode(65 + j) + (i + 2) })))
         .reduce((prev, next) => prev.concat(next))
-        .reduce(
-          (prev, next) =>
-            Object.assign({}, prev, { [next.position]: { v: next.v } }),
-          {}
-        );
+        .reduce((prev, next) => Object.assign({}, prev, { [next.position]: { v: next.v } }), {});
 
       // 合并 headers 和 data
       const output = Object.assign({}, headers, data);
@@ -519,15 +503,13 @@ class TrainplanService extends CrudService {
   // 导出学校大表
   async exportSchool({ trainplanId }) {
     const rows = [
-      [ '学校名称', '期数' ],
-      [ '       ', '班级数' ],
-      [ '       ', '时间' ],
-      [ '       ', '备注' ],
+      ['学校名称', '期数'],
+      ['       ', '班级数'],
+      ['       ', '时间'],
+      ['       ', '备注'],
     ];
     // 操作
-    const operaList = [
-      { startRow: 1, startCol: 1, endRow: 5, endCol: 1 },
-    ];
+    const operaList = [{ startRow: 1, startCol: 1, endRow: 5, endCol: 1 }];
     // 操作:
     // step1: 班级类型的动态列
     // step2: 1行:期数需要合并列:需要合并的列数根据下面的批次决定
@@ -538,7 +520,7 @@ class TrainplanService extends CrudService {
     // 批次期次都在这里面
     let trainplan = await this.model.findById(trainplanId);
     if (trainplan) trainplan = JSON.parse(JSON.stringify(trainplan));
-    const fn = trainplan.title;// 文件名
+    const fn = trainplan.title; // 文件名
     let classType = await this.ctmodel.find();
     if (classType) classType = JSON.parse(JSON.stringify(classType));
     let schtime = await this.schmodel.find({ planid: trainplanId });
@@ -546,13 +528,13 @@ class TrainplanService extends CrudService {
     // step1
     // 整理班级类型的顺序
     if (_.isArray(classType) && classType.length > 0) {
-      classType = classType.map(i => {
+      classType = classType.map((i) => {
         i.sort = parseInt(i.code);
         return i;
       });
-      classType = _.orderBy(classType, [ 'sort' ], [ 'desc' ]);
+      classType = _.orderBy(classType, ['sort'], ['desc']);
     }
-    const row5 = [ '' ];
+    const row5 = [''];
     for (const ct of classType) {
       const { name } = ct;
       row5.push(name);
@@ -621,23 +603,23 @@ class TrainplanService extends CrudService {
   sortPlan(termnum) {
     if (_.isArray(termnum) && termnum.length > 0) {
       // 数据排序
-      termnum = termnum.map(t => {
+      termnum = termnum.map((t) => {
         const { batchnum, term } = t;
         t.termnum = parseInt(term);
-        t.batchnum = batchnum.map(b => {
+        t.batchnum = batchnum.map((b) => {
           const { batch, class: classes } = b;
           b.batchnum = _.isNumber(parseInt(batch)) ? parseInt(batch) : batch;
-          b.class = classes.map(c => {
+          b.class = classes.map((c) => {
             const { name } = c;
             c.classnum = _.isNumber(parseInt(name)) ? parseInt(name) : name;
             return c;
           });
-          b.class = _.orderBy(b.class, [ 'classnum' ], [ 'asc' ]);
+          b.class = _.orderBy(b.class, ['classnum'], ['asc']);
           return b;
         });
         return t;
       });
-      termnum = _.orderBy(termnum, [ 'termnum' ], [ 'asc' ]);
+      termnum = _.orderBy(termnum, ['termnum'], ['asc']);
     }
     return termnum;
   }
@@ -652,7 +634,7 @@ class TrainplanService extends CrudService {
     let word = '';
     if (c) {
       const { type } = c;
-      const r = classType.find(f => f.code === type);
+      const r = classType.find((f) => f.code === type);
       word = classes.length;
       if (r) word = `${word}(${r.name})`;
     }
@@ -677,7 +659,7 @@ class TrainplanService extends CrudService {
     // 整理完备注,按照顺序,依次去找,是否有备注,有就推进去备注,没有推空
     const remarks = _.cloneDeep(remarkRowData);
     for (const b of batchs) {
-      const r = arr.find(f => ObjectId(f.batchid).equals(b._id));
+      const r = arr.find((f) => ObjectId(f.batchid).equals(b._id));
       if (r) remarks.push(r.remark);
       else remarks.push('');
     }
@@ -704,11 +686,11 @@ class TrainplanService extends CrudService {
     // 学校按code排序
     if (schoolList && schoolList.length > 0) {
       schoolList = JSON.parse(JSON.stringify(schoolList));
-      schoolList = schoolList.map(i => {
+      schoolList = schoolList.map((i) => {
         i.schnum = this.toParseInt(i.code);
         return i;
       });
-      schoolList = _.orderBy(schoolList, [ 'schnum' ], [ 'asc' ]);
+      schoolList = _.orderBy(schoolList, ['schnum'], ['asc']);
     }
 
     // 实际安排的学校计划
@@ -725,15 +707,15 @@ class TrainplanService extends CrudService {
     for (const sch of schoolList) {
       const { name, code } = sch;
       // 该学校的数据
-      const arr = [ name ];
+      const arr = [name];
 
       // 学校实际分配的计划, 先不管别的,先把计划的问题处理了
-      const reaFRes = schArrange.filter(f => f.schid === code);
+      const reaFRes = schArrange.filter((f) => f.schid === code);
       // 过滤出来学校已经分配的数据后,需要知道是什么类型的
       const reaObj = { total: 0, reaTotal: 0 }; // key:班级类型, value:为实际分配的人数
       for (const rr of reaFRes) {
         const { batchid, number } = rr;
-        const r = batchs.find(f => f._id === batchid);
+        const r = batchs.find((f) => f._id === batchid);
         if (r) {
           const { type } = r;
           reaObj[type] = (this.toParseInt(reaObj[type]) || 0) + this.toParseInt(number); // 计划人数累加
@@ -742,14 +724,14 @@ class TrainplanService extends CrudService {
       }
 
       // 先查预计划有没有
-      const p = schPlan.find(f => f.code === code);
+      const p = schPlan.find((f) => f.code === code);
       if (p) {
         // 获取到预设的学校计划
         const { classnum } = p;
         // 班级类型对应的计划
         for (const ct of classType) {
           const { code } = ct;
-          const r = classnum.find(f => f.code === code);
+          const r = classnum.find((f) => f.code === code);
           // n为要求的人数
           let n = 0;
           if (r) {
@@ -762,7 +744,7 @@ class TrainplanService extends CrudService {
           let word = _.subtract(n - rea);
           // n===0:表示原来计划里没有这个类型,word再为0,说明实际上也没有这个类型,就不需要显示了
           if (n === 0 && word === 0) word = '';
-          reaObj.total = _.add(reaObj.total, n);// 计划人数累加
+          reaObj.total = _.add(reaObj.total, n); // 计划人数累加
           arr.push(word);
         }
       } else {
@@ -770,10 +752,10 @@ class TrainplanService extends CrudService {
         const keys = Object.keys(reaObj);
         for (const ct of classType) {
           if (keys.length <= 0) {
-          // 没分配,填充,下一个
+            // 没分配,填充,下一个
             arr.push('');
           } else {
-          // 没计划但是实际分配了,就需要体现出来了
+            // 没计划但是实际分配了,就需要体现出来了
             const word = reaObj[ct.code];
             if (word && word !== 0) {
               arr.push(`-${word}`);
@@ -789,7 +771,7 @@ class TrainplanService extends CrudService {
 
       // 循环学校列表,找到学校的所有安排,然后找到对应的索引,进行数据整理
       for (const rea of reaFRes) {
-        const index = batchs.findIndex(f => f._id === rea.batchid);
+        const index = batchs.findIndex((f) => f._id === rea.batchid);
         if (index < 0) continue;
         arr[index + 5] = rea.number;
       }
@@ -797,7 +779,7 @@ class TrainplanService extends CrudService {
     }
     // 合计行:只有学校列不计算,其他的列全部计算=>批次列(batchs.length)+班级类型列(classType.length)+总人数列(1)+实际分配人数列(1)
     const colTotal = batchs.length + classType.length + 1 + 1;
-    const count = [ '合计' ];
+    const count = ['合计'];
     // 第一列不需要,是学校/合计列
     for (let i = 1; i <= colTotal; i++) {
       const cmid = [];
@@ -833,7 +815,7 @@ class TrainplanService extends CrudService {
           const head = _.head(classes);
           if (head) {
             const { type } = head;
-            if (type)obj.type = type;
+            if (type) obj.type = type;
           }
           const all = classes.reduce((p, n) => p + (parseInt(n.number) || 0), 0);
           if (_.isNumber(all)) b.all = all;
@@ -1021,13 +1003,9 @@ class TrainplanService extends CrudService {
       monthList.push(colRowBJSSL);
 
       const resDate = this.makeCalendar(trainplan.year, index);
-      data.push([ '' ]);
-      data.push(
-        [[ this.getBigMonth(index) + '月' ]]
-          .concat(resDate.dlist)
-          .concat([ '人数' ].concat([ '班级数' ]))
-      );
-      data.push([ '' ].concat(resDate.tlist));
+      data.push(['']);
+      data.push([[this.getBigMonth(index) + '月']].concat(resDate.dlist).concat(['人数'].concat(['班级数'])));
+      data.push([''].concat(resDate.tlist));
       // 加列数组
       for (let i = 0; i < classNum; i++) {
         data.push('');
@@ -1040,10 +1018,8 @@ class TrainplanService extends CrudService {
 
     // 构建 workbook 对象
     const nowDate = new Date().getTime();
-    const path =
-      'D:\\wwwroot\\service\\service-file\\upload\\train\\' + nowDate + '.xlsx';
-    const respath =
-      'http://free.liaoningdoupo.com:80/files/train/' + nowDate + '.xlsx';
+    const path = 'D:\\wwwroot\\service\\service-file\\upload\\train\\' + nowDate + '.xlsx';
+    const respath = 'http://free.liaoningdoupo.com:80/files/train/' + nowDate + '.xlsx';
     // 导出
     const wb = XLSX.utils.book_new();
     XLSX.utils.book_append_sheet(wb, ws, 'Sheet1');
@@ -1083,32 +1059,13 @@ class TrainplanService extends CrudService {
   getfestivalList(festivals) {
     let dateList = [];
     for (let index = 0; index < festivals.length; index++) {
-      dateList = [
-        ...dateList,
-        ...utils.begindateEnddateSum(
-          festivals[index].begindate,
-          festivals[index].finishdate
-        ),
-      ];
+      dateList = [...dateList, ...utils.begindateEnddateSum(festivals[index].begindate, festivals[index].finishdate)];
     }
     return dateList;
   }
   // 获取大月份传过来的值是以1月份开始的
   getBigMonth(index) {
-    const monthBig = [
-      '一',
-      '二',
-      '三',
-      '四',
-      '五',
-      '六',
-      '七',
-      '八',
-      '九',
-      '十',
-      '十一',
-      '十二',
-    ];
+    const monthBig = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'];
     return monthBig[index - 1];
   }
   // 获取这个月份的所有日期1~30号或者31或者28,或者29
@@ -1149,7 +1106,7 @@ class TrainplanService extends CrudService {
   getWeekDay(datestr) {
     const weekday = moment(datestr).weekday();
     if (weekday || weekday === 0) {
-      const arr = [ '日', '一', '二', '三', '四', '五', '六' ];
+      const arr = ['日', '一', '二', '三', '四', '五', '六'];
       return '星期' + arr[weekday];
     }
     return '';
@@ -1158,10 +1115,7 @@ class TrainplanService extends CrudService {
   //   assert(trainplanid && classid && rightHeader, '缺少参数项');
 
   async updateclass({ trainplanid, termid, batchid, classid, rightHeader }) {
-    assert(
-      trainplanid && termid && batchid && classid && rightHeader,
-      '缺少参数项'
-    );
+    assert(trainplanid && termid && batchid && classid && rightHeader, '缺少参数项');
     // 根据全年计划表id查出对应的全年计划详细信息
     const trainplan = await this.model.findById(trainplanid);
     if (!trainplan) {
@@ -1209,4 +1163,3 @@ class TrainplanService extends CrudService {
   }
 }
 module.exports = TrainplanService;
-