增加统计综合得分逻辑在查询和导出接口中 屏蔽不用的接口

master
xiaoCJ 3 months ago
parent c99d1dba9c
commit 2c7c6742b2

@ -191,30 +191,6 @@ public class TeaGradeManageController {
} }
// @GetMapping("/exportExam")
// @ApiOperation("考试模式--页面单个考试导出")
public void exportExam() {
//TODO 待写 页面单个考试导出
}
// @AnonymousAccess
// @GetMapping("/test")
// @ApiOperation("测试导出")
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
response.setContentType("application/vnd.openxmlformats-officedocument.wordprocessingml.document");
response.setHeader("Content-Disposition", "attachment; filename=exam_result.docx");
XWPFDocument document = new XWPFDocument();
XWPFParagraph paragraph = document.createParagraph();
XWPFRun run = paragraph.createRun();
run.setText("Python程序设计2022-2023学年度第一学期期末考试\n"
+ "答题人:沙志梅 学号21200780 课程Python程序设计 班级21金融科技华强2 提交时间2022-12-02 10:42 ip10.100.66.8 考试得分: 82 分\n"
+ "一. 单选题 (共15题,45分\n"
+ "1.赋值语句... (这里是你的题目内容)");
document.write(response.getOutputStream());
}
@AnonymousAccess @AnonymousAccess
@PostMapping("/getCountChart") @PostMapping("/getCountChart")
@ -448,21 +424,21 @@ public class TeaGradeManageController {
return new ResultEntity<PageInfo<TeaTrainingInfoDTO>>(iTeaGradeManageService.getTrainingInfo(index, size, schoolId, keyWord, classId, systemOwner)); return new ResultEntity<PageInfo<TeaTrainingInfoDTO>>(iTeaGradeManageService.getTrainingInfo(index, size, schoolId, keyWord, classId, systemOwner));
} }
@AnonymousAccess // @AnonymousAccess
@GetMapping("/exportTrainingInfo") // @GetMapping("/exportTrainingInfo")
@ApiOperation("***练习模式--页面导出") // @ApiOperation("***练习模式--页面导出")
public void exportTrainingInfo(HttpServletResponse response, // public void exportTrainingInfo(HttpServletResponse response,
@RequestParam String schoolId, // @RequestParam String schoolId,
@ApiParam("学号或姓名搜索框") @RequestParam(required = false) String keyWord, // @ApiParam("学号或姓名搜索框") @RequestParam(required = false) String keyWord,
@RequestParam(required = false) String classId, // @RequestParam(required = false) String classId,
@RequestParam String systemOwner) { // @RequestParam String systemOwner) {
iTeaGradeManageService.exportTrainingInfo(response, schoolId, keyWord, classId, systemOwner); // iTeaGradeManageService.exportTrainingInfo(response, schoolId, keyWord, classId, systemOwner);
} // }
//
// @AnonymousAccess // @AnonymousAccess
// @PostMapping("/getTrainingDetailsInfo") // @PostMapping("/getTrainingDetailsInfo")
// @ApiOperation("练习模式--详情页面展示") // @ApiOperation("练习模式--详情页面展示")
// public ResultEntity<List<TeaTrainingDto>> getTrainingDetailsInfo(@RequestParam String userId) { // public ResultEntity<List<StuTrainingDto>> getTrainingDetailsInfo(@RequestParam String userId) {
// try { // try {
// return new ResultEntity<>(iTeaGradeManageService.getTrainingDetailsInfo(userId)); // return new ResultEntity<>(iTeaGradeManageService.getTrainingDetailsInfo(userId));
// } catch (IOException e) { // } catch (IOException e) {
@ -677,33 +653,7 @@ public class TeaGradeManageController {
return new ResultEntity<>(pageInfo); return new ResultEntity<>(pageInfo);
} }
//
// @AnonymousAccess
// @ApiOperation("老师端/练习模式得分详情展示")
// @PostMapping("getScoreInfo")
// public ResultEntity<List<StuTrainingDto>> getScoreInfo(@RequestParam String userId,
// @RequestParam String schoolId,
// @RequestParam String systemOwner) {
// List<StuTrainingDto> list = new ArrayList<>();
//
// StuTrainingExample stuTrainingExample = new StuTrainingExample();
// stuTrainingExample.createCriteria().andUserIdEqualTo(userId);
// List<StuTrainingWithBLOBs> 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 @AnonymousAccess
@ApiOperation("老师端/练习模式得分详情展示") @ApiOperation("老师端/练习模式得分详情展示")

