caozixuan 2 жил өмнө
parent
commit
ac29af406a
30 өөрчлөгдсөн 63 нэмэгдсэн , 82 устгасан
  1. 2 2
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamPaperStructureServiceImpl.java
  2. 2 2
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamTaskServiceImpl.java
  3. 1 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/GradeBatchServiceImpl.java
  4. 2 2
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/GradePaperDimensionServiceImpl.java
  5. 1 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/GradePaperStructServiceImpl.java
  6. 2 2
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/TeachCourseServiceImpl.java
  7. 1 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/TeachStudentServiceImpl.java
  8. 4 7
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/execute/AsyncStudentDataImportService.java
  9. 3 2
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/execute/AsyncSysUserDataImportService.java
  10. 18 22
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/service/impl/TaskLogicServiceImpl.java
  11. BIN
      distributed-print/src/main/resources/temps/course.xlsx
  12. BIN
      distributed-print/src/main/resources/temps/examTask.xlsx
  13. BIN
      distributed-print/src/main/resources/temps/examTaskStudent.xlsx
  14. BIN
      distributed-print/src/main/resources/temps/org.xlsx
  15. BIN
      distributed-print/src/main/resources/temps/student.xlsx
  16. BIN
      distributed-print/src/main/resources/temps/teachClass.xlsx
  17. BIN
      distributed-print/src/main/resources/temps/teachCourse.xlsx
  18. BIN
      distributed-print/src/main/resources/temps/teachTeacher.xlsx
  19. BIN
      distributed-print/src/main/resources/temps/user.xlsx
  20. 1 1
      distributed-print/src/test/java/com/qmth/distributed/print/ImportTest.java
  21. 0 11
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/bean/dto/excel/BasicStudentImportDto.java
  22. 2 5
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/enums/ImportTemplateEnum.java
  23. 1 1
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/impl/BasicCourseServiceImpl.java
  24. 2 1
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/impl/BasicStudentServiceImpl.java
  25. 1 1
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/impl/SysOrgServiceImpl.java
  26. 1 3
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/impl/SysUserServiceImpl.java
  27. 14 12
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/util/ExcelUtil.java
  28. 3 3
      teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/service/impl/CourseUnitOperateServiceImpl.java
  29. 1 1
      teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/service/impl/TBExamStudentServiceImpl.java
  30. 1 1
      teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/service/impl/TBTeacherServiceImpl.java

+ 2 - 2
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamPaperStructureServiceImpl.java

@@ -640,7 +640,7 @@ public class ExamPaperStructureServiceImpl extends ServiceImpl<ExamPaperStructur
                 throw ExceptionResultEnum.ERROR.exception(JSONObject.toJSONString(errors));
             }
             return finalExcelList;
-        });
+        },2);
         List<Object> list = new ArrayList<>();
         for (LinkedMultiValueMap<Integer, Object> map : finalList) {
             for (Map.Entry<Integer, List<Object>> entry : map.entrySet()) {
@@ -699,7 +699,7 @@ public class ExamPaperStructureServiceImpl extends ServiceImpl<ExamPaperStructur
                 throw ExceptionResultEnum.ERROR.exception(JSONObject.toJSONString(errors));
             }
             return finalExcelList;
-        });
+        },2);
         List<Object> list = new ArrayList<>();
         for (LinkedMultiValueMap<Integer, Object> map : finalList) {
             for (Map.Entry<Integer, List<Object>> entry : map.entrySet()) {

+ 2 - 2
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamTaskServiceImpl.java

@@ -492,7 +492,7 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
                 throw ExceptionResultEnum.ERROR.exception(JSONObject.toJSONString(errors));
             }
             return finalExcelList;
-        });
+        },2);
         return executeImportExamTaskBatch(finalList);
     }
 
@@ -1862,7 +1862,7 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
                 throw ExceptionResultEnum.ERROR.exception(JSONObject.toJSONString(errors));
             }
             return finalExcelList;
-        });
+        },2);
         // 校验已经有的考生所在部门的信息是否正确
         // 导入的excel创建或查询的学生集合
         List<BasicStudentResult> studentDatasource = basicStudentService.basicStudentList(requestUser.getSchoolId(), null, null, null, null);

