diff --git a/src/main/java/com/sztzjy/financial_bigdata/controller/tea/TeaGradeManageController.java b/src/main/java/com/sztzjy/financial_bigdata/controller/tea/TeaGradeManageController.java index 9d508a3..82e1be3 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/controller/tea/TeaGradeManageController.java +++ b/src/main/java/com/sztzjy/financial_bigdata/controller/tea/TeaGradeManageController.java @@ -454,28 +454,33 @@ public class TeaGradeManageController { iTeaGradeManageService.exportTrainingInfo(response, schoolId, keyWord, classId, systemOwner); } - @AnonymousAccess - @PostMapping("/getTrainingDetailsInfo") - @ApiOperation("练习模式--详情页面展示") - public ResultEntity> getTrainingDetailsInfo(@RequestParam String userId) { - try { - return new ResultEntity<>(iTeaGradeManageService.getTrainingDetailsInfo(userId)); - } catch (IOException e) { - return new ResultEntity<>(HttpStatus.BAD_REQUEST, "资源中心异常"); - } - } +// @AnonymousAccess +// @PostMapping("/getTrainingDetailsInfo") +// @ApiOperation("练习模式--详情页面展示") +// public ResultEntity> getTrainingDetailsInfo(@RequestParam String userId) { +// try { +// return new ResultEntity<>(iTeaGradeManageService.getTrainingDetailsInfo(userId)); +// } catch (IOException e) { +// return new ResultEntity<>(HttpStatus.BAD_REQUEST, "资源中心异常"); +// } +// } @AnonymousAccess @GetMapping("/exportTrainingDetailsInfo") @ApiOperation("练习模式--详情页面导出") - public void exportTrainingDetailsInfo(HttpServletResponse response, @RequestParam String userId) { + public void exportTrainingDetailsInfo(HttpServletResponse response, + @RequestParam String userId, + @RequestParam String schoolId, + @RequestParam String systemOwner) { try { - iTeaGradeManageService.exportTrainingDetailsInfo(response, userId); + iTeaGradeManageService.exportTrainingDetailsInfo(response, userId,schoolId,systemOwner); } catch (IOException e) { e.printStackTrace(); } + } + @AnonymousAccess @PostMapping("/getReportBySchoolID") @ApiOperation("练习模式--实训报告展示") @@ -720,7 +725,6 @@ public class TeaGradeManageController { } - } diff --git a/src/main/java/com/sztzjy/financial_bigdata/entity/stu_dto/StuTrainingDto.java b/src/main/java/com/sztzjy/financial_bigdata/entity/stu_dto/StuTrainingDto.java index ac0316c..88ea4d9 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/entity/stu_dto/StuTrainingDto.java +++ b/src/main/java/com/sztzjy/financial_bigdata/entity/stu_dto/StuTrainingDto.java @@ -72,4 +72,7 @@ public class StuTrainingDto { @ApiModelProperty("模板名称") private String taskModule; + + @ApiModelProperty("模块得分") + private BigDecimal moduleScore; } diff --git a/src/main/java/com/sztzjy/financial_bigdata/entity/tea_dto/StuTheoryRecordDto.java b/src/main/java/com/sztzjy/financial_bigdata/entity/tea_dto/StuTheoryRecordDto.java index 342f43b..175dc26 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/entity/tea_dto/StuTheoryRecordDto.java +++ b/src/main/java/com/sztzjy/financial_bigdata/entity/tea_dto/StuTheoryRecordDto.java @@ -1,15 +1,52 @@ package com.sztzjy.financial_bigdata.entity.tea_dto; import com.sztzjy.financial_bigdata.entity.StuTheoryRecord; +import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; +import java.math.BigDecimal; + /** * @Author xcj * @Date 2024/4/10 */ -@Data @NoArgsConstructor -public class StuTheoryRecordDto extends StuTheoryRecord { +@Data +public class StuTheoryRecordDto { private int rank; + + @ApiModelProperty("用户ID") + private String userId; + + @ApiModelProperty("学校ID") + private String schoolId; + + @ApiModelProperty("班级ID") + private String classId; + + @ApiModelProperty("姓名") + private String name; + + @ApiModelProperty("学号") + private String studentId; + + @ApiModelProperty("考试次数") + private Integer examCount; + + @ApiModelProperty("考试最高分") + private BigDecimal highestScore; + + @ApiModelProperty("考试最低分") + private BigDecimal lowestScore; + + @ApiModelProperty("考试合计时长") + private Integer totalDuration; + + @ApiModelProperty("平均分") + private BigDecimal averageScore; + + @ApiModelProperty("归属系统") + private String systemOwner; } diff --git a/src/main/java/com/sztzjy/financial_bigdata/service/stu/impl/StuScoreServiceImpl.java b/src/main/java/com/sztzjy/financial_bigdata/service/stu/impl/StuScoreServiceImpl.java index c20dad9..a8732d4 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/service/stu/impl/StuScoreServiceImpl.java +++ b/src/main/java/com/sztzjy/financial_bigdata/service/stu/impl/StuScoreServiceImpl.java @@ -140,9 +140,31 @@ public class StuScoreServiceImpl implements StuScoreService { // 设置报告相关数据 setReportData(stuTrainingDto, stuTrainingWithBLOBs.getReportId()); + //计算模块总得分 + setTotalScore(stuTrainingDto); return stuTrainingDto; } + private void setTotalScore(StuTrainingDto stuTrainingDto) { + BigDecimal totalScore = BigDecimal.ZERO; + if (stuTrainingDto.getKnowledgeSummaryScore() != null) { + totalScore = totalScore.add(stuTrainingDto.getKnowledgeSummaryScore()); + } + if (stuTrainingDto.getResourceLearningScore() != null) { + totalScore = totalScore.add(stuTrainingDto.getResourceLearningScore()); + } + if (stuTrainingDto.getLearningEvalScore() != null) { + totalScore = totalScore.add(stuTrainingDto.getLearningEvalScore()); + } + if (stuTrainingDto.getCaseStuScore() != null) { + totalScore = totalScore.add(stuTrainingDto.getCaseStuScore()); + } + if (stuTrainingDto.getReportScore() != null) { + totalScore = totalScore.add(stuTrainingDto.getReportScore()); + } + stuTrainingDto.setModuleScore(totalScore); + } + private void setDefaultWeights(StuTrainingDto stuTrainingDto) { stuTrainingDto.setKnowledgeSummaryDefaultRule(BigDecimal.valueOf(60)); stuTrainingDto.setResourceLearningDefaultRule(BigDecimal.valueOf(60)); diff --git a/src/main/java/com/sztzjy/financial_bigdata/service/tea/ITeaGradeManageService.java b/src/main/java/com/sztzjy/financial_bigdata/service/tea/ITeaGradeManageService.java index 73f3e5b..3813b6f 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/service/tea/ITeaGradeManageService.java +++ b/src/main/java/com/sztzjy/financial_bigdata/service/tea/ITeaGradeManageService.java @@ -3,11 +3,10 @@ package com.sztzjy.financial_bigdata.service.tea; import com.github.pagehelper.PageInfo; import com.sztzjy.financial_bigdata.entity.StuTheoryRecord; import com.sztzjy.financial_bigdata.entity.SysWeight; +import com.sztzjy.financial_bigdata.entity.stu_dto.StuTrainingDto; import com.sztzjy.financial_bigdata.entity.stu_dto.StuUserDto; import com.sztzjy.financial_bigdata.entity.tea_dto.TeaExaminationDetailsDto; -import com.sztzjy.financial_bigdata.entity.tea_dto.TeaTrainingDto; import com.sztzjy.financial_bigdata.entity.tea_dto.TeaTrainingInfoDTO; -import com.sztzjy.financial_bigdata.util.ResultEntity; import javax.servlet.http.HttpServletResponse; import java.io.IOException; @@ -18,21 +17,21 @@ import java.util.List; * @Date 2024/3/19 */ public interface ITeaGradeManageService { - PageInfo getTrainingInfo(Integer index, Integer size, String schoolId, String keyWord, String classId,String systemOwner); + PageInfo getTrainingInfo(Integer index, Integer size, String schoolId, String keyWord, String classId, String systemOwner); - void exportTrainingInfo(HttpServletResponse response, String schoolId, String keyWord, String classId,String systemOwner); + void exportTrainingInfo(HttpServletResponse response, String schoolId, String keyWord, String classId, String systemOwner); TeaExaminationDetailsDto getCountChart(String examManageId, String classId); - List getTrainingDetailsInfo(String userId) throws IOException; + List getTrainingDetailsInfo(String userId, String schoolId, String systemOwner) throws IOException; - void exportTrainingDetailsInfo(HttpServletResponse response, String userId) throws IOException; + void exportTrainingDetailsInfo(HttpServletResponse response, String userId, String schoolId, String systemOwner) throws IOException; PageInfo getReportCorrect(String schoolId, Integer index, Integer size, String module, String classId, String keyWord); - PageInfo getTheoryInfo(Integer index, Integer size, String schoolId, String classId, String keyWord,String systemOwner); + PageInfo getTheoryInfo(Integer index, Integer size, String schoolId, String classId, String keyWord, String systemOwner); - void exportTheoryExamInfo(HttpServletResponse response,String classId, String schoolId); + void exportTheoryExamInfo(HttpServletResponse response, String classId, String schoolId); SysWeight getSysWeightResultEntity(String courseId, String schoolId, String systemOwner); } diff --git a/src/main/java/com/sztzjy/financial_bigdata/service/tea/impl/TeaGradeManageServiceImpl.java b/src/main/java/com/sztzjy/financial_bigdata/service/tea/impl/TeaGradeManageServiceImpl.java index eb068e1..7e27bc7 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/service/tea/impl/TeaGradeManageServiceImpl.java +++ b/src/main/java/com/sztzjy/financial_bigdata/service/tea/impl/TeaGradeManageServiceImpl.java @@ -1,19 +1,24 @@ package com.sztzjy.financial_bigdata.service.tea.impl; +import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.util.IdUtil; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.sztzjy.financial_bigdata.entity.*; import com.sztzjy.financial_bigdata.entity.resource_entity.SysThreeCatalog; +import com.sztzjy.financial_bigdata.entity.stu_dto.StuTrainingDto; import com.sztzjy.financial_bigdata.entity.stu_dto.StuUserDto; -import com.sztzjy.financial_bigdata.entity.tea_dto.*; +import com.sztzjy.financial_bigdata.entity.tea_dto.StuTheoryRecordDto; +import com.sztzjy.financial_bigdata.entity.tea_dto.TeaExamAndUserDto; +import com.sztzjy.financial_bigdata.entity.tea_dto.TeaExaminationDetailsDto; +import com.sztzjy.financial_bigdata.entity.tea_dto.TeaTrainingInfoDTO; import com.sztzjy.financial_bigdata.mapper.*; import com.sztzjy.financial_bigdata.resourceCenterAPI.CourseAPI; +import com.sztzjy.financial_bigdata.service.stu.StuScoreService; import com.sztzjy.financial_bigdata.service.tea.ITeaGradeManageService; import com.sztzjy.financial_bigdata.util.PageUtil; import com.sztzjy.financial_bigdata.util.excel.FilePortUtil; import org.apache.commons.lang3.StringUtils; -import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -48,19 +53,25 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService { private StuTheoryRecordMapper stuTheoryRecordMapper; @Autowired private StuTrainingMapper stuTrainingMapper; - + @Autowired + private StuScoreService stuScoreService; @Override public PageInfo getTrainingInfo(Integer index, Integer size, String schoolId, String keyWord, String classId, String systemOwner) { + List list = getTrainingInfoDTOS(schoolId, keyWord, classId, systemOwner); + return PageUtil.pageHelper(list, index, size); + } + + private List getTrainingInfoDTOS(String schoolId, String keyWord, String classId, String systemOwner) { List list = getTeaTrainingInfoDTOS(schoolId, keyWord, classId, systemOwner); - assert !list.isEmpty(); + assert !Objects.requireNonNull(list).isEmpty(); list.sort(new TotalScoreComparator()); int i = 0; for (TeaTrainingInfoDTO teaTrainingInfoDTO : list) { i++; teaTrainingInfoDTO.setRank(i); } - return PageUtil.pageHelper(list, index, size); + return list; } @@ -72,7 +83,8 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService { */ @Override public void exportTrainingInfo(HttpServletResponse response, String schoolId, String keyWord, String classId, String systemOwner) { - List list = getTeaTrainingInfoDTOS(schoolId, keyWord, classId, systemOwner); + List list = getTrainingInfoDTOS(schoolId, keyWord, classId, systemOwner); + //导出的表名 String title = IdUtil.simpleUUID(); //表中第一行表头字段 @@ -168,29 +180,58 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService { } +// @Override +// public List getTrainingDetailsInfo(String userId) throws IOException { +// StuTrainingExample trainingExample = new StuTrainingExample(); +// trainingExample.createCriteria().andUserIdEqualTo(userId); +// List stuTrainingWithBLOBs = trainingMapper.selectByExampleWithBLOBs(trainingExample); +// List list = new ArrayList<>(); +// for (StuTrainingWithBLOBs stuTrainingWithBLOB : stuTrainingWithBLOBs) { +// BigDecimal moduleScore = getModuleScore(stuTrainingWithBLOB); +// SysThreeCatalog sysCourseChapter = CourseAPI.selectChapterByChapterId(stuTrainingWithBLOB.getChapterId()); +// TeaTrainingDto newData = new TeaTrainingDto(); +// BeanUtils.copyProperties(stuTrainingWithBLOB, newData); +// if (sysCourseChapter != null) { +// newData.setTaskModule(sysCourseChapter.getThreeName()); +// } +// if (StringUtils.isNotBlank(stuTrainingWithBLOB.getReportId())) { +// String reportId = stuTrainingWithBLOB.getReportId(); +// TrainingReport trainingReport = trainingReportMapper.selectByPrimaryKey(reportId); +// newData.setReportScore(trainingReport.getTeacherScore()); +// } +// newData.setModuleScore(moduleScore); +// list.add(newData); +// } +// return list; +// } + + @Override - public List getTrainingDetailsInfo(String userId) throws IOException { - StuTrainingExample trainingExample = new StuTrainingExample(); - trainingExample.createCriteria().andUserIdEqualTo(userId); - List stuTrainingWithBLOBs = trainingMapper.selectByExampleWithBLOBs(trainingExample); - List list = new ArrayList<>(); - for (StuTrainingWithBLOBs stuTrainingWithBLOB : stuTrainingWithBLOBs) { - BigDecimal moduleScore = getModuleScore(stuTrainingWithBLOB); - SysThreeCatalog sysCourseChapter = CourseAPI.selectChapterByChapterId(stuTrainingWithBLOB.getChapterId()); - TeaTrainingDto newData = new TeaTrainingDto(); - BeanUtils.copyProperties(stuTrainingWithBLOB, newData); - if (sysCourseChapter != null) { - newData.setTaskModule(sysCourseChapter.getThreeName()); - } - if (StringUtils.isNotBlank(stuTrainingWithBLOB.getReportId())) { - String reportId = stuTrainingWithBLOB.getReportId(); - TrainingReport trainingReport = trainingReportMapper.selectByPrimaryKey(reportId); - newData.setReportScore(trainingReport.getTeacherScore()); + public List getTrainingDetailsInfo(String userId, String schoolId, String systemOwner) { + List list = new ArrayList<>(); + + StuTrainingExample stuTrainingExample = new StuTrainingExample(); + stuTrainingExample.createCriteria().andUserIdEqualTo(userId); + List stuTrainings = stuTrainingMapper.selectByExampleWithBLOBs(stuTrainingExample); + + Map chapterMap = new HashMap<>(); + + try { + for (StuTrainingWithBLOBs stuTraining : stuTrainings) { + String chapterId = stuTraining.getChapterId(); + SysThreeCatalog sysCourseChapter = chapterMap.get(chapterId); + if (sysCourseChapter == null) { + sysCourseChapter = CourseAPI.selectChapterByChapterId(chapterId); + chapterMap.put(chapterId, sysCourseChapter); + } + StuTrainingDto stuTrainingDto = new StuTrainingDto(); + stuTrainingDto.setTaskModule(sysCourseChapter.getThreeName()); + list.add(stuScoreService.getScoreByChapterId(schoolId, systemOwner, stuTraining, stuTrainingDto, sysCourseChapter)); } - newData.setModuleScore(moduleScore); - list.add(newData); + return list; + } catch (Exception e) { + return null; } - return list; } //计算模块得分 @@ -203,15 +244,15 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService { } @Override - public void exportTrainingDetailsInfo(HttpServletResponse response, String userId) throws IOException { - List list = getTrainingDetailsInfo(userId); + public void exportTrainingDetailsInfo(HttpServletResponse response, String userId, String schoolId, String systemOwner) throws IOException { + List list = getTrainingDetailsInfo(userId, schoolId, systemOwner); //导出的表名 String title = IdUtil.simpleUUID(); //表中第一行表头字段 String[] headers = {"任务模块", "模块得分", "知识概要得分", "资源学习得分", "学习测评得分", "实验实训得分", "实验报告得分"}; //具体需要写入excel需要哪些字段,这些字段取自UserReward类,也就是上面的实际数据结果集的泛型 - List listColumn = Arrays.asList("taskModule", "moduleScore", "knowledgeSummaryScore", "resourceLearningScore", "learningEvalScore", "expTrainingScore", "reportScore"); + List listColumn = Arrays.asList("taskModule", "moduleScore", "knowledgeSummaryScore", "resourceLearningScore", "learningEvalScore", "caseStuScore", "reportScore"); try { FilePortUtil.exportExcel(response, title, headers, list, listColumn); } catch (Exception e) { @@ -268,7 +309,12 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService { s.setOrderByClause("average_score ASC"); List list = stuTheoryRecordMapper.selectByExample(s); List dtoList = new ArrayList<>(); - BeanUtils.copyProperties(list, dtoList); +// BeanUtils.copyProperties(list, dtoList); + for (StuTheoryRecord stuTheoryRecord : list) { + StuTheoryRecordDto stuTheoryRecordDto = new StuTheoryRecordDto(); + BeanUtil.copyProperties(stuTheoryRecord, stuTheoryRecordDto); + dtoList.add(stuTheoryRecordDto); + } int i = 0; for (StuTheoryRecordDto stuTheoryRecordDto : dtoList) { stuTheoryRecordDto.setRank(i++); @@ -279,7 +325,7 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService { String[] headers = {"排名", "姓名", "学号", "考试次数", "考试最高分", "考试最低分", "考试合计时长"}; //具体需要写入excel需要哪些字段,这些字段取自UserReward类,也就是上面的实际数据结果集的泛型 - List listColumn = Arrays.asList("rank", "name", "studentId", "examCount", "highestScore", "lowestScore", "averageScore"); + List listColumn = Arrays.asList("rank", "name", "studentId", "examCount", "highestScore", "lowestScore", "totalDuration"); try { FilePortUtil.exportExcel(response, title, headers, dtoList, listColumn); } catch (Exception e) {