|
@@ -35,6 +35,7 @@ import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* Created by zhengmin on 2017/1/18.
|
|
@@ -210,7 +211,7 @@ public class ScoreExporter {
|
|
|
* @param workId
|
|
|
* @param subjectMap
|
|
|
*/
|
|
|
- public Sheet drawExcelFixedHeadLevel(int type, Sheet sheet, CellStyle style, Row row, Map<String, Map<String, ExportLevelResultDTO>> subjectMap, Long workId) {
|
|
|
+ public Sheet drawExcelFixedHeadLevel(int type, Sheet sheet, CellStyle style, Row row, Map<String, Map<String, ExportLevelResultDTO>> subjectMap, Long workId, Map<String, String> markSubjectMap) {
|
|
|
//准考证号
|
|
|
Cell cell = row.createCell(0);
|
|
|
cell.setCellValue(EXAM_NUMBER);
|
|
@@ -245,7 +246,7 @@ public class ScoreExporter {
|
|
|
}
|
|
|
int scSumCount = level + size + 5;
|
|
|
Cell cell4 = row.createCell(level);
|
|
|
- cell4.setCellValue(SC_NAME);
|
|
|
+ cell4.setCellValue(markSubjectMap.get(Subject.SC.toString()));
|
|
|
cell4.setCellStyle(style);
|
|
|
if (level != scSumCount) {
|
|
|
CellRangeAddress region5 = new CellRangeAddress(0, 0, (short) level, scSumCount);
|
|
@@ -261,7 +262,7 @@ public class ScoreExporter {
|
|
|
}
|
|
|
int smSumCount = scSumCount + size + 5;//最终列+1,因为从0开始
|
|
|
Cell cell7 = row.createCell(scSumCount);
|
|
|
- cell7.setCellValue(SM_NAME);
|
|
|
+ cell7.setCellValue(markSubjectMap.get(Subject.SM.toString()));
|
|
|
cell7.setCellStyle(style);
|
|
|
if (scSumCount != smSumCount) {
|
|
|
CellRangeAddress region6 = new CellRangeAddress(0, 0, (short) scSumCount, smSumCount);
|
|
@@ -276,7 +277,7 @@ public class ScoreExporter {
|
|
|
}
|
|
|
int sxSumCount = smSumCount + size + 5;//最终列+1,因为从0开始
|
|
|
Cell cell8 = row.createCell(smSumCount);
|
|
|
- cell8.setCellValue(SX_NAME);
|
|
|
+ cell8.setCellValue(markSubjectMap.get(Subject.SX.toString()));
|
|
|
cell8.setCellStyle(style);
|
|
|
if (smSumCount != sxSumCount) {
|
|
|
CellRangeAddress region9 = new CellRangeAddress(0, 0, (short) smSumCount, sxSumCount);
|
|
@@ -318,7 +319,7 @@ public class ScoreExporter {
|
|
|
* @param workId
|
|
|
* @param subjectMap
|
|
|
*/
|
|
|
- public Sheet drawExcelFixedHead(int type, Sheet sheet, CellStyle style, Row row, Map<String, Map<String, ExportLevelResultDTO>> subjectMap, Long workId) {
|
|
|
+ public Sheet drawExcelFixedHead(int type, Sheet sheet, CellStyle style, Row row, Map<String, Map<String, ExportLevelResultDTO>> subjectMap, Long workId, Map<String, String> markSubjectMap) {
|
|
|
//准考证号
|
|
|
Cell cell = row.createCell(0);
|
|
|
cell.setCellValue(EXAM_NUMBER);
|
|
@@ -372,7 +373,7 @@ public class ScoreExporter {
|
|
|
scSumCount = score + size;
|
|
|
}
|
|
|
Cell cell6 = row.createCell(score);
|
|
|
- cell6.setCellValue(SC_NAME);
|
|
|
+ cell6.setCellValue(markSubjectMap.get(Subject.SC.toString()));
|
|
|
cell6.setCellStyle(style);
|
|
|
if (score != scSumCount) {
|
|
|
CellRangeAddress region7 = new CellRangeAddress(0, 0, (short) score, scSumCount);
|
|
@@ -393,7 +394,7 @@ public class ScoreExporter {
|
|
|
smSumCount = scSumCount + size;
|
|
|
}
|
|
|
Cell cell7 = row.createCell(scSumCount);
|
|
|
- cell7.setCellValue(SM_NAME);
|
|
|
+ cell7.setCellValue(markSubjectMap.get(Subject.SM.toString()));
|
|
|
cell7.setCellStyle(style);
|
|
|
if (scSumCount != smSumCount) {
|
|
|
CellRangeAddress region8 = new CellRangeAddress(0, 0, (short) scSumCount, smSumCount);
|
|
@@ -413,7 +414,7 @@ public class ScoreExporter {
|
|
|
sxSumCount = smSumCount + size;
|
|
|
}
|
|
|
Cell cell8 = row.createCell(smSumCount);
|
|
|
- cell8.setCellValue(SX_NAME);
|
|
|
+ cell8.setCellValue(markSubjectMap.get(Subject.SX.toString()));
|
|
|
cell8.setCellStyle(style);
|
|
|
if (smSumCount != sxSumCount) {
|
|
|
CellRangeAddress region9 = new CellRangeAddress(0, 0, (short) smSumCount, sxSumCount);
|
|
@@ -489,8 +490,12 @@ public class ScoreExporter {
|
|
|
style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); //垂直居中
|
|
|
Row row = sheet.createRow(0);
|
|
|
|
|
|
+ // 科目名称
|
|
|
+ List<MarkSubject> markSubjectList = markSubjectRepo.findAllByWorkId(workId);
|
|
|
+ Map<String, String> markSubjectMap = markSubjectList.stream().collect(Collectors.toMap(m->m.getSubject().name(), MarkSubject::getName));
|
|
|
+
|
|
|
//绘制固定表头
|
|
|
- sheet = drawExcelFixedHeadLevel(levelInterval, sheet, style, row, subjectMap, workId);
|
|
|
+ sheet = drawExcelFixedHeadLevel(levelInterval, sheet, style, row, subjectMap, workId, markSubjectMap);
|
|
|
|
|
|
//绘制动态表头
|
|
|
Row dynamicHeadRow = sheet.createRow(1);
|
|
@@ -665,8 +670,12 @@ public class ScoreExporter {
|
|
|
style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); //垂直居中
|
|
|
Row row = sheet.createRow(0);
|
|
|
|
|
|
+ // 科目名称
|
|
|
+ List<MarkSubject> markSubjectList = markSubjectRepo.findAllByWorkId(workId);
|
|
|
+ Map<String, String> markSubjectMap = markSubjectList.stream().collect(Collectors.toMap(m -> m.getSubject().name(), MarkSubject::getName));
|
|
|
+
|
|
|
//绘制固定表头
|
|
|
- sheet = drawExcelFixedHead(scoreInterval, sheet, style, row, subjectMap, workId);
|
|
|
+ sheet = drawExcelFixedHead(scoreInterval, sheet, style, row, subjectMap, workId, markSubjectMap);
|
|
|
|
|
|
//绘制动态表头
|
|
|
Row dynamicHeadRow = sheet.createRow(1);
|