Quellcode durchsuchen

导出数据优化分页

wangliang vor 3 Jahren
Ursprung
Commit
9eff3b48bf

+ 1 - 1
pom.xml

@@ -38,7 +38,7 @@
         <bcprov.version>1.52</bcprov.version>
         <redis.version>3.3.0</redis.version>
         <rocket.version>2.1.0</rocket.version>
-        <mybatis-plus.version>3.3.1</mybatis-plus.version>
+        <mybatis-plus.version>3.4.2</mybatis-plus.version>
         <spring-boot.version>2.3.0.RELEASE</spring-boot.version>
         <gson.version>2.8.6</gson.version>
         <commons.version>3.10</commons.version>

+ 18 - 12
themis-business/src/main/java/com/qmth/themis/business/config/MybatisPlusConfig.java

@@ -1,27 +1,21 @@
 package com.qmth.themis.business.config;
 
+import com.baomidou.mybatisplus.annotation.DbType;
+import com.baomidou.mybatisplus.autoconfigure.ConfigurationCustomizer;
 import com.baomidou.mybatisplus.core.config.GlobalConfig;
-import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
+import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
+import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
 import org.mybatis.spring.annotation.MapperScan;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 
 @Configuration
-@MapperScan(basePackages={"com.qmth.themis.business.dao"})
+@MapperScan(basePackages = {"com.qmth.themis.business.dao"})
 public class MybatisPlusConfig {
-	
-    /**
-     * mybatis-plus分页插件<br>
-     */
-    @Bean
-    public PaginationInterceptor paginationInterceptor() {
-        PaginationInterceptor page = new PaginationInterceptor();
-        page.setDialectType("mysql");
-        return page;
-    }
 
     /**
      * 自动填充功能
+     *
      * @return
      */
     @Bean
@@ -30,4 +24,16 @@ public class MybatisPlusConfig {
         globalConfig.setMetaObjectHandler(new MetaHandler());
         return globalConfig;
     }
+
+    @Bean
+    public MybatisPlusInterceptor mybatisPlusInterceptor() {
+        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
+        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
+        return interceptor;
+    }
+
+    @Bean
+    public ConfigurationCustomizer configurationCustomizer() {
+        return configuration -> configuration.setUseDeprecatedExecutor(false);
+    }
 }

+ 4 - 0
themis-business/src/main/java/com/qmth/themis/business/constant/SystemConstant.java

