浏览代码

学生成绩录入

dzx 11 月之前
父节点
当前提交
d8b0672754

+ 9 - 0
src/main/java/com/xjrsoft/module/xycxedu/controller/ExamSubjectScoreController.java

@@ -67,6 +67,15 @@ public class ExamSubjectScoreController {
         return RT.ok(result);
     }
 
+    @GetMapping(value = "/enter-page")
+    @ApiOperation(value="根据录入id考试成绩查询(分页)")
+    @SaCheckPermission("examsubjectscore:enter-page")
+    @XjrLog("根据录入id查询考试成绩")
+    public RT<PageOutput<ExamSubjectScoreEnterImportVo>> enterPage(@Valid ExamSubjectScoreEnterDto dto){
+        PageOutput<ExamSubjectScoreEnterImportVo> result = scoreService.getEnterScoreStudentPage(new Page<>(dto.getLimit(), dto.getSize()), dto);
+        return RT.ok(result);
+    }
+
 
     @PutMapping
     @ApiOperation(value = "修改学生成绩")

+ 1 - 1
src/main/java/com/xjrsoft/module/xycxedu/dto/ExamSubjectScoreEnterDto.java

@@ -7,7 +7,7 @@ import lombok.EqualsAndHashCode;
 
 @Data
 @EqualsAndHashCode(callSuper = false)
