|
|
|
@ -7,7 +7,6 @@ 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.resource_entity.TestSysCaseQuestionStep;
|
|
|
|
|
import com.sztzjy.financial_bigdata.entity.resource_entity.TestTestSysCaseQuestionStepWithBLOBs;
|
|
|
|
|
import com.sztzjy.financial_bigdata.entity.stu_dto.StuTrainingDto;
|
|
|
|
|
import com.sztzjy.financial_bigdata.entity.stu_dto.StuUserDto;
|
|
|
|
@ -114,24 +113,91 @@ 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());
|
|
|
|
|
ArrayList<String> userIdList = new ArrayList<>(userIds);
|
|
|
|
|
StuTrainingExample stuTrainingExample = new StuTrainingExample();
|
|
|
|
|
stuTrainingExample.createCriteria().andUserIdIn(new ArrayList<>(userIds));
|
|
|
|
|
stuTrainingExample.createCriteria().andUserIdIn(userIdList);
|
|
|
|
|
List<StuTrainingWithBLOBs> stuTrainingsWithBLOBs = trainingMapper.selectByExampleWithBLOBs(stuTrainingExample);
|
|
|
|
|
if (stuTrainingsWithBLOBs.isEmpty()) {
|
|
|
|
|
return Collections.emptyList();
|
|
|
|
|
}
|
|
|
|
|
// 实训记录按用户ID分组
|
|
|
|
|
Map<String, List<StuTrainingWithBLOBs>> userIdToTrainingsMap = stuTrainingsWithBLOBs.stream().collect(Collectors.groupingBy(StuTrainingWithBLOBs::getUserId));
|
|
|
|
|
List<String> chapterIdList = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<SysTwoCatalog> sysTwoCatalogs = new ArrayList<>();
|
|
|
|
|
try {
|
|
|
|
|
sysTwoCatalogs = CourseAPI.selectCourseList(systemOwner, schoolId);
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (SysTwoCatalog sysTwoCatalog : sysTwoCatalogs) {
|
|
|
|
|
try {
|
|
|
|
|
List<SysThreeCatalog> sysThreeCatalogs = CourseAPI.selectThreeCatalogListByTwoId(sysTwoCatalog.getTwoId(), schoolId);
|
|
|
|
|
List<String> threeCatalogs = sysThreeCatalogs.stream().map(SysThreeCatalog::getThreeId).collect(Collectors.toList());
|
|
|
|
|
chapterIdList.addAll(threeCatalogs);
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//一次性取到所有案例题步骤,给实验实训算分用
|
|
|
|
|
List<TestTestSysCaseQuestionStepWithBLOBs> stepList = new ArrayList<>();
|
|
|
|
|
try {
|
|
|
|
|
stepList = CaseApi.selectCaseStepListBatchByIdList(chapterIdList); //
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Map<String, List<BigDecimal>> map1 = stepList.stream() //循环里算分方法调用 步骤分数
|
|
|
|
|
.collect(Collectors.groupingBy(TestTestSysCaseQuestionStepWithBLOBs::getThreeId,
|
|
|
|
|
Collectors.mapping(TestTestSysCaseQuestionStepWithBLOBs::getScore, Collectors.toList())));
|
|
|
|
|
|
|
|
|
|
Map<String, List<String>> map = stepList.stream() //循环里算分方法调用,步骤ID
|
|
|
|
|
.collect(Collectors.groupingBy(TestTestSysCaseQuestionStepWithBLOBs::getThreeId,
|
|
|
|
|
Collectors.mapping(TestTestSysCaseQuestionStepWithBLOBs::getCaseStepId, Collectors.toList())));
|
|
|
|
|
|
|
|
|
|
//3.记录表中所有ID得分之和
|
|
|
|
|
StuTrainingStepRecordExample trainingStepRecordExample = new StuTrainingStepRecordExample();
|
|
|
|
|
trainingStepRecordExample.createCriteria().andUserIdIn(userIdList);
|
|
|
|
|
List<StuTrainingStepRecord> stuTrainingStepRecords = trainingStepRecordMapper.selectByExampleWithBLOBs(trainingStepRecordExample);
|
|
|
|
|
for (StuTrainingStepRecord stuTrainingStepRecord : stuTrainingStepRecords) {
|
|
|
|
|
for (TestTestSysCaseQuestionStepWithBLOBs testTestSysCaseQuestionStepWithBLOBs : stepList) {
|
|
|
|
|
if (testTestSysCaseQuestionStepWithBLOBs.getCaseStepId().equals(stuTrainingStepRecord.getCaseStepId())) {
|
|
|
|
|
stuTrainingStepRecord.setThreeId(testTestSysCaseQuestionStepWithBLOBs.getThreeId());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 假设您已经定义了 stuTrainingStepRecords 这个 List<StuTrainingStepRecord>
|
|
|
|
|
Map<String, Map<String, BigDecimal>> resultMap = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
// 逐个处理每个记录
|
|
|
|
|
for (StuTrainingStepRecord record : stuTrainingStepRecords) {
|
|
|
|
|
String userId = record.getUserId(); // 获取 userId
|
|
|
|
|
String threeId = record.getThreeId(); // 获取 threeId
|
|
|
|
|
String score = record.getScore(); // 获取 score
|
|
|
|
|
|
|
|
|
|
// 确保 userId 的 Map 存在
|
|
|
|
|
resultMap.putIfAbsent(userId, new HashMap<>());
|
|
|
|
|
|
|
|
|
|
// 获取用户的 inner Map
|
|
|
|
|
Map<String, BigDecimal> innerMap = resultMap.get(userId);
|
|
|
|
|
|
|
|
|
|
// 累加分数
|
|
|
|
|
if (innerMap.containsKey(threeId)) {
|
|
|
|
|
// 如果已经存在,则累加分数
|
|
|
|
|
BigDecimal existingScore = innerMap.get(threeId);
|
|
|
|
|
BigDecimal newScore = existingScore.add(new BigDecimal(score));
|
|
|
|
|
innerMap.put(threeId, newScore); // 更新分数
|
|
|
|
|
} else {
|
|
|
|
|
// 如果不存在,则直接添加
|
|
|
|
|
innerMap.put(threeId, new BigDecimal(score)); // 新的三维 ID,直接添加分数
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 批量获取报告分数
|
|
|
|
|
Set<String> reportIds = stuTrainingsWithBLOBs.stream().map(StuTrainingWithBLOBs::getReportId).collect(Collectors.toSet());
|
|
|
|
@ -144,6 +210,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<>();
|
|
|
|
@ -152,7 +223,6 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService {
|
|
|
|
|
if (userTrainings.isEmpty()) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TeaTrainingInfoDTO teaTrainingInfoDTO = new TeaTrainingInfoDTO();
|
|
|
|
|
teaTrainingInfoDTO.setClassName(classIdToNameMap.get(stuUser.getClassId()));
|
|
|
|
|
teaTrainingInfoDTO.setStudentId(stuUser.getStudentId());
|
|
|
|
@ -167,18 +237,17 @@ 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);
|
|
|
|
|
BigDecimal moduleScore = getModuleScore(training, sysWeight, map, map1, resultMap);
|
|
|
|
|
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);
|
|
|
|
|
if (totalScore.compareTo(BigDecimal.ZERO) > 0) { //减一,资源中心查出来33,这里只查出来32,
|
|
|
|
|
score = totalScore.divide(chapterNum.subtract(BigDecimal.ONE), 2, RoundingMode.HALF_UP);
|
|
|
|
|
}
|
|
|
|
|
teaTrainingInfoDTO.setTotalScore(score);
|
|
|
|
|
|
|
|
|
@ -351,8 +420,9 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//计算模块得分
|
|
|
|
|
private BigDecimal getModuleScore(StuTrainingWithBLOBs stuTrainingWithBLOB, SysWeight sysWeight) {
|
|
|
|
|
//计算模块得分 章节下所有的案例步骤得分之和 / 章节下所有的案例步骤满分
|
|
|
|
|
private BigDecimal getModuleScore(StuTrainingWithBLOBs stuTrainingWithBLOB, SysWeight sysWeight,
|
|
|
|
|
Map<String, List<String>> map, Map<String, List<BigDecimal>> map1, Map<String, Map<String, BigDecimal>> resultMap) {
|
|
|
|
|
BigDecimal knowledgeSummaryWeight = sysWeight.getKnowledgeSummaryWeight();
|
|
|
|
|
BigDecimal resourceLearningWeight = sysWeight.getResourceLearningWeight();
|
|
|
|
|
BigDecimal learningEvalWeight = sysWeight.getLearningEvalWeight();
|
|
|
|
@ -361,7 +431,6 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService {
|
|
|
|
|
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).divide(BigDecimal.valueOf(100).setScale(2, RoundingMode.HALF_UP));
|
|
|
|
|
if (knowledgeSummaryScore.compareTo(knowledgeSummaryWeight) > 0) {
|
|
|
|
@ -378,36 +447,39 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService {
|
|
|
|
|
|
|
|
|
|
//实验实训
|
|
|
|
|
String chapterId = stuTrainingWithBLOB.getChapterId();
|
|
|
|
|
//1.取出章节下的有所案例ID
|
|
|
|
|
List<TestTestSysCaseQuestionStepWithBLOBs> stepList = null;
|
|
|
|
|
try {
|
|
|
|
|
stepList = CaseApi.selectCaseStepListBatchByIdListAndSort(chapterId);
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
throw new RuntimeException("资源中心根据根据案例题IDS批量查询失败");
|
|
|
|
|
}
|
|
|
|
|
List<String> stepIdList = stepList.stream().map(TestSysCaseQuestionStep::getCaseStepId).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
//2.步骤表中所有得分之和
|
|
|
|
|
BigDecimal rightTotalScore = stepList.stream()
|
|
|
|
|
.map(TestTestSysCaseQuestionStepWithBLOBs::getScore)
|
|
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
|
|
|
|
|
|
//3.记录表中所有ID得分之和
|
|
|
|
|
StuTrainingStepRecordExample example =new StuTrainingStepRecordExample();
|
|
|
|
|
example.createCriteria().andCaseStepIdIn(stepIdList);
|
|
|
|
|
List<StuTrainingStepRecord> stuTrainingStepRecords = trainingStepRecordMapper.selectByExampleWithBLOBs(example);
|
|
|
|
|
|
|
|
|
|
double stuTotalScore = stuTrainingStepRecords.stream() //学生总共得分
|
|
|
|
|
.map(StuTrainingStepRecord::getScore)
|
|
|
|
|
.mapToDouble(Double::parseDouble)
|
|
|
|
|
.sum();
|
|
|
|
|
|
|
|
|
|
BigDecimal accuracy = BigDecimal.valueOf(stuTotalScore).divide(rightTotalScore,2,RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)).multiply(expTrainingWeight.divide(BigDecimal.valueOf(100)));
|
|
|
|
|
|
|
|
|
|
if (accuracy.compareTo(expTrainingWeight) > 0) {
|
|
|
|
|
accuracy = expTrainingWeight;
|
|
|
|
|
List<String> stepIdList = map.get(chapterId);
|
|
|
|
|
List<BigDecimal> scoreList = map1.get(chapterId);
|
|
|
|
|
BigDecimal expTrainingScore = BigDecimal.ZERO;
|
|
|
|
|
if (stepIdList != null && !stepIdList.isEmpty()) {
|
|
|
|
|
// List<String> stepIdList = stepList.stream().map(TestSysCaseQuestionStep::getCaseStepId).collect(Collectors.toList());
|
|
|
|
|
//2.步骤表中所有得分之和
|
|
|
|
|
BigDecimal rightTotalScore = scoreList.stream()
|
|
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
|
|
|
|
|
|
String userId = stuTrainingWithBLOB.getUserId();
|
|
|
|
|
|
|
|
|
|
//提出循环外了这段
|
|
|
|
|
// StuTrainingStepRecordExample example = new StuTrainingStepRecordExample();
|
|
|
|
|
// example.createCriteria().andCaseStepIdIn(stepIdList).andUserIdEqualTo(userId);
|
|
|
|
|
// List<StuTrainingStepRecord> stuTrainingStepRecords = trainingStepRecordMapper.selectByExampleWithBLOBs(example);
|
|
|
|
|
// double stuTotalScore = stuTrainingStepRecords.stream() //学生总共得分
|
|
|
|
|
// .map(StuTrainingStepRecord::getScore)
|
|
|
|
|
// .mapToDouble(Double::parseDouble)
|
|
|
|
|
// .sum();
|
|
|
|
|
|
|
|
|
|
//3.记录表中所有ID得分之和
|
|
|
|
|
Map<String, BigDecimal> scoreMap = resultMap.get(userId);
|
|
|
|
|
if (scoreMap != null && !scoreMap.isEmpty()) {
|
|
|
|
|
BigDecimal score = scoreMap.get(chapterId);
|
|
|
|
|
if (score != null) {
|
|
|
|
|
expTrainingScore = score.divide(rightTotalScore, 2, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)).multiply(expTrainingWeight.divide(BigDecimal.valueOf(100)));
|
|
|
|
|
if (expTrainingScore.compareTo(expTrainingWeight) > 0) {
|
|
|
|
|
expTrainingScore = expTrainingWeight;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return knowledgeSummaryScore.add(resourceLearningScore).add(learningEvalScore).add(accuracy);
|
|
|
|
|
return knowledgeSummaryScore.add(resourceLearningScore).add(learningEvalScore).add(expTrainingScore);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -439,32 +511,11 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService {
|
|
|
|
|
@Override
|
|
|
|
|
public PageInfo<StuTheoryRecord> getTheoryInfo(Integer index, Integer size, String schoolId, String classId, String keyWord, String systemOwner) {
|
|
|
|
|
PageHelper.startPage(index, size);
|
|
|
|
|
// List<StuTheoryRecord> list = getStuTheoryRecordPageInfo(schoolId, classId, keyWord, systemOwner);
|
|
|
|
|
List<StuTheoryRecord> list = stuTheoryRecordMapper.selectConditions(schoolId, classId, keyWord, systemOwner);
|
|
|
|
|
PageInfo<StuTheoryRecord> pageInfo = new PageInfo<>(list);
|
|
|
|
|
return pageInfo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// //查询方法
|
|
|
|
|
// private List<StuTheoryRecord> 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, String systemOwner) {
|
|
|
|
@ -602,6 +653,7 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//todo 原版代码 速度有点慢
|
|
|
|
|
private List<TeaTrainingInfoDTO> getTeaTrainingInfoDTOS(String schoolId, String keyWord, String classId, String systemOwner) {
|
|
|
|
|
List<StuUser> stuUsers = userMapper.getByNameAndStudentID(schoolId, keyWord, classId, systemOwner);
|
|
|
|
|
|
|
|
|
@ -622,14 +674,89 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService {
|
|
|
|
|
|
|
|
|
|
// 批量获取实训记录
|
|
|
|
|
Set<String> userIds = stuUsers.stream().map(StuUser::getUserid).collect(Collectors.toSet());
|
|
|
|
|
ArrayList<String> userIdList = new ArrayList<>(userIds);
|
|
|
|
|
StuTrainingExample stuTrainingExample = new StuTrainingExample();
|
|
|
|
|
stuTrainingExample.createCriteria().andUserIdIn(new ArrayList<>(userIds));
|
|
|
|
|
stuTrainingExample.createCriteria().andUserIdIn(userIdList);
|
|
|
|
|
List<StuTrainingWithBLOBs> stuTrainingsWithBLOBs = trainingMapper.selectByExampleWithBLOBs(stuTrainingExample);
|
|
|
|
|
if (stuTrainingsWithBLOBs.isEmpty()) {
|
|
|
|
|
return Collections.emptyList();
|
|
|
|
|
}
|
|
|
|
|
// 实训记录按用户ID分组
|
|
|
|
|
Map<String, List<StuTrainingWithBLOBs>> userIdToTrainingsMap = stuTrainingsWithBLOBs.stream().collect(Collectors.groupingBy(StuTrainingWithBLOBs::getUserId));
|
|
|
|
|
List<String> chapterIdList = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<SysTwoCatalog> sysTwoCatalogs = new ArrayList<>();
|
|
|
|
|
try {
|
|
|
|
|
sysTwoCatalogs = CourseAPI.selectCourseList(systemOwner, schoolId);
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (SysTwoCatalog sysTwoCatalog : sysTwoCatalogs) {
|
|
|
|
|
try {
|
|
|
|
|
List<SysThreeCatalog> sysThreeCatalogs = CourseAPI.selectThreeCatalogListByTwoId(sysTwoCatalog.getTwoId(), schoolId);
|
|
|
|
|
List<String> threeCatalogs = sysThreeCatalogs.stream().map(SysThreeCatalog::getThreeId).collect(Collectors.toList());
|
|
|
|
|
chapterIdList.addAll(threeCatalogs);
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//一次性取到所有案例题步骤,给实验实训算分用
|
|
|
|
|
List<TestTestSysCaseQuestionStepWithBLOBs> stepList = new ArrayList<>();
|
|
|
|
|
try {
|
|
|
|
|
stepList = CaseApi.selectCaseStepListBatchByIdList(chapterIdList); //
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Map<String, List<BigDecimal>> map1 = stepList.stream() //循环里算分方法调用 步骤分数
|
|
|
|
|
.collect(Collectors.groupingBy(TestTestSysCaseQuestionStepWithBLOBs::getThreeId,
|
|
|
|
|
Collectors.mapping(TestTestSysCaseQuestionStepWithBLOBs::getScore, Collectors.toList())));
|
|
|
|
|
|
|
|
|
|
Map<String, List<String>> map = stepList.stream() //循环里算分方法调用,步骤ID
|
|
|
|
|
.collect(Collectors.groupingBy(TestTestSysCaseQuestionStepWithBLOBs::getThreeId,
|
|
|
|
|
Collectors.mapping(TestTestSysCaseQuestionStepWithBLOBs::getCaseStepId, Collectors.toList())));
|
|
|
|
|
|
|
|
|
|
//3.记录表中所有ID得分之和
|
|
|
|
|
StuTrainingStepRecordExample trainingStepRecordExample = new StuTrainingStepRecordExample();
|
|
|
|
|
trainingStepRecordExample.createCriteria().andUserIdIn(userIdList);
|
|
|
|
|
List<StuTrainingStepRecord> stuTrainingStepRecords = trainingStepRecordMapper.selectByExampleWithBLOBs(trainingStepRecordExample);
|
|
|
|
|
for (StuTrainingStepRecord stuTrainingStepRecord : stuTrainingStepRecords) {
|
|
|
|
|
for (TestTestSysCaseQuestionStepWithBLOBs testTestSysCaseQuestionStepWithBLOBs : stepList) {
|
|
|
|
|
if (testTestSysCaseQuestionStepWithBLOBs.getCaseStepId().equals(stuTrainingStepRecord.getCaseStepId())) {
|
|
|
|
|
stuTrainingStepRecord.setThreeId(testTestSysCaseQuestionStepWithBLOBs.getThreeId());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 假设您已经定义了 stuTrainingStepRecords 这个 List<StuTrainingStepRecord>
|
|
|
|
|
Map<String, Map<String, BigDecimal>> resultMap = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
// 逐个处理每个记录
|
|
|
|
|
for (StuTrainingStepRecord record : stuTrainingStepRecords) {
|
|
|
|
|
String userId = record.getUserId(); // 获取 userId
|
|
|
|
|
String threeId = record.getThreeId(); // 获取 threeId
|
|
|
|
|
String score = record.getScore(); // 获取 score
|
|
|
|
|
|
|
|
|
|
// 确保 userId 的 Map 存在
|
|
|
|
|
resultMap.putIfAbsent(userId, new HashMap<>());
|
|
|
|
|
|
|
|
|
|
// 获取用户的 inner Map
|
|
|
|
|
Map<String, BigDecimal> innerMap = resultMap.get(userId);
|
|
|
|
|
|
|
|
|
|
// 累加分数
|
|
|
|
|
if (innerMap.containsKey(threeId)) {
|
|
|
|
|
// 如果已经存在,则累加分数
|
|
|
|
|
BigDecimal existingScore = innerMap.get(threeId);
|
|
|
|
|
BigDecimal newScore = existingScore.add(new BigDecimal(score));
|
|
|
|
|
innerMap.put(threeId, newScore); // 更新分数
|
|
|
|
|
} else {
|
|
|
|
|
// 如果不存在,则直接添加
|
|
|
|
|
innerMap.put(threeId, new BigDecimal(score)); // 新的三维 ID,直接添加分数
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 批量获取报告分数
|
|
|
|
|
Set<String> reportIds = stuTrainingsWithBLOBs.stream().map(StuTrainingWithBLOBs::getReportId).collect(Collectors.toSet());
|
|
|
|
@ -655,8 +782,6 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService {
|
|
|
|
|
if (userTrainings.isEmpty()) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TeaTrainingInfoDTO teaTrainingInfoDTO = new TeaTrainingInfoDTO();
|
|
|
|
|
teaTrainingInfoDTO.setClassName(classIdToNameMap.get(stuUser.getClassId()));
|
|
|
|
|
teaTrainingInfoDTO.setStudentId(stuUser.getStudentId());
|
|
|
|
@ -675,13 +800,13 @@ public class TeaGradeManageServiceImpl implements ITeaGradeManageService {
|
|
|
|
|
totalScore = totalScore.add(reportScore);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
BigDecimal moduleScore = getModuleScore(training, sysWeight);
|
|
|
|
|
BigDecimal moduleScore = getModuleScore(training, sysWeight, map, map1, resultMap);
|
|
|
|
|
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);
|
|
|
|
|
if (totalScore.compareTo(BigDecimal.ZERO) > 0) { //减一,资源中心查出来33,这里只查出来32,
|
|
|
|
|
score = totalScore.divide(chapterNum.subtract(BigDecimal.ONE), 2, RoundingMode.HALF_UP);
|
|
|
|
|
}
|
|
|
|
|
teaTrainingInfoDTO.setTotalScore(score);
|
|
|
|
|
|
|
|
|
|