Przeglądaj źródła

评价结果调整

dzx 4 miesięcy temu
rodzic
commit
6f33c4c7ee

+ 53 - 22
src/main/java/com/xjrsoft/module/evaluate/service/impl/EvaluateResultServiceImpl.java

@@ -38,7 +38,10 @@ import com.xjrsoft.module.evaluate.vo.ResultViewingPageVo;
 import com.xjrsoft.module.teacher.entity.XjrUser;
 import lombok.AllArgsConstructor;
 import me.zhyd.oauth.log.Log;
+import org.apache.poi.ss.usermodel.BorderStyle;
 import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.CellStyle;
+import org.apache.poi.ss.usermodel.Font;
 import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.ss.usermodel.Workbook;
@@ -55,6 +58,7 @@ import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.stream.Collectors;
 
 /**
@@ -298,17 +302,11 @@ public class EvaluateResultServiceImpl extends MPJBaseServiceImpl<EvaluateResult
 
 //        int startRow = 1;
 //        List<Map<Integer, Integer>> mergeList = new ArrayList<>();
-            List<Long> objectList = list.stream().map(ResultViewingPageVo::getObjectId).collect(Collectors.toList());
+            Set<Long> objectList = list.stream().map(ResultViewingPageVo::getObjectId).collect(Collectors.toSet());
             Map<Long, Integer> sortCodeMap = new HashMap<>();
 
             int sortCode = 1;
             for (Long objectId : objectList) {
-//            Map<Integer, Integer> rowColumn = new HashMap<>();
-//            rowColumn.put(startRow, startRow + itemList.size() - 1);
-//            mergeList.add(rowColumn);
-//
-//            startRow = startRow + itemList.size();
-
                 sortCodeMap.put(objectId, sortCode);
                 sortCode ++;
             }
@@ -316,18 +314,25 @@ public class EvaluateResultServiceImpl extends MPJBaseServiceImpl<EvaluateResult
             Workbook workbook = new XSSFWorkbook();
             Sheet sheet = workbook.createSheet("数据");
 
+            Font font = workbook.createFont();
+            font.setFontName("宋体");
+            font.setFontHeightInPoints((short)12);
+
+            CellStyle contentCellStyle = workbook.createCellStyle();
+            contentCellStyle.setFont(font);
+            contentCellStyle.setWrapText(true);
+            contentCellStyle.setBorderTop(BorderStyle.THIN);
+            contentCellStyle.setBorderBottom(BorderStyle.THIN);
+            contentCellStyle.setBorderLeft(BorderStyle.THIN);
+            contentCellStyle.setBorderRight(BorderStyle.THIN);
+
             Row headerRow = sheet.createRow(0);
             String[] headers = {"序号", "被评人", "应打分人数", "实际打分人数", "题目", "得分", "标题", "得分", "综合得分"};
             for (int i = 0; i < headers.length; i++) {
                 Cell cell = headerRow.createCell(i);
                 cell.setCellValue(headers[i]);
+                cell.setCellStyle(contentCellStyle);
             }
-
-            // 自动调整列宽
-            for (int i = 0; i < headers.length; i++) {
-                sheet.autoSizeColumn(i);
-            }
-
             // 填充数据并记录合并的行
             int rowCount = 1;
             Map<Long, Integer> classStartRows = new HashMap<>();
@@ -338,15 +343,41 @@ public class EvaluateResultServiceImpl extends MPJBaseServiceImpl<EvaluateResult
 
             for (ResultViewingPageVo el : list) {
                 Row row = sheet.createRow(rowCount ++);
-                row.createCell(0).setCellValue(sortCodeMap.get(el.getObjectId()));
-                row.createCell(1).setCellValue(el.getObjectIdCN());
-                row.createCell(2).setCellValue(el.getPlanExecuterNum());
-                row.createCell(3).setCellValue(el.getActualExecuterNum());
-                row.createCell(4).setCellValue(el.getProblem());
-                row.createCell(5).setCellValue(el.getSumScore());
-                row.createCell(6).setCellValue(el.getTopic());
-                row.createCell(7).setCellValue(el.getTopicScore());
-                row.createCell(8).setCellValue(el.getSynthesisScore());
+                Cell cell = row.createCell(0);
+                cell.setCellValue(sortCodeMap.get(el.getObjectId()));
+                cell.setCellStyle(contentCellStyle);
+
+                cell = row.createCell(1);
+                cell.setCellValue(el.getObjectIdCN());
+                cell.setCellStyle(contentCellStyle);
+
+                cell = row.createCell(2);
+                cell.setCellValue(el.getPlanExecuterNum());
+                cell.setCellStyle(contentCellStyle);
+
+                cell = row.createCell(3);
+                cell.setCellValue(el.getActualExecuterNum());
+                cell.setCellStyle(contentCellStyle);
+
+                cell = row.createCell(4);
+                cell.setCellValue(el.getProblem());
+                cell.setCellStyle(contentCellStyle);
+
+                cell = row.createCell(5);
+                cell.setCellValue(el.getSumScore());
+                cell.setCellStyle(contentCellStyle);
+
+                cell = row.createCell(6);
+                cell.setCellValue(el.getTopic());
+                cell.setCellStyle(contentCellStyle);
+
+                cell = row.createCell(7);
+                cell.setCellValue(el.getTopicScore());
+                cell.setCellStyle(contentCellStyle);
+
+                cell = row.createCell(8);
+                cell.setCellValue(el.getSynthesisScore());
+                cell.setCellStyle(contentCellStyle);
 
                 Long objectId = el.getObjectId();
                 if (!classStartRows.containsKey(objectId)) {