diff --git a/src/main/java/com/sztzjy/financial_bigdata/config/Constant.java b/src/main/java/com/sztzjy/financial_bigdata/config/Constant.java index 5b864c4..bb83d7c 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/config/Constant.java +++ b/src/main/java/com/sztzjy/financial_bigdata/config/Constant.java @@ -38,6 +38,6 @@ public class Constant { public static final String THEORY = "理论考试模块"; public static final String RESOURCE = "资源中心模块"; public static final String API_URL = "http://120.79.54.255:8889"; -// public static final String API_URL = "http://192.168.2.44:8889"; +// public static final String API_URL = "http://192.168.2.25:8889"; } diff --git a/src/main/java/com/sztzjy/financial_bigdata/controller/stu/ExerciseLearningEvaluation.java b/src/main/java/com/sztzjy/financial_bigdata/controller/stu/ExerciseLearningEvaluation.java index c63b0f8..ed1cdb5 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/controller/stu/ExerciseLearningEvaluation.java +++ b/src/main/java/com/sztzjy/financial_bigdata/controller/stu/ExerciseLearningEvaluation.java @@ -48,10 +48,13 @@ public class ExerciseLearningEvaluation { @AnonymousAccess public ResultEntity commitObjectQuestionList(@RequestBody List objectiveQuestionDtoList, @RequestParam String userId, - @ApiParam("章节Id")@RequestParam String chapterId,@RequestParam String schoolId,@RequestParam String systemOwner){ + @ApiParam("章节Id")@RequestParam String chapterId, + @RequestParam String schoolId, + @RequestParam String systemOwner, + @RequestParam String courseId){ Boolean flag= null; try { - flag = exerciseService.commitObjectQuestionList(objectiveQuestionDtoList,userId,chapterId, schoolId, systemOwner); + flag = exerciseService.commitObjectQuestionList(objectiveQuestionDtoList,userId,chapterId, schoolId, systemOwner,courseId); } catch (IOException e) { return new ResultEntity<>(HttpStatus.BAD_REQUEST, "资源中心客观题主键查询失败"); } diff --git a/src/main/java/com/sztzjy/financial_bigdata/controller/stu/StuIndexController.java b/src/main/java/com/sztzjy/financial_bigdata/controller/stu/StuIndexController.java index e2cfbc3..7277a2c 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/controller/stu/StuIndexController.java +++ b/src/main/java/com/sztzjy/financial_bigdata/controller/stu/StuIndexController.java @@ -132,8 +132,10 @@ public class StuIndexController { List stuClassList = stuClassMapper.selectByExample(example); StuClass stuClass = stuClassList.get(0); stuUserDto.setClassName(stuClass.getClassName()); - stuUserDto.setIpPlace(sysLoginLogs.get(0).getIpAddress()); - stuUserDto.setLastIP(sysLoginLogs.get(0).getLoginIp()); + if(!sysLoginLogs.isEmpty()){ + stuUserDto.setIpPlace(sysLoginLogs.get(0).getIpAddress()); + stuUserDto.setLastIP(sysLoginLogs.get(0).getLoginIp()); + } return new ResultEntity(stuUserDto); } diff --git a/src/main/java/com/sztzjy/financial_bigdata/controller/stu/StuKnowledgeNote.java b/src/main/java/com/sztzjy/financial_bigdata/controller/stu/StuKnowledgeNote.java index c125bac..0372898 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/controller/stu/StuKnowledgeNote.java +++ b/src/main/java/com/sztzjy/financial_bigdata/controller/stu/StuKnowledgeNote.java @@ -182,25 +182,27 @@ public class StuKnowledgeNote { @RequestParam String systemOwner, @RequestParam String trainingId) { StuTrainingWithBLOBs stuTrainingWithBLOBs = stuTrainingMapper.selectByPrimaryKey(trainingId); - if (stuTrainingWithBLOBs.getKnowledgeSummaryCompleteStatus() != null) { - //不为空直接返回 - return new ResultEntity<>(stuTrainingWithBLOBs.getKnowledgeSummaryScore()); - } //为空设置 SysWeight sysWeight = iTeaGradeManageService.getSysWeightResultEntity(courseId, schoolId, systemOwner); BigDecimal knowledgeSummaryDefaultRule = sysWeight.getKnowledgeSummaryDefaultRule(); + Integer knowledgeSummaryCompleteStatus = stuTrainingWithBLOBs.getKnowledgeSummaryCompleteStatus()==null?0:stuTrainingWithBLOBs.getKnowledgeSummaryCompleteStatus(); + minutes=minutes+knowledgeSummaryCompleteStatus; if (minutes < 1) { stuTrainingWithBLOBs.setKnowledgeSummaryScore(BigDecimal.ZERO); } else if (minutes == 1) { stuTrainingWithBLOBs.setKnowledgeSummaryScore(knowledgeSummaryDefaultRule); //老师只能修改这个分值 } else { int extraMinutes = minutes - 1; - int totalScore = 60 + extraMinutes * 10; + int totalScore = knowledgeSummaryDefaultRule.intValue() + extraMinutes * 10; knowledgeSummaryDefaultRule = BigDecimal.valueOf(totalScore); - stuTrainingWithBLOBs.setKnowledgeSummaryScore(knowledgeSummaryDefaultRule); + if(knowledgeSummaryDefaultRule.compareTo(BigDecimal.valueOf(100))>0){ + stuTrainingWithBLOBs.setKnowledgeSummaryScore(BigDecimal.valueOf(100)); + }else { + stuTrainingWithBLOBs.setKnowledgeSummaryScore(knowledgeSummaryDefaultRule); + } } - stuTrainingWithBLOBs.setResourceLearningCompleteStatus(minutes); + stuTrainingWithBLOBs.setKnowledgeSummaryCompleteStatus(minutes); stuTrainingMapper.updateByPrimaryKey(stuTrainingWithBLOBs); return new ResultEntity<>(knowledgeSummaryDefaultRule); } 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..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 @@ -78,6 +78,8 @@ public class TeaGradeManageController { private StuTrainingMapper stuTrainingMapper; @Autowired StuScoreService stuScoreService; + @Value("${file.path}") + private String filePath; @AnonymousAccess @@ -93,25 +95,32 @@ public class TeaGradeManageController { return null; } List teaExamManageCountDtos = new ArrayList<>(); - Map userMap = new HashMap<>(); + Map userMap = new HashMap<>(); - List userIds = new ArrayList<>(); + List userIds = new ArrayList<>(); for (TeaExamManage teaExamManage : teaExamManages) { - Integer zyUserId = Integer.parseInt(teaExamManage.getUserId()); //这里是智云 zyUserId - userIds.add(zyUserId); + userIds.add(teaExamManage.getUserId()); } //存储用户信息 StuUserExample example = new StuUserExample(); - example.createCriteria().andSystemOnwerEqualTo(systemOwner).andZyUseridIn(userIds); + example.createCriteria().andSystemOnwerEqualTo(systemOwner).andUseridIn(userIds); List stuUsers = userMapper.selectByExample(example); for (StuUser stuUser : stuUsers) { - userMap.put(stuUser.getZyUserid(), stuUser); + userMap.put(stuUser.getUserid(), stuUser); } for (TeaExamManage teaExamManage : teaExamManages) { TeaExamManageCountDto copyexamManageWithBLOBs = new TeaExamManageCountDto(); + String userId = teaExamManage.getUserId(); + StuUser stuUser = userMap.get(userId); + if (stuUser == null) { + continue; + } + copyexamManageWithBLOBs.setName(stuUser.getName()); //发布人 + teaExamManageCountDtos.add(copyexamManageWithBLOBs); + //获取班级和考试人数 TeaAndStudentExam teaAndStudentExam = teaAndStudentExamMapper.selectByExamMangeId(teaExamManage.getExamManageId()); @@ -139,10 +148,6 @@ public class TeaGradeManageController { String concatenatedTimeString = startTime + " -- " + endTime; copyexamManageWithBLOBs.setExamTime(concatenatedTimeString); //考试时间 - String userId = teaExamManage.getUserId(); - StuUser stuUser = userMap.get(Integer.parseInt(userId)); - copyexamManageWithBLOBs.setName(stuUser.getName()); //发布人 - teaExamManageCountDtos.add(copyexamManageWithBLOBs); } PageInfo pageInfo = PageUtil.pageHelper(teaExamManageCountDtos, index, size); return new ResultEntity<>(pageInfo); @@ -186,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") @@ -443,39 +424,54 @@ 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 - @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("/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) { +// 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(); } } + + //todo 新增的导出 + @AnonymousAccess + @GetMapping("/exportAllStuTrainingInfo") + @ApiOperation("***练习模式--页面导出") + public void exportAllStuTrainingInfo(HttpServletResponse response, + @RequestParam String schoolId, + @RequestParam String systemOwner) throws IOException { + iTeaGradeManageService.exportAllStuTrainingInfo(response, schoolId, systemOwner); + } + + @AnonymousAccess @PostMapping("/getReportBySchoolID") @ApiOperation("练习模式--实训报告展示") @@ -535,9 +531,6 @@ public class TeaGradeManageController { } - @Value("${file.path}") - private String filePath; - @GetMapping("/getReportByReportId") @ApiOperation("评阅--获取单个学生报告接口") @AnonymousAccess @@ -639,8 +632,9 @@ public class TeaGradeManageController { @ApiOperation("理论考试--导出理论考试信息") public void exportTheoryExamInfo(HttpServletResponse response, @ApiParam("不选择班级就是学习全部导出") @RequestParam(required = false) String classId, - @RequestParam String schoolId) { - iTeaGradeManageService.exportTheoryExamInfo(response, classId, schoolId); + @RequestParam String schoolId, + @RequestParam String systemOwner) { + iTeaGradeManageService.exportTheoryExamInfo(response, classId, schoolId, systemOwner); } @@ -659,68 +653,48 @@ 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("老师端/练习模式得分详情展示") @PostMapping("getScoreInfo") public ResultEntity> getScoreInfo(@RequestParam String userId, @RequestParam String schoolId, - @RequestParam String systemOwner) { + @RequestParam String systemOwner) throws IOException { List list = new ArrayList<>(); + List sysTwoCatalogs = CourseAPI.selectCourseList(systemOwner,schoolId); + + ListallChapterId =new ArrayList<>(); + for (SysTwoCatalog sysTwoCatalog : sysTwoCatalogs) { + List sysThreeCatalogs = CourseAPI.selectThreeCatalogListByTwoId(sysTwoCatalog.getTwoId(), schoolId); + allChapterId.addAll(sysThreeCatalogs); + } + StuTrainingExample stuTrainingExample = new StuTrainingExample(); stuTrainingExample.createCriteria().andUserIdEqualTo(userId); List stuTrainings = stuTrainingMapper.selectByExampleWithBLOBs(stuTrainingExample); - Map chapterMap = new HashMap<>(); + Map chapterIds = allChapterId.stream().collect(Collectors.toMap(SysThreeCatalog::getThreeId, sysThreeCatalog -> sysThreeCatalog)); 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); + SysThreeCatalog sysCourseChapter = chapterIds.get(chapterId); + if (sysCourseChapter==null){ + continue; } StuTrainingDto stuTrainingDto = new StuTrainingDto(); stuTrainingDto.setTaskModule(sysCourseChapter.getThreeName()); list.add(stuScoreService.getScoreByChapterId(schoolId, systemOwner, stuTraining, stuTrainingDto, sysCourseChapter)); } - } catch (IOException e) { + } catch (Exception e) { return new ResultEntity<>(HttpStatus.BAD_REQUEST, "资源中心根据章节ID查询章节信息失败"); } return new ResultEntity<>(list); } - } diff --git a/src/main/java/com/sztzjy/financial_bigdata/controller/tea/TeaResourceCenterController.java b/src/main/java/com/sztzjy/financial_bigdata/controller/tea/TeaResourceCenterController.java index 3ce9c8e..fd0281c 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/controller/tea/TeaResourceCenterController.java +++ b/src/main/java/com/sztzjy/financial_bigdata/controller/tea/TeaResourceCenterController.java @@ -80,28 +80,33 @@ public class TeaResourceCenterController { @ApiOperation("学习资源-算分") @PostMapping("getResourceScore") //观看资源1分钟得60分,1分钟以下不得分,多1分钟加10分。 public ResultEntity getScore(@ApiParam("数字 单位分钟") @RequestParam Integer minutes, - @RequestParam String courseId, - @RequestParam String schoolId, - @RequestParam String systemOwner, - @RequestParam String trainingId) { + @RequestParam String courseId, + @RequestParam String schoolId, + @RequestParam String systemOwner, + @RequestParam String trainingId) { StuTrainingWithBLOBs stuTrainingWithBLOBs = stuTrainingMapper.selectByPrimaryKey(trainingId); - if (stuTrainingWithBLOBs.getKnowledgeSummaryCompleteStatus() != null) { - //不为空直接返回 - return new ResultEntity<>(stuTrainingWithBLOBs.getResourceLearningScore()); - } - //为空设置 SysWeight sysWeight = iTeaGradeManageService.getSysWeightResultEntity(courseId, schoolId, systemOwner); BigDecimal resourceLearningDefaultRule = sysWeight.getResourceLearningDefaultRule(); + + if (stuTrainingWithBLOBs.getResourceLearningCompleteStatus() != null) { + minutes = minutes + stuTrainingWithBLOBs.getResourceLearningCompleteStatus(); //累加时间 + } + if (minutes < 1) { stuTrainingWithBLOBs.setResourceLearningScore(BigDecimal.ZERO); } else if (minutes == 1) { stuTrainingWithBLOBs.setResourceLearningScore(resourceLearningDefaultRule); //老师只能修改这个分值 } else { int extraMinutes = minutes - 1; - int totalScore = 60 + extraMinutes * 10; + int totalScore = resourceLearningDefaultRule.intValue() + extraMinutes * 10; resourceLearningDefaultRule = BigDecimal.valueOf(totalScore); - stuTrainingWithBLOBs.setResourceLearningScore(resourceLearningDefaultRule); + + if (resourceLearningDefaultRule.compareTo(BigDecimal.valueOf(100)) > 0) { + stuTrainingWithBLOBs.setResourceLearningScore(BigDecimal.valueOf(100)); + }else { + stuTrainingWithBLOBs.setResourceLearningScore(resourceLearningDefaultRule); + } } stuTrainingWithBLOBs.setResourceLearningCompleteStatus(minutes); stuTrainingMapper.updateByPrimaryKey(stuTrainingWithBLOBs); diff --git a/src/main/java/com/sztzjy/financial_bigdata/entity/ExcelDto.java b/src/main/java/com/sztzjy/financial_bigdata/entity/ExcelDto.java new file mode 100644 index 0000000..18c879b --- /dev/null +++ b/src/main/java/com/sztzjy/financial_bigdata/entity/ExcelDto.java @@ -0,0 +1,37 @@ +package com.sztzjy.financial_bigdata.entity; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.math.BigDecimal; +import java.util.List; +import java.util.Map; + +/** + * @Author xcj + * @Date 2024/12/10 + */ +@Data +@NoArgsConstructor +public class ExcelDto { + @ApiModelProperty("排名") + private int rank; + + @ApiModelProperty("姓名") + private String name; + + @ApiModelProperty("学号") + private String studentId; + + @ApiModelProperty("班级名称") + private String className; + + @ApiModelProperty("综合得分") + private BigDecimal totalScore; + + @ApiModelProperty("实训进度") + private BigDecimal progress; + + private Mapmap; +} 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/mapper/StuTheoryRecordMapper.java b/src/main/java/com/sztzjy/financial_bigdata/mapper/StuTheoryRecordMapper.java index 88a0b04..fa049e4 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/mapper/StuTheoryRecordMapper.java +++ b/src/main/java/com/sztzjy/financial_bigdata/mapper/StuTheoryRecordMapper.java @@ -33,4 +33,9 @@ public interface StuTheoryRecordMapper { int updateByPrimaryKey(StuTheoryRecord record); StuTheoryIndexInfoDto selectTheoryInfo(@Param("userId") String userId); + + List selectConditions(@Param("schoolId") String schoolId, + @Param("classId") String classId, + @Param("keyWord") String keyWord, + @Param("systemOwner") String systemOwner); } \ No newline at end of file diff --git a/src/main/java/com/sztzjy/financial_bigdata/service/stu/IExerciseService.java b/src/main/java/com/sztzjy/financial_bigdata/service/stu/IExerciseService.java index d8bbc53..c5d6eac 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/service/stu/IExerciseService.java +++ b/src/main/java/com/sztzjy/financial_bigdata/service/stu/IExerciseService.java @@ -9,5 +9,5 @@ import java.util.List; public interface IExerciseService { List selectObjectQuestionListByChapterId(String chapterId, String userId,String schoolId,String systemOwner) throws IOException; - Boolean commitObjectQuestionList(List objectiveQuestionDtoList, String userId, String chapterId,String schoolId,String systemOwner) throws IOException; + Boolean commitObjectQuestionList(List objectiveQuestionDtoList, String userId, String chapterId,String schoolId,String systemOwner,String courseId) throws IOException; } diff --git a/src/main/java/com/sztzjy/financial_bigdata/service/stu/impl/ExerciseServiceImpl.java b/src/main/java/com/sztzjy/financial_bigdata/service/stu/impl/ExerciseServiceImpl.java index 2492979..70ba434 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/service/stu/impl/ExerciseServiceImpl.java +++ b/src/main/java/com/sztzjy/financial_bigdata/service/stu/impl/ExerciseServiceImpl.java @@ -1,13 +1,13 @@ package com.sztzjy.financial_bigdata.service.stu.impl; -import com.sztzjy.financial_bigdata.entity.StuTraining; -import com.sztzjy.financial_bigdata.entity.StuTrainingExample; -import com.sztzjy.financial_bigdata.entity.StuTrainingWithBLOBs; -import com.sztzjy.financial_bigdata.entity.SysObjectiveQuestion; +import cn.hutool.core.util.IdUtil; +import com.sztzjy.financial_bigdata.entity.*; import com.sztzjy.financial_bigdata.entity.resource_entity.SysObjectiveQuestions; +import com.sztzjy.financial_bigdata.entity.stu_dto.StuTrainingDto; import com.sztzjy.financial_bigdata.entity.sys_dto.SysObjectiveQuestionDto; import com.sztzjy.financial_bigdata.mapper.StuTrainingMapper; import com.sztzjy.financial_bigdata.mapper.SysObjectiveQuestionMapper; +import com.sztzjy.financial_bigdata.mapper.SysWeightMapper; import com.sztzjy.financial_bigdata.resourceCenterAPI.ObjectiveApi; import com.sztzjy.financial_bigdata.service.stu.IExerciseService; import com.sztzjy.financial_bigdata.service.tea.ITeaObjectiveService; @@ -27,6 +27,8 @@ public class ExerciseServiceImpl implements IExerciseService { ITeaObjectiveService objectiveService; @Autowired SysObjectiveQuestionMapper objectiveQuestionMapper; + @Autowired + SysWeightMapper sysWeightMapper; @Override public List selectObjectQuestionListByChapterId(String chapterId, String userId,String schoolId,String systemOwner) throws IOException { @@ -111,12 +113,37 @@ public class ExerciseServiceImpl implements IExerciseService { } + @Override - public Boolean commitObjectQuestionList(List objectiveQuestionDtoList, String userId, String chapterId,String schoolId,String systemOwner) throws IOException { + public Boolean commitObjectQuestionList(List objectiveQuestionDtoList, String userId, String chapterId,String schoolId,String systemOwner,String courseId) throws IOException { StuTrainingExample example = new StuTrainingExample(); example.createCriteria().andUserIdEqualTo(userId).andChapterIdEqualTo(chapterId); List stuTrainingWithBLOBs = trainingMapper.selectByExampleWithBLOBs(example); + SysWeightExample sysWeightExample =new SysWeightExample(); + sysWeightExample.createCriteria().andSchoolIdEqualTo(schoolId).andSystemOwnerEqualTo(systemOwner).andCourseIdEqualTo(courseId); + List sysWeights = sysWeightMapper.selectByExample(sysWeightExample); + SysWeight sysWeight = new SysWeight(); + if (sysWeights.isEmpty()){ + //设置默认权重 + sysWeight.setCourseId(courseId); + sysWeight.setWeightId(IdUtil.randomUUID()); + sysWeight.setSchoolId(schoolId); + sysWeight.setSystemOwner(systemOwner); + sysWeight.setKnowledgeSummaryDefaultRule(BigDecimal.valueOf(60)); //知识概要默认计分规则 阅读1分钟得60分,1分钟以下不得分,多1分钟加10分。 + sysWeight.setResourceLearningDefaultRule(BigDecimal.valueOf(60)); //资源学习默认计分规则 观看资源1分钟得60分,1分钟以下不得分,多1分钟加10分。 + sysWeight.setLearningEvalDefaultRule(BigDecimal.valueOf(10)); //学习测评默认计分规则 客观题10分每道 + sysWeight.setExpTrainingDefautRule(BigDecimal.valueOf(2));//实训题,输错/选错次数扣2分,最低0分 + sysWeight.setKnowledgeSummaryWeight(BigDecimal.valueOf(5)); + sysWeight.setResourceLearningWeight(BigDecimal.valueOf(5)); + sysWeight.setLearningEvalWeight(BigDecimal.valueOf(20)); + sysWeight.setExpTrainingWeight(BigDecimal.valueOf(60)); + sysWeight.setReportWeight(BigDecimal.valueOf(10)); + sysWeightMapper.insert(sysWeight); + }else { + sysWeight = sysWeights.get(0); + } + // if (stuTrainingWithBLOBs.get(0).getLearningEvalAnswer()!=null){ // return false; // } @@ -133,7 +160,7 @@ public class ExerciseServiceImpl implements IExerciseService { String answer = objectiveQuestion.getAnswer(); stuAnswerList.add(stuAnswer); if(answer.equals(stuAnswer)){ - learning_eval_score= learning_eval_score.add(objectiveQuestion.getScore()); + learning_eval_score= learning_eval_score.add(sysWeight.getLearningEvalDefaultRule()); }else { errorCount++; } 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..cb10602 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 @@ -135,14 +135,96 @@ public class StuScoreServiceImpl implements StuScoreService { BeanUtils.copyProperties(stuTrainingWithBLOBs, stuTrainingDto); // 完成情况和得分 // 计算各模块得分 - calculateModuleScores(stuTrainingWithBLOBs, stuTrainingDto); + //知识概要和学习资源得分已经乘过权重,直接返回 + if (stuTrainingDto.getCaseStuScore() == null) { + stuTrainingDto.setCaseStuScore(BigDecimal.ZERO); + } else { + BigDecimal caseStuScore = stuTrainingDto.getCaseStuScore(); //实验实训得分 + BigDecimal expTrainingWeight = stuTrainingDto.getExpTrainingWeight(); //实验实训权重 + BigDecimal weightCaseScore = expTrainingWeight.multiply(caseStuScore).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP); + stuTrainingDto.setCaseStuScore(weightCaseScore); //返回乘过权重的 + } + + //学习测评 + if (stuTrainingDto.getLearningEvalScore() == null) { + stuTrainingDto.setLearningEvalScore(BigDecimal.ZERO); + } else { + BigDecimal learningEvalScore = stuTrainingDto.getLearningEvalScore(); + BigDecimal learningEvalWeight = stuTrainingDto.getLearningEvalWeight(); + BigDecimal weightLearningEvalScore = learningEvalWeight.multiply(learningEvalScore).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP); + stuTrainingDto.setLearningEvalScore(weightLearningEvalScore); + } + + + //学习资源 + if (stuTrainingDto.getResourceLearningScore()==null){ + stuTrainingDto.setResourceLearningScore(BigDecimal.ZERO); + }else { + BigDecimal resourceLearningScore = stuTrainingDto.getResourceLearningScore(); + BigDecimal resourceLearningWeight = stuTrainingDto.getResourceLearningWeight(); + BigDecimal weightLearningEvalScore = resourceLearningWeight.multiply(resourceLearningScore).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP); + stuTrainingDto.setResourceLearningScore(weightLearningEvalScore); + } + + //知识概要 + if (stuTrainingDto.getKnowledgeSummaryScore() == null) { + stuTrainingDto.setKnowledgeSummaryScore(BigDecimal.ZERO); + } else { + BigDecimal knowledgeSummaryScore = stuTrainingDto.getKnowledgeSummaryScore(); + BigDecimal knowledgeSummaryWeight = stuTrainingDto.getKnowledgeSummaryWeight(); + BigDecimal weightKnowledgeSummaryScore = knowledgeSummaryWeight.multiply(knowledgeSummaryScore).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP); + stuTrainingDto.setKnowledgeSummaryScore(weightKnowledgeSummaryScore); + } + // 设置报告相关数据 - setReportData(stuTrainingDto, stuTrainingWithBLOBs.getReportId()); + TrainingReport trainingReport = trainingReportMapper.selectByPrimaryKey(stuTrainingWithBLOBs.getReportId()); + if (trainingReport == null) { + stuTrainingDto.setReportCompleteStatus("未提交"); + stuTrainingDto.setReportScore(BigDecimal.ZERO); + } else { + BigDecimal reportScore = trainingReport.getTeacherScore(); + BigDecimal reportWeight = stuTrainingDto.getReportWeight(); + BigDecimal weightReportScore = reportScore.multiply(reportWeight).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP); + stuTrainingDto.setReportScore(weightReportScore); + stuTrainingDto.setReportCompleteStatus("已提交"); + } + //计算模块总得分 + setTotalScore(stuTrainingDto); return stuTrainingDto; } + private void setTotalScore(StuTrainingDto stuTrainingDto) { + BigDecimal totalScore = BigDecimal.ZERO; + if (stuTrainingDto.getKnowledgeSummaryScore() != null) { + totalScore = totalScore.add(stuTrainingDto.getKnowledgeSummaryScore()); + } else { + stuTrainingDto.setKnowledgeSummaryScore(BigDecimal.ZERO); + } + if (stuTrainingDto.getResourceLearningScore() != null) { + totalScore = totalScore.add(stuTrainingDto.getResourceLearningScore()); + } else { + stuTrainingDto.setResourceLearningScore(BigDecimal.ZERO); + } + if (stuTrainingDto.getLearningEvalScore() != null) { + totalScore = totalScore.add(stuTrainingDto.getLearningEvalScore()); + } else { + stuTrainingDto.setLearningEvalScore(BigDecimal.ZERO); + } + if (stuTrainingDto.getCaseStuScore() != null) { + totalScore = totalScore.add(stuTrainingDto.getCaseStuScore()); + } else { + stuTrainingDto.setCaseStuScore(BigDecimal.ZERO); + } + if (stuTrainingDto.getReportScore() != null) { + totalScore = totalScore.add(stuTrainingDto.getReportScore()); + } else { + stuTrainingDto.setReportScore(BigDecimal.ZERO); + } + stuTrainingDto.setModuleScore(totalScore); + } + private void setDefaultWeights(StuTrainingDto stuTrainingDto) { stuTrainingDto.setKnowledgeSummaryDefaultRule(BigDecimal.valueOf(60)); stuTrainingDto.setResourceLearningDefaultRule(BigDecimal.valueOf(60)); @@ -155,58 +237,4 @@ public class StuScoreServiceImpl implements StuScoreService { stuTrainingDto.setReportWeight(BigDecimal.valueOf(10)); } - private void calculateModuleScores(StuTrainingWithBLOBs stuTrainingWithBLOBs, StuTrainingDto stuTrainingDto) { - stuTrainingDto.setKnowledgeSummaryScore(calculateScore( - stuTrainingDto.getKnowledgeSummaryDefaultRule(), - stuTrainingDto.getKnowledgeSummaryWeight(), - stuTrainingWithBLOBs.getKnowledgeSummaryCompleteStatus() - )); - - stuTrainingDto.setResourceLearningScore(calculateScore( - stuTrainingDto.getResourceLearningDefaultRule(), - stuTrainingDto.getResourceLearningWeight(), - stuTrainingWithBLOBs.getResourceLearningCompleteStatus() - )); - - stuTrainingDto.setLearningEvalScore(calculateEvaluationScore( - stuTrainingDto.getLearningEvalDefaultRule(), - stuTrainingDto.getLearningEvalWeight(), - stuTrainingWithBLOBs.getLearningEvalCompleteStatus() - )); - - stuTrainingDto.setCaseStuScore(calculateEvaluationScore( - stuTrainingDto.getExpTrainingDefautRule(), - stuTrainingDto.getExpTrainingWeight(), - stuTrainingWithBLOBs.getExpTrainingCompleteStatus() - )); - } - - private BigDecimal calculateScore(BigDecimal defaultRule, BigDecimal weight, Integer completeStatus) { - if (completeStatus != null && completeStatus > 0) { - BigDecimal score = defaultRule.add(BigDecimal.valueOf((completeStatus - 1) * 10)); - score = score.min(BigDecimal.valueOf(100)); // 确保分数不超过100 - return score.multiply(weight.divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP)); - } - return BigDecimal.ZERO; - } - - private BigDecimal calculateEvaluationScore(BigDecimal defaultRule, BigDecimal weight, Integer completeStatus) { - if (completeStatus != null) { - BigDecimal score = BigDecimal.valueOf(100).subtract(defaultRule.multiply(BigDecimal.valueOf(completeStatus))); - return score.max(BigDecimal.ZERO).multiply(weight.divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP)); - } - return BigDecimal.ZERO; - } - - private void setReportData(StuTrainingDto stuTrainingDto, String reportId) { - TrainingReport trainingReport = trainingReportMapper.selectByPrimaryKey(reportId); - if (trainingReport == null || trainingReport.getTeacherScore() == null) { - stuTrainingDto.setReportCompleteStatus("未提交"); - stuTrainingDto.setReportScore(null); - } else { - stuTrainingDto.setReportCompleteStatus("已提交"); - stuTrainingDto.setReportScore(trainingReport.getTeacherScore()); - } - } - } 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..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 @@ -3,11 +3,11 @@ 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 +18,23 @@ 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,String systemOwner); SysWeight getSysWeightResultEntity(String courseId, String schoolId, String systemOwner); + + void exportAllStuTrainingInfo(HttpServletResponse response, String schoolId, String systemOwner) throws IOException; } diff --git a/src/main/java/com/sztzjy/financial_bigdata/service/tea/impl/TeaCaseStepServiceImpl.java b/src/main/java/com/sztzjy/financial_bigdata/service/tea/impl/TeaCaseStepServiceImpl.java index bdef376..57a3d44 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/service/tea/impl/TeaCaseStepServiceImpl.java +++ b/src/main/java/com/sztzjy/financial_bigdata/service/tea/impl/TeaCaseStepServiceImpl.java @@ -148,7 +148,7 @@ public class TeaCaseStepServiceImpl implements ITeaCaseStepService { StuTrainingStepRecord stepRecord = stuTrainingStepRecords.get(0); stepRecord.setStuAnswer(commitCaseDto.getStuAnswer()); trainingStepRecordMapper.updateByPrimaryKeyWithBLOBs(stepRecord); - return false; + return true; } } } 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..197cd98 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,25 @@ 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.resource_entity.SysTwoCatalog; +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 +54,135 @@ 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; + } + + private List getTrainingInfoDTOSNew(String schoolId, String systemOwner) { + List list = getTeaTrainingInfoDTOSNew(schoolId, systemOwner); + assert !Objects.requireNonNull(list).isEmpty(); + list.sort(new TotalScoreComparator()); + int i = 0; + for (TeaTrainingInfoDTO teaTrainingInfoDTO : list) { + i++; + teaTrainingInfoDTO.setRank(i); + } + return list; + } + + + private List getTeaTrainingInfoDTOSNew(String schoolId, String systemOwner) { + StuUserExample example1 = new StuUserExample(); + example1.createCriteria().andSchoolIdEqualTo(schoolId).andSystemOnwerEqualTo(systemOwner).andRoleIdEqualTo(4); + List stuUsers = userMapper.selectByExample(example1); + + // 查询学生用户列表 + if (stuUsers.isEmpty()) { + return Collections.emptyList(); + } + + // 批量获取班级信息 + Set classIds = stuUsers.stream().map(StuUser::getClassId).collect(Collectors.toSet()); + + StuClassExample example = new StuClassExample(); + List IDlist = new ArrayList<>(classIds); + example.createCriteria().andClassIdIn(IDlist).andSystemOwnerEqualTo(systemOwner); + + 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(); + stuTrainingExample.createCriteria().andUserIdIn(new ArrayList<>(userIds)); + List stuTrainingsWithBLOBs = trainingMapper.selectByExampleWithBLOBs(stuTrainingExample); + if (stuTrainingsWithBLOBs.isEmpty()) { + return Collections.emptyList(); + } + // 实训记录按用户ID分组 + Map> userIdToTrainingsMap = stuTrainingsWithBLOBs.stream().collect(Collectors.groupingBy(StuTrainingWithBLOBs::getUserId)); + + // 批量获取报告分数 + Set reportIds = stuTrainingsWithBLOBs.stream().map(StuTrainingWithBLOBs::getReportId).collect(Collectors.toSet()); + List trainingReports = trainingReportMapper.selectByPrimaryKeys(reportIds); + Map reportIdToScoreMap = trainingReports.stream().collect(Collectors.toMap(TrainingReport::getReportId, TrainingReport::getTeacherScore)); + // 获取总模块数量 + BigDecimal chapterNum = null; + try { + chapterNum = BigDecimal.valueOf(CourseAPI.getTotalChapterCount(systemOwner)); + } catch (IOException e) { + return null; + } + + // 遍历用户,计算分数并封装DTO + List list = new ArrayList<>(); + for (StuUser stuUser : stuUsers) { + List userTrainings = userIdToTrainingsMap.getOrDefault(stuUser.getUserid(), Collections.emptyList()); + if (userTrainings.isEmpty()) { + continue; + } + + TeaTrainingInfoDTO teaTrainingInfoDTO = new TeaTrainingInfoDTO(); + teaTrainingInfoDTO.setClassName(classIdToNameMap.get(stuUser.getClassId())); + teaTrainingInfoDTO.setStudentId(stuUser.getStudentId()); + teaTrainingInfoDTO.setName(stuUser.getName()); + teaTrainingInfoDTO.setUserId(stuUser.getUserid()); + + BigDecimal allProgress = BigDecimal.ZERO; + BigDecimal totalScore = BigDecimal.ZERO; + for (StuTrainingWithBLOBs training : userTrainings) { + allProgress = allProgress.add(Optional.ofNullable(training.getProgress()).orElse(BigDecimal.ZERO)); + String reportId = training.getReportId(); + if (reportId != null) { + BigDecimal reportScore = reportIdToScoreMap.getOrDefault(reportId, BigDecimal.ZERO); + if (BigDecimal.ZERO.compareTo(reportScore) != 0) { + 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); + } + teaTrainingInfoDTO.setTotalScore(score); + + BigDecimal progress = allProgress.divide(BigDecimal.valueOf(userTrainings.size()), 2, RoundingMode.HALF_UP); + teaTrainingInfoDTO.setProgress(progress); + + list.add(teaTrainingInfoDTO); + } + + return list; } @@ -70,22 +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 = getTeaTrainingInfoDTOS(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 @@ -168,50 +291,91 @@ 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; } //计算模块得分 - private BigDecimal getModuleScore(StuTrainingWithBLOBs stuTrainingWithBLOB) { + private BigDecimal getModuleScore(StuTrainingWithBLOBs stuTrainingWithBLOB, SysWeight sysWeight) { + BigDecimal knowledgeSummaryWeight = sysWeight.getKnowledgeSummaryWeight(); + BigDecimal resourceLearningWeight = sysWeight.getResourceLearningWeight(); + BigDecimal learningEvalWeight = sysWeight.getLearningEvalWeight(); + 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); + resourceLearningScore = resourceLearningScore.multiply(resourceLearningWeight); + learningEvalScore = learningEvalScore.multiply(learningEvalWeight).divide(BigDecimal.valueOf(100).setScale(2,RoundingMode.HALF_UP)); + expTrainingScore = expTrainingScore.multiply(expTrainingWeight).divide(BigDecimal.valueOf(100).setScale(2,RoundingMode.HALF_UP)); + return knowledgeSummaryScore.add(resourceLearningScore).add(learningEvalScore).add(expTrainingScore); } @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) { @@ -231,44 +395,50 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService { @Override public PageInfo getTheoryInfo(Integer index, Integer size, String schoolId, String classId, String keyWord, String systemOwner) { PageHelper.startPage(index, size); - List list = getStuTheoryRecordPageInfo(schoolId, classId, keyWord, systemOwner); +// List list = getStuTheoryRecordPageInfo(schoolId, classId, keyWord, systemOwner); + List list = stuTheoryRecordMapper.selectConditions(schoolId, classId, keyWord, systemOwner); PageInfo pageInfo = new PageInfo<>(list); return pageInfo; } - //查询方法 - private List getStuTheoryRecordPageInfo(String schoolId, String classId, String keyWord, String systemOwner) { - StuTheoryRecordExample s = new StuTheoryRecordExample(); - StuTheoryRecordExample.Criteria criteria = s.createCriteria(); - StuTheoryRecordExample.Criteria orCriteria = s.createCriteria(); - criteria.andSchoolIdEqualTo(schoolId).andSystemOwnerEqualTo(systemOwner); - orCriteria.andSchoolIdEqualTo(schoolId).andSystemOwnerEqualTo(systemOwner); - if (StringUtils.isNotBlank(classId)) { - criteria.andClassIdEqualTo(classId); - orCriteria.andClassIdEqualTo(classId); - } - if (StringUtils.isNotBlank(keyWord)) { - criteria.andStudentIdEqualTo(keyWord); - orCriteria.andNameEqualTo(keyWord); - } - s.or(orCriteria); - s.setOrderByClause("average_score ASC"); - return stuTheoryRecordMapper.selectByExample(s); - } +// //查询方法 +// private List getStuTheoryRecordPageInfo(String schoolId, String classId, String keyWord, String systemOwner) { +// StuTheoryRecordExample s = new StuTheoryRecordExample(); +// StuTheoryRecordExample.Criteria criteria = s.createCriteria(); +// StuTheoryRecordExample.Criteria orCriteria = s.createCriteria(); +// criteria.andSchoolIdEqualTo(schoolId).andSystemOwnerEqualTo(systemOwner); +// orCriteria.andSchoolIdEqualTo(schoolId).andSystemOwnerEqualTo(systemOwner); +// if (StringUtils.isNotBlank(classId)) { +// criteria.andClassIdEqualTo(classId); +// orCriteria.andClassIdEqualTo(classId); +// } +// if (StringUtils.isNotBlank(keyWord)) { +// criteria.andStudentIdEqualTo(keyWord); +// orCriteria.andNameEqualTo(keyWord); +// } +// s.or(orCriteria); +// s.setOrderByClause("average_score ASC"); +// return stuTheoryRecordMapper.selectByExample(s); +// } @Override - public void exportTheoryExamInfo(HttpServletResponse response, String classId, String schoolId) { + public void exportTheoryExamInfo(HttpServletResponse response, String classId, String schoolId, String systemOwner) { StuTheoryRecordExample s = new StuTheoryRecordExample(); StuTheoryRecordExample.Criteria criteria = s.createCriteria(); - criteria.andSchoolIdEqualTo(schoolId); + criteria.andSchoolIdEqualTo(schoolId).andSystemOwnerEqualTo(systemOwner); if (StringUtils.isNotBlank(classId)) { criteria.andClassIdEqualTo(classId); } 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 +449,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) { @@ -315,6 +485,79 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService { } + //todo 新的导出 + @Override + public void exportAllStuTrainingInfo(HttpServletResponse response, String schoolId, String systemOwner) throws IOException { + List trainingInfoDTOSNew = getTrainingInfoDTOSNew(schoolId, systemOwner); + List sysTwoCatalogs = CourseAPI.selectCourseList(systemOwner, schoolId); + List allChapterId = new ArrayList<>(); + for (SysTwoCatalog sysTwoCatalog : sysTwoCatalogs) { + List sysThreeCatalogs = CourseAPI.selectThreeCatalogListByTwoId(sysTwoCatalog.getTwoId(), schoolId); + allChapterId.addAll(sysThreeCatalogs); + } + Map chapterIds = allChapterId.stream().collect(Collectors.toMap(SysThreeCatalog::getThreeId, sysThreeCatalog -> sysThreeCatalog)); + List excelDtos = new ArrayList<>(); + + for (TeaTrainingInfoDTO teaTrainingInfoDTO : trainingInfoDTOSNew) { + ExcelDto excelDto = new ExcelDto(); + excelDto.setProgress(teaTrainingInfoDTO.getProgress()); + excelDto.setName(teaTrainingInfoDTO.getName()); + excelDto.setStudentId(teaTrainingInfoDTO.getStudentId()); + excelDto.setRank(teaTrainingInfoDTO.getRank()); + excelDto.setTotalScore(teaTrainingInfoDTO.getTotalScore()); + + String userId = teaTrainingInfoDTO.getUserId(); + StuTrainingExample stuTrainingExample = new StuTrainingExample(); + stuTrainingExample.createCriteria().andUserIdEqualTo(userId); + List stuTrainings = stuTrainingMapper.selectByExampleWithBLOBs(stuTrainingExample); + + LinkedHashMap map = new LinkedHashMap<>(); + LinkedHashMap chapterMap = new LinkedHashMap<>(); + + + 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()); + + StuTrainingDto scoreByChapterId = stuScoreService.getScoreByChapterId(schoolId, systemOwner, stuTraining, stuTrainingDto, sysCourseChapter); + + BigDecimal moduleScore = scoreByChapterId.getModuleScore(); + String taskModule = scoreByChapterId.getTaskModule(); + map.put(taskModule, moduleScore); + } + excelDto.setMap(map); + excelDtos.add(excelDto); + } + + //导出的表名 + String title = IdUtil.simpleUUID(); + //表中第一行表头字段 + String[] headers = {"排名", "姓名", "学号", "班级名称", "综合得分", "实训进度"}; + + List headerList = new ArrayList<>(Arrays.asList(headers)); // 将headers数组转换为List + for (Map.Entry stringBigDecimalEntry : chapterIds.entrySet()) { + String name = stringBigDecimalEntry.getValue().getThreeName(); + headerList.add(name); + } + headers = headerList.toArray(new String[0]); // 将List转回数组 + + //具体需要写入excel需要哪些字段,这些字段取自UserReward类,也就是上面的实际数据结果集的泛型 + List listColumn = Arrays.asList("rank", "name", "studentId", "className", "totalScore", "progress"); + try { + FilePortUtil.exportExcelNew(response, title, headers, excelDtos, listColumn); + } catch ( + Exception e) { + e.printStackTrace(); + } + } + + private List getTeaTrainingInfoDTOS(String schoolId, String keyWord, String classId, String systemOwner) { List stuUsers = userMapper.getByNameAndStudentID(schoolId, keyWord, classId, systemOwner); @@ -355,6 +598,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<>(); @@ -364,6 +612,7 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService { continue; } + TeaTrainingInfoDTO teaTrainingInfoDTO = new TeaTrainingInfoDTO(); teaTrainingInfoDTO.setClassName(classIdToNameMap.get(stuUser.getClassId())); teaTrainingInfoDTO.setStudentId(stuUser.getStudentId()); @@ -378,10 +627,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; diff --git a/src/main/java/com/sztzjy/financial_bigdata/util/excel/FilePortUtil.java b/src/main/java/com/sztzjy/financial_bigdata/util/excel/FilePortUtil.java index cc80810..6f1c2c6 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/util/excel/FilePortUtil.java +++ b/src/main/java/com/sztzjy/financial_bigdata/util/excel/FilePortUtil.java @@ -3,6 +3,7 @@ package com.sztzjy.financial_bigdata.util.excel; import com.github.xiaoymin.knife4j.core.util.CollectionUtils; import org.apache.commons.lang3.time.DateFormatUtils; import org.apache.poi.hssf.usermodel.*; +import org.geolatte.geom.M; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -10,9 +11,8 @@ import javax.servlet.http.HttpServletResponse; import java.beans.PropertyDescriptor; import java.lang.reflect.Field; import java.lang.reflect.Method; -import java.util.Date; -import java.util.Iterator; -import java.util.List; +import java.math.BigDecimal; +import java.util.*; /* * @author xcj @@ -83,6 +83,79 @@ public class FilePortUtil { } } + + public static void exportExcelNew(HttpServletResponse response, String title, String[] headers, List list, List containBean) throws Exception { + HSSFWorkbook workbook = null; + try { + workbook = new HSSFWorkbook(); + HSSFSheet sheet = workbook.createSheet(title); + HSSFRow row = sheet.createRow(0); + /*创建第一行表头*/ + for (short i = 0; i < headers.length; i++) { + HSSFCell cell = row.createCell(i); + HSSFRichTextString text = new HSSFRichTextString(headers[i]); + cell.setCellValue(text); + } + Iterator it = list.iterator(); + int index = 0; + while (it.hasNext()) { + index++; + row = sheet.createRow(index); + T t = (T) it.next(); + /*反射得到字段*/ + Field[] fields = t.getClass().getDeclaredFields(); + /*如果需要匹配*/ + if (CollectionUtils.isNotEmpty(containBean)) { + for (int j = 0; j < containBean.size(); j++) { + for (int i = 0; i < fields.length; i++) { + Field field = fields[i]; + if (!field.getName().equals(containBean.get(j))) + continue; + /*给每一列set值*/ + setCellValue(t, field, row, j); + } + } + } else { + for (int i = 0; i < fields.length; i++) { + Field field = fields[i]; + setCellValue(t, field, row, i); + } + } + + Field mapField = t.getClass().getDeclaredField("map"); + mapField.setAccessible(true); + List list1 = Arrays.asList(headers); + LinkedHashMap map = (LinkedHashMap) mapField.get(t); + for (Map.Entry entry : map.entrySet()) { + BigDecimal moduleScore = entry.getValue(); + String key = entry.getKey(); + for (String header : list1) { + if (key.equals(header)){ + // 处理 moduleScore,例如将其写入Excel 中对应的单元格 + int i = list1.indexOf(header); + HSSFCell cell = row.createCell(i); + if (moduleScore != null) { + cell.setCellValue(moduleScore.doubleValue()); + } + } + } + } + headers = list1.toArray(new String[0]); // 将List转回数组 + } + /*application/vnd.ms-excel告诉浏览器要下载的是个excel*/ + response.setContentType("application/vnd.ms-excel;charset=UTF-8"); + /*请求头设置,Content-Disposition为下载标识,attachment标识以附件方式下载*/ + response.addHeader("Content-Disposition", "attachment;filename=" + new String((title).getBytes(), "ISO8859-1") + ".xls"); + workbook.write(response.getOutputStream()); + } finally { + if (workbook != null) { + workbook.close(); + } + } + } + + + /** * 设置每一行中的列 * diff --git a/src/main/resources/mapper/StuTheoryRecordMapper.xml b/src/main/resources/mapper/StuTheoryRecordMapper.xml index 5cfe0bb..e3279bf 100644 --- a/src/main/resources/mapper/StuTheoryRecordMapper.xml +++ b/src/main/resources/mapper/StuTheoryRecordMapper.xml @@ -1,340 +1,366 @@ - - - - - - - - - - - - - - - - - - - - - - and ${criterion.condition} - - - and ${criterion.condition} #{criterion.value} - - - and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} - - - and ${criterion.condition} - - #{listItem} - - - + + + + + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + - - - - - - - - - - - - - - and ${criterion.condition} - - - and ${criterion.condition} #{criterion.value} - - - and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} - - - and ${criterion.condition} - - #{listItem} - - - + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + - - - - - - - user_id, school_id, class_id, name, student_id, exam_count, highest_score, lowest_score, + + + + user_id + , school_id, class_id, name, student_id, exam_count, highest_score, lowest_score, total_duration, average_score, system_owner - - - - - delete from stu_theory_record - where user_id = #{userId,jdbcType=VARCHAR} - - - delete from stu_theory_record - - - - - - insert into stu_theory_record (user_id, school_id, class_id, - name, student_id, exam_count, - highest_score, lowest_score, total_duration, - average_score, system_owner) - values (#{userId,jdbcType=VARCHAR}, #{schoolId,jdbcType=VARCHAR}, #{classId,jdbcType=VARCHAR}, - #{name,jdbcType=VARCHAR}, #{studentId,jdbcType=VARCHAR}, #{examCount,jdbcType=INTEGER}, - #{highestScore,jdbcType=DECIMAL}, #{lowestScore,jdbcType=DECIMAL}, #{totalDuration,jdbcType=INTEGER}, - #{averageScore,jdbcType=DECIMAL}, #{systemOwner,jdbcType=VARCHAR}) - - - insert into stu_theory_record - - - user_id, - - - school_id, - - - class_id, - - - name, - - - student_id, - - - exam_count, - - - highest_score, - - - lowest_score, - - - total_duration, - - - average_score, - - - system_owner, - - - - - #{userId,jdbcType=VARCHAR}, - - - #{schoolId,jdbcType=VARCHAR}, - - - #{classId,jdbcType=VARCHAR}, - - - #{name,jdbcType=VARCHAR}, - - - #{studentId,jdbcType=VARCHAR}, - - - #{examCount,jdbcType=INTEGER}, - - - #{highestScore,jdbcType=DECIMAL}, - - - #{lowestScore,jdbcType=DECIMAL}, - - - #{totalDuration,jdbcType=INTEGER}, - - - #{averageScore,jdbcType=DECIMAL}, - - - #{systemOwner,jdbcType=VARCHAR}, - - - - - - update stu_theory_record - - - user_id = #{record.userId,jdbcType=VARCHAR}, - - + + + + + delete + from stu_theory_record + where user_id = #{userId,jdbcType=VARCHAR} + + + delete from stu_theory_record + + + + + + insert into stu_theory_record (user_id, school_id, class_id, + name, student_id, exam_count, + highest_score, lowest_score, total_duration, + average_score, system_owner) + values (#{userId,jdbcType=VARCHAR}, #{schoolId,jdbcType=VARCHAR}, #{classId,jdbcType=VARCHAR}, + #{name,jdbcType=VARCHAR}, #{studentId,jdbcType=VARCHAR}, #{examCount,jdbcType=INTEGER}, + #{highestScore,jdbcType=DECIMAL}, #{lowestScore,jdbcType=DECIMAL}, #{totalDuration,jdbcType=INTEGER}, + #{averageScore,jdbcType=DECIMAL}, #{systemOwner,jdbcType=VARCHAR}) + + + insert into stu_theory_record + + + user_id, + + + school_id, + + + class_id, + + + name, + + + student_id, + + + exam_count, + + + highest_score, + + + lowest_score, + + + total_duration, + + + average_score, + + + system_owner, + + + + + #{userId,jdbcType=VARCHAR}, + + + #{schoolId,jdbcType=VARCHAR}, + + + #{classId,jdbcType=VARCHAR}, + + + #{name,jdbcType=VARCHAR}, + + + #{studentId,jdbcType=VARCHAR}, + + + #{examCount,jdbcType=INTEGER}, + + + #{highestScore,jdbcType=DECIMAL}, + + + #{lowestScore,jdbcType=DECIMAL}, + + + #{totalDuration,jdbcType=INTEGER}, + + + #{averageScore,jdbcType=DECIMAL}, + + + #{systemOwner,jdbcType=VARCHAR}, + + + + + + update stu_theory_record + + + user_id = #{record.userId,jdbcType=VARCHAR}, + + + school_id = #{record.schoolId,jdbcType=VARCHAR}, + + + class_id = #{record.classId,jdbcType=VARCHAR}, + + + name = #{record.name,jdbcType=VARCHAR}, + + + student_id = #{record.studentId,jdbcType=VARCHAR}, + + + exam_count = #{record.examCount,jdbcType=INTEGER}, + + + highest_score = #{record.highestScore,jdbcType=DECIMAL}, + + + lowest_score = #{record.lowestScore,jdbcType=DECIMAL}, + + + total_duration = #{record.totalDuration,jdbcType=INTEGER}, + + + average_score = #{record.averageScore,jdbcType=DECIMAL}, + + + system_owner = #{record.systemOwner,jdbcType=VARCHAR}, + + + + + + + + update stu_theory_record + set user_id = #{record.userId,jdbcType=VARCHAR}, school_id = #{record.schoolId,jdbcType=VARCHAR}, - - class_id = #{record.classId,jdbcType=VARCHAR}, - - name = #{record.name,jdbcType=VARCHAR}, - - student_id = #{record.studentId,jdbcType=VARCHAR}, - - exam_count = #{record.examCount,jdbcType=INTEGER}, - - highest_score = #{record.highestScore,jdbcType=DECIMAL}, - - lowest_score = #{record.lowestScore,jdbcType=DECIMAL}, - - total_duration = #{record.totalDuration,jdbcType=INTEGER}, - - average_score = #{record.averageScore,jdbcType=DECIMAL}, - - - system_owner = #{record.systemOwner,jdbcType=VARCHAR}, - - - - - - - - update stu_theory_record - set user_id = #{record.userId,jdbcType=VARCHAR}, - school_id = #{record.schoolId,jdbcType=VARCHAR}, - class_id = #{record.classId,jdbcType=VARCHAR}, - name = #{record.name,jdbcType=VARCHAR}, - student_id = #{record.studentId,jdbcType=VARCHAR}, - exam_count = #{record.examCount,jdbcType=INTEGER}, - highest_score = #{record.highestScore,jdbcType=DECIMAL}, - lowest_score = #{record.lowestScore,jdbcType=DECIMAL}, - total_duration = #{record.totalDuration,jdbcType=INTEGER}, - average_score = #{record.averageScore,jdbcType=DECIMAL}, - system_owner = #{record.systemOwner,jdbcType=VARCHAR} - - - - - - update stu_theory_record - - - school_id = #{schoolId,jdbcType=VARCHAR}, - - - class_id = #{classId,jdbcType=VARCHAR}, - - - name = #{name,jdbcType=VARCHAR}, - - - student_id = #{studentId,jdbcType=VARCHAR}, - - - exam_count = #{examCount,jdbcType=INTEGER}, - - - highest_score = #{highestScore,jdbcType=DECIMAL}, - - - lowest_score = #{lowestScore,jdbcType=DECIMAL}, - - - total_duration = #{totalDuration,jdbcType=INTEGER}, - - - average_score = #{averageScore,jdbcType=DECIMAL}, - - - system_owner = #{systemOwner,jdbcType=VARCHAR}, - - - where user_id = #{userId,jdbcType=VARCHAR} - - - update stu_theory_record - set school_id = #{schoolId,jdbcType=VARCHAR}, - class_id = #{classId,jdbcType=VARCHAR}, - name = #{name,jdbcType=VARCHAR}, - student_id = #{studentId,jdbcType=VARCHAR}, - exam_count = #{examCount,jdbcType=INTEGER}, - highest_score = #{highestScore,jdbcType=DECIMAL}, - lowest_score = #{lowestScore,jdbcType=DECIMAL}, - total_duration = #{totalDuration,jdbcType=INTEGER}, - average_score = #{averageScore,jdbcType=DECIMAL}, - system_owner = #{systemOwner,jdbcType=VARCHAR} - where user_id = #{userId,jdbcType=VARCHAR} - + system_owner = #{record.systemOwner,jdbcType=VARCHAR} + + + + + + update stu_theory_record + + + school_id = #{schoolId,jdbcType=VARCHAR}, + + + class_id = #{classId,jdbcType=VARCHAR}, + + + name = #{name,jdbcType=VARCHAR}, + + + student_id = #{studentId,jdbcType=VARCHAR}, + + + exam_count = #{examCount,jdbcType=INTEGER}, + + + highest_score = #{highestScore,jdbcType=DECIMAL}, + + + lowest_score = #{lowestScore,jdbcType=DECIMAL}, + + + total_duration = #{totalDuration,jdbcType=INTEGER}, + + + average_score = #{averageScore,jdbcType=DECIMAL}, + + + system_owner = #{systemOwner,jdbcType=VARCHAR}, + + + where user_id = #{userId,jdbcType=VARCHAR} + + + update stu_theory_record + set school_id = #{schoolId,jdbcType=VARCHAR}, + class_id = #{classId,jdbcType=VARCHAR}, + name = #{name,jdbcType=VARCHAR}, + student_id = #{studentId,jdbcType=VARCHAR}, + exam_count = #{examCount,jdbcType=INTEGER}, + highest_score = #{highestScore,jdbcType=DECIMAL}, + lowest_score = #{lowestScore,jdbcType=DECIMAL}, + total_duration = #{totalDuration,jdbcType=INTEGER}, + average_score = #{averageScore,jdbcType=DECIMAL}, + system_owner = #{systemOwner,jdbcType=VARCHAR} + where user_id = #{userId,jdbcType=VARCHAR} + - - - - - - + + + + + + - + SELECT ste.score, + str.total_duration, + str.exam_count, + ( + SELECT COUNT(*) AS `rank` + FROM stu_theory_exam + WHERE accuracy >= ( + SELECT accuracy + FROM stu_theory_exam + WHERE user_id = 4 + ORDER BY exam_time DESC + LIMIT 1 ) ) AS `rank` - FROM stu_theory_exam ste - JOIN stu_theory_record str ON ste.user_id = str.user_id - WHERE ste.user_id = 4 - AND ste.answered = 1 - AND ste.accuracy >= ( - SELECT accuracy - FROM stu_theory_exam - WHERE user_id = 4 - ORDER BY exam_time DESC - LIMIT 1 - ) - ORDER BY ste.exam_time DESC - LIMIT 1; - + FROM stu_theory_exam ste + JOIN stu_theory_record str + ON ste.user_id = str.user_id + WHERE ste.user_id = 4 + AND ste.answered = 1 + AND ste.accuracy >= ( + SELECT accuracy + FROM stu_theory_exam + WHERE user_id = 4 + ORDER BY exam_time DESC + LIMIT 1 + ) + ORDER BY ste.exam_time DESC + LIMIT 1; + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/StuUserMapper.xml b/src/main/resources/mapper/StuUserMapper.xml index aa558c3..f574baf 100644 --- a/src/main/resources/mapper/StuUserMapper.xml +++ b/src/main/resources/mapper/StuUserMapper.xml @@ -456,7 +456,7 @@ AND u.role_id = 4 AND u.school_id = #{schoolId} - AND student_id like CONCAT ('%',#{keyWord},'%') or name like CONCAT ('%',#{keyWord},'%') + AND (student_id like CONCAT ('%',#{keyWord},'%') or name like CONCAT ('%',#{keyWord},'%')) AND u.class_id = #{classId} @@ -491,7 +491,7 @@ AND school_id = #{schoolId} - AND student_id like CONCAT ('%',#{keyWord},'%') or name like CONCAT ('%',#{keyWord},'%') + AND (student_id like CONCAT ('%',#{keyWord},'%') or name like CONCAT ('%',#{keyWord},'%'))