Przeglądaj źródła

add:考生导入方法更换

caozixuan 1 rok temu
rodzic
commit
cbe8075dec

+ 2 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/dto/BasicExamStudentDto.java

@@ -1,6 +1,7 @@
 package com.qmth.distributed.print.business.bean.dto;
 
 import com.qmth.boot.tools.excel.annotation.ExcelColumn;
+import com.qmth.teachcloud.common.annotation.ExcelError;
 import com.qmth.teachcloud.common.annotation.ExcelNote;
 import com.qmth.teachcloud.common.annotation.ExcelProperty;
 import io.swagger.annotations.ApiModelProperty;
@@ -103,6 +104,7 @@ public class BasicExamStudentDto {
     private String examRoom;
 
     @ApiModelProperty("异常信息")
+    @ExcelError
     private String errorMsg;
 
     public String getCourseName() {

+ 0 - 2
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/BasicExamStudentService.java

@@ -106,6 +106,4 @@ public interface BasicExamStudentService extends IService<BasicExamStudent> {
      * @return 考生字典
      */
     BasicExamStudent editEntityHelp(BasicExamStudentParam basicExamStudentParam, SysUser requestUser);
-
-    void testImport(MultipartFile file) throws Exception;
 }

+ 0 - 12
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/BasicExamStudentServiceImpl.java

@@ -1,12 +1,9 @@
 package com.qmth.distributed.print.business.service.impl;
 
-import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.qmth.boot.tools.excel.ExcelReader;
-import com.qmth.boot.tools.excel.enums.ExcelType;
 import com.qmth.distributed.print.business.bean.dto.BasicExamStudentDto;
 import com.qmth.distributed.print.business.bean.params.BasicExamStudentParam;
 import com.qmth.distributed.print.business.bean.result.BasicExamStudentResult;
@@ -32,7 +29,6 @@ import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
-import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletResponse;
@@ -320,12 +316,4 @@ public class BasicExamStudentServiceImpl extends ServiceImpl<BasicExamStudentMap
 
         return basicExamStudent;
     }
-
-    @Override
-    public void testImport(MultipartFile file) throws Exception {
-        ExcelReader excelReader = ExcelReader.create(ExcelType.XLSX, file.getInputStream(), 1);
-        List<String[]> list = excelReader.getDataArrayList();
-
-        System.out.println(JSON.toJSONString(list));
-    }
 }

+ 1 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/execute/SyncBasicExamStudentImportService.java