-public class ExamSubjectScoreEnterDto{
+public class ExamSubjectScoreEnterDto extends PageInput{
     private static final long serialVersionUID = 1L;
     /**
      * 用户ID(xjr_user)

+ 52 - 0
src/main/java/com/xjrsoft/module/xycxedu/dto/ExamSubjectScoreEnterImportDto.java

@@ -0,0 +1,52 @@
+package com.xjrsoft.module.xycxedu.dto;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.xjrsoft.common.annotation.Required;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+
+/**
+* @title: 成绩录入
+* @Author dzx
+* @Date: 2025-01-06
+* @Version 1.0
+*/
+@Data
+public class ExamSubjectScoreEnterImportDto {
+
+
+    @ExcelProperty("班级")
+    @ApiModelProperty("班级")
+    @Required
+    private String className;
+
+    @ExcelProperty("学生姓名")
+    @ApiModelProperty("学生姓名")
+    @Required
+    private String studentName;
+
+    @ExcelProperty("学生身份证")
+    @ApiModelProperty("学生身份证")
+    @Required
+    private String credentialNumber;
+
+    @ExcelProperty("科目")
+    @ApiModelProperty("科目")
+    @Required
+    private String courseSubjectName;
+
+    @ExcelProperty("成绩")
+    @ApiModelProperty("成绩")
+    @Required
+    private String score;
+
+    @ExcelProperty("班级排名")
+    @ApiModelProperty("班级排名")
+    private Integer classRanking;
+
+    @ExcelProperty("年级排名")
+    @ApiModelProperty("年级排名")
+    private Integer gradeRanking;
+
+}

+ 3 - 0
src/main/java/com/xjrsoft/module/xycxedu/service/IExamSubjectScoreService.java

@@ -2,6 +2,7 @@ package com.xjrsoft.module.xycxedu.service;
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.github.yulichang.base.MPJBaseService;
+import com.xjrsoft.common.page.PageOutput;
 import com.xjrsoft.module.xycxedu.dto.ExamStatisticsPageDto;
 import com.xjrsoft.module.xycxedu.dto.ExamSubjectScoreDto;
 import com.xjrsoft.module.xycxedu.dto.ExamSubjectScoreEnterDto;
@@ -29,4 +30,6 @@ public interface IExamSubjectScoreService extends MPJBaseService<ExamSubjectScor
 
 
     List<ExamSubjectScoreEnterImportVo> getEnterScoreStudentList(ExamSubjectScoreEnterDto dto);
+
+    PageOutput<ExamSubjectScoreEnterImportVo> getEnterScoreStudentPage(Page<ExamSubjectScoreEnterImportVo> page, ExamSubjectScoreEnterDto dto);
 }

+ 6 - 6
src/main/java/com/xjrsoft/module/xycxedu/service/impl/ExamSubjectScoreEnterServiceImpl.java

@@ -20,6 +20,7 @@ import com.xjrsoft.module.student.entity.BaseStudentSchoolRoll;
 import com.xjrsoft.module.veb.util.ImportExcelUtil;
 import com.xjrsoft.module.xycxedu.dto.AddExamSubjectScoreEnterDto;
 import com.xjrsoft.module.xycxedu.dto.ExamSubjectScoreEnterDto;
+import com.xjrsoft.module.xycxedu.dto.ExamSubjectScoreEnterImportDto;
 import com.xjrsoft.module.xycxedu.dto.ExamSubjectScoreEnterPageDto;
 import com.xjrsoft.module.xycxedu.entity.ExamSubjectScore;
 import com.xjrsoft.module.xycxedu.entity.ExamSubjectScoreEnter;
@@ -32,6 +33,7 @@ import com.xjrsoft.module.xycxedu.vo.ExamSubjectScoreEnterVo;
 import lombok.AllArgsConstructor;
 import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.ss.usermodel.CellStyle;
+import org.apache.poi.ss.usermodel.FillPatternType;
 import org.apache.poi.ss.usermodel.Font;
 import org.apache.poi.ss.usermodel.HorizontalAlignment;
 import org.apache.poi.ss.usermodel.IndexedColors;
@@ -72,14 +74,14 @@ public class ExamSubjectScoreEnterServiceImpl extends MPJBaseServiceImpl<ExamSub
     @Transactional(rollbackFor = Exception.class)
     public Boolean importData(Long id, MultipartFile file) throws IOException {
         ExamSubjectScoreEnter enter = this.getById(id);
-        List<ExamSubjectScoreEnterImportVo> dataList = EasyExcel.read(file.getInputStream()).headRowNumber(2).head(ExamSubjectScoreEnterImportVo.class).sheet().doReadSync();
+        List<ExamSubjectScoreEnterImportDto> dataList = EasyExcel.read(file.getInputStream()).headRowNumber(2).head(ExamSubjectScoreEnterImportDto.class).sheet().doReadSync();
         List<BaseCourseSubject> classList = courseSubjectService.list(
                 new QueryWrapper<BaseCourseSubject>().lambda()
                         .eq(BaseCourseSubject::getDeleteMark, DeleteMark.NODELETE.getCode())
         );
         Map<Long, String> courseSubjectMaps = classList.stream().collect(Collectors.toMap(BaseCourseSubject::getId, BaseCourseSubject::getName));
 
-        List<String> credentialNumbers = dataList.stream().filter(x -> StrUtil.isNotEmpty(x.getCredentialNumber())).map(ExamSubjectScoreEnterImportVo::getCredentialNumber).collect(Collectors.toList());
+        List<String> credentialNumbers = dataList.stream().filter(x -> StrUtil.isNotEmpty(x.getCredentialNumber())).map(ExamSubjectScoreEnterImportDto::getCredentialNumber).collect(Collectors.toList());
         if(credentialNumbers.isEmpty()){
             return true;
         }
@@ -99,7 +101,7 @@ public class ExamSubjectScoreEnterServiceImpl extends MPJBaseServiceImpl<ExamSub
         Map<Long, ExamSubjectScore> listMap = scoreList.stream().collect(Collectors.toMap(ExamSubjectScore::getUserId, x -> x));
 
         List<ExamSubjectScore> updateList = new ArrayList<>();
-        for (ExamSubjectScoreEnterImportVo importVo : dataList) {
+        for (ExamSubjectScoreEnterImportDto importVo : dataList) {
             Long userId = userMaps.get(importVo.getCredentialNumber());
             ExamSubjectScore examSubjectScores = listMap.get(userId);
             examSubjectScores.setCourseSubjectId(enter.getCourseSubjectId());
@@ -209,9 +211,6 @@ public class ExamSubjectScoreEnterServiceImpl extends MPJBaseServiceImpl<ExamSub
         for (ArrayList<String> rowData : dataList) {
             Row dataRow = sheet.createRow(dataRowNumber);
             for (int i = 0; i < rowData.size(); i ++){
-                if(dataRowNumber == 3){
-                    sheet.autoSizeColumn(i);
-                }
                 String content = rowData.get(i);
                 Font font = workbook.createFont();
                 font.setBold(false);// 设置为粗体
@@ -304,6 +303,7 @@ public class ExamSubjectScoreEnterServiceImpl extends MPJBaseServiceImpl<ExamSub
         cellStyle2.setVerticalAlignment(VerticalAlignment.CENTER);
         cellStyle2.setAlignment(HorizontalAlignment.CENTER);
         cellStyle2.setFillForegroundColor(IndexedColors.YELLOW.getIndex());
+        cellStyle2.setFillPattern(FillPatternType.SOLID_FOREGROUND);//设置填充模式
 
         Row row1 = sheet.createRow(rowNumber);
         List<ImportConfig> importConfigs = ImportExcelUtil.getAllFieldCN(clazz);

+ 28 - 0
src/main/java/com/xjrsoft/module/xycxedu/service/impl/ExamSubjectScoreServiceImpl.java

@@ -1,9 +1,12 @@
 package com.xjrsoft.module.xycxedu.service.impl;
 
 import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.github.yulichang.base.MPJBaseServiceImpl;
 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.organization.entity.User;
 import com.xjrsoft.module.student.entity.BaseStudentSchoolRoll;
@@ -68,4 +71,29 @@ public class ExamSubjectScoreServiceImpl extends MPJBaseServiceImpl<ExamSubjectS
         );
         return result;
     }
+
+    @Override
+    public PageOutput<ExamSubjectScoreEnterImportVo> getEnterScoreStudentPage(Page<ExamSubjectScoreEnterImportVo> page, ExamSubjectScoreEnterDto dto) {
+        IPage<ExamSubjectScoreEnterImportVo> voIPage = this.selectJoinListPage(page, ExamSubjectScoreEnterImportVo.class,
+                new MPJLambdaWrapper<ExamSubjectScore>()
+                        .select(ExamSubjectScore::getId)
+                        .selectAs(BaseClass::getName, ExamSubjectScoreEnterImportVo::getClassName)
+                        .selectAs(User::getName, ExamSubjectScoreEnterImportVo::getStudentName)
+                        .selectAs(User::getCredentialNumber, ExamSubjectScoreEnterImportVo::getCredentialNumber)
+                        .select(ExamSubjectScore::getScore)
+                        .select(ExamSubjectScore::getClassRanking)
+                        .select(ExamSubjectScore::getGradeRanking)
+                        .innerJoin(User.class, User::getId, ExamSubjectScore::getUserId)
+                        .innerJoin(BaseStudentSchoolRoll.class, BaseStudentSchoolRoll::getUserId, ExamSubjectScore::getUserId)
+                        .innerJoin(BaseClass.class, BaseClass::getId, BaseStudentSchoolRoll::getClassId)
+                        .eq(dto.getClassId() != null, BaseClass::getId, dto.getClassId())
+                        .like(StrUtil.isNotEmpty(dto.getStudentName()), User::getName, dto.getStudentName())
+                        .like(StrUtil.isNotEmpty(dto.getCredentialNumber()), User::getCredentialNumber, dto.getCredentialNumber())
+                        .isNotNull(dto.getIsEnter() != null && dto.getIsEnter() == 1, ExamSubjectScore::getScore)
+                        .isNull(dto.getIsEnter() != null && dto.getIsEnter() == 1, ExamSubjectScore::getScore)
+                        .eq(dto.getExamSubjectScoreEnterId() != null, ExamSubjectScore::getExamSubjectScoreEnterId, dto.getExamSubjectScoreEnterId())
+        );
+        PageOutput<ExamSubjectScoreEnterImportVo> pageOutput = ConventPage.getPageOutput(page, ExamSubjectScoreEnterImportVo.class);
+        return pageOutput;
+    }
 }