+ 1 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/GradeBatchServiceImpl.java

@@ -355,7 +355,7 @@ public class GradeBatchServiceImpl extends ServiceImpl<GradeBatchMapper, GradeBa
                 throw ExceptionResultEnum.ERROR.exception(JSONObject.toJSONString(errors));
             }
             return finalExcelList;
-        });
+        },2);
 
         executeImportGradeBatchStudent(batchId, list);
     }

+ 2 - 2
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/GradePaperDimensionServiceImpl.java

@@ -81,7 +81,7 @@ public class GradePaperDimensionServiceImpl extends ServiceImpl<GradePaperDimens
                 throw ExceptionResultEnum.ERROR.exception(JSONObject.toJSONString(finalExcelErrorList));
             }
             return finalExcelList;
-        });
+        },2);
         List<GradePaperDimensionDatasource> gradePaperDimensionDatasourceList = new ArrayList<>();
 
         if (Objects.nonNull(finalList) && finalList.size() > 0) {
@@ -125,7 +125,7 @@ public class GradePaperDimensionServiceImpl extends ServiceImpl<GradePaperDimens
                 throw ExceptionResultEnum.ERROR.exception(JSONObject.toJSONString(finalExcelErrorList));
             }
             return finalExcelList;
-        });
+        },2);
         List<GradePaperDimensionDatasource> gradePaperDimensionDatasourceList = new ArrayList<>();
 
         if (Objects.nonNull(finalList) && finalList.size() > 0) {

+ 1 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/GradePaperStructServiceImpl.java

@@ -191,7 +191,7 @@ public class GradePaperStructServiceImpl extends ServiceImpl<GradePaperStructMap
                 throw ExceptionResultEnum.ERROR.exception(JSONObject.toJSONString(finalExcelErrorList));
             }
             return finalExcelList;
-        });
+        },2);
         GradePaperStructParam gradePaperStructParam = new GradePaperStructParam();
         gradePaperStructParam.setPaperNumber(paperNumber);
         gradePaperStructParam.setPaperType(paperType);

+ 2 - 2
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/TeachCourseServiceImpl.java

@@ -174,7 +174,7 @@ public class TeachCourseServiceImpl extends ServiceImpl<TeachCourseMapper, Teach
                 throw ExceptionResultEnum.ERROR.exception(JSONObject.toJSONString(finalExcelErrorList));
             }
             return finalExcelList;
-        });
+        },2);
 
         if (Objects.nonNull(finalList) && finalList.size() > 0) {
             for (int i = 0; i < finalList.size(); i++) {
@@ -329,7 +329,7 @@ public class TeachCourseServiceImpl extends ServiceImpl<TeachCourseMapper, Teach
                 throw ExceptionResultEnum.ERROR.exception(JSONObject.toJSONString(finalExcelErrorList));
             }
             return finalExcelList;
-        });
+        },2);
 
         if (Objects.nonNull(finalList) && finalList.size() > 0) {
             for (int i = 0; i < finalList.size(); i++) {

+ 1 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/TeachStudentServiceImpl.java

@@ -94,7 +94,7 @@ public class TeachStudentServiceImpl extends ServiceImpl<TeachStudentMapper, Tea
                 throw ExceptionResultEnum.ERROR.exception(JSONObject.toJSONString(finalExcelErrorList));
             }
             return finalExcelList;
-        });
+        },2);
 
         List<BasicStudent> basicStudentDatasource = basicStudentService.list(new QueryWrapper<BasicStudent>().lambda().eq(BasicStudent::getSchoolId, schoolId));
         Set<String> studentCodeSet = new HashSet<>();

+ 4 - 7
distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/execute/AsyncStudentDataImportService.java

@@ -4,28 +4,25 @@ import cn.hutool.core.date.DateUtil;
 import com.qmth.boot.api.exception.ApiException;
 import com.qmth.distributed.print.business.templete.importData.AsyncImportTaskTemplete;
 import com.qmth.distributed.print.business.templete.service.TaskLogicService;
-import com.qmth.teachcloud.common.bean.dto.excel.BasicStudentImportDto;
 import com.qmth.teachcloud.common.bean.dto.excel.export.BasicStudentErrorExportDto;
 import com.qmth.teachcloud.common.contant.SpringContextHolder;
 import com.qmth.teachcloud.common.contant.SystemConstant;
