|
@@ -1,11 +1,13 @@
|
|
package com.qmth.themis.business.templete.impl;
|
|
package com.qmth.themis.business.templete.impl;
|
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
|
+import com.google.common.reflect.TypeToken;
|
|
|
|
+import com.google.gson.Gson;
|
|
|
|
+import com.qmth.themis.business.annotation.ExcelNotExport;
|
|
import com.qmth.themis.business.annotation.ExcelNote;
|
|
import com.qmth.themis.business.annotation.ExcelNote;
|
|
import com.qmth.themis.business.constant.SystemConstant;
|
|
import com.qmth.themis.business.constant.SystemConstant;
|
|
import com.qmth.themis.business.dto.MarkResultSimpleExportDto;
|
|
import com.qmth.themis.business.dto.MarkResultSimpleExportDto;
|
|
-import com.qmth.themis.business.dto.RoomCodeExportDto;
|
|
|
|
-import com.qmth.themis.business.service.TBExamInvigilateUserService;
|
|
|
|
|
|
+import com.qmth.themis.business.dto.MarkResultStandardExportDto;
|
|
import com.qmth.themis.business.service.TEExamStudentService;
|
|
import com.qmth.themis.business.service.TEExamStudentService;
|
|
import com.qmth.themis.business.templete.TaskExportCommon;
|
|
import com.qmth.themis.business.templete.TaskExportCommon;
|
|
import com.qmth.themis.business.templete.TaskExportTemplete;
|
|
import com.qmth.themis.business.templete.TaskExportTemplete;
|
|
@@ -22,6 +24,7 @@ import javax.annotation.Resource;
|
|
import java.io.File;
|
|
import java.io.File;
|
|
import java.io.FileOutputStream;
|
|
import java.io.FileOutputStream;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
|
+import java.lang.annotation.Annotation;
|
|
import java.lang.reflect.Field;
|
|
import java.lang.reflect.Field;
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
@@ -70,7 +73,9 @@ public class TaskMarkResultStandardExportTemplete implements TaskExportTemplete
|
|
String name = (String) map.get("name");
|
|
String name = (String) map.get("name");
|
|
String courseCode = (String) map.get("courseCode");
|
|
String courseCode = (String) map.get("courseCode");
|
|
List<MarkResultSimpleExportDto> markResultSimpleExportDtoList = teExamStudentService.markResultQueryExport(examId, activityId, identity, name, courseCode);
|
|
List<MarkResultSimpleExportDto> markResultSimpleExportDtoList = teExamStudentService.markResultQueryExport(examId, activityId, identity, name, courseCode);
|
|
-
|
|
|
|
|
|
+ Gson gson = new Gson();
|
|
|
|
+ List<MarkResultStandardExportDto> markResultStandardExportDtoList = gson.fromJson(gson.toJson(markResultSimpleExportDtoList), new TypeToken<List<MarkResultStandardExportDto>>() {
|
|
|
|
+ }.getType());
|
|
boolean oss = (boolean) taskExportCommon.getOssEnv().get(SystemConstant.OSS);
|
|
boolean oss = (boolean) taskExportCommon.getOssEnv().get(SystemConstant.OSS);
|
|
StringJoiner stringJoiner = new StringJoiner("");
|
|
StringJoiner stringJoiner = new StringJoiner("");
|
|
if (!oss) {
|
|
if (!oss) {
|
|
@@ -92,32 +97,38 @@ public class TaskMarkResultStandardExportTemplete implements TaskExportTemplete
|
|
style.setAlignment(HorizontalAlignment.CENTER); // 水平居中格式
|
|
style.setAlignment(HorizontalAlignment.CENTER); // 水平居中格式
|
|
style.setVerticalAlignment(VerticalAlignment.CENTER); //垂直居中
|
|
style.setVerticalAlignment(VerticalAlignment.CENTER); //垂直居中
|
|
Row row = sheet.createRow(0);
|
|
Row row = sheet.createRow(0);
|
|
- Field[] fields = MarkResultSimpleExportDto.class.getDeclaredFields();
|
|
|
|
|
|
+ Field[] fields = MarkResultStandardExportDto.class.getDeclaredFields();
|
|
//绘制表头
|
|
//绘制表头
|
|
for (int i = 0; i < fields.length; i++) {
|
|
for (int i = 0; i < fields.length; i++) {
|
|
Field field = fields[i];
|
|
Field field = fields[i];
|
|
field.setAccessible(true);
|
|
field.setAccessible(true);
|
|
- Cell cell = row.createCell(i);
|
|
|
|
- cell.setCellValue(field.getAnnotation(ExcelNote.class).value());
|
|
|
|
- cell.setCellStyle(style);
|
|
|
|
-// sheet.setColumnWidth(i, 15 * 256);
|
|
|
|
|
|
+ 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 * 256);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- int cellIndex = 0, max = SystemConstant.MAX_EXPORT_SIZE, size = markResultSimpleExportDtoList.size();
|
|
|
|
|
|
+ int cellIndex = 0, max = SystemConstant.MAX_EXPORT_SIZE, size = markResultStandardExportDtoList.size();
|
|
if (max >= size) {
|
|
if (max >= size) {
|
|
max = size;
|
|
max = size;
|
|
}
|
|
}
|
|
while (max <= size) {
|
|
while (max <= size) {
|
|
- List subList = markResultSimpleExportDtoList.subList(min, max);
|
|
|
|
|
|
+ List subList = markResultStandardExportDtoList.subList(min, max);
|
|
//绘制数据
|
|
//绘制数据
|
|
for (; y < subList.size(); y++) {
|
|
for (; y < subList.size(); y++) {
|
|
- MarkResultSimpleExportDto markResultSimpleExportDto = (MarkResultSimpleExportDto) subList.get(y);
|
|
|
|
|
|
+ MarkResultStandardExportDto markResultStandardExportDto = (MarkResultStandardExportDto) subList.get(y);
|
|
int firstRow = y + 1;
|
|
int firstRow = y + 1;
|
|
cellIndex = 0;
|
|
cellIndex = 0;
|
|
Row sxssfRow = sheet.createRow(firstRow);
|
|
Row sxssfRow = sheet.createRow(firstRow);
|
|
for (Field field : fields) {
|
|
for (Field field : fields) {
|
|
field.setAccessible(true);
|
|
field.setAccessible(true);
|
|
- taskExportCommon.createExcelCell(sxssfRow, cellIndex, field.get(markResultSimpleExportDto), style);
|
|
|
|
- cellIndex++;
|
|
|
|
|
|
+ Annotation annotation = field.getAnnotation(ExcelNotExport.class);
|
|
|
|
+ if (Objects.isNull(annotation)) {
|
|
|
|
+ taskExportCommon.createExcelCell(sxssfRow, cellIndex, field.get(markResultStandardExportDto), style);
|
|
|
|
+ cellIndex++;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
map.put("max", max);
|
|
map.put("max", max);
|