|
|
|
@ -19,6 +19,7 @@ import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.math.RoundingMode;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @Author xcj
|
|
|
|
@ -286,6 +287,7 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private List<TeaTrainingInfoDTO> getTeaTrainingInfoDTOS(String schoolId, String keyWord, String classId) {
|
|
|
|
|
StuUserExample userExample = new StuUserExample();
|
|
|
|
|
StuUserExample.Criteria criteria = userExample.createCriteria();
|
|
|
|
@ -298,86 +300,82 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService {
|
|
|
|
|
userExample.or().andSchoolIdEqualTo(schoolId).andNameEqualTo(keyWord);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 查询学生用户列表
|
|
|
|
|
List<StuUser> stuUsers = userMapper.selectByExample(userExample);
|
|
|
|
|
List<TeaTrainingInfoDTO> list = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
if (stuUsers.isEmpty()) {
|
|
|
|
|
return null;
|
|
|
|
|
} else {
|
|
|
|
|
for (StuUser stuUser : stuUsers) { //先查出学校下所有的用户ID,再根据USERid去实训表中查实训记录,实训记录为空就跳过,有数据就封装
|
|
|
|
|
StuClass stuClass = classMapper.selectByPrimaryKey(stuUser.getClassId());
|
|
|
|
|
TeaTrainingInfoDTO teaTrainingInfoDTO = new TeaTrainingInfoDTO();
|
|
|
|
|
//封装user表的数据
|
|
|
|
|
teaTrainingInfoDTO.setClassName(stuClass.getClassName());
|
|
|
|
|
teaTrainingInfoDTO.setStudentId(stuUser.getStudentId());
|
|
|
|
|
teaTrainingInfoDTO.setName(stuUser.getName());
|
|
|
|
|
teaTrainingInfoDTO.setUserId(stuUser.getUserid());
|
|
|
|
|
//看用户在实训表有没有记录
|
|
|
|
|
StuTrainingExample stuTrainingExample = new StuTrainingExample();
|
|
|
|
|
stuTrainingExample.createCriteria().andUserIdEqualTo(stuUser.getUserid());
|
|
|
|
|
List<StuTrainingWithBLOBs> stuTrainings = trainingMapper.selectByExampleWithBLOBs(stuTrainingExample);
|
|
|
|
|
|
|
|
|
|
if (stuTrainings.isEmpty()) { //实训为空跳过这个用户
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
return Collections.emptyList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//初始化分数和进度参数
|
|
|
|
|
BigDecimal allProgress = BigDecimal.ZERO;
|
|
|
|
|
BigDecimal totalScore = BigDecimal.ZERO;
|
|
|
|
|
// 批量获取班级信息
|
|
|
|
|
Set<String> classIds = stuUsers.stream().map(StuUser::getClassId).collect(Collectors.toSet());
|
|
|
|
|
List<StuClass> stuClasses = classMapper.selectByPrimaryKeys(classIds);
|
|
|
|
|
Map<String, String> classIdToNameMap = stuClasses.stream().collect(Collectors.toMap(StuClass::getClassId, StuClass::getClassName));
|
|
|
|
|
|
|
|
|
|
for (StuTrainingWithBLOBs stuTrainingWithBLOB : stuTrainings) {
|
|
|
|
|
// 批量获取实训记录
|
|
|
|
|
Set<String> userIds = stuUsers.stream().map(StuUser::getUserid).collect(Collectors.toSet());
|
|
|
|
|
StuTrainingExample stuTrainingExample = new StuTrainingExample();
|
|
|
|
|
stuTrainingExample.createCriteria().andUserIdIn(new ArrayList<>(userIds));
|
|
|
|
|
List<StuTrainingWithBLOBs> stuTrainingsWithBLOBs = trainingMapper.selectByExampleWithBLOBs(stuTrainingExample);
|
|
|
|
|
|
|
|
|
|
//综合实训进度
|
|
|
|
|
if (stuTrainingWithBLOB.getProgress() != null) {
|
|
|
|
|
BigDecimal progress = stuTrainingWithBLOB.getProgress();
|
|
|
|
|
allProgress = progress.add(allProgress);
|
|
|
|
|
}
|
|
|
|
|
// 实训记录按用户ID分组
|
|
|
|
|
Map<String, List<StuTrainingWithBLOBs>> userIdToTrainingsMap = stuTrainingsWithBLOBs.stream().collect(Collectors.groupingBy(StuTrainingWithBLOBs::getUserId));
|
|
|
|
|
|
|
|
|
|
//求综合得分 拿到每个已完成的章节分数
|
|
|
|
|
TrainingReport trainingReport = trainingReportMapper.selectByPrimaryKey(stuTrainingWithBLOB.getReportId());
|
|
|
|
|
BigDecimal reportScore = null;
|
|
|
|
|
if (trainingReport != null) {
|
|
|
|
|
reportScore = trainingReport.getTeacherScore();
|
|
|
|
|
}
|
|
|
|
|
BigDecimal expTrainingScore = stuTrainingWithBLOB.getExpTrainingScore();
|
|
|
|
|
BigDecimal knowledgeSummaryScore = stuTrainingWithBLOB.getKnowledgeSummaryScore();
|
|
|
|
|
BigDecimal resourceLearningScore = stuTrainingWithBLOB.getResourceLearningScore();
|
|
|
|
|
BigDecimal learningEvalScore = stuTrainingWithBLOB.getLearningEvalScore();
|
|
|
|
|
// 批量获取报告分数
|
|
|
|
|
Set<String> reportIds = stuTrainingsWithBLOBs.stream().map(StuTrainingWithBLOBs::getReportId).collect(Collectors.toSet());
|
|
|
|
|
List<TrainingReport> trainingReports = trainingReportMapper.selectByPrimaryKeys(reportIds);
|
|
|
|
|
Map<String, BigDecimal> reportIdToScoreMap = trainingReports.stream().collect(Collectors.toMap(TrainingReport::getReportId, TrainingReport::getTeacherScore));
|
|
|
|
|
|
|
|
|
|
if (reportScore != null && BigDecimal.ZERO.compareTo(reportScore) == 0) { //报告得分不等于0或null
|
|
|
|
|
// 获取总模块数量
|
|
|
|
|
BigDecimal chapterNum = sysCourseChapterMapper.selectChapterBySchoolId(schoolId);
|
|
|
|
|
|
|
|
|
|
// 遍历用户,计算分数并封装DTO
|
|
|
|
|
List<TeaTrainingInfoDTO> list = new ArrayList<>();
|
|
|
|
|
for (StuUser stuUser : stuUsers) {
|
|
|
|
|
List<StuTrainingWithBLOBs> 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);
|
|
|
|
|
}
|
|
|
|
|
if (expTrainingScore != null && BigDecimal.ZERO.compareTo(expTrainingScore) != 0) {
|
|
|
|
|
totalScore = totalScore.add(expTrainingScore);
|
|
|
|
|
}
|
|
|
|
|
if (knowledgeSummaryScore != null && BigDecimal.ZERO.compareTo(knowledgeSummaryScore) != 0) {
|
|
|
|
|
totalScore = totalScore.add(knowledgeSummaryScore);
|
|
|
|
|
}
|
|
|
|
|
if (resourceLearningScore != null && BigDecimal.ZERO.compareTo(resourceLearningScore) != 0) {
|
|
|
|
|
totalScore = totalScore.add(resourceLearningScore);
|
|
|
|
|
}
|
|
|
|
|
if (learningEvalScore != null && BigDecimal.ZERO.compareTo(learningEvalScore) != 0) {
|
|
|
|
|
totalScore = totalScore.add(learningEvalScore);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 省略其他分数加法代码
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//封装参数
|
|
|
|
|
BigDecimal chapterNum = sysCourseChapterMapper.selectChapterBySchoolId(schoolId);
|
|
|
|
|
if (totalScore.intValue() != 0) {
|
|
|
|
|
BigDecimal score = totalScore.divide(chapterNum, 2, RoundingMode.HALF_UP);//已完成的模块分数/总模块数量
|
|
|
|
|
teaTrainingInfoDTO.setTotalScore(score);
|
|
|
|
|
}else {
|
|
|
|
|
teaTrainingInfoDTO.setTotalScore(BigDecimal.ZERO);
|
|
|
|
|
}
|
|
|
|
|
if (allProgress.intValue() != 0 && stuTrainings.size() != 0) {
|
|
|
|
|
BigDecimal divide = allProgress.divide(BigDecimal.valueOf(stuTrainings.size()), 2, RoundingMode.HALF_UP);
|
|
|
|
|
teaTrainingInfoDTO.setProgress(divide);
|
|
|
|
|
}
|
|
|
|
|
list.add(teaTrainingInfoDTO);
|
|
|
|
|
BigDecimal score = totalScore;
|
|
|
|
|
if (totalScore.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
|
|
score = totalScore.divide(chapterNum, 2, RoundingMode.HALF_UP);
|
|
|
|
|
}
|
|
|
|
|
return list;
|
|
|
|
|
teaTrainingInfoDTO.setTotalScore(score);
|
|
|
|
|
|
|
|
|
|
BigDecimal progress = allProgress.divide(BigDecimal.valueOf(userTrainings.size()), 2, RoundingMode.HALF_UP);
|
|
|
|
|
teaTrainingInfoDTO.setProgress(progress);
|
|
|
|
|
|
|
|
|
|
list.add(teaTrainingInfoDTO);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class TotalScoreComparator implements Comparator<TeaTrainingInfoDTO> {
|
|
|
|
|
@Override
|
|
|
|
|
public int compare(TeaTrainingInfoDTO o1, TeaTrainingInfoDTO o2) {
|
|
|
|
|