-import com.qmth.teachcloud.common.entity.SysUser;
 import com.qmth.teachcloud.common.entity.TBTask;
-import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
 import com.qmth.teachcloud.common.enums.TaskResultEnum;
 import com.qmth.teachcloud.common.enums.TaskStatusEnum;
 import com.qmth.teachcloud.common.service.TBTaskService;
-import com.qmth.teachcloud.common.util.ExcelUtil;
 import com.qmth.teachcloud.common.util.Result;
 import com.qmth.teachcloud.common.util.ResultUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Service;
 
-import java.io.File;
-import java.io.IOException;
 import java.io.InputStream;
 import java.text.MessageFormat;
-import java.util.*;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.StringJoiner;
 
 /**
  * @Description: 异步-学生基础信息导入

+ 3 - 2
distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/execute/AsyncSysUserDataImportService.java

@@ -5,6 +5,7 @@ import com.qmth.boot.api.exception.ApiException;
 import com.qmth.distributed.print.business.templete.importData.AsyncImportTaskTemplete;
 import com.qmth.distributed.print.business.templete.service.TaskLogicService;
 import com.qmth.teachcloud.common.bean.dto.excel.export.BasicStudentErrorExportDto;
+import com.qmth.teachcloud.common.bean.dto.excel.export.SysUserErrorExportDto;
 import com.qmth.teachcloud.common.contant.SpringContextHolder;
 import com.qmth.teachcloud.common.contant.SystemConstant;
 import com.qmth.teachcloud.common.entity.TBTask;
@@ -57,8 +58,8 @@ public class AsyncSysUserDataImportService extends AsyncImportTaskTemplete {
 
             //错误数据,生成文件
             if (result.containsKey(SystemConstant.ERROR_DATA_LIST)) {
-                List<BasicStudentErrorExportDto> errorDataList = (List<BasicStudentErrorExportDto>) result.get(SystemConstant.ERROR_DATA_LIST);
-                super.createErrorFile(tbTask, BasicStudentErrorExportDto.class, errorDataList);
+                List<SysUserErrorExportDto> errorDataList = (List<SysUserErrorExportDto>) result.get(SystemConstant.ERROR_DATA_LIST);
+                super.createErrorFile(tbTask, SysUserErrorExportDto.class, errorDataList);
             }
 
 //            // 执行用户同步数据

+ 18 - 22
distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/service/impl/TaskLogicServiceImpl.java

@@ -1380,7 +1380,6 @@ public class TaskLogicServiceImpl implements TaskLogicService {
 
                     String studentName = StringUtils.isNotBlank(basicStudentImportDto.getStudentName()) ? basicStudentImportDto.getStudentName().trim() : null;
                     String studentCode = StringUtils.isNotBlank(basicStudentImportDto.getStudentCode()) ? basicStudentImportDto.getStudentCode().trim() : null;
-                    String phoneNumber = StringUtils.isNotBlank(basicStudentImportDto.getPhoneNumber()) ? basicStudentImportDto.getPhoneNumber().trim() : null;
                     studentCodeList.add(studentCode);
 
                     StringJoiner errorStringJoiner = new StringJoiner(";");
@@ -1398,21 +1397,10 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                             checkCodeMap.put(studentCode, studentName);
                         }
                     }
-                    // 如果电话有值则检验电话excel中唯一性
-                    if (SystemConstant.strNotNull(phoneNumber)) {
-                        if (checkPhoneMap.containsKey(phoneNumber)) {
-                            errorStringJoiner.add("手机号[" + phoneNumber + "]查询到多条数据");
-                        } else {
-                            checkPhoneMap.put(phoneNumber, studentCode);
-                        }
-                    }
 
                     if (Objects.nonNull(studentCode) && !studentCode.matches(SystemConstant.REGULAR_EXPRESSION_OF_CODE)) {
                         errorStringJoiner.add("学号[" + studentCode + "]不符合规范");
                     }
-                    if (Objects.nonNull(phoneNumber) && !phoneNumber.matches(SystemConstant.REGULAR_EXPRESSION_OF_PHONE)) {
-                        errorStringJoiner.add("手机号[" + phoneNumber + "]不符合规范");
-                    }
                     String errorString = errorStringJoiner.toString();
                     if (errorString.length() > 0) {
                         basicStudentErrorExportDto.setErrorMsg(errorString);
@@ -1432,7 +1420,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
             map.put(SystemConstant.SUCCESS_DATA_COUNT, successInteger.get());
             map.put(SystemConstant.ERROR_DATA_COUNT, errorDataList.size());
             return finalExcelList;
-        });
+        },2);
         return basicStudentService.executeBasicStudentImportLogic(finalList, map);
     }
 
@@ -1450,11 +1438,12 @@ public class TaskLogicServiceImpl implements TaskLogicService {
             for (int i = 0; i < finalExcelList.size(); i++) {
                 LinkedMultiValueMap<Integer, Object> excelMap = finalExcelList.get(i);
                 List<Object> sysUserImportDtoList = excelMap.get(i);
-                if (sysUserImportDtoList.isEmpty() || sysUserImportDtoList.get(0) instanceof DescribeImportDto) {
+                if (CollectionUtils.isEmpty(sysUserImportDtoList)) {
                     continue;
                 }
                 map.put(SystemConstant.DATA_COUNT, sysUserImportDtoList.size());
-                List<SysUserImportDto> duplicateData = new ArrayList<>();
+                List<Integer> errorIndex = new ArrayList<>();
+                Map<String, Integer> phoneNumberMap = new HashMap<>();
                 for (int y = 0; y < Objects.requireNonNull(sysUserImportDtoList).size(); y++) {
                     SysUserImportDto sysUserImportDto = (SysUserImportDto) sysUserImportDtoList.get(y);
                     totalInteger.getAndIncrement();
@@ -1472,7 +1461,6 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                     if (errorStringEmpty.length() > 0) {
                         errorStringJoiner.add(errorStringEmpty);
                     }
-
                     if (checkDtoMap.containsKey(code)) {
                         SysUserImportDto primaryCell = checkDtoMap.get(code);
                         String priName = primaryCell.getName();
@@ -1492,7 +1480,6 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                             priRoleName = priRoleName + SystemConstant.COMMA + roleName;
                             primaryCell.setRoleName(priRoleName);
                         }
-                        duplicateData.add(sysUserImportDto);
                     } else {
                         checkDtoMap.put(code, sysUserImportDto);
                     }
@@ -1503,17 +1490,26 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                     if (Objects.nonNull(phoneNumber) && !phoneNumber.matches(SystemConstant.REGULAR_EXPRESSION_OF_PHONE)) {
                         errorStringJoiner.add("[手机号]不符合输入规范");
                     }
-
+                    if (Objects.nonNull(phoneNumber)) {
+                        if (phoneNumberMap.containsKey(phoneNumber)) {
+                            errorStringJoiner.add("[手机号]和第" + phoneNumberMap.get(phoneNumber) + "重复");
+                        } else {
+                            phoneNumberMap.put(phoneNumber, y);
+                        }
+                    }
                     String errorString = errorStringJoiner.toString();
                     if (errorString.length() > 0) {
                         sysUserErrorExportDto.setErrorMsg(errorString);
                         errorDataList.add(sysUserErrorExportDto);
-                        sysUserImportDtoList.remove(y);
+                        errorIndex.add(y);
                     } else {
                         // 校验通过的数据
                         successInteger.getAndIncrement();
                     }
                 }
+                for (int index : errorIndex) {
+                    sysUserImportDtoList.remove(index);
+                }
             }
             if (!errorDataList.isEmpty()) {
                 map.put(SystemConstant.ERROR_DATA_LIST, errorDataList);
@@ -1522,7 +1518,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
             map.put(SystemConstant.SUCCESS_DATA_COUNT, successInteger.get());
             map.put(SystemConstant.ERROR_DATA_COUNT, errorDataList.size());
             return finalExcelList;
-        });
+        }, 2);
         return sysUserService.executeSysUserImportLogic(finalList, map);
     }
 
@@ -1560,7 +1556,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                 throw ExceptionResultEnum.ERROR.exception(JSONObject.toJSONString(excelErrorTemp));
             }
             return finalExcelList;
-        });
+        },2);
         return basicClazzService.executeBasicClazzImportLogic(finalList, map);
     }
 
@@ -1637,7 +1633,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
             tcStatisticsService.importJoinData(tcStatisticsImportTempList);
             tcStatisticsTempService.removeByIds(tcStatisticsImportTempList.stream().map(BaseEntity::getId).collect(Collectors.toSet()));
             return finalExcelList;
-        });
+        },2);
         return map;
     }
 

BIN
distributed-print/src/main/resources/temps/course.xlsx


BIN
distributed-print/src/main/resources/temps/examTask.xlsx


BIN
distributed-print/src/main/resources/temps/examTaskStudent.xlsx


BIN
distributed-print/src/main/resources/temps/org.xlsx


BIN
distributed-print/src/main/resources/temps/student.xlsx


BIN
distributed-print/src/main/resources/temps/teachClass.xlsx


BIN
distributed-print/src/main/resources/temps/teachCourse.xlsx


BIN
distributed-print/src/main/resources/temps/teachTeacher.xlsx


BIN
distributed-print/src/main/resources/temps/user.xlsx


+ 1 - 1
distributed-print/src/test/java/com/qmth/distributed/print/ImportTest.java

@@ -46,7 +46,7 @@ public class ImportTest {
                 throw ExceptionResultEnum.ERROR.exception(JSONObject.toJSONString(finalExcelErrorList));
             }
             return finalExcelList;
-        });
+        },2);
 
         Map<String,BasicCourseImportDto> courseMap = new HashMap<>();
         if (Objects.nonNull(finalList) && finalList.size() > 0) {

+ 0 - 11
teachcloud-common/src/main/java/com/qmth/teachcloud/common/bean/dto/excel/BasicStudentImportDto.java

@@ -21,9 +21,6 @@ public class BasicStudentImportDto implements Serializable {
     @NotNull
     private String studentCode;
 
-    @ExcelNote(value = "手机号")
-    private String phoneNumber;
-
     @ExcelNote(value = "学院")
     @NotNull
     private String collegeName;
@@ -52,14 +49,6 @@ public class BasicStudentImportDto implements Serializable {
         this.studentCode = studentCode;
     }
 
-    public String getPhoneNumber() {
-        return phoneNumber;
-    }
-
-    public void setPhoneNumber(String phoneNumber) {
-        this.phoneNumber = phoneNumber;
-    }
-
     public String getCollegeName() {
         return collegeName;
     }

+ 2 - 5
teachcloud-common/src/main/java/com/qmth/teachcloud/common/enums/ImportTemplateEnum.java

@@ -1,8 +1,5 @@
 package com.qmth.teachcloud.common.enums;
 
-import java.util.ArrayList;
-import java.util.List;
-
 /**
  * 模板下载类型
  */
