liuyu 4 năm trước cách đây
mục cha
commit
5044b9dfb5
1 tập tin đã thay đổi với 9 bổ sung0 xóa
  1. 9 0
      app/service/school.js

+ 9 - 0
app/service/school.js

@@ -27,6 +27,12 @@ class SchoolService extends CrudService {
     if (!plan) {
       throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '计划信息不存在');
     }
+    const schs = await plan.school;
+    const sch_ = _.find(schs, { code: schid });
+    let num_ = '0';
+    if (sch_) {
+      num_ = sch_.num;
+    }
     const planid = plan.id;
     const planyearid = plan.planyearid;
     // 取得excle中数据
@@ -34,6 +40,9 @@ class SchoolService extends CrudService {
     console.log(_filepath);
     const studatas = await this.getImportXLSXData(_filepath, termid, schid, planid, planyearid);
     console.log(studatas);
+    if (studatas.length > Number(num_)) {
+      throw new BusinessError(ErrorCode.SERVICE_FAULT, '学校上传人数超过预期人数');
+    }
     // 将得到的数据校验
     const datacheck = await this.datacheck(studatas);
     if (datacheck.errorcode === '1') {