|
@@ -4,6 +4,7 @@ import cn.hutool.core.date.DateUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.google.common.reflect.TypeToken;
|
|
|
import com.google.gson.Gson;
|
|
|
+import com.qmth.themis.business.annotation.ExcelDynamicExport;
|
|
|
import com.qmth.themis.business.annotation.ExcelNotExport;
|
|
|
import com.qmth.themis.business.annotation.ExcelNote;
|
|
|
import com.qmth.themis.business.cache.bean.ObjectiveAnswerCacheBean;
|
|
@@ -92,6 +93,7 @@ public class TaskMarkResultStandardExportTemplete implements TaskExportTemplete
|
|
|
}.getType());
|
|
|
Map<Long, List<ExcelDto>> excelDtoMap = null;
|
|
|
Map<Long, Map<String, ObjectiveAnswerCacheBean>> paperObjectiveAnswerMap = new HashMap<>();
|
|
|
+ List<ExcelDto> dynamicExcelHead = new ArrayList<>();
|
|
|
if (Objects.nonNull(markResultStandardExportDtoList) && markResultStandardExportDtoList.size() > 0) {
|
|
|
for (MarkResultStandardExportDto m : markResultStandardExportDtoList) {
|
|
|
excelDtoMap = new HashMap<>();
|
|
@@ -103,6 +105,16 @@ public class TaskMarkResultStandardExportTemplete implements TaskExportTemplete
|
|
|
} else {
|
|
|
objectiveAnswerCacheBeanMap = paperObjectiveAnswerMap.get(m.getPaperId());
|
|
|
}
|
|
|
+ if (dynamicExcelHead.size() == 0) {
|
|
|
+ objectiveAnswerCacheBeanMap.forEach((k, v) -> {
|
|
|
+ ObjectiveAnswerCacheBean objectiveAnswerCacheBean = v;
|
|
|
+ String title = QuestionTypeEnum.convertToTitle(objectiveAnswerCacheBean.getStructType()) + k;
|
|
|
+ ExcelDto excelAnswerDto = new ExcelDto(title + "作答");
|
|
|
+ ExcelDto excelScoreDto = new ExcelDto(title + "得分");
|
|
|
+ dynamicExcelHead.add(excelAnswerDto);
|
|
|
+ dynamicExcelHead.add(excelScoreDto);
|
|
|
+ });
|
|
|
+ }
|
|
|
} else {
|
|
|
continue;
|
|
|
}
|
|
@@ -165,18 +177,30 @@ public class TaskMarkResultStandardExportTemplete implements TaskExportTemplete
|
|
|
style.setVerticalAlignment(VerticalAlignment.CENTER); //垂直居中
|
|
|
Row row = sheet.createRow(0);
|
|
|
Field[] fields = MarkResultStandardExportDto.class.getDeclaredFields();
|
|
|
+ int num = 0;
|
|
|
//绘制表头
|
|
|
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)) {
|
|
|
+ Annotation annotation = field.getAnnotation(ExcelNote.class);
|
|
|
+ if (Objects.nonNull(annotation)) {
|
|
|
Cell cell = row.createCell(i);
|
|
|
cell.setCellValue(field.getAnnotation(ExcelNote.class).value());
|
|
|
cell.setCellStyle(style);
|
|
|
-// sheet.setColumnWidth(i, 15 * 256);
|
|
|
+ num = i;
|
|
|
}
|
|
|
}
|
|
|
+ num++;
|
|
|
+ Map<String, Integer> position = new HashMap<>();
|
|
|
+ //动态表头
|
|
|
+ for (ExcelDto excelDto : dynamicExcelHead) {
|
|
|
+ Cell cell = row.createCell(num);
|
|
|
+ cell.setCellValue(excelDto.getTitle());
|
|
|
+ cell.setCellStyle(style);
|
|
|
+ sheet.setColumnWidth(num, 15 * 256);
|
|
|
+ position.put(excelDto.getTitle(), num);
|
|
|
+ num++;
|
|
|
+ }
|
|
|
int cellIndex = 0, max = SystemConstant.MAX_EXPORT_SIZE, size = markResultStandardExportDtoList.size();
|
|
|
if (max >= size) {
|
|
|
max = size;
|
|
@@ -193,8 +217,19 @@ public class TaskMarkResultStandardExportTemplete implements TaskExportTemplete
|
|
|
field.setAccessible(true);
|
|
|
Annotation annotation = field.getAnnotation(ExcelNotExport.class);
|
|
|
if (Objects.isNull(annotation)) {
|
|
|
- taskExportCommon.createExcelCell(sxssfRow, cellIndex, field.get(markResultStandardExportDto), style);
|
|
|
- cellIndex++;
|
|
|
+ Annotation dynamicExport = field.getAnnotation(ExcelDynamicExport.class);
|
|
|
+ if (Objects.nonNull(dynamicExport)) {
|
|
|
+ Map<Long, List<ExcelDto>> answerExcetDto = markResultStandardExportDto.getAnswerExcetDto();
|
|
|
+ if (Objects.nonNull(answerExcetDto)) {
|
|
|
+ List<ExcelDto> excelDtoList = answerExcetDto.get(markResultStandardExportDto.getExamStudentId());
|
|
|
+ excelDtoList.forEach(s -> {
|
|
|
+ taskExportCommon.createExcelCell(sxssfRow, position.get(s.getTitle()), s.getContent(), style);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ taskExportCommon.createExcelCell(sxssfRow, cellIndex, field.get(markResultStandardExportDto), style);
|
|
|
+ cellIndex++;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|