@ -6,6 +6,7 @@ import com.sztzjy.financial_bigdata.entity.SysWeight;
import com.sztzjy.financial_bigdata.entity.stu_dto.StuTrainingDto; import com.sztzjy.financial_bigdata.entity.stu_dto.StuTrainingDto;
import com.sztzjy.financial_bigdata.entity.stu_dto.StuUserDto; 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.TeaExaminationDetailsDto;
import com.sztzjy.financial_bigdata.entity.tea_dto.TeaTrainingDto;
import com.sztzjy.financial_bigdata.entity.tea_dto.TeaTrainingInfoDTO; import com.sztzjy.financial_bigdata.entity.tea_dto.TeaTrainingInfoDTO;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
@ -19,7 +20,7 @@ import java.util.List;
public interface ITeaGradeManageService { public interface ITeaGradeManageService {
PageInfo<TeaTrainingInfoDTO> getTrainingInfo(Integer index, Integer size, String schoolId, String keyWord, String classId, String systemOwner); PageInfo<TeaTrainingInfoDTO> 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); TeaExaminationDetailsDto getCountChart(String examManageId, String classId);

@ -28,7 +28,6 @@ import java.io.IOException;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.util.*; import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -109,6 +108,14 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService {
List<StuClass> stuClasses = classMapper.selectByExample(example); List<StuClass> stuClasses = classMapper.selectByExample(example);
Map<String, String> classIdToNameMap = stuClasses.stream().collect(Collectors.toMap(StuClass::getClassId, StuClass::getClassName)); Map<String, String> classIdToNameMap = stuClasses.stream().collect(Collectors.toMap(StuClass::getClassId, StuClass::getClassName));
//拿到权重
SysWeightExample sysWeightExample = new SysWeightExample();
sysWeightExample.createCriteria().andSchoolIdEqualTo(schoolId);
List<SysWeight> sysWeights = sysWeightMapper.selectByExample(sysWeightExample);
SysWeight sysWeight = sysWeights.get(0);
// 批量获取实训记录 // 批量获取实训记录
Set<String> userIds = stuUsers.stream().map(StuUser::getUserid).collect(Collectors.toSet()); Set<String> userIds = stuUsers.stream().map(StuUser::getUserid).collect(Collectors.toSet());
StuTrainingExample stuTrainingExample = new StuTrainingExample(); StuTrainingExample stuTrainingExample = new StuTrainingExample();
@ -157,9 +164,12 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService {
totalScore = totalScore.add(reportScore); totalScore = totalScore.add(reportScore);
} }
} }
// 省略其他分数加法代码 //其他模块算分
BigDecimal moduleScore = getModuleScore(training, sysWeight);
totalScore = moduleScore.add(totalScore).setScale(2,RoundingMode.HALF_UP);
} }
//这个综合得分的公式为 各个页面得分*权重 = 单个模块得分 所有模块得分之和/系统章节数 = 综合得分
BigDecimal score = totalScore; BigDecimal score = totalScore;
if (totalScore.compareTo(BigDecimal.ZERO) > 0) { if (totalScore.compareTo(BigDecimal.ZERO) > 0) {
score = totalScore.divide(chapterNum, 2, RoundingMode.HALF_UP); score = totalScore.divide(chapterNum, 2, RoundingMode.HALF_UP);
@ -182,23 +192,23 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService {
* @author xcj * @author xcj
* @Date 2024/3/19 * @Date 2024/3/19
*/ */
@Override // @Override
public void exportTrainingInfo(HttpServletResponse response, String schoolId, String keyWord, String classId, String systemOwner) { // public void exportTrainingInfo(HttpServletResponse response, String schoolId, String keyWord, String classId, String systemOwner) {
List<TeaTrainingInfoDTO> list = getTrainingInfoDTOS(schoolId, keyWord, classId, systemOwner); // List<TeaTrainingInfoDTO> list = getTrainingInfoDTOS(schoolId, keyWord, classId, systemOwner);
//
//导出的表名 // //导出的表名
String title = IdUtil.simpleUUID(); // String title = IdUtil.simpleUUID();
//表中第一行表头字段 // //表中第一行表头字段
String[] headers = {"排名", "姓名", "学号", "班级名称", "综合得分", "实训进度"}; // String[] headers = {"排名", "姓名", "学号", "班级名称", "综合得分", "实训进度"};
//
//具体需要写入excel需要哪些字段这些字段取自UserReward类也就是上面的实际数据结果集的泛型 // //具体需要写入excel需要哪些字段这些字段取自UserReward类也就是上面的实际数据结果集的泛型
List<String> listColumn = Arrays.asList("rank", "name", "studentId", "className", "totalScore", "progress"); // List<String> listColumn = Arrays.asList("rank", "name", "studentId", "className", "totalScore", "progress");
try { // try {
FilePortUtil.exportExcel(response, title, headers, list, listColumn); // FilePortUtil.exportExcel(response, title, headers, list, listColumn);
} catch (Exception e) { // } catch (Exception e) {
e.printStackTrace(); // e.printStackTrace();
} // }
} // }
//饼形图 //饼形图
@Override @Override
@ -336,11 +346,22 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService {
} }
//计算模块得分 //计算模块得分
private BigDecimal getModuleScore(StuTrainingWithBLOBs stuTrainingWithBLOB) { private BigDecimal getModuleScore(StuTrainingWithBLOBs stuTrainingWithBLOB, SysWeight sysWeight) {
BigDecimal knowledgeSummaryWeight = sysWeight.getKnowledgeSummaryWeight();
BigDecimal learningEvalWeight = sysWeight.getLearningEvalWeight();
BigDecimal resourceLearningWeight = sysWeight.getResourceLearningWeight();
BigDecimal expTrainingWeight = sysWeight.getExpTrainingWeight();
BigDecimal knowledgeSummaryScore = Optional.ofNullable(stuTrainingWithBLOB.getKnowledgeSummaryScore()).orElse(BigDecimal.ZERO); BigDecimal knowledgeSummaryScore = Optional.ofNullable(stuTrainingWithBLOB.getKnowledgeSummaryScore()).orElse(BigDecimal.ZERO);
BigDecimal resourceLearningScore = Optional.ofNullable(stuTrainingWithBLOB.getResourceLearningScore()).orElse(BigDecimal.ZERO); BigDecimal resourceLearningScore = Optional.ofNullable(stuTrainingWithBLOB.getResourceLearningScore()).orElse(BigDecimal.ZERO);
BigDecimal learningEvalScore = Optional.ofNullable(stuTrainingWithBLOB.getLearningEvalScore()).orElse(BigDecimal.ZERO); BigDecimal learningEvalScore = Optional.ofNullable(stuTrainingWithBLOB.getLearningEvalScore()).orElse(BigDecimal.ZERO);
BigDecimal expTrainingScore = Optional.ofNullable(stuTrainingWithBLOB.getExpTrainingScore()).orElse(BigDecimal.ZERO); BigDecimal expTrainingScore = Optional.ofNullable(stuTrainingWithBLOB.getExpTrainingScore()).orElse(BigDecimal.ZERO);
knowledgeSummaryScore = knowledgeSummaryWeight.multiply(knowledgeSummaryScore);
learningEvalScore = learningEvalScore.multiply(learningEvalWeight);
resourceLearningScore = resourceLearningScore.multiply(resourceLearningWeight);
expTrainingScore = expTrainingScore.multiply(expTrainingWeight);
return knowledgeSummaryScore.add(resourceLearningScore).add(learningEvalScore).add(expTrainingScore); return knowledgeSummaryScore.add(resourceLearningScore).add(learningEvalScore).add(expTrainingScore);
} }
@ -492,6 +513,7 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService {
LinkedHashMap<String, BigDecimal> map = new LinkedHashMap<>(); LinkedHashMap<String, BigDecimal> map = new LinkedHashMap<>();
LinkedHashMap<String, SysThreeCatalog> chapterMap = new LinkedHashMap<>(); LinkedHashMap<String, SysThreeCatalog> chapterMap = new LinkedHashMap<>();
for (StuTrainingWithBLOBs stuTraining : stuTrainings) { for (StuTrainingWithBLOBs stuTraining : stuTrainings) {
String chapterId = stuTraining.getChapterId(); String chapterId = stuTraining.getChapterId();
SysThreeCatalog sysCourseChapter = chapterMap.get(chapterId); SysThreeCatalog sysCourseChapter = chapterMap.get(chapterId);
@ -575,6 +597,11 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService {
} catch (IOException e) { } catch (IOException e) {
return null; return null;
} }
//拿到权重
SysWeightExample sysWeightExample = new SysWeightExample();
sysWeightExample.createCriteria().andSchoolIdEqualTo(schoolId);
List<SysWeight> sysWeights = sysWeightMapper.selectByExample(sysWeightExample);
SysWeight sysWeight = sysWeights.get(0);
// 遍历用户计算分数并封装DTO // 遍历用户计算分数并封装DTO
List<TeaTrainingInfoDTO> list = new ArrayList<>(); List<TeaTrainingInfoDTO> list = new ArrayList<>();
@ -584,6 +611,7 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService {
continue; continue;
} }
TeaTrainingInfoDTO teaTrainingInfoDTO = new TeaTrainingInfoDTO(); TeaTrainingInfoDTO teaTrainingInfoDTO = new TeaTrainingInfoDTO();
teaTrainingInfoDTO.setClassName(classIdToNameMap.get(stuUser.getClassId())); teaTrainingInfoDTO.setClassName(classIdToNameMap.get(stuUser.getClassId()));
teaTrainingInfoDTO.setStudentId(stuUser.getStudentId()); teaTrainingInfoDTO.setStudentId(stuUser.getStudentId());
@ -598,10 +626,12 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService {
if (reportId != null) { if (reportId != null) {
BigDecimal reportScore = reportIdToScoreMap.getOrDefault(reportId, BigDecimal.ZERO); BigDecimal reportScore = reportIdToScoreMap.getOrDefault(reportId, BigDecimal.ZERO);
if (BigDecimal.ZERO.compareTo(reportScore) != 0) { if (BigDecimal.ZERO.compareTo(reportScore) != 0) {
reportScore = reportScore.multiply(sysWeight.getReportWeight().setScale(2, RoundingMode.HALF_UP));
totalScore = totalScore.add(reportScore); totalScore = totalScore.add(reportScore);
} }
} }
// 省略其他分数加法代码 BigDecimal moduleScore = getModuleScore(training, sysWeight);
totalScore = moduleScore.add(totalScore).setScale(2,RoundingMode.HALF_UP);
} }
BigDecimal score = totalScore; BigDecimal score = totalScore;

Loading…
Cancel
Save