Browse Source

班级成绩查看导出

dzx 1 month ago
parent
commit
f0f7127ade

+ 31 - 2
src/main/java/com/xjrsoft/module/xycxedu/service/impl/ExamSubjectScoreServiceImpl.java

@@ -10,6 +10,8 @@ import com.github.yulichang.wrapper.MPJLambdaWrapper;
 import com.xjrsoft.common.page.ConventPage;
 import com.xjrsoft.common.page.PageOutput;
 import com.xjrsoft.module.base.entity.BaseClass;
+import com.xjrsoft.module.base.entity.BaseSemester;
+import com.xjrsoft.module.base.service.IBaseSemesterService;
 import com.xjrsoft.module.organization.entity.User;
 import com.xjrsoft.module.student.dto.BaseStudentUserPageDto;
 import com.xjrsoft.module.student.entity.BaseStudentSchoolRoll;
@@ -19,8 +21,10 @@ import com.xjrsoft.module.xycxedu.dto.ClassStudentScorePageDto;
 import com.xjrsoft.module.xycxedu.dto.ExamStatisticsPageDto;
 import com.xjrsoft.module.xycxedu.dto.ExamSubjectScoreDto;
 import com.xjrsoft.module.xycxedu.dto.ExamSubjectScoreEnterDto;
+import com.xjrsoft.module.xycxedu.entity.ExamPlan;
 import com.xjrsoft.module.xycxedu.entity.ExamSubjectScore;
 import com.xjrsoft.module.xycxedu.mapper.ExamSubjectScoreMappper;
+import com.xjrsoft.module.xycxedu.service.IExamPlanService;
 import com.xjrsoft.module.xycxedu.service.IExamSubjectScoreService;
 import com.xjrsoft.module.xycxedu.vo.ClassStudentScorePageVo;
 import com.xjrsoft.module.xycxedu.vo.ClassStudentScoreTitleVo;
@@ -59,6 +63,8 @@ import java.util.stream.Collectors;
 public class ExamSubjectScoreServiceImpl extends MPJBaseServiceImpl<ExamSubjectScoreMappper, ExamSubjectScore> implements IExamSubjectScoreService {
 
     private final IStudentManagerService studentManagerService;
+    private final IBaseSemesterService semesterService;
+    private final IExamPlanService examPlanService;
 
     @Override
     public Long getUserIdByIdNumber(String idNumber) {
@@ -187,6 +193,8 @@ public class ExamSubjectScoreServiceImpl extends MPJBaseServiceImpl<ExamSubjectS
         String sheetName = "数据";
         Sheet sheet = workbook.createSheet(sheetName);
 
+        createFirstTitle(workbook, sheet, semesterService.getById(dto.getSemesterId()), examPlanService.getById(dto.getExamPlanId()));
+
         createTitle(workbook, sheet, titleList);
 
         //查询数据
@@ -257,6 +265,27 @@ public class ExamSubjectScoreServiceImpl extends MPJBaseServiceImpl<ExamSubjectS
         return bot.toByteArray();
     }
 
+    void createFirstTitle(Workbook workbook, Sheet sheet, BaseSemester semester, ExamPlan examPlan) {
+        int rowNumber = 0;
+        Font font = workbook.createFont();
+        font.setBold(true);// 设置为粗体
+        font.setFontName("宋体");
+        //font.setColor(IndexedColors.RED.getIndex()); // 设置字体颜色为红色
+        font.setFontHeightInPoints((short)14);
+
+        CellStyle cellStyle = workbook.createCellStyle();
+        cellStyle.setFont(font); // 将字体应用到样式
+        cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
+        cellStyle.setAlignment(HorizontalAlignment.CENTER);
+
+        Row row = sheet.createRow(rowNumber);
+
+        int cellNumber = 1;
+        Cell cell = row.createCell(cellNumber);
+        cell.setCellValue(semester.getName() + "-" + examPlan.getName());
+        cell.setCellStyle(cellStyle);
+    }
+
     void createTitle(Workbook workbook, Sheet sheet, List<ClassStudentScoreTitleVo> titleList) {
         int rowNumber = 0;
         Font font = workbook.createFont();
@@ -272,7 +301,7 @@ public class ExamSubjectScoreServiceImpl extends MPJBaseServiceImpl<ExamSubjectS
 
         Row row = sheet.createRow(rowNumber);
 
-        int cellNumber = 0;
+        int cellNumber = 1;
         Cell cell = row.createCell(cellNumber);
         cell.setCellValue("序号");
         cell.setCellStyle(cellStyle);
@@ -332,7 +361,7 @@ public class ExamSubjectScoreServiceImpl extends MPJBaseServiceImpl<ExamSubjectS
         cellStyle.setFont(font); // 将字体应用到样式
         cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
         cellStyle.setAlignment(HorizontalAlignment.CENTER);
-        int rowNumber = 1;
+        int rowNumber = 2;
         for (ArrayList<String> rowData : excelDataList) {
             Row row = sheet.createRow(rowNumber);
             for (int i =0; i < rowData.size(); i ++) {