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 327b991..0ee9402 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 @@ -3,9 +3,11 @@ package com.sztzjy.financial_bigdata.controller.tea; import cn.hutool.core.util.IdUtil; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; +import com.sztzjy.financial_bigdata.annotation.AnonymousAccess; import com.sztzjy.financial_bigdata.entity.*; import com.sztzjy.financial_bigdata.entity.tea_dto.TeaExamAndUserDto; import com.sztzjy.financial_bigdata.entity.tea_dto.TeaExamManageCountDto; +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.service.tea.ITeaGradeManageService; @@ -17,14 +19,22 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import org.apache.commons.lang3.StringUtils; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.apache.poi.xwpf.usermodel.XWPFDocument; +import org.apache.poi.xwpf.usermodel.XWPFParagraph; +import org.apache.poi.xwpf.usermodel.XWPFRun; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import java.io.FileOutputStream; +import java.io.IOException; import java.text.SimpleDateFormat; import java.util.*; @@ -33,8 +43,8 @@ import java.util.*; * @Date 2024/3/15 */ @RestController -@RequestMapping -@Api("老师端--成绩管理") +@RequestMapping("/tea/score") +@Api(tags = "老师端--成绩管理") public class TeaGradeManageController { @Autowired private TeaExamManageMapper teaExamManageMapper; @@ -48,7 +58,8 @@ public class TeaGradeManageController { private ITeaGradeManageService iTeaGradeManageService; @Autowired private TrainingReportMapper reportMapper; - + @Autowired + private TeaAndStudentExamMapper teaAndStudentExamMapper; @PostMapping("/getExamInfo") @ApiOperation("考试模式--页面展示") @@ -96,7 +107,6 @@ public class TeaGradeManageController { } - @PostMapping("/exportExam") @ApiOperation("考试模式--页面单个考试导出") public void exportExam() { @@ -104,19 +114,57 @@ public class TeaGradeManageController { } + @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()); + } @PostMapping("/getCountChart") - @ApiOperation("考试模式--图表统计接口") //TODO 待写 图表统计接口 - public void getCountChart() { + @ApiOperation("考试模式--图表统计接口") + public ResultEntity getCountChart(@RequestParam String examManageId, + @RequestParam (required = false)String classId) { + return new ResultEntity(iTeaGradeManageService.getCountChart(examManageId,classId)); + } + + + @PostMapping("/getClassByExamManageId") + @ApiOperation("考试模式--图表统计接口班级下拉框返回classID和班级名") //只显示新建实训时添加的班级 + public ResultEntity> getClassByExamManageId(@RequestParam String examManageId) { + TeaAndStudentExamExample teaAndStudentExamExample = new TeaAndStudentExamExample(); + teaAndStudentExamExample.createCriteria().andExamManageIdEqualTo(examManageId); + List teaAndStudentExams = teaAndStudentExamMapper.selectByExample(teaAndStudentExamExample); + Map map = new HashMap<>(); + for (TeaAndStudentExam teaAndStudentExam : teaAndStudentExams) { + String classId = teaAndStudentExam.getClassId(); + StuClass stuClass = stuClassMapper.selectByPrimaryKey(classId); + String className = stuClass.getClassName(); + map.put(classId, className); + } + return new ResultEntity>(map); } + @PostMapping("/getGradeReport") @ApiOperation("考试模式--成绩报告接口") //TODO 待写 成绩报告接口 public void getGradeReport() { } + @PostMapping("/getGradeDetails") @ApiOperation("考试模式--成绩详情页面") //TODO 待写 成绩详情页面 public void getGradeDetails() { @@ -124,7 +172,6 @@ public class TeaGradeManageController { } - @PostMapping("/exportRank") @ApiOperation("考试模式--成绩排名页面导出") public void exportRank(HttpServletResponse response, @@ -209,7 +256,6 @@ public class TeaGradeManageController { } - @PostMapping("/exportTrainingInfo") @ApiOperation("练习模式--页面导出") public void exportTrainingInfo(HttpServletResponse response, @@ -220,7 +266,6 @@ public class TeaGradeManageController { } - @PostMapping("/getTrainingDetailsInfo") @ApiOperation("练习模式--详情页面展示") public void getTrainingDetailsInfo() { //todo 待写 详情页面展示 @@ -246,7 +291,6 @@ public class TeaGradeManageController { } - @PostMapping("/getReportCorrect") @ApiOperation("练习模式--实训报告评阅页面") public void getReportCorrect() { //todo 待写 实训报告评阅页面 diff --git a/src/main/java/com/sztzjy/financial_bigdata/controller/tea/UserController.java b/src/main/java/com/sztzjy/financial_bigdata/controller/tea/UserController.java index d7a62d2..e4547d1 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/controller/tea/UserController.java +++ b/src/main/java/com/sztzjy/financial_bigdata/controller/tea/UserController.java @@ -42,7 +42,6 @@ public class UserController { private ITeaUserService userService; - @PostMapping("/login") @ApiOperation("登录接口") public ResultEntity login() { //todo 保存日志/与智云打通 @@ -50,7 +49,6 @@ public class UserController { } - /* 添加班级 * @author xcj * @Date 2024/3/11 @@ -299,10 +297,10 @@ public class UserController { @PostMapping("/selectLogs") @ApiOperation("学生管理--日志查询") public ResultEntity> selectLogs(@RequestParam Integer index, - @RequestParam Integer size, - @RequestParam String schoolId, - @RequestParam(required = false) String studentId, - @RequestParam(required = false) String classId) { + @RequestParam Integer size, + @RequestParam String schoolId, + @RequestParam(required = false) String studentId, + @RequestParam(required = false) String classId) { return userService.selectLogs(index, size, schoolId, studentId, classId); } @@ -314,6 +312,6 @@ public class UserController { @RequestParam String schoolId, @RequestParam(required = false) String studentId, @RequestParam(required = false) String classId) { - userService.logExport(response,schoolId, studentId, classId); + userService.logExport(response, schoolId, studentId, classId); } } \ No newline at end of file diff --git a/src/main/java/com/sztzjy/financial_bigdata/entity/TeaExamManage.java b/src/main/java/com/sztzjy/financial_bigdata/entity/TeaExamManage.java index 79d50de..89ee09c 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/entity/TeaExamManage.java +++ b/src/main/java/com/sztzjy/financial_bigdata/entity/TeaExamManage.java @@ -17,9 +17,6 @@ public class TeaExamManage { @ApiModelProperty("学校ID") private String schoolId; - @ApiModelProperty("中间表ID") - private String teaAndStudentExamId; - @ApiModelProperty("这里为发布考试的人ID") private String userId; @@ -72,14 +69,6 @@ public class TeaExamManage { this.schoolId = schoolId == null ? null : schoolId.trim(); } - public String getTeaAndStudentExamId() { - return teaAndStudentExamId; - } - - public void setTeaAndStudentExamId(String teaAndStudentExamId) { - this.teaAndStudentExamId = teaAndStudentExamId == null ? null : teaAndStudentExamId.trim(); - } - public String getUserId() { return userId; } diff --git a/src/main/java/com/sztzjy/financial_bigdata/entity/TeaExamManageExample.java b/src/main/java/com/sztzjy/financial_bigdata/entity/TeaExamManageExample.java index d3680fe..5f7e044 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/entity/TeaExamManageExample.java +++ b/src/main/java/com/sztzjy/financial_bigdata/entity/TeaExamManageExample.java @@ -246,76 +246,6 @@ public class TeaExamManageExample { return (Criteria) this; } - public Criteria andTeaAndStudentExamIdIsNull() { - addCriterion("tea_and_student_exam_id is null"); - return (Criteria) this; - } - - public Criteria andTeaAndStudentExamIdIsNotNull() { - addCriterion("tea_and_student_exam_id is not null"); - return (Criteria) this; - } - - public Criteria andTeaAndStudentExamIdEqualTo(String value) { - addCriterion("tea_and_student_exam_id =", value, "teaAndStudentExamId"); - return (Criteria) this; - } - - public Criteria andTeaAndStudentExamIdNotEqualTo(String value) { - addCriterion("tea_and_student_exam_id <>", value, "teaAndStudentExamId"); - return (Criteria) this; - } - - public Criteria andTeaAndStudentExamIdGreaterThan(String value) { - addCriterion("tea_and_student_exam_id >", value, "teaAndStudentExamId"); - return (Criteria) this; - } - - public Criteria andTeaAndStudentExamIdGreaterThanOrEqualTo(String value) { - addCriterion("tea_and_student_exam_id >=", value, "teaAndStudentExamId"); - return (Criteria) this; - } - - public Criteria andTeaAndStudentExamIdLessThan(String value) { - addCriterion("tea_and_student_exam_id <", value, "teaAndStudentExamId"); - return (Criteria) this; - } - - public Criteria andTeaAndStudentExamIdLessThanOrEqualTo(String value) { - addCriterion("tea_and_student_exam_id <=", value, "teaAndStudentExamId"); - return (Criteria) this; - } - - public Criteria andTeaAndStudentExamIdLike(String value) { - addCriterion("tea_and_student_exam_id like", value, "teaAndStudentExamId"); - return (Criteria) this; - } - - public Criteria andTeaAndStudentExamIdNotLike(String value) { - addCriterion("tea_and_student_exam_id not like", value, "teaAndStudentExamId"); - return (Criteria) this; - } - - public Criteria andTeaAndStudentExamIdIn(List values) { - addCriterion("tea_and_student_exam_id in", values, "teaAndStudentExamId"); - return (Criteria) this; - } - - public Criteria andTeaAndStudentExamIdNotIn(List values) { - addCriterion("tea_and_student_exam_id not in", values, "teaAndStudentExamId"); - return (Criteria) this; - } - - public Criteria andTeaAndStudentExamIdBetween(String value1, String value2) { - addCriterion("tea_and_student_exam_id between", value1, value2, "teaAndStudentExamId"); - return (Criteria) this; - } - - public Criteria andTeaAndStudentExamIdNotBetween(String value1, String value2) { - addCriterion("tea_and_student_exam_id not between", value1, value2, "teaAndStudentExamId"); - return (Criteria) this; - } - public Criteria andUserIdIsNull() { addCriterion("user_id is null"); return (Criteria) this; diff --git a/src/main/java/com/sztzjy/financial_bigdata/entity/tea_dto/TeaExaminationDetailsDto.java b/src/main/java/com/sztzjy/financial_bigdata/entity/tea_dto/TeaExaminationDetailsDto.java new file mode 100644 index 0000000..8387e65 --- /dev/null +++ b/src/main/java/com/sztzjy/financial_bigdata/entity/tea_dto/TeaExaminationDetailsDto.java @@ -0,0 +1,50 @@ +package com.sztzjy.financial_bigdata.entity.tea_dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author xcj + * @Date 2024/4/2 + */ +//查看图标按钮 +@Data +@NoArgsConstructor +public class TeaExaminationDetailsDto { + @ApiModelProperty("考试名称") + private String examName; + + @ApiModelProperty("考试人数") + private Integer examNum; + + @ApiModelProperty("实际考试人数") + private Integer examActualNum; + + @ApiModelProperty("优秀人数") + private Integer excellentNumber; + + @ApiModelProperty("良好人数") + private Integer goodNumber; + + @ApiModelProperty("一般人数") + private Integer generalNum; + + @ApiModelProperty("及格人数") + private Integer examPassNum; + + @ApiModelProperty("不及格人数") + private Integer failingNumber; + + @ApiModelProperty("最高分") + private Integer topScore; + + @ApiModelProperty("平均分") + private Integer averageScore; + + @ApiModelProperty("最低分") + private Integer lossScore; + + @ApiModelProperty("错误率最高的三个案例名称") + private String caseName; +} diff --git a/src/main/java/com/sztzjy/financial_bigdata/mapper/StuUserMapper.java b/src/main/java/com/sztzjy/financial_bigdata/mapper/StuUserMapper.java index fff98ce..eaf4af1 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/mapper/StuUserMapper.java +++ b/src/main/java/com/sztzjy/financial_bigdata/mapper/StuUserMapper.java @@ -34,4 +34,19 @@ public interface StuUserMapper { @Select("select DISTINCT stu_userinfo.school_name from stu_users where school_id =#{schoolId}") String selectSchoolNameById(@Param("schoolId")String schoolId); + + @Select("SELECT SUM(user_count) AS total_user_count " + + "FROM ( " + + " SELECT class_id, COUNT(*) AS user_count " + + " FROM stu_userinfo " + + " WHERE class_id IN (SELECT class_id " + + " FROM tea_and_student_exam " + + " WHERE exam_manage_id = #{examManageId}" + + " " + + " AND class_id = #{classId}" + + " " + + " ) " + + " GROUP BY class_id " + + ") AS subquery;") + int getAllUsersByExamManageId(@Param("examManageId") String examManageId, @Param("classId") String classId); } \ No newline at end of file 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 7d7a1c1..cb573e5 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 @@ -1,6 +1,7 @@ package com.sztzjy.financial_bigdata.service.tea; import com.github.pagehelper.PageInfo; +import com.sztzjy.financial_bigdata.entity.tea_dto.TeaExaminationDetailsDto; import com.sztzjy.financial_bigdata.entity.tea_dto.TeaTrainingInfoDTO; import javax.servlet.http.HttpServletResponse; @@ -14,4 +15,7 @@ public interface ITeaGradeManageService { PageInfo getTrainingInfo(Integer index, Integer size, String schoolId, String keyWord, String classId); void exportTrainingInfo(HttpServletResponse response, String schoolId, String keyWord, String classId); + + TeaExaminationDetailsDto getCountChart(String examManageId,String classId); + } diff --git a/src/main/java/com/sztzjy/financial_bigdata/service/tea/impl/TeaExamManageServiceImpl.java b/src/main/java/com/sztzjy/financial_bigdata/service/tea/impl/TeaExamManageServiceImpl.java index 8211d79..c24e6a6 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/service/tea/impl/TeaExamManageServiceImpl.java +++ b/src/main/java/com/sztzjy/financial_bigdata/service/tea/impl/TeaExamManageServiceImpl.java @@ -1,8 +1,11 @@ package com.sztzjy.financial_bigdata.service.tea.impl; +import cn.hutool.core.util.IdUtil; +import com.sztzjy.financial_bigdata.entity.TeaAndStudentExam; import com.sztzjy.financial_bigdata.entity.TeaExamManageWithBLOBs; import com.sztzjy.financial_bigdata.entity.tea_dto.TeaExamManageDto; import com.sztzjy.financial_bigdata.mapper.SysObjectiveQuestionMapper; +import com.sztzjy.financial_bigdata.mapper.TeaAndStudentExamMapper; import com.sztzjy.financial_bigdata.mapper.TeaExamManageMapper; import com.sztzjy.financial_bigdata.service.tea.ITeaExamManageService; import com.sztzjy.financial_bigdata.util.ResultEntity; @@ -14,6 +17,8 @@ import org.springframework.http.HttpStatus; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; +import java.util.UUID; + /** * @Author xcj * @Date 2024/3/14 @@ -26,7 +31,8 @@ public class TeaExamManageServiceImpl implements ITeaExamManageService { private TeaExamManageMapper teaExamManageMapper; @Autowired private SysObjectiveQuestionMapper sysObjectiveQuestionMapper; - + @Autowired + private TeaAndStudentExamMapper teaAndStudentExamMapper; /* 新增考试 * @author xcj @@ -35,7 +41,7 @@ public class TeaExamManageServiceImpl implements ITeaExamManageService { @Override public ResultEntity addExam(TeaExamManageDto teaExamManagedto) { TeaExamManageWithBLOBs teaExamManageWithBLOBs = new TeaExamManageWithBLOBs(); - BeanUtils.copyProperties(teaExamManagedto, teaExamManageWithBLOBs); //todo 需要修改 classid + BeanUtils.copyProperties(teaExamManagedto, teaExamManageWithBLOBs); //上传图片 if (teaExamManagedto.getFile() != null) { MultipartFile file = teaExamManagedto.getFile(); @@ -54,6 +60,17 @@ public class TeaExamManageServiceImpl implements ITeaExamManageService { if (teaExamManageWithBLOBs.getCaseWeight() == null || teaExamManageWithBLOBs.getObjectiveWeight() == null) { return new ResultEntity<>(HttpStatus.BAD_REQUEST, "请输入题型得分权重!"); } + String examManageId = IdUtil.randomUUID(); + //将班级ID新增到中间表 + String[] split = teaExamManagedto.getClassId().split(","); + for (String s : split) { + TeaAndStudentExam teaAndStudentExam = new TeaAndStudentExam(); + teaAndStudentExam.setExamManageId(examManageId); + teaAndStudentExam.setClassId(s); + teaAndStudentExam.setId(IdUtil.randomUUID()); + teaAndStudentExamMapper.insert(teaAndStudentExam); + } + teaExamManageWithBLOBs.setExamManageId(examManageId); teaExamManageMapper.insert(teaExamManageWithBLOBs); return new ResultEntity<>(HttpStatus.OK, "添加考试成功!"); } 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 074d3ab..aca2fdc 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 @@ -4,6 +4,7 @@ import cn.hutool.core.util.IdUtil; import com.github.pagehelper.PageInfo; import com.sztzjy.financial_bigdata.entity.*; 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.service.tea.ITeaGradeManageService; @@ -37,13 +38,18 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService { private SysWeightMapper sysWeightMapper; @Autowired private TrainingReportMapper trainingReportMapper; - + @Autowired + private TeaExamManageMapper teaExamManageMapper; + @Autowired + private TeaAndStudentExamMapper teaAndStudentExamMapper; + @Autowired + private StuStudentExamMapper studentExamMapper; @Override public PageInfo getTrainingInfo(Integer index, Integer size, String schoolId, String keyWord, String classId) { List list = getTeaTrainingInfoDTOS(schoolId, keyWord, classId); list.sort(new TotalScoreComparator()); - int i =0; + int i = 0; for (TeaTrainingInfoDTO teaTrainingInfoDTO : list) { i++; teaTrainingInfoDTO.setRank(i); @@ -52,12 +58,14 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService { } - /**进度字段类型为int 无法添加‘%’ + /** + * 进度字段类型为int 无法添加‘%’ + * * @author xcj * @Date 2024/3/19 */ @Override - public void exportTrainingInfo(HttpServletResponse response,String schoolId, String keyWord, String classId) { + public void exportTrainingInfo(HttpServletResponse response, String schoolId, String keyWord, String classId) { List list = getTeaTrainingInfoDTOS(schoolId, keyWord, classId); //导出的表名 String title = IdUtil.simpleUUID(); @@ -73,6 +81,86 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService { } } + //饼形图 + @Override + public TeaExaminationDetailsDto getCountChart(String examManageId,String classId) { + int passNum = 0; //及格人数 + int topScore = 0; //最高分 + int lowScore = 0; //最低分 + int avgScore = 0; //平均分 + int excellentNum = 0; //优秀人数 90-100 + int goodNum = 0; //良好人数 80-89 + int generalNum = 0; //一般人数 60-79 + int failNumber = 0; //不及格人数 + //根据考试ID查出所有user的数量 + int sumUserCount = userMapper.getAllUsersByExamManageId(examManageId,classId); //获取老师指定的参加考试的人数 + TeaExaminationDetailsDto teaExaminationDetailsDto = new TeaExaminationDetailsDto(); + teaExaminationDetailsDto.setExamNum(sumUserCount); + TeaExamManageWithBLOBs teaExamManageWithBLOBs = teaExamManageMapper.selectByPrimaryKey(examManageId); + teaExaminationDetailsDto.setExamName(teaExamManageWithBLOBs.getExamName()); + //实考人数 查出考试ID下有多少条数据 + StuStudentExamExample studentExamExample = new StuStudentExamExample(); + StuStudentExamExample.Criteria criteria = studentExamExample.createCriteria(); + criteria.andExamManageIdEqualTo(examManageId); + if (StringUtils.isNotBlank(classId)){ + criteria.andClassIdEqualTo(classId); + } + List stuStudentExamWithBLOBs = studentExamMapper.selectByExampleWithBLOBs(studentExamExample); + if (stuStudentExamWithBLOBs.isEmpty()) { + teaExaminationDetailsDto.setExamActualNum(0); //为空代表没学生提交考试 实考人数为0 + } else { + teaExaminationDetailsDto.setExamActualNum(stuStudentExamWithBLOBs.size()); //否则为集合的长度 + for (StuStudentExamWithBLOBs stuStudentExamWithBLOB : stuStudentExamWithBLOBs) { //不为就求分数 + BigDecimal score = stuStudentExamWithBLOB.getTotalScore(); + int passThreshold = 60; // 60是及格分数 + int totalStudents = stuStudentExamWithBLOBs.size(); + int totalScore = 0; + totalScore += score.intValue(); + + if (score.intValue() >= passThreshold) { + passNum++; + } + + // 更新最高分和最低分 + if (score.intValue() > topScore) { + topScore = score.intValue(); + } + if (score.intValue() < lowScore) { + lowScore = score.intValue(); + } + + // 更新不同成绩等级的学生人数 + if (score.intValue() >= 90) { + excellentNum++; + } else if (score.intValue() >= 80) { + goodNum++; + } else if (score.intValue() >= 60) { + generalNum++; + } else { + failNumber++; + } +// 计算平均分 + if (totalStudents > 0) { + avgScore = totalScore / totalStudents; + } +// 将计算出的值设置到 TeaExaminationDetailsDto 对象中 + teaExaminationDetailsDto.setExamPassNum(passNum); + teaExaminationDetailsDto.setTopScore(topScore); + teaExaminationDetailsDto.setLossScore(lowScore); + teaExaminationDetailsDto.setAverageScore(avgScore); + teaExaminationDetailsDto.setExcellentNumber(excellentNum); + teaExaminationDetailsDto.setGoodNumber(goodNum); + teaExaminationDetailsDto.setGeneralNum(generalNum); + teaExaminationDetailsDto.setFailingNumber(failNumber); + teaExaminationDetailsDto.setCaseName(""); //todo 补充 暂时没有 + +// 返回填充好数值的 teaExaminationDetailsDto 对象 + } + } + return teaExaminationDetailsDto; + } + + private List getTeaTrainingInfoDTOS(String schoolId, String keyWord, String classId) { StuUserExample userExample = new StuUserExample(); @@ -114,19 +202,19 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService { teaTrainingInfoDTO.setProgress(stuTrainingWithBLOB.getProgress()); BigDecimal totalScore = BigDecimal.valueOf(0); if (reportScore != null && BigDecimal.ZERO.compareTo(reportScore) == 0) { - totalScore = totalScore.add(reportScore.multiply(reportWeight).setScale(2,RoundingMode.HALF_UP)); + totalScore = totalScore.add(reportScore.multiply(reportWeight).setScale(2, RoundingMode.HALF_UP)); } if (expTrainingScore != null && BigDecimal.ZERO.compareTo(expTrainingScore) == 0) { - totalScore = totalScore.add(expTrainingScore.multiply(expTrainingWeight).setScale(2,RoundingMode.HALF_UP)); + totalScore = totalScore.add(expTrainingScore.multiply(expTrainingWeight).setScale(2, RoundingMode.HALF_UP)); } if (knowledgeSummaryScore != null && BigDecimal.ZERO.compareTo(knowledgeSummaryScore) == 0) { - totalScore = totalScore.add(knowledgeSummaryScore.multiply(knowledgeSummaryWeight).setScale(2,RoundingMode.HALF_UP)); + totalScore = totalScore.add(knowledgeSummaryScore.multiply(knowledgeSummaryWeight).setScale(2, RoundingMode.HALF_UP)); } if (resourceLearningScore != null && BigDecimal.ZERO.compareTo(resourceLearningScore) == 0) { - totalScore = totalScore.add(resourceLearningScore.multiply(resourceLearningWeight).setScale(2,RoundingMode.HALF_UP)); + totalScore = totalScore.add(resourceLearningScore.multiply(resourceLearningWeight).setScale(2, RoundingMode.HALF_UP)); } if (learningEvalScore != null && BigDecimal.ZERO.compareTo(learningEvalScore) == 0) { - totalScore = totalScore.add(learningEvalScore.multiply(learningEvalWeight).setScale(2,RoundingMode.HALF_UP)); + totalScore = totalScore.add(learningEvalScore.multiply(learningEvalWeight).setScale(2, RoundingMode.HALF_UP)); } teaTrainingInfoDTO.setTotalScore(totalScore); list.add(teaTrainingInfoDTO); @@ -137,7 +225,6 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService { } - public class TotalScoreComparator implements Comparator { @Override public int compare(TeaTrainingInfoDTO o1, TeaTrainingInfoDTO o2) { diff --git a/src/main/resources/mapper/TeaExamManageMapper.xml b/src/main/resources/mapper/TeaExamManageMapper.xml index 88c3357..e2c579a 100644 --- a/src/main/resources/mapper/TeaExamManageMapper.xml +++ b/src/main/resources/mapper/TeaExamManageMapper.xml @@ -4,7 +4,6 @@ - @@ -86,9 +85,9 @@ - exam_manage_id, school_id, tea_and_student_exam_id, user_id, exam_name, start_time, - end_time, logo_address, exam_Description, Objective_weight, case_weight, single_score, - many_score, judge_score, case_score + exam_manage_id, school_id, user_id, exam_name, start_time, end_time, logo_address, + exam_Description, Objective_weight, case_weight, single_score, many_score, judge_score, + case_score single_idList, many_idList, judge_idList, case_idList, single_answer, many_answer, @@ -143,22 +142,22 @@ - insert into tea_exam_manage (exam_manage_id, school_id, tea_and_student_exam_id, - user_id, exam_name, start_time, - end_time, logo_address, exam_Description, - Objective_weight, case_weight, single_score, - many_score, judge_score, case_score, - single_idList, many_idList, judge_idList, - case_idList, single_answer, many_answer, - judge_answer) - values (#{examManageId,jdbcType=VARCHAR}, #{schoolId,jdbcType=VARCHAR}, #{teaAndStudentExamId,jdbcType=VARCHAR}, - #{userId,jdbcType=VARCHAR}, #{examName,jdbcType=VARCHAR}, #{startTime,jdbcType=TIMESTAMP}, - #{endTime,jdbcType=TIMESTAMP}, #{logoAddress,jdbcType=VARCHAR}, #{examDescription,jdbcType=VARCHAR}, - #{objectiveWeight,jdbcType=DECIMAL}, #{caseWeight,jdbcType=DECIMAL}, #{singleScore,jdbcType=DECIMAL}, - #{manyScore,jdbcType=DECIMAL}, #{judgeScore,jdbcType=DECIMAL}, #{caseScore,jdbcType=DECIMAL}, - #{singleIdlist,jdbcType=LONGVARCHAR}, #{manyIdlist,jdbcType=LONGVARCHAR}, #{judgeIdlist,jdbcType=LONGVARCHAR}, - #{caseIdlist,jdbcType=LONGVARCHAR}, #{singleAnswer,jdbcType=LONGVARCHAR}, #{manyAnswer,jdbcType=LONGVARCHAR}, - #{judgeAnswer,jdbcType=LONGVARCHAR}) + insert into tea_exam_manage (exam_manage_id, school_id, user_id, + exam_name, start_time, end_time, + logo_address, exam_Description, Objective_weight, + case_weight, single_score, many_score, + judge_score, case_score, single_idList, + many_idList, judge_idList, case_idList, + single_answer, many_answer, judge_answer + ) + values (#{examManageId,jdbcType=VARCHAR}, #{schoolId,jdbcType=VARCHAR}, #{userId,jdbcType=VARCHAR}, + #{examName,jdbcType=VARCHAR}, #{startTime,jdbcType=TIMESTAMP}, #{endTime,jdbcType=TIMESTAMP}, + #{logoAddress,jdbcType=VARCHAR}, #{examDescription,jdbcType=VARCHAR}, #{objectiveWeight,jdbcType=DECIMAL}, + #{caseWeight,jdbcType=DECIMAL}, #{singleScore,jdbcType=DECIMAL}, #{manyScore,jdbcType=DECIMAL}, + #{judgeScore,jdbcType=DECIMAL}, #{caseScore,jdbcType=DECIMAL}, #{singleIdlist,jdbcType=LONGVARCHAR}, + #{manyIdlist,jdbcType=LONGVARCHAR}, #{judgeIdlist,jdbcType=LONGVARCHAR}, #{caseIdlist,jdbcType=LONGVARCHAR}, + #{singleAnswer,jdbcType=LONGVARCHAR}, #{manyAnswer,jdbcType=LONGVARCHAR}, #{judgeAnswer,jdbcType=LONGVARCHAR} + ) insert into tea_exam_manage @@ -169,9 +168,6 @@ school_id, - - tea_and_student_exam_id, - user_id, @@ -237,9 +233,6 @@ #{schoolId,jdbcType=VARCHAR}, - - #{teaAndStudentExamId,jdbcType=VARCHAR}, - #{userId,jdbcType=VARCHAR}, @@ -314,9 +307,6 @@ school_id = #{record.schoolId,jdbcType=VARCHAR}, - - tea_and_student_exam_id = #{record.teaAndStudentExamId,jdbcType=VARCHAR}, - user_id = #{record.userId,jdbcType=VARCHAR}, @@ -383,7 +373,6 @@ update tea_exam_manage set exam_manage_id = #{record.examManageId,jdbcType=VARCHAR}, school_id = #{record.schoolId,jdbcType=VARCHAR}, - tea_and_student_exam_id = #{record.teaAndStudentExamId,jdbcType=VARCHAR}, user_id = #{record.userId,jdbcType=VARCHAR}, exam_name = #{record.examName,jdbcType=VARCHAR}, start_time = #{record.startTime,jdbcType=TIMESTAMP}, @@ -411,7 +400,6 @@ update tea_exam_manage set exam_manage_id = #{record.examManageId,jdbcType=VARCHAR}, school_id = #{record.schoolId,jdbcType=VARCHAR}, - tea_and_student_exam_id = #{record.teaAndStudentExamId,jdbcType=VARCHAR}, user_id = #{record.userId,jdbcType=VARCHAR}, exam_name = #{record.examName,jdbcType=VARCHAR}, start_time = #{record.startTime,jdbcType=TIMESTAMP}, @@ -434,9 +422,6 @@ school_id = #{schoolId,jdbcType=VARCHAR}, - - tea_and_student_exam_id = #{teaAndStudentExamId,jdbcType=VARCHAR}, - user_id = #{userId,jdbcType=VARCHAR}, @@ -500,7 +485,6 @@ update tea_exam_manage set school_id = #{schoolId,jdbcType=VARCHAR}, - tea_and_student_exam_id = #{teaAndStudentExamId,jdbcType=VARCHAR}, user_id = #{userId,jdbcType=VARCHAR}, exam_name = #{examName,jdbcType=VARCHAR}, start_time = #{startTime,jdbcType=TIMESTAMP}, @@ -525,7 +509,6 @@ update tea_exam_manage set school_id = #{schoolId,jdbcType=VARCHAR}, - tea_and_student_exam_id = #{teaAndStudentExamId,jdbcType=VARCHAR}, user_id = #{userId,jdbcType=VARCHAR}, exam_name = #{examName,jdbcType=VARCHAR}, start_time = #{startTime,jdbcType=TIMESTAMP},