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 7bf3c74..cbf7418 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 @@ -191,30 +191,6 @@ public class TeaGradeManageController { } - // @GetMapping("/exportExam") -// @ApiOperation("考试模式--页面单个考试导出") - public void exportExam() { - //TODO 待写 页面单个考试导出 - - } - - // @AnonymousAccess -// @GetMapping("/test") -// @ApiOperation("测试导出") - protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { - response.setContentType("application/vnd.openxmlformats-officedocument.wordprocessingml.document"); - response.setHeader("Content-Disposition", "attachment; filename=exam_result.docx"); - - XWPFDocument document = new XWPFDocument(); - XWPFParagraph paragraph = document.createParagraph(); - XWPFRun run = paragraph.createRun(); - run.setText("Python程序设计2022-2023学年度第一学期期末考试\n" - + "答题人:沙志梅 学号:21200780 课程:Python程序设计 班级:21金融科技(华强)2 提交时间:2022-12-02 10:42 ip:10.100.66.8 考试得分: 82 分\n" - + "一. 单选题 (共15题,45分)\n" - + "1.赋值语句... (这里是你的题目内容)"); - - document.write(response.getOutputStream()); - } @AnonymousAccess @PostMapping("/getCountChart") @@ -448,21 +424,21 @@ public class TeaGradeManageController { return new ResultEntity>(iTeaGradeManageService.getTrainingInfo(index, size, schoolId, keyWord, classId, systemOwner)); } - @AnonymousAccess - @GetMapping("/exportTrainingInfo") - @ApiOperation("***练习模式--页面导出") - public void exportTrainingInfo(HttpServletResponse response, - @RequestParam String schoolId, - @ApiParam("学号或姓名搜索框") @RequestParam(required = false) String keyWord, - @RequestParam(required = false) String classId, - @RequestParam String systemOwner) { - iTeaGradeManageService.exportTrainingInfo(response, schoolId, keyWord, classId, systemOwner); - } - +// @AnonymousAccess +// @GetMapping("/exportTrainingInfo") +// @ApiOperation("***练习模式--页面导出") +// public void exportTrainingInfo(HttpServletResponse response, +// @RequestParam String schoolId, +// @ApiParam("学号或姓名搜索框") @RequestParam(required = false) String keyWord, +// @RequestParam(required = false) String classId, +// @RequestParam String systemOwner) { +// iTeaGradeManageService.exportTrainingInfo(response, schoolId, keyWord, classId, systemOwner); +// } +// // @AnonymousAccess // @PostMapping("/getTrainingDetailsInfo") // @ApiOperation("练习模式--详情页面展示") -// public ResultEntity> getTrainingDetailsInfo(@RequestParam String userId) { +// public ResultEntity> getTrainingDetailsInfo(@RequestParam String userId) { // try { // return new ResultEntity<>(iTeaGradeManageService.getTrainingDetailsInfo(userId)); // } catch (IOException e) { @@ -677,33 +653,7 @@ public class TeaGradeManageController { return new ResultEntity<>(pageInfo); } -// -// @AnonymousAccess -// @ApiOperation("老师端/练习模式得分详情展示") -// @PostMapping("getScoreInfo") -// public ResultEntity> getScoreInfo(@RequestParam String userId, -// @RequestParam String schoolId, -// @RequestParam String systemOwner) { -// List list = new ArrayList<>(); -// -// StuTrainingExample stuTrainingExample = new StuTrainingExample(); -// stuTrainingExample.createCriteria().andUserIdEqualTo(userId); -// List stuTrainings = stuTrainingMapper.selectByExampleWithBLOBs(stuTrainingExample); -// //根据章节ID拿到课程ID 再去拿权重 -// try { -// for (StuTrainingWithBLOBs stuTraining : stuTrainings) { -// StuTrainingDto stuTrainingDto = new StuTrainingDto(); -// String chapterId = stuTraining.getChapterId(); -// SysThreeCatalog sysCourseChapter = CourseAPI.selectChapterByChapterId(chapterId); -// stuTrainingDto.setTaskModule(sysCourseChapter.getThreeName()); -// stuTrainingDto = stuScoreService.getScoreByChapterId(schoolId, systemOwner, stuTraining, stuTrainingDto, sysCourseChapter); -// list.add(stuTrainingDto); -// } -// } catch (IOException e) { -// return new ResultEntity<>(HttpStatus.BAD_REQUEST, "资源中心根据章节ID查询章节信息失败"); -// } -// return new ResultEntity<>(list); -// } + @AnonymousAccess @ApiOperation("老师端/练习模式得分详情展示") 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 80277bd..c154f2f 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 @@ -6,6 +6,7 @@ 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 javax.servlet.http.HttpServletResponse; @@ -19,11 +20,11 @@ import java.util.List; public interface ITeaGradeManageService { 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, String schoolId, String systemOwner) throws IOException; + List getTrainingDetailsInfo(String userId,String schoolId, String systemOwner) throws IOException; void exportTrainingDetailsInfo(HttpServletResponse response, String userId, String schoolId, String systemOwner) throws IOException; 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 9858810..2a49a27 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 @@ -28,7 +28,6 @@ import java.io.IOException; import java.math.BigDecimal; import java.math.RoundingMode; import java.util.*; -import java.util.function.Function; import java.util.stream.Collectors; /** @@ -109,6 +108,14 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService { List stuClasses = classMapper.selectByExample(example); Map classIdToNameMap = stuClasses.stream().collect(Collectors.toMap(StuClass::getClassId, StuClass::getClassName)); + + //拿到权重 + SysWeightExample sysWeightExample = new SysWeightExample(); + sysWeightExample.createCriteria().andSchoolIdEqualTo(schoolId); + List sysWeights = sysWeightMapper.selectByExample(sysWeightExample); + SysWeight sysWeight = sysWeights.get(0); + + // 批量获取实训记录 Set userIds = stuUsers.stream().map(StuUser::getUserid).collect(Collectors.toSet()); StuTrainingExample stuTrainingExample = new StuTrainingExample(); @@ -157,9 +164,12 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService { totalScore = totalScore.add(reportScore); } } - // 省略其他分数加法代码 + //其他模块算分 + BigDecimal moduleScore = getModuleScore(training, sysWeight); + totalScore = moduleScore.add(totalScore).setScale(2,RoundingMode.HALF_UP); } + //这个综合得分的公式为 各个页面得分*权重 = 单个模块得分 所有模块得分之和/系统章节数 = 综合得分 BigDecimal score = totalScore; if (totalScore.compareTo(BigDecimal.ZERO) > 0) { score = totalScore.divide(chapterNum, 2, RoundingMode.HALF_UP); @@ -182,23 +192,23 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService { * @author xcj * @Date 2024/3/19 */ - @Override - public void exportTrainingInfo(HttpServletResponse response, String schoolId, String keyWord, String classId, String systemOwner) { - List list = getTrainingInfoDTOS(schoolId, keyWord, classId, systemOwner); - - //导出的表名 - String title = IdUtil.simpleUUID(); - //表中第一行表头字段 - String[] headers = {"排名", "姓名", "学号", "班级名称", "综合得分", "实训进度"}; - - //具体需要写入excel需要哪些字段,这些字段取自UserReward类,也就是上面的实际数据结果集的泛型 - List listColumn = Arrays.asList("rank", "name", "studentId", "className", "totalScore", "progress"); - try { - FilePortUtil.exportExcel(response, title, headers, list, listColumn); - } catch (Exception e) { - e.printStackTrace(); - } - } +// @Override +// public void exportTrainingInfo(HttpServletResponse response, String schoolId, String keyWord, String classId, String systemOwner) { +// List list = getTrainingInfoDTOS(schoolId, keyWord, classId, systemOwner); +// +// //导出的表名 +// String title = IdUtil.simpleUUID(); +// //表中第一行表头字段 +// String[] headers = {"排名", "姓名", "学号", "班级名称", "综合得分", "实训进度"}; +// +// //具体需要写入excel需要哪些字段,这些字段取自UserReward类,也就是上面的实际数据结果集的泛型 +// List listColumn = Arrays.asList("rank", "name", "studentId", "className", "totalScore", "progress"); +// try { +// FilePortUtil.exportExcel(response, title, headers, list, listColumn); +// } catch (Exception e) { +// e.printStackTrace(); +// } +// } //饼形图 @Override @@ -336,11 +346,22 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService { } //计算模块得分 - private BigDecimal getModuleScore(StuTrainingWithBLOBs stuTrainingWithBLOB) { + private BigDecimal getModuleScore(StuTrainingWithBLOBs stuTrainingWithBLOB, SysWeight sysWeight) { + BigDecimal knowledgeSummaryWeight = sysWeight.getKnowledgeSummaryWeight(); + BigDecimal learningEvalWeight = sysWeight.getLearningEvalWeight(); + BigDecimal resourceLearningWeight = sysWeight.getResourceLearningWeight(); + BigDecimal expTrainingWeight = sysWeight.getExpTrainingWeight(); + BigDecimal knowledgeSummaryScore = Optional.ofNullable(stuTrainingWithBLOB.getKnowledgeSummaryScore()).orElse(BigDecimal.ZERO); BigDecimal resourceLearningScore = Optional.ofNullable(stuTrainingWithBLOB.getResourceLearningScore()).orElse(BigDecimal.ZERO); BigDecimal learningEvalScore = Optional.ofNullable(stuTrainingWithBLOB.getLearningEvalScore()).orElse(BigDecimal.ZERO); BigDecimal expTrainingScore = Optional.ofNullable(stuTrainingWithBLOB.getExpTrainingScore()).orElse(BigDecimal.ZERO); + + knowledgeSummaryScore = knowledgeSummaryWeight.multiply(knowledgeSummaryScore); + learningEvalScore = learningEvalScore.multiply(learningEvalWeight); + resourceLearningScore = resourceLearningScore.multiply(resourceLearningWeight); + expTrainingScore = expTrainingScore.multiply(expTrainingWeight); + return knowledgeSummaryScore.add(resourceLearningScore).add(learningEvalScore).add(expTrainingScore); } @@ -467,8 +488,8 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService { @Override public void exportAllStuTrainingInfo(HttpServletResponse response, String schoolId, String systemOwner) throws IOException { List trainingInfoDTOSNew = getTrainingInfoDTOSNew(schoolId, systemOwner); - List sysTwoCatalogs = CourseAPI.selectCourseList(systemOwner,schoolId); - ListallChapterId =new ArrayList<>(); + List sysTwoCatalogs = CourseAPI.selectCourseList(systemOwner, schoolId); + List allChapterId = new ArrayList<>(); for (SysTwoCatalog sysTwoCatalog : sysTwoCatalogs) { List sysThreeCatalogs = CourseAPI.selectThreeCatalogListByTwoId(sysTwoCatalog.getTwoId(), schoolId); allChapterId.addAll(sysThreeCatalogs); @@ -489,9 +510,10 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService { stuTrainingExample.createCriteria().andUserIdEqualTo(userId); List stuTrainings = stuTrainingMapper.selectByExampleWithBLOBs(stuTrainingExample); - LinkedHashMapmap =new LinkedHashMap<>(); + LinkedHashMap map = new LinkedHashMap<>(); LinkedHashMap chapterMap = new LinkedHashMap<>(); + for (StuTrainingWithBLOBs stuTraining : stuTrainings) { String chapterId = stuTraining.getChapterId(); SysThreeCatalog sysCourseChapter = chapterMap.get(chapterId); @@ -506,7 +528,7 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService { BigDecimal moduleScore = scoreByChapterId.getModuleScore(); String taskModule = scoreByChapterId.getTaskModule(); - map.put(taskModule,moduleScore); + map.put(taskModule, moduleScore); } excelDto.setMap(map); excelDtos.add(excelDto); @@ -575,6 +597,11 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService { } catch (IOException e) { return null; } + //拿到权重 + SysWeightExample sysWeightExample = new SysWeightExample(); + sysWeightExample.createCriteria().andSchoolIdEqualTo(schoolId); + List sysWeights = sysWeightMapper.selectByExample(sysWeightExample); + SysWeight sysWeight = sysWeights.get(0); // 遍历用户,计算分数并封装DTO List list = new ArrayList<>(); @@ -584,6 +611,7 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService { continue; } + TeaTrainingInfoDTO teaTrainingInfoDTO = new TeaTrainingInfoDTO(); teaTrainingInfoDTO.setClassName(classIdToNameMap.get(stuUser.getClassId())); teaTrainingInfoDTO.setStudentId(stuUser.getStudentId()); @@ -598,10 +626,12 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService { if (reportId != null) { BigDecimal reportScore = reportIdToScoreMap.getOrDefault(reportId, BigDecimal.ZERO); if (BigDecimal.ZERO.compareTo(reportScore) != 0) { + reportScore = reportScore.multiply(sysWeight.getReportWeight().setScale(2, RoundingMode.HALF_UP)); totalScore = totalScore.add(reportScore); } } - // 省略其他分数加法代码 + BigDecimal moduleScore = getModuleScore(training, sysWeight); + totalScore = moduleScore.add(totalScore).setScale(2,RoundingMode.HALF_UP); } BigDecimal score = totalScore;