@@ -159,7 +159,7 @@ public class SyncBasicExamStudentImportService extends SyncImportTaskTemplate {
         String describe = SystemConstant.BASIC_EXAM_STUDENT_DESCRIBE;
         describe = describe.trim();
         XSSFRow rowDescribe = sheet.createRow(0);
-        rowDescribe.setHeightInPoints(195); //行高设置成195px
+        rowDescribe.setHeightInPoints(100); //行高设置成100px
         for (int i = 0; i < cellCount; i++) {
             XSSFCell cell = rowDescribe.createCell(i);
             if (i == 0) {

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

@@ -10,6 +10,7 @@ import com.google.common.reflect.TypeToken;
 import com.google.gson.Gson;
 import com.itextpdf.text.DocumentException;
 import com.qmth.boot.api.exception.ApiException;
+import com.qmth.teachcloud.common.bean.result.ExcelResult;
 import com.qmth.teachcloud.common.bean.vo.PrintPathVo;
 import com.qmth.distributed.print.business.bean.dto.*;
 import com.qmth.distributed.print.business.bean.examRule.CodeNameEnableValue;
@@ -2062,7 +2063,6 @@ public class TaskLogicServiceImpl implements TaskLogicService {
     @Transactional
     @Override
     public Map<String, Object> executeImportBasicExamStudentLogic(Map<String, Object> map) throws Exception {
-
         SysUser requestUser = (SysUser) map.get(SystemConstant.USER);
         InputStream inputStream = (InputStream) map.get("inputStream");
         Long examId = SystemConstant.convertIdToLong(String.valueOf(map.get("examId")));
@@ -2084,110 +2084,92 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                 BaseEntity::getId));
         // excel中学生学号和学生字典对象关系
         Map<String, BasicExamStudent> studentCodeObjMap = new HashMap<>();
-        List<BasicExamStudentDto> errorDataList = new ArrayList<>();
         AtomicInteger successInteger = new AtomicInteger(0);
         AtomicInteger exceptionInteger = new AtomicInteger(0);
 
-        ExcelUtil.excelReader(inputStream, Lists.newArrayList(BasicExamStudentDto.class),
-                (finalExcelList, finalColumnNameList, finalExcelErrorList) -> {
+        ExcelResult<BasicExamStudentDto> excelResult = ConvertUtil.analyzeExcel(inputStream, BasicExamStudentDto.class,
+                true, 1);
+        List<BasicExamStudentDto> basicExamStudentDtoList = excelResult.getDatasource();
+        boolean success = excelResult.isSuccess();
+        for (BasicExamStudentDto basicExamStudentDto : basicExamStudentDtoList) {
+            List<String> errorMsgList = new ArrayList<>();
+            // 行索引
+            String courseName = basicExamStudentDto.getCourseName();
+            String courseCode = basicExamStudentDto.getCourseCode();
+            String studentName = basicExamStudentDto.getStudentName();
+            String studentCode = basicExamStudentDto.getStudentCode();
+            String college = basicExamStudentDto.getCollege();
+            String major = basicExamStudentDto.getMajor();
+            String teachClazz = basicExamStudentDto.getTeachClazz();
+            String paperNumber = basicExamStudentDto.getPaperNumber();
+            String teacherName = basicExamStudentDto.getTeacherName();
+            String teacherCode = basicExamStudentDto.getTeacherCode();
+            String examDate = basicExamStudentDto.getExamDate();
+            String examTime = basicExamStudentDto.getExamTime();
+            String examPlace = basicExamStudentDto.getExamPlace();
+            String examRoom = basicExamStudentDto.getExamRoom();
 
-                    for (int i = 0; i < finalExcelList.size(); i++) {
-                        LinkedMultiValueMap<Integer, Object> excelMap = finalExcelList.get(i);
-                        List<Object> basicExamStudentDtoList = excelMap.get(i);
-                        // 无数据,跳过
-                        if (CollectionUtils.isEmpty(basicExamStudentDtoList)) {
-                            continue;
-                        }
-                        for (int y = 0; y < Objects.requireNonNull(basicExamStudentDtoList).size(); y++) {
-                            List<String> errorMsgList = new ArrayList<>();
-                            // 行索引
-                            BasicExamStudentDto basicExamStudentDto = (BasicExamStudentDto) basicExamStudentDtoList.get(
-                                    y);
-                            String courseName = StringUtils.trimToNull(basicExamStudentDto.getCourseName());
-                            String courseCode = StringUtils.trimToNull(basicExamStudentDto.getCourseCode());
-                            String studentName = StringUtils.trimToNull(basicExamStudentDto.getStudentName());
-                            String studentCode = StringUtils.trimToNull(basicExamStudentDto.getStudentCode());
-                            String college = StringUtils.trimToNull(basicExamStudentDto.getCollege());
-                            String major = StringUtils.trimToNull(basicExamStudentDto.getMajor());
-                            String teachClazz = StringUtils.trimToNull(basicExamStudentDto.getTeachClazz());
-                            String paperNumber = StringUtils.trimToNull(basicExamStudentDto.getPaperNumber());
-                            String teacherName = StringUtils.trimToNull(basicExamStudentDto.getTeacherName());
-                            String teacherCode = StringUtils.trimToNull(basicExamStudentDto.getTeacherCode());
-                            String examDate = StringUtils.trimToNull(basicExamStudentDto.getExamDate());
-                            String examTime = StringUtils.trimToNull(basicExamStudentDto.getExamTime());
-                            String examPlace = StringUtils.trimToNull(basicExamStudentDto.getExamPlace());
-                            String examRoom = StringUtils.trimToNull(basicExamStudentDto.getExamRoom());
-
-                            // 本行全部列为空,跳过
-                            if (StringUtils.isAllBlank(courseName, courseCode, studentName, studentCode, college, major,
-                                    teachClazz, paperNumber, teacherName, teacherCode, examDate, examTime, examPlace,
-                                    examRoom)) {
-                                continue;
-                            }
-                            Long examStartTime = null;
-                            Long examEndTime = null;
-                            try {
-                                if (SystemConstant.strNotNull(examDate) && SystemConstant.strNotNull(examTime)) {
-                                    Map<String, Object> timeMap = ConvertUtil.analyzeStartAndEndTime(examDate, examTime);
-                                    examStartTime = SystemConstant.convertIdToLong(String.valueOf(timeMap.get("startTime")));
-                                    examEndTime = SystemConstant.convertIdToLong(String.valueOf(timeMap.get("endTime")));
-                                }
-                            } catch (Exception e) {
-                                errorMsgList.add(e.getMessage());
-                            }
+            Long examStartTime = null;
+            Long examEndTime = null;
+            try {
+                if (SystemConstant.strNotNull(examDate) && SystemConstant.strNotNull(examTime)) {
+                    Map<String, Object> timeMap = ConvertUtil.analyzeStartAndEndTime(examDate, examTime);
+                    examStartTime = SystemConstant.convertIdToLong(String.valueOf(timeMap.get("startTime")));
+                    examEndTime = SystemConstant.convertIdToLong(String.valueOf(timeMap.get("endTime")));
+                }
+            } catch (Exception e) {
+                errorMsgList.add(e.getMessage());
+            }
+
+            String key = examId + SystemConstant.HYPHEN + courseCode + SystemConstant.HYPHEN + studentCode;
+            Long id = null;
+            if (studentCodeIdMap.containsKey(key)) {
+                id = studentCodeIdMap.get(key);
+            }
+            BasicExamStudentParam basicExamStudentParam = new BasicExamStudentParam();
+            basicExamStudentParam.setId(id);
+            basicExamStudentParam.setSemesterId(semesterId);
+            basicExamStudentParam.setExamId(examId);
+            basicExamStudentParam.setCourseCode(courseCode);
+            basicExamStudentParam.setStudentName(studentName);
+            basicExamStudentParam.setStudentCode(studentCode);
+            basicExamStudentParam.setCollege(college);
+            basicExamStudentParam.setMajor(major);
+            basicExamStudentParam.setTeachClazz(teachClazz);
+            basicExamStudentParam.setPaperNumber(paperNumber);
+            basicExamStudentParam.setTeacherName(teacherName);
+            basicExamStudentParam.setTeacherCode(teacherCode);
+            basicExamStudentParam.setExamStartTime(examStartTime);
+            basicExamStudentParam.setExamEndTime(examEndTime);
+            basicExamStudentParam.setExamPlace(examPlace);
+            basicExamStudentParam.setExamRoom(examRoom);
+            try {
+                BasicExamStudent basicExamStudent = basicExamStudentService.editEntityHelp(basicExamStudentParam,
+                        requestUser);
+                // 考试课程下学号重复 后面的替换前面的
+                studentCodeObjMap.put(key, basicExamStudent);
+            } catch (Exception e) {
+                errorMsgList.add(e.getMessage());
+            }
 
-                            String key = examId + SystemConstant.HYPHEN + courseCode + SystemConstant.HYPHEN + studentCode;
-                            Long id = null;
-                            if (studentCodeIdMap.containsKey(key)) {
-                                id = studentCodeIdMap.get(key);
-                            }
-                            BasicExamStudentParam basicExamStudentParam = new BasicExamStudentParam();
-                            basicExamStudentParam.setId(id);
-                            basicExamStudentParam.setSemesterId(semesterId);
-                            basicExamStudentParam.setExamId(examId);
-                            basicExamStudentParam.setCourseCode(courseCode);
-                            basicExamStudentParam.setStudentName(studentName);
-                            basicExamStudentParam.setStudentCode(studentCode);
-                            basicExamStudentParam.setCollege(college);
-                            basicExamStudentParam.setMajor(major);
-                            basicExamStudentParam.setTeachClazz(teachClazz);
-                            basicExamStudentParam.setPaperNumber(paperNumber);
-                            basicExamStudentParam.setTeacherName(teacherName);
-                            basicExamStudentParam.setTeacherCode(teacherCode);
-                            basicExamStudentParam.setExamStartTime(examStartTime);
-                            basicExamStudentParam.setExamEndTime(examEndTime);
-                            basicExamStudentParam.setExamPlace(examPlace);
-                            basicExamStudentParam.setExamRoom(examRoom);
-                            try {
-                                BasicExamStudent basicExamStudent = basicExamStudentService.editEntityHelp(
-                                        basicExamStudentParam, requestUser);
-                                // 考试课程下学号重复 后面的替换前面的
-                                studentCodeObjMap.put(key, basicExamStudent);
-                            } catch (Exception e) {
-                                errorMsgList.add(e.getMessage());
-                            }
+            if (CollectionUtils.isNotEmpty(errorMsgList)) {
+                basicExamStudentDto.setErrorMsg(basicExamStudentDto.getErrorMsg() + ";" + String.join(";", errorMsgList));
+                exceptionInteger.getAndIncrement();
+            } else {
+                successInteger.getAndIncrement();
+            }
 
-                            if (CollectionUtils.isNotEmpty(errorMsgList)) {
-                                basicExamStudentDto.setErrorMsg(String.join(";", errorMsgList));
-                                exceptionInteger.getAndIncrement();
-                            } else {
-                                successInteger.getAndIncrement();
-                            }
-                            errorDataList.add(basicExamStudentDto);
-                        }
-                    }
+        }
 
-                    if (errorDataList.stream().anyMatch(e -> SystemConstant.strNotNull(e.getErrorMsg()))) {
-                        map.put(SystemConstant.ERROR_DATA_LIST, errorDataList);
-                    } else {
-                        List<BasicExamStudent> basicExamStudentList = new ArrayList<>(studentCodeObjMap.values());
-                        map.put(SystemConstant.DATASOURCE, basicExamStudentList);
-                    }
-                    map.put(SystemConstant.DATA_COUNT, errorDataList.size());
-                    map.put(SystemConstant.SUCCESS_DATA_COUNT, successInteger.get());
-                    map.put(SystemConstant.ERROR_DATA_COUNT, exceptionInteger.get());
-                    return finalExcelList;
-                }, 2);
+        if (basicExamStudentDtoList.stream().anyMatch(e -> SystemConstant.strNotNull(e.getErrorMsg()))) {
+            map.put(SystemConstant.ERROR_DATA_LIST, basicExamStudentDtoList);
+        } else {
+            List<BasicExamStudent> basicExamStudentList = new ArrayList<>(studentCodeObjMap.values());
+            map.put(SystemConstant.DATASOURCE, basicExamStudentList);
+        }
+        map.put(SystemConstant.DATA_COUNT, basicExamStudentDtoList.size());
+        map.put(SystemConstant.SUCCESS_DATA_COUNT, successInteger.get());
+        map.put(SystemConstant.ERROR_DATA_COUNT, exceptionInteger.get());
         return map;
     }
 

+ 1 - 3
distributed-print/src/main/java/com/qmth/distributed/print/api/BasicExamStudentController.java

@@ -1,6 +1,7 @@
 package com.qmth.distributed.print.api;
 
 import com.qmth.boot.api.constant.ApiConstant;
+import com.qmth.distributed.print.business.bean.dto.BasicExamStudentDto;
 import com.qmth.distributed.print.business.bean.params.BasicExamStudentParam;
 import com.qmth.distributed.print.business.bean.result.BasicExamStudentResult;
 import com.qmth.distributed.print.business.service.BasicExamStudentService;
@@ -90,9 +91,6 @@ public class BasicExamStudentController {
         Map<String, Object> map = printCommonService.saveTask(file, SystemConstant.convertIdToLong(examId), TaskTypeEnum.BASIC_EXAM_STUDENT_IMPORT);
         map.put("examId", SystemConstant.convertIdToLong(examId));
         return syncBasicExamStudentImportService.importTask(map);
-
-//        basicExamStudentService.testImport(file);
-//        return ResultUtil.ok();
     }
 
     @ApiOperation(value = "导出")

+ 13 - 0
teachcloud-common/src/main/java/com/qmth/teachcloud/common/annotation/ExcelError.java

@@ -0,0 +1,13 @@
+package com.qmth.teachcloud.common.annotation;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * @Description: excel映射类记录错误信息的属性
+ * @Author: CaoZixuan
+ * @Date: 2024-03-25
+ */
+@Retention(RetentionPolicy.RUNTIME) //定义注解运行策略
+public @interface ExcelError {
+}

+ 35 - 0
teachcloud-common/src/main/java/com/qmth/teachcloud/common/bean/result/ExcelResult.java

@@ -0,0 +1,35 @@
+package com.qmth.teachcloud.common.bean.result;
+
+import io.swagger.annotations.ApiModelProperty;
+
+import java.util.List;
+
+/**
+ * @Description: excel结果
+ * @Author: CaoZixuan
+ * @Date: 2024-03-26
+ */
+public class ExcelResult<T> {
+
+    @ApiModelProperty("数据")
+    private List<T> datasource;
+
+    @ApiModelProperty("是否成功")
+    private boolean success;
+
+    public List<T> getDatasource() {
+        return datasource;
+    }
+
+    public void setDatasource(List<T> datasource) {
+        this.datasource = datasource;
+    }
+
+    public boolean isSuccess() {
+        return success;
+    }
+
+    public void setSuccess(boolean success) {
+        this.success = success;
+    }
+}

+ 100 - 40
teachcloud-common/src/main/java/com/qmth/teachcloud/common/util/ConvertUtil.java

@@ -1,24 +1,31 @@
 package com.qmth.teachcloud.common.util;
 
+import com.qmth.boot.tools.excel.ExcelReader;
+import com.qmth.boot.tools.excel.annotation.ExcelColumn;
+import com.qmth.boot.tools.excel.enums.ExcelType;
+import com.qmth.teachcloud.common.annotation.ExcelError;
+import com.qmth.teachcloud.common.bean.result.ExcelResult;
 import com.qmth.teachcloud.common.contant.SystemConstant;
 import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
+import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.pdfbox.pdmodel.PDDocument;
 import org.apache.pdfbox.pdmodel.PDPageTree;
 import org.apache.pdfbox.rendering.PDFRenderer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Component;
 
-import javax.annotation.Resource;
 import javax.imageio.ImageIO;
 import javax.servlet.http.HttpServletResponse;
 import java.awt.image.BufferedImage;
 import java.io.*;
+import java.lang.reflect.Field;
 import java.net.URLEncoder;
 import java.text.SimpleDateFormat;
 import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * @Description: 转换工具类
@@ -28,28 +35,8 @@ import java.util.*;
 
 @Component
 public class ConvertUtil {
-    private final static Logger log = LoggerFactory.getLogger(ConvertUtil.class);
-
-    @Resource
-    RedisTemplate<String, Object> redisTemplate;
-
-    // inputStream转outputStream
-    public static ByteArrayOutputStream parse(final InputStream in) throws Exception {
-        final ByteArrayOutputStream swapStream = new ByteArrayOutputStream();
-//        int ch;
-//        while ((ch = in.read()) != -1) {
-//            swapStream.write(ch);
-//        }
-        IOUtils.copy(in, swapStream);
-        return swapStream;
-    }
 
-    // outputStream转inputStream
-    public static ByteArrayInputStream parse(final OutputStream out) {
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        baos = (ByteArrayOutputStream) out;
-        return new ByteArrayInputStream(baos.toByteArray());
-    }
+    private final static Logger log = LoggerFactory.getLogger(ConvertUtil.class);
 
     /**
      * 转换,解析时间
@@ -68,7 +55,8 @@ public class ConvertUtil {
         String startTimeStr = date + " " + arr[0];
         String endTimeStr = date + " " + arr[1];
         if (Objects.isNull(DateDisposeUtils.parseDate(startTimeStr)) || Objects.isNull(DateDisposeUtils.parseDate(endTimeStr))) {
-            throw ExceptionResultEnum.ERROR.exception("提供的日期时间格式异常 \n考试日期[" + date + "]应该使用如下的格式(考试日期:2021-09-01 或 2021/09/01 或 2021.09.01)" + "\n考试时间[" + time + "]应该使用如下的格式(考试时间:18:00-20:00)");
+            throw ExceptionResultEnum.ERROR.exception(
+                    "提供的日期时间格式异常 \n考试日期[" + date + "]应该使用如下的格式(考试日期:2021-09-01 或 2021/09/01 或 2021.09.01)" + "\n考试时间[" + time + "]应该使用如下的格式(考试时间:18:00-20:00)");
         }
         long startTime = DateDisposeUtils.parseDate(startTimeStr).getTime();
         long endTime = DateDisposeUtils.parseDate(endTimeStr).getTime();
@@ -97,7 +85,6 @@ public class ConvertUtil {
         String date;
         String time;
 
-
         Map<String, Object> map = new HashMap<>();
 
         Calendar calendar = Calendar.getInstance();
@@ -121,7 +108,6 @@ public class ConvertUtil {
         return map;
     }
 
-
     /**
      * 根据开始时间和结束时间解析日期和时间
      *
@@ -148,6 +134,81 @@ public class ConvertUtil {
         }
     }
 
+    /**
+     * 解析excel
+     *
+     * @param inputStream   inputStream
+     * @param clazz         实体类映射对象
+     * @param fillError     是否为映射对象添加错误信息(如果要添加的话映射对象的属性必须有一个字段有@ExcelError注解)
+     * @param columnNameRow 从第几行开始
+     * @throws Exception 异常
+     */
+    public static <T> ExcelResult<T> analyzeExcel(InputStream inputStream, Class<T> clazz, boolean fillError, int columnNameRow)
+            throws Exception {
+        boolean analyzeResult = true;
+        ExcelReader excelReader = ExcelReader.create(ExcelType.XLSX, inputStream, columnNameRow);
+        List<String[]> excelDatasource = excelReader.getDataArrayList();
+        List<T> dtoList = new ArrayList<>();
+        if (CollectionUtils.isNotEmpty(excelDatasource)) {
+            List<String> columnNameList = Arrays.asList(excelReader.getColumnNames());
+            Field[] fields = clazz.getDeclaredFields();
+            Field errorField = null;
+            if (fillError) {
+                for (Field field : fields) {
+                    ExcelError annotation = field.getAnnotation(ExcelError.class);
+                    if (Objects.nonNull(annotation)) {
+                        errorField = field;
+                        break;
+                    }
+                }
+            }
+            // 要导入的字段
+            List<Field> fieldList = Arrays.stream(fields).filter(field -> {
+                ExcelColumn annotation = field.getAnnotation(ExcelColumn.class);
+                return Objects.nonNull(annotation);
+            }).collect(Collectors.toList());
+            List<String> fieldNameList = fieldList.stream().map(e -> e.getAnnotation(ExcelColumn.class).name()).collect(Collectors.toList());
+
+            if (columnNameList.size() != fieldNameList.size()) {
+                throw ExceptionResultEnum.ERROR.exception(String.format("表头错误,应为[%s]", String.join(";", fieldNameList)));
+            }
+            for (String[] cell : excelDatasource) {
+                T dto = clazz.newInstance();
+                boolean emptyCell = true;
+                List<String> excelErrorList = new ArrayList<>();
+                for (int i = 0; i < cell.length; i++) {
+                    String v = StringUtils.trimToNull(cell[i]);
+                    Field field = fieldList.get(i);
+                    ExcelColumn annotation = field.getAnnotation(ExcelColumn.class);
+                    if (SystemConstant.strNotNull(v)) {
+                        field.setAccessible(true);
+                        field.set(dto, v);
+                        emptyCell = false;
+                    } else if (annotation.nullable()) {
+                        excelErrorList.add(String.format("[%s]不能为空", annotation.name()));
+                    }
+                }
+                if (emptyCell) {
+                    // 舍弃全空行
+                    continue;
+                }
+                if (CollectionUtils.isNotEmpty(excelErrorList)) {
+                    // 有异常数据
+                    analyzeResult = false;
+                    if (fillError && Objects.nonNull(errorField)) {
+                        errorField.setAccessible(true);
+                        errorField.set(dto, String.join(",", excelErrorList));
+                    }
+                }
+                dtoList.add(dto);
+            }
+        }
+        ExcelResult<T> excelResult = new ExcelResult<>();
+        excelResult.setSuccess(analyzeResult);
+        excelResult.setDatasource(dtoList);
+        return excelResult;
+    }
+
     public static void delFolder(String folderPath) {
         try {
             delAllFile(folderPath); //删除完里面所有内容
@@ -190,8 +251,8 @@ public class ConvertUtil {
 
     public static void outputFile(HttpServletResponse response, InputStream inputStream, String fileName) {
         try {
-//            byte[] buf = new byte[1024];
-//            int len = 0;
+            //            byte[] buf = new byte[1024];
+            //            int len = 0;
 
             String fName = new String(fileName.getBytes(), "ISO-8859-1");
 
@@ -199,15 +260,15 @@ public class ConvertUtil {
             response.setContentType("application/x-msdownload");
             response.setHeader("Content-Disposition", "attachment; filename=" + fName);
 
-//            OutputStream outStream = response.getOutputStream();
+            //            OutputStream outStream = response.getOutputStream();
 
-//            while ((len = inputStream.read(buf)) > 0) {
-//                outStream.write(buf, 0, len);
-//            }
+            //            while ((len = inputStream.read(buf)) > 0) {
+            //                outStream.write(buf, 0, len);
+            //            }
 
             IOUtils.copy(inputStream, response.getOutputStream());
             inputStream.close();
-//            outStream.close();
+            //            outStream.close();
         } catch (IOException e) {
             log.error(SystemConstant.LOG_ERROR, e);
         }
@@ -221,9 +282,9 @@ public class ConvertUtil {
             response.setContentType("application/x-msdownload");
             response.setHeader("Content-Disposition", "attachment; filename=" + fName);
 
-//            OutputStream outStream = response.getOutputStream();
-//            baos.writeTo(outStream);
-//            outStream.close();
+            //            OutputStream outStream = response.getOutputStream();
+            //            baos.writeTo(outStream);
+            //            outStream.close();
             IOUtils.write(baos.toByteArray(), response.getOutputStream());
         } catch (IOException e) {
             throw new Exception("下载失败");
@@ -234,7 +295,7 @@ public class ConvertUtil {
         PDDocument doc = null;
         ByteArrayOutputStream os = null;
         InputStream stream = null;
-//        OutputStream out = null;
+        //        OutputStream out = null;
         List<File> fileList = new ArrayList<>();
         try {
             // pdf路径
@@ -255,9 +316,9 @@ public class ConvertUtil {
                     file.getParentFile().mkdirs();
                     file.createNewFile();
                 }
-//                out = new FileOutputStream(file);
+                //                out = new FileOutputStream(file);
                 IOUtils.write(os.toByteArray(), new FileOutputStream(file));
-//                out.write(dataList);
+                //                out.write(dataList);
                 fileList.add(file);
             }
         } catch (Exception e) {
@@ -320,5 +381,4 @@ public class ConvertUtil {
         }
         return fileList;
     }
-
 }