@@ -212,6 +212,10 @@ public class SystemConstant {
 
     public static final int MAX_EXPORT_SIZE = 500;
 
+    public static final int MIN_QUERY_SIZE = 1;
+
+    public static final int MAX_QUERY_SIZE = 1000;
+
     public static final int MAX_EXAM_STATUS_COUNT = 20;
 
     public static final String EXCEL_PREFIX = ".xlsx";

+ 16 - 3
themis-business/src/main/java/com/qmth/themis/business/dao/TEExamStudentMapper.java

@@ -46,10 +46,10 @@ public interface TEExamStudentMapper extends BaseMapper<TEExamStudent> {
                                                     @Param("roomCode") String roomCode, @Param("courseCode") String courseCode, @Param("grade") String grade,
                                                     @Param("enable") Integer enable, @Param("classNo") String classNo, @Param("hasPhoto") Integer hasPhoto);
 
-    public List<Map<String, Object>> getTotalCount(@Param("orgId")Long orgId,@Param("examId") Long examId, @Param("activityId") Long activityId,
+    public List<Map<String, Object>> getTotalCount(@Param("orgId") Long orgId, @Param("examId") Long examId, @Param("activityId") Long activityId,
                                                    @Param("roomCode") String roomCode, @Param("courseCode") String courseCode);
 
-    public IPage<ExamViewCountListBean> getTotalCountInfo(IPage<Map> iPage,@Param("orgId")Long orgId, @Param("examId") Long examId, @Param("activityId") Long activityId,
+    public IPage<ExamViewCountListBean> getTotalCountInfo(IPage<Map> iPage, @Param("orgId") Long orgId, @Param("examId") Long examId, @Param("activityId") Long activityId,
                                                           @Param("roomCode") String roomCode, @Param("courseCode") String courseCode);
 
     public List<Map<String, Object>> getDoneCountByActivityIds(@Param("examId") Long examId, @Param("activityIds") List<Long> activityIds);
@@ -68,7 +68,7 @@ public interface TEExamStudentMapper extends BaseMapper<TEExamStudent> {
                                                                @Param("activityId") Long activityId, @Param("roomCode") String roomCode,
                                                                @Param("courseCode") String courseCode, @Param("name") String name, @Param("identity") String identity, @Param("activityIds") List<Long> activityIds);
 
-    public IPage<ExamStudentLogListBean> getPageForStudentLog(IPage<ExamStudentLogListBean> iPage,@Param("orgId") Long orgId,@Param("examId") Long examId,
+    public IPage<ExamStudentLogListBean> getPageForStudentLog(IPage<ExamStudentLogListBean> iPage, @Param("orgId") Long orgId, @Param("examId") Long examId,
                                                               @Param("activityId") Long activityId, @Param("roomCode") String roomCode,
                                                               @Param("courseCode") String courseCode, @Param("name") String name, @Param("identity") String identity);
 
@@ -107,6 +107,19 @@ public interface TEExamStudentMapper extends BaseMapper<TEExamStudent> {
      */
     public List<MarkResultSimpleExportDto> markResultQueryExport(@Param("examId") Long examId, @Param("activityId") Long activityId, @Param("identity") String identity, @Param("name") String name, @Param("courseCode") String courseCode);
 
+    /**
+     * 查询学生成绩信息(分页导出用)
+     *
+     * @param iPage
+     * @param examId
+     * @param activityId
+     * @param identity
+     * @param name
+     * @param courseCode
+     * @return
+     */
+    public IPage<MarkResultSimpleExportDto> markResultQueryExportIpage(IPage<Map> iPage, @Param("examId") Long examId, @Param("activityId") Long activityId, @Param("identity") String identity, @Param("name") String name, @Param("courseCode") String courseCode);
+
     public List<TEExamStudentDto> findExamStudentNeedMark(@Param("examId") Long examId, @Param("courseCode") String courseCode,
                                                           @Param("idGt") Long idGt, @Param("count") Integer count);
 }

+ 59 - 56
themis-business/src/main/java/com/qmth/themis/business/dto/response/TEExamStudentDto.java

@@ -2,84 +2,95 @@ package com.qmth.themis.business.dto.response;
 
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import com.qmth.themis.business.annotation.ExcelNotExport;
+import com.qmth.themis.business.annotation.ExcelNote;
 import io.swagger.annotations.ApiModelProperty;
 
 import java.io.Serializable;
 
-import com.qmth.themis.business.excel.ExcelProperty;
-
-/** 
-* @Description: 考生dto
-* @Param:  
-* @return:  
-* @Author: wangliang
-* @Date: 2020/8/3 
-*/ 
+/**
+ * @Description: 考生dto
+ * @Param:
+ * @return:
+ * @Author: wangliang
+ * @Date: 2020/8/3
+ */
 public class TEExamStudentDto implements Serializable {
 
-    @JsonSerialize(using = ToStringSerializer.class)
-    @ApiModelProperty(name = "考生id")
-    private Long id;//考生id
-
-    @ApiModelProperty(name = "考试批次名称")
-    private String examName;//考试批次名称
+    @ExcelNote(value = "场次代码")
+    @ApiModelProperty(name = "场次代码")
+    private String activityCode;//场次代码
 
-    @ExcelProperty(name = "姓名", width = 30, index = 2)
+    @ExcelNote(value = "姓名")
     @ApiModelProperty(name = "考生姓名")
     private String name;//考生姓名
 
-    @ExcelProperty(name = "证件号", width = 30, index = 3)
+    @ExcelNote(value = "证件号")
     @ApiModelProperty(name = "证件号")
     private String identity;//证件号
 
-    @ApiModelProperty(name = "考试场次代码")
-    private String code;//考试场次代码
+    @ExcelNote(value = "科目名称")
+    @ApiModelProperty(name = "科目名称")
+    private String courseName;//科目名称
 
-    @ExcelProperty(name = "科目代码", width = 30, index = 5)
+    @ExcelNote(value = "科目代码")
     @ApiModelProperty(name = "科目代码")
     private String courseCode;//科目代码
 
-    @ExcelProperty(name = "科目名称", width = 30, index = 4)
-    @ApiModelProperty(name = "科目名称")
-    private String courseName;//科目名称
-
-    @ExcelProperty(name = "状态", width = 30, index = 6)
+    @ExcelNote(value = "状态")
     private String enableText;
-    
-    @ApiModelProperty(name = "考生是否启用,0:停用,1:启用")
-    private Integer enable;//考生是否启用
 
-    @ExcelProperty(name = "考场代码", width = 30, index = 7)
+    @ExcelNote(value = "考场代码")
     @ApiModelProperty(name = "考场代码")
     private String roomCode;//考场代码
 
-    @ExcelProperty(name = "考场名称", width = 30, index = 8)
+    @ExcelNote(value = "考场名称")
     @ApiModelProperty(name = "考场名称")
     private String roomName;//考场名称
 
-    @ExcelProperty(name = "年级", width = 30, index = 9)
+    @ExcelNote(value = "年级")
     @ApiModelProperty(name = "年级")
     private String grade;//年级
 
-    @ExcelProperty(name = "教学班级", width = 30, index = 10)
+    @ExcelNote(value = "教学班级")
     @ApiModelProperty(name = "教学班级")
     private String classNo;//教学班级
 
+    @JsonSerialize(using = ToStringSerializer.class)
+    @ApiModelProperty(name = "考生id")
+    @ExcelNotExport
+    private Long id;//考生id
+
+    @ApiModelProperty(name = "考试批次名称")
+    @ExcelNotExport
+    private String examName;//考试批次名称
+
+    @ApiModelProperty(name = "考试场次代码")
+    @ExcelNotExport
+    private String code;//考试场次代码
+
+    @ApiModelProperty(name = "考生是否启用,0:停用,1:启用")
+    @ExcelNotExport
+    private Integer enable;//考生是否启用
+
     @JsonSerialize(using = ToStringSerializer.class)
     @ApiModelProperty(name = "场次id")
+    @ExcelNotExport
     private Long examActivityId;//场次id
 
-    @ExcelProperty(name = "场次代码", width = 30, index = 1)
-    @ApiModelProperty(name = "场次代码")
-    private String activityCode;//场次代码
-
     @JsonSerialize(using = ToStringSerializer.class)
     @ApiModelProperty(name = "考试批次id")
+    @ExcelNotExport
     private Long examId;//考试批次id
-    
+
     @ApiModelProperty(name = "底照url")
+    @ExcelNotExport
     private String basePhotoUrl;
 
+    public void setEnableText(String enableText) {
+        this.enableText = enableText;
+    }
+
     public Long getExamId() {
         return examId;
     }
@@ -200,23 +211,15 @@ public class TEExamStudentDto implements Serializable {
         this.classNo = classNo;
     }
 
-	public String getBasePhotoUrl() {
-		return basePhotoUrl;
-	}
-
-	public void setBasePhotoUrl(String basePhotoUrl) {
-		this.basePhotoUrl = basePhotoUrl;
-	}
-
-	public String getEnableText() {
-		if(enable!=null&&enable.intValue()==1) {
-			return "启用";
-		}else {
-			return "停用";
-		}
-		
-	}
-    
-	
-    
+    public String getBasePhotoUrl() {
+        return basePhotoUrl;
+    }
+
+    public void setBasePhotoUrl(String basePhotoUrl) {
+        this.basePhotoUrl = basePhotoUrl;
+    }
+
+    public String getEnableText() {
+        return enableText;
+    }
 }

+ 0 - 1
themis-business/src/main/java/com/qmth/themis/business/entity/TBTaskHistory.java

@@ -91,7 +91,6 @@ public class TBTaskHistory implements Serializable {
 
     @JsonSerialize(using = ToStringSerializer.class)
     @ApiModelProperty(value = "机构id")
-    @TableId(value = "org_id")
     private Long orgId;
 
     public TBTaskHistory() {

+ 13 - 0
themis-business/src/main/java/com/qmth/themis/business/service/TEExamStudentService.java

@@ -92,5 +92,18 @@ public interface TEExamStudentService extends IService<TEExamStudent> {
      */
     public List<MarkResultSimpleExportDto> markResultQueryExport(Long examId, Long examActivityId, String identity, String name, String courseCode);
 
+    /**
+     * 查询学生成绩信息(分页导出用)
+     *
+     * @param iPage
+     * @param examId
+     * @param examActivityId
+     * @param identity
+     * @param name
+     * @param courseCode
+     * @return
+     */
+    public IPage<MarkResultSimpleExportDto> markResultQueryExportIpage(IPage<Map> iPage, Long examId, Long examActivityId, String identity, String name, String courseCode);
+
     public List<TEExamStudentDto> findExamStudentNeedMark(Long examId, String courseCode, Long idGt, Integer count);
 }

+ 21 - 5
themis-business/src/main/java/com/qmth/themis/business/service/impl/TEExamStudentServiceImpl.java

@@ -52,8 +52,8 @@ public class TEExamStudentServiceImpl extends ServiceImpl<TEExamStudentMapper, T
      */
     @Override
     public IPage<TEExamStudentDto> examStudentQuery(IPage<Map> iPage, Long examId, Long examActivityId, String identity,
-            String name, String roomCode, String courseCode, String grade, Integer enable, String classNo,
-            Integer hasPhoto) {
+                                                    String name, String roomCode, String courseCode, String grade, Integer enable, String classNo,
+                                                    Integer hasPhoto) {
         return teExamStudentMapper
                 .examStudentQuery(iPage, examId, examActivityId, identity, name, roomCode, courseCode, grade, enable,
                         classNo, hasPhoto);
@@ -133,7 +133,7 @@ public class TEExamStudentServiceImpl extends ServiceImpl<TEExamStudentMapper, T
 
     @Override
     public List<TEExamStudentDto> examStudentList(Long examId, Long examActivityId, String identity, String name,
-            String roomCode, String courseCode, String grade, Integer enable, String classNo, Integer hasPhoto) {
+                                                  String roomCode, String courseCode, String grade, Integer enable, String classNo, Integer hasPhoto) {
         return teExamStudentMapper
                 .examStudentList(examId, examActivityId, identity, name, roomCode, courseCode, grade, enable, classNo,
                         hasPhoto);
@@ -166,7 +166,7 @@ public class TEExamStudentServiceImpl extends ServiceImpl<TEExamStudentMapper, T
      */
     @Override
     public IPage<MarkResultDto> markResultQuery(IPage<Map> iPage, Long examId, Long examActivityId, String identity,
-            String name, String courseCode) {
+                                                String name, String courseCode) {
         return teExamStudentMapper.markResultQuery(iPage, examId, examActivityId, identity, name, courseCode);
     }
 
@@ -182,10 +182,26 @@ public class TEExamStudentServiceImpl extends ServiceImpl<TEExamStudentMapper, T
      */
     @Override
     public List<MarkResultSimpleExportDto> markResultQueryExport(Long examId, Long examActivityId, String identity,
-            String name, String courseCode) {
+                                                                 String name, String courseCode) {
         return teExamStudentMapper.markResultQueryExport(examId, examActivityId, identity, name, courseCode);
     }
 
+    /**
+     * 查询学生成绩信息(分页导出用)
+     *
+     * @param iPage
+     * @param examId
+     * @param examActivityId
+     * @param identity
+     * @param name
+     * @param courseCode
+     * @return
+     */
+    @Override
+    public IPage<MarkResultSimpleExportDto> markResultQueryExportIpage(IPage<Map> iPage, Long examId, Long examActivityId, String identity, String name, String courseCode) {
+        return teExamStudentMapper.markResultQueryExportIpage(iPage, examId, examActivityId, identity, name, courseCode);
+    }
+
     @Override
     public List<TEExamStudentDto> findExamStudentNeedMark(Long examId, String courseCode, Long idGt, Integer count) {
         return teExamStudentMapper.findExamStudentNeedMark(examId, courseCode, idGt, count);

+ 116 - 47
themis-business/src/main/java/com/qmth/themis/business/templete/impl/TaskExamStudentExportTemplete.java

@@ -1,34 +1,29 @@
 package com.qmth.themis.business.templete.impl;
 
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.text.SimpleDateFormat;
-import java.util.Collections;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.StringJoiner;
-
-import javax.annotation.Resource;
-
-import com.qmth.themis.common.exception.BusinessException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Service;
-
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.qmth.themis.business.annotation.ExcelNotExport;
+import com.qmth.themis.business.annotation.ExcelNote;
 import com.qmth.themis.business.constant.SystemConstant;
 import com.qmth.themis.business.dto.response.TEExamStudentDto;
-import com.qmth.themis.business.enums.TaskStatusEnum;
-import com.qmth.themis.business.excel.ExportUtils;
 import com.qmth.themis.business.service.TEExamStudentService;
 import com.qmth.themis.business.templete.TaskExportCommon;
 import com.qmth.themis.business.templete.TaskExportTemplete;
+import com.qmth.themis.business.templete.service.TempleteLogicService;
 import com.qmth.themis.common.util.Result;
 import com.qmth.themis.common.util.ResultUtil;
+import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.xssf.streaming.SXSSFWorkbook;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.io.*;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.time.LocalDateTime;
+import java.util.*;
 
 /**
  * @Description: 考场导出任务
@@ -40,10 +35,13 @@ import com.qmth.themis.common.util.ResultUtil;
 @Service
 public class TaskExamStudentExportTemplete implements TaskExportTemplete {
     private final static Logger log = LoggerFactory.getLogger(TaskExamStudentExportTemplete.class);
-    private SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
+
     @Resource
     TEExamStudentService teExamStudentService;
 
+    @Resource
+    TempleteLogicService templeteLogicService;
+
     /**
      * 考生导出模版
      *
@@ -56,18 +54,14 @@ public class TaskExamStudentExportTemplete implements TaskExportTemplete {
         long start = System.currentTimeMillis();
         TaskExportCommon taskExportCommon = new TaskExportCommon(transMap);
         taskExportCommon.init();
-        ByteArrayOutputStream fos = null;
+        taskExportCommon.setTxtList(new ArrayList());
         InputStream inputStream = null;
+        ByteArrayOutputStream out = null;
         StringJoiner stringJoiner = null;
         String excelFilePath = null;
-        boolean oss = (boolean) taskExportCommon.getOssEnv().get(SystemConstant.OSS);
+        int min = 0, line = 0;
+        SXSSFWorkbook wb = null;
         try {
-            stringJoiner = new StringJoiner("");
-            if (!oss) {
-                stringJoiner.add(SystemConstant.FILES_DIR).add(File.separator);
-            }
-            stringJoiner.add(sdf.format(new Date()));
-            fos = new ByteArrayOutputStream();
             Long examId = (Long) transMap.get(SystemConstant.EXAM_ID);
             Long activityId = (Long) transMap.get(SystemConstant.ACTIVITY_ID);
             String identity = (String) transMap.get("identity");
@@ -78,31 +72,106 @@ public class TaskExamStudentExportTemplete implements TaskExportTemplete {
             Integer enable = (Integer) transMap.get("enable");
             String classNo = (String) transMap.get("classNo");
             Integer hasPhoto = (Integer) transMap.get("hasPhoto");
-            List<TEExamStudentDto> list = teExamStudentService.examStudentList(examId, activityId, identity, name, roomCode, courseCode, grade,
-                    enable, classNo, hasPhoto);
-            ExportUtils.makeExcel(TEExamStudentDto.class, list, fos);
-            inputStream = new ByteArrayInputStream(fos.toByteArray());
+
+            List<TEExamStudentDto> list = null;
+            int pageSize = SystemConstant.MAX_QUERY_SIZE, pageNumber = SystemConstant.MIN_QUERY_SIZE;
+            IPage<TEExamStudentDto> examStudentDtoIPage = teExamStudentService.examStudentQuery(new Page<>(pageNumber, pageSize), examId, activityId, identity, name, roomCode, courseCode, grade, enable, classNo, hasPhoto);
+            while (Objects.nonNull(examStudentDtoIPage) && examStudentDtoIPage.getRecords().size() > 0) {
+                list = Objects.isNull(list) ? new ArrayList<>(examStudentDtoIPage.getRecords().size() * 10) : list;
+                pageNumber++;
+                list.addAll(examStudentDtoIPage.getRecords());
+                examStudentDtoIPage = teExamStudentService.examStudentQuery(new Page<>(pageNumber, pageSize), examId, activityId, identity, name, roomCode, courseCode, grade, enable, classNo, hasPhoto);
+            }
+
+            boolean oss = (boolean) taskExportCommon.getOssEnv().get(SystemConstant.OSS);
+            stringJoiner = new StringJoiner("");
+            if (!oss) {
+                stringJoiner.add(SystemConstant.FILES_DIR).add(File.separator);
+            }
+            LocalDateTime nowTime = LocalDateTime.now();
+            stringJoiner.add(String.valueOf(nowTime.getYear())).add(File.separator)
+                    .add(String.format("%02d", nowTime.getMonthValue())).add(File.separator)
+                    .add(String.format("%02d", nowTime.getDayOfMonth()));
+            //创建excel
+            wb = new SXSSFWorkbook();
+            Sheet sheet = wb.createSheet("考生导出");
+            CellStyle style = wb.createCellStyle();
+            style.setAlignment(HorizontalAlignment.CENTER); // 水平居中格式
+            style.setVerticalAlignment(VerticalAlignment.CENTER); //垂直居中
+            Row row = sheet.createRow(0);
+            Field[] fields = TEExamStudentDto.class.getDeclaredFields();
+            //绘制表头
+            for (int i = 0; i < fields.length; i++) {
+                Field field = fields[i];
+                field.setAccessible(true);
+                Annotation annotation = field.getAnnotation(ExcelNotExport.class);
+                if (Objects.isNull(annotation)) {
+                    Cell cell = row.createCell(i);
+                    cell.setCellValue(field.getAnnotation(ExcelNote.class).value());
+                    cell.setCellStyle(style);
+                    sheet.setColumnWidth(i, 15 * 400);
+                }
+            }
+            int rowIndex = 0, cellIndex = 0, max = SystemConstant.MAX_EXPORT_SIZE, size = list.size();
+            if (max >= size) {
+                max = size;
+            }
+            while (max <= size) {
+                List subList = list.subList(min, max);
+                //绘制数据
+                for (int y = 0; y < subList.size(); y++) {
+                    line++;
+                    TEExamStudentDto teExamStudentDto = (TEExamStudentDto) subList.get(y);
+                    rowIndex++;
+                    cellIndex = 0;
+                    Row sxssfRow = sheet.createRow(rowIndex);
+                    for (Field field : fields) {
+                        field.setAccessible(true);
+                        Annotation annotation = field.getAnnotation(ExcelNotExport.class);
+                        if (Objects.isNull(annotation)) {
+                            taskExportCommon
+                                    .createExcelCell(sxssfRow, cellIndex, field.get(teExamStudentDto), style);
+                            cellIndex++;
+                        }
+                    }
+                }
+                transMap.put("max", max);
+                transMap.put("min", min);
+                transMap.put("size", size);
+                transMap = templeteLogicService.execExportExamStudentLogic(transMap);
+                if (max == size) {
+                    break;
+                }
+                min = max;
+                max += SystemConstant.MAX_EXPORT_SIZE;
+                if (max >= size) {
+                    max = size;
+                }
+            }
+            //临时缓冲区
+            out = new ByteArrayOutputStream();
+            wb.write(out);
+            byte[] bookByteAry = out.toByteArray();
+            inputStream = new ByteArrayInputStream(bookByteAry);
             excelFilePath = taskExportCommon.ossUpload(inputStream, stringJoiner.toString());
-            taskExportCommon.getTbTaskHistory().setSummary("处理成功");
             long end = System.currentTimeMillis();
             log.info("导出考生数据结束,============耗时============:{}秒", (end - start) / 1000);
         } catch (Exception e) {
             log.error("导出报错", e);
-            taskExportCommon.setException(true);
-            taskExportCommon.getTbTaskHistory().setSummary("处理出错");
+            taskExportCommon.exception(line, e, taskExportCommon.getTxtList());
         } finally {
-            taskExportCommon.getTbTaskHistory().setFinishTime(System.currentTimeMillis());
-            taskExportCommon.getTbTaskHistory().setStatus(TaskStatusEnum.FINISH);
-            taskExportCommon.getTbTaskHistory().setProgress(100.0d);
             //这里写入txt文件
-            taskExportCommon.writeExportResultTxt(stringJoiner.toString(), "", excelFilePath);
-            if (Objects.nonNull(fos)) {
-        		fos.flush();
-        		fos.close();
-        	}
-        	if (Objects.nonNull(inputStream)) {
+            taskExportCommon.writeExportResultTxt(stringJoiner.toString(), taskExportCommon.getTxtList().toString(), excelFilePath);
+            if (Objects.nonNull(wb)) {
+                wb.dispose();
+            }
+            if (Objects.nonNull(inputStream)) {
                 inputStream.close();
             }
+            if (Objects.nonNull(out)) {
+                out.flush();
+                out.close();
+            }
         }
         return ResultUtil.ok(true);
     }

+ 14 - 3
themis-business/src/main/java/com/qmth/themis/business/templete/impl/TaskMarkResultSimpleExportTemplete.java

@@ -1,6 +1,8 @@
 package com.qmth.themis.business.templete.impl;
 
 import cn.hutool.core.date.DateUtil;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.google.gson.Gson;
 import com.qmth.themis.business.annotation.ExcelNotExport;
 import com.qmth.themis.business.annotation.ExcelNote;
@@ -82,9 +84,18 @@ public class TaskMarkResultSimpleExportTemplete implements TaskExportTemplete {
             String identity = (String) map.get("identity");
             String name = (String) map.get(SystemConstant.NAME);
             String courseCode = (String) map.get(SystemConstant.COURSE_CODE);
+
+            List<MarkResultSimpleExportDto> markResultSimpleExportDtoList = null;
+            int pageSize = SystemConstant.MAX_QUERY_SIZE, pageNumber = SystemConstant.MIN_QUERY_SIZE;
+            IPage<MarkResultSimpleExportDto> markResultQueryExportIpage = teExamStudentService.markResultQueryExportIpage(new Page<>(pageNumber, pageSize), examId, activityId, identity, name, courseCode);
+            while (Objects.nonNull(markResultQueryExportIpage) && markResultQueryExportIpage.getRecords().size() > 0) {
+                markResultSimpleExportDtoList = Objects.isNull(markResultSimpleExportDtoList) ? new ArrayList<>(markResultQueryExportIpage.getRecords().size() * 10) : markResultSimpleExportDtoList;
+                pageNumber++;
+                markResultSimpleExportDtoList.addAll(markResultQueryExportIpage.getRecords());
+                markResultQueryExportIpage = teExamStudentService.markResultQueryExportIpage(new Page<>(pageNumber, pageSize), examId, activityId, identity, name, courseCode);
+            }
+
             Gson gson = new Gson();
-            List<MarkResultSimpleExportDto> markResultSimpleExportDtoList = teExamStudentService
-                    .markResultQueryExport(examId, activityId, identity, name, courseCode);
             if (Objects.nonNull(markResultSimpleExportDtoList) && markResultSimpleExportDtoList.size() > 0) {
                 for (MarkResultSimpleExportDto markResultSimpleExportDto : markResultSimpleExportDtoList) {
                     MarkResultDto markResultDto = gson
@@ -133,7 +144,7 @@ public class TaskMarkResultSimpleExportTemplete implements TaskExportTemplete {
                     Cell cell = row.createCell(i);
                     cell.setCellValue(field.getAnnotation(ExcelNote.class).value());
                     cell.setCellStyle(style);
-                    //                    sheet.setColumnWidth(i, 15 * 256);
+//                    sheet.setColumnWidth(i, 15 * 256);
                 }
             }
             int rowIndex = 0, cellIndex = 0, max = SystemConstant.MAX_EXPORT_SIZE, size = markResultSimpleExportDtoList

+ 13 - 2
themis-business/src/main/java/com/qmth/themis/business/templete/impl/TaskMarkResultStandardExportTemplete.java

@@ -2,6 +2,8 @@ package com.qmth.themis.business.templete.impl;
 
 import cn.hutool.core.date.DateUtil;
 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.google.common.reflect.TypeToken;
 import com.google.gson.Gson;
 import com.qmth.themis.business.annotation.ExcelDynamicExport;
@@ -98,9 +100,18 @@ public class TaskMarkResultStandardExportTemplete implements TaskExportTemplete
             String identity = (String) map.get("identity");
             String name = (String) map.get(SystemConstant.NAME);
             String courseCode = (String) map.get(SystemConstant.COURSE_CODE);
+
+            List<MarkResultSimpleExportDto> markResultSimpleExportDtoList = null;
+            int pageSize = SystemConstant.MAX_QUERY_SIZE, pageNumber = SystemConstant.MIN_QUERY_SIZE;
+            IPage<MarkResultSimpleExportDto> markResultQueryExportIpage = teExamStudentService.markResultQueryExportIpage(new Page<>(pageNumber, pageSize), examId, activityId, identity, name, courseCode);
+            while (Objects.nonNull(markResultQueryExportIpage) && markResultQueryExportIpage.getRecords().size() > 0) {
+                markResultSimpleExportDtoList = Objects.isNull(markResultSimpleExportDtoList) ? new ArrayList<>(markResultQueryExportIpage.getRecords().size() * 10) : markResultSimpleExportDtoList;
+                pageNumber++;
+                markResultSimpleExportDtoList.addAll(markResultQueryExportIpage.getRecords());
+                markResultQueryExportIpage = teExamStudentService.markResultQueryExportIpage(new Page<>(pageNumber, pageSize), examId, activityId, identity, name, courseCode);
+            }
+
             Gson gson = new Gson();
-            List<MarkResultSimpleExportDto> markResultSimpleExportDtoList = teExamStudentService
-                    .markResultQueryExport(examId, activityId, identity, name, courseCode);
             if (Objects.nonNull(markResultSimpleExportDtoList) && markResultSimpleExportDtoList.size() > 0) {
                 for (MarkResultSimpleExportDto markResultSimpleExportDto : markResultSimpleExportDtoList) {
                     MarkResultDto markResultDto = gson

+ 8 - 0
themis-business/src/main/java/com/qmth/themis/business/templete/service/TempleteLogicService.java

@@ -56,4 +56,12 @@ public interface TempleteLogicService {
      * @return
      */
     public Map<String, Object> execExportMarkResultStandardLogic(Map<String, Object> map);
+
+    /**
+     * 考生导出逻辑
+     *
+     * @param map
+     * @return
+     */
+    public Map<String, Object> execExportExamStudentLogic(Map<String, Object> map);
 }

+ 11 - 0
themis-business/src/main/java/com/qmth/themis/business/templete/service/impl/TempleteLogicServiceImpl.java

@@ -307,6 +307,17 @@ public class TempleteLogicServiceImpl implements TempleteLogicService {
         return commonExport(map);
     }
 
+    /**
+     * 考生导出
+     *
+     * @param map
+     * @return
+     */
+    @Override
+    public Map<String, Object> execExportExamStudentLogic(Map<String, Object> map) {
+        return commonExport(map);
+    }
+
     /**
      * 查询监考帐号是否存在
      *

+ 5 - 0
themis-business/src/main/resources/mapper/TEExamStudentMapper.xml

@@ -14,6 +14,7 @@
         teea.code,
         tees.course_code as courseCode,
         tees.course_name as courseName,
+        if(tees.enable = 1,'启用','停用') as enableText,
         tees.enable,
         tees.room_code as roomCode,
         tees.room_name as roomName,
@@ -412,6 +413,10 @@
         <include refid="markResultCommon" />
     </select>
 
+    <select id="markResultQueryExportIpage" resultType="com.qmth.themis.business.dto.MarkResultSimpleExportDto">
+        <include refid="markResultCommon" />
+    </select>
+
     <select id="findExamStudentNeedMark" resultType="com.qmth.themis.business.dto.response.TEExamStudentDto">
         select
         tees.id,