@@ -25,8 +22,8 @@ public enum ImportTemplateEnum {
         this.fileName = fileName;
     }
 
-    private String templateName;
-    private String fileName;
+    private final String templateName;
+    private final String fileName;
 
     public String getTemplateName() {
         return templateName;

+ 1 - 1
teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/impl/BasicCourseServiceImpl.java

@@ -304,7 +304,7 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
                 throw ExceptionResultEnum.ERROR.exception(JSONObject.toJSONString(excelErrorTemp));
             }
             return finalExcelList;
-        });
+        },2);
         return this.executeBasicCourseImportLogic(finalList);
     }
 

+ 2 - 1
teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/impl/BasicStudentServiceImpl.java

@@ -302,7 +302,7 @@ public class BasicStudentServiceImpl extends ServiceImpl<BasicStudentMapper, Bas
                 BasicStudentExtrasParam basicStudentExtrasParam = new BasicStudentExtrasParam();
                 basicStudentExtrasParam.setStudentName(StringUtils.isNotBlank(e.getStudentName()) ? e.getStudentName().trim() : null);
                 basicStudentExtrasParam.setStudentCode(StringUtils.isNotBlank(e.getStudentCode()) ? e.getStudentCode().trim() : null);
-                basicStudentExtrasParam.setPhoneNumber(StringUtils.isNotBlank(e.getPhoneNumber()) ? e.getPhoneNumber().trim() : null);
+                basicStudentExtrasParam.setPhoneNumber(null);
                 basicStudentExtrasParam.setCollegeName(StringUtils.isNotBlank(e.getCollegeName()) ? e.getCollegeName().trim() : null);
                 basicStudentExtrasParam.setMajorName(StringUtils.isNotBlank(e.getMajorName()) ? e.getMajorName().trim() : null);
                 basicStudentExtrasParam.setClazzName(StringUtils.isNotBlank(e.getClazzName()) ? e.getClazzName().trim() : null);
