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