@@ -364,6 +364,7 @@ public class BasicStudentServiceImpl extends ServiceImpl<BasicStudentMapper, Bas
         basicStudent.setMajorId(majorId);
         basicStudent.setClazzId(clazzId);
         basicStudent.setSchoolId(schoolId);
+        basicStudent.setOrgId(collegeId);
 
         BasicStudent checkCode = this.getOne(new QueryWrapper<BasicStudent>().lambda()
                 .eq(BasicStudent::getSchoolId, schoolId)

+ 1 - 1
teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/impl/SysOrgServiceImpl.java

@@ -541,7 +541,7 @@ public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> impleme
     public void executeImportSysOrgLogic(MultipartFile file) {
         try {
             InputStream inputStream = file.getInputStream();
-            List<LinkedMultiValueMap<Integer, Object>> finalList = ExcelUtil.excelReader(inputStream, Lists.newArrayList(SysOrgImportDto.class, DescribeImportDto.class), (finalExcelList, finalColumnNameList, finalExcelErrorList) -> finalExcelList);
+            List<LinkedMultiValueMap<Integer, Object>> finalList = ExcelUtil.excelReader(inputStream, Lists.newArrayList(SysOrgImportDto.class, DescribeImportDto.class), (finalExcelList, finalColumnNameList, finalExcelErrorList) -> finalExcelList,2);
             List<String> orgInfoList = new ArrayList<>();
             for (int i = 0; i < finalList.size(); i++) {
                 LinkedMultiValueMap<Integer, Object> excelMap = finalList.get(i);

+ 1 - 3
teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/impl/SysUserServiceImpl.java

@@ -756,11 +756,9 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
         for (int i = 0; i < finalList.size(); i++) {
             LinkedMultiValueMap<Integer, Object> excelMap = finalList.get(i);
             List<Object> sysUserImportDtoList = excelMap.get(i);
-            assert sysUserImportDtoList != null;
-            if (sysUserImportDtoList.get(0) instanceof DescribeImportDto) {
+            if (CollectionUtils.isEmpty(sysUserImportDtoList)){
                 continue;
             }
-
             //  处理机构
             if (sysUserImportDtoList.get(0) instanceof SysUserImportDto) {
                 List<SysUserImportDto> datasource = sysUserImportDtoList.stream().map(e -> {

+ 14 - 12
teachcloud-common/src/main/java/com/qmth/teachcloud/common/util/ExcelUtil.java

@@ -130,15 +130,17 @@ public class ExcelUtil {
 
     /**
      * excel读取
-     *
-     * @param inputStream
-     * @param clazz
-     * @param callback
-     * @return
-     * @throws NoSuchFieldException
-     * @throws IOException
+     * @param inputStream inputStream
+     * @param clazz clazz
+     * @param callback callback
+     * @param headRow 表头所在行(从第几行开始是表头) - 默认第一行
      */
-    public static List<LinkedMultiValueMap<Integer, Object>> excelReader(InputStream inputStream, List<Class<?>> clazz, ExcelCallback callback) throws NoSuchFieldException, IOException {
+    public static List<LinkedMultiValueMap<Integer, Object>> excelReader(InputStream inputStream, List<Class<?>> clazz, ExcelCallback callback , Integer headRow) throws NoSuchFieldException, IOException {
+        // 表头行索引
+        int headIndex = 0;
+        if (Objects.nonNull(headRow) && headRow > 0){
+            headIndex = headRow - 1;
+        }
         Object o = null;
         try {
             log.info("开始读取excel里的数据");
@@ -160,7 +162,7 @@ public class ExcelUtil {
                 LinkedMultiValueMap<Integer, Object> oList = new LinkedMultiValueMap<>();
                 LinkedMultiValueMap<Integer, String> columnNameList = new LinkedMultiValueMap<>();
                 LinkedMultiValueMap<Integer, ExcelError> excelErrorList = new LinkedMultiValueMap<>();
-                for (int i = 0; i < lastrow + 1; i++) {
+                for (int i = headIndex; i < lastrow + 1; i++) {
                     //获取哪一行i
                     Row row = sheet.getRow(i);
                     if (Objects.nonNull(row)) {
@@ -172,7 +174,7 @@ public class ExcelUtil {
                         Field[] fields = o.getClass().getDeclaredFields();
 
                         // 只校验第一个sheet的第一行表头格式
-                        if (y == 0 && i == 0) {
+                        if (y == 0 && i == headIndex) {
                             for (Field field : fields) {
                                 ExcelNote excelNote = field.getAnnotation(ExcelNote.class);
                                 if(Objects.nonNull(excelNote)) {
@@ -190,7 +192,7 @@ public class ExcelUtil {
                         for (int j = firstcell; j < lastcell; j++) {
                             //获取第j列
                             Cell cell = row.getCell(j);
-                            if (i == 0) {
+                            if (i == headIndex) {
                                 String cellName = String.valueOf(cell);
                                 if (y == 0) {
                                     if (!headList.contains(cellName)) {
@@ -242,7 +244,7 @@ public class ExcelUtil {
                                 }
                             }
                         }
-                        if (i > 0 && emptyRowSum - (lastcell - firstcell) != 0) {
+                        if (i > headIndex && emptyRowSum - (lastcell - firstcell) != 0) {
                             oList.add(y, o);
                         }
                     }

+ 3 - 3
teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/service/impl/CourseUnitOperateServiceImpl.java

@@ -68,7 +68,7 @@ public class CourseUnitOperateServiceImpl implements CourseUnitOperateService {
                 throw ExceptionResultEnum.ERROR.exception(JSONObject.toJSONString(finalExcelErrorList));
             }
             return finalExcelList;
-        });
+        },2);
         List<BasicCourse> updateData = new ArrayList<>();
         if (Objects.nonNull(finalList) && finalList.size() > 0) {
             for (int i = 0; i < finalList.size(); i++) {
@@ -118,7 +118,7 @@ public class CourseUnitOperateServiceImpl implements CourseUnitOperateService {
                 throw ExceptionResultEnum.ERROR.exception(JSONObject.toJSONString(finalExcelErrorList));
             }
             return finalExcelList;
-        });
+        },2);
         List<SysOrg> updateData = new ArrayList<>();
         Map<String, Integer> nameCheck = new HashMap<>();
 
@@ -178,7 +178,7 @@ public class CourseUnitOperateServiceImpl implements CourseUnitOperateService {
                 throw ExceptionResultEnum.ERROR.exception(JSONObject.toJSONString(finalExcelErrorList));
             }
             return finalExcelList;
-        });
+        },2);
 
         List<SysUser> updateData = new ArrayList<>();
 

+ 1 - 1
teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/service/impl/TBExamStudentServiceImpl.java

@@ -241,7 +241,7 @@ public class TBExamStudentServiceImpl extends ServiceImpl<TBExamStudentMapper, T
                 throw ExceptionResultEnum.ERROR.exception(JSONObject.toJSONString(errors));
             }
             return finalExcelList;
-        });
+        },2);
 
         for (int i = 0; i < finalList.size(); i++) {
             LinkedMultiValueMap<Integer, Object> excelMap = finalList.get(i);

+ 1 - 1
teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/service/impl/TBTeacherServiceImpl.java

@@ -72,7 +72,7 @@ public class TBTeacherServiceImpl extends ServiceImpl<TBTeacherMapper, TBTeacher
                 throw ExceptionResultEnum.ERROR.exception(JSONObject.toJSONString(finalExcelErrorList));
             }
             return finalExcelList;
-        });
+        },2);
 
         Map<String,String> checkCode = new HashMap<>();
         List<TBTeacher> tbTeacherList = new ArrayList<>();