|
|
|
@ -0,0 +1,212 @@
|
|
|
|
|
package com.sztzjy.financial_bigdata.service.stu.impl;
|
|
|
|
|
|
|
|
|
|
import com.sztzjy.financial_bigdata.entity.StuTrainingWithBLOBs;
|
|
|
|
|
import com.sztzjy.financial_bigdata.entity.SysWeight;
|
|
|
|
|
import com.sztzjy.financial_bigdata.entity.SysWeightExample;
|
|
|
|
|
import com.sztzjy.financial_bigdata.entity.TrainingReport;
|
|
|
|
|
import com.sztzjy.financial_bigdata.entity.resource_entity.SysThreeCatalog;
|
|
|
|
|
import com.sztzjy.financial_bigdata.entity.stu_dto.StuTrainingDto;
|
|
|
|
|
import com.sztzjy.financial_bigdata.mapper.SysWeightMapper;
|
|
|
|
|
import com.sztzjy.financial_bigdata.mapper.TrainingReportMapper;
|
|
|
|
|
import com.sztzjy.financial_bigdata.service.stu.StuScoreService;
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.math.RoundingMode;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @Author xcj
|
|
|
|
|
* @Date 2024/11/22
|
|
|
|
|
*/
|
|
|
|
|
@Service
|
|
|
|
|
public class StuScoreServiceImpl implements StuScoreService {
|
|
|
|
|
@Autowired
|
|
|
|
|
private SysWeightMapper sysWeightMapper;
|
|
|
|
|
@Autowired
|
|
|
|
|
TrainingReportMapper trainingReportMapper;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// @Override
|
|
|
|
|
// public StuTrainingDto getScoreByChapterId(String schoolId, String systemOwner, StuTrainingWithBLOBs stuTrainingWithBLOBs, StuTrainingDto stuTrainingDto, SysThreeCatalog sysCourseChapter) {
|
|
|
|
|
// SysWeightExample sysWeightExample = new SysWeightExample();
|
|
|
|
|
// sysWeightExample.createCriteria().andCourseIdEqualTo(sysCourseChapter.getTwoId()).andSchoolIdEqualTo(schoolId).andSystemOwnerEqualTo(systemOwner);
|
|
|
|
|
// List<SysWeight> sysWeights = sysWeightMapper.selectByExample(sysWeightExample);
|
|
|
|
|
// if (!sysWeights.isEmpty()) {
|
|
|
|
|
// SysWeight sysWeight = sysWeights.get(0);
|
|
|
|
|
// BeanUtils.copyProperties(sysWeight, stuTrainingDto); //五个权重
|
|
|
|
|
// } else {
|
|
|
|
|
// //设置默认权重
|
|
|
|
|
// stuTrainingDto.setKnowledgeSummaryDefaultRule(BigDecimal.valueOf(60)); //知识概要默认计分规则 阅读1分钟得60分,1分钟以下不得分,多1分钟加10分。
|
|
|
|
|
// stuTrainingDto.setResourceLearningDefaultRule(BigDecimal.valueOf(60)); //资源学习默认计分规则 观看资源1分钟得60分,1分钟以下不得分,多1分钟加10分。
|
|
|
|
|
// stuTrainingDto.setLearningEvalDefaultRule(BigDecimal.valueOf(10)); //学习测评默认计分规则 客观题10分每道
|
|
|
|
|
// stuTrainingDto.setExpTrainingDefautRule(BigDecimal.valueOf(2));//实训题,输错/选错次数扣2分,最低0分
|
|
|
|
|
// stuTrainingDto.setKnowledgeSummaryWeight(BigDecimal.valueOf(5));
|
|
|
|
|
// stuTrainingDto.setResourceLearningWeight(BigDecimal.valueOf(5));
|
|
|
|
|
// stuTrainingDto.setLearningEvalWeight(BigDecimal.valueOf(20));
|
|
|
|
|
// stuTrainingDto.setExpTrainingWeight(BigDecimal.valueOf(60));
|
|
|
|
|
// stuTrainingDto.setReportWeight(BigDecimal.valueOf(10));
|
|
|
|
|
// }
|
|
|
|
|
// BeanUtils.copyProperties(stuTrainingWithBLOBs, stuTrainingDto); //四个完成情况和四个得分
|
|
|
|
|
// //知识概要得分
|
|
|
|
|
// Integer knowledgeSummaryCompleteStatus = 0;
|
|
|
|
|
// BigDecimal knowledgeSummaryScore = BigDecimal.ZERO;
|
|
|
|
|
// if (stuTrainingWithBLOBs.getKnowledgeSummaryCompleteStatus() != null && stuTrainingWithBLOBs.getKnowledgeSummaryCompleteStatus() != 0) {
|
|
|
|
|
// knowledgeSummaryCompleteStatus = stuTrainingWithBLOBs.getKnowledgeSummaryCompleteStatus();
|
|
|
|
|
// knowledgeSummaryScore = stuTrainingDto.getKnowledgeSummaryDefaultRule().add(BigDecimal.valueOf((knowledgeSummaryCompleteStatus - 1) * 10));
|
|
|
|
|
// if (knowledgeSummaryScore.compareTo(BigDecimal.valueOf(100)) > 0) {
|
|
|
|
|
// knowledgeSummaryScore = BigDecimal.valueOf(100);
|
|
|
|
|
// }
|
|
|
|
|
// knowledgeSummaryScore = knowledgeSummaryScore.multiply(stuTrainingDto.getKnowledgeSummaryWeight().divide(BigDecimal.valueOf(100), 2, BigDecimal.ROUND_HALF_UP));
|
|
|
|
|
// }
|
|
|
|
|
// stuTrainingDto.setKnowledgeSummaryScore(knowledgeSummaryScore);
|
|
|
|
|
// //资源学习得分
|
|
|
|
|
// Integer resourceLearningCompleteStatus = 0;
|
|
|
|
|
// BigDecimal resourceLearningScore = BigDecimal.ZERO;
|
|
|
|
|
// if (stuTrainingWithBLOBs.getResourceLearningCompleteStatus() != null && stuTrainingWithBLOBs.getResourceLearningCompleteStatus() != 0) {
|
|
|
|
|
// resourceLearningCompleteStatus = stuTrainingWithBLOBs.getResourceLearningCompleteStatus();
|
|
|
|
|
// resourceLearningScore = stuTrainingDto.getResourceLearningDefaultRule().add(BigDecimal.valueOf((resourceLearningCompleteStatus - 1) * 10));
|
|
|
|
|
// if (resourceLearningScore.compareTo(BigDecimal.valueOf(100)) > 0) {
|
|
|
|
|
// resourceLearningScore = BigDecimal.valueOf(100);
|
|
|
|
|
// }
|
|
|
|
|
// resourceLearningScore = resourceLearningScore.multiply(stuTrainingDto.getResourceLearningWeight().divide(BigDecimal.valueOf(100), 2, BigDecimal.ROUND_HALF_UP));
|
|
|
|
|
// }
|
|
|
|
|
// stuTrainingDto.setResourceLearningScore(resourceLearningScore);
|
|
|
|
|
//
|
|
|
|
|
// //学习评测得分
|
|
|
|
|
// Integer learningEvalCompleteStatus = 0;
|
|
|
|
|
// BigDecimal learningEvalScore = BigDecimal.ZERO;
|
|
|
|
|
// if (stuTrainingWithBLOBs.getLearningEvalCompleteStatus() != null) {
|
|
|
|
|
// learningEvalCompleteStatus = stuTrainingWithBLOBs.getLearningEvalCompleteStatus();
|
|
|
|
|
// learningEvalScore = BigDecimal.valueOf(100).subtract(stuTrainingDto.getLearningEvalDefaultRule().multiply(BigDecimal.valueOf(learningEvalCompleteStatus)));
|
|
|
|
|
// if (learningEvalScore.compareTo(BigDecimal.valueOf(0)) < 0) {
|
|
|
|
|
// learningEvalScore = BigDecimal.valueOf(0);
|
|
|
|
|
// }
|
|
|
|
|
// stuTrainingDto.setLearningEvalScore(learningEvalScore.multiply(stuTrainingDto.getLearningEvalWeight().divide(BigDecimal.valueOf(100), 2, BigDecimal.ROUND_HALF_UP)));
|
|
|
|
|
// } else {
|
|
|
|
|
// stuTrainingDto.setLearningEvalScore(learningEvalScore);
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// //实验实训分数计算
|
|
|
|
|
// Integer expTrainingCompleteStatus = 0;
|
|
|
|
|
// BigDecimal expTrainingScore = BigDecimal.ZERO;
|
|
|
|
|
// if (stuTrainingWithBLOBs.getExpTrainingCompleteStatus() != null) {
|
|
|
|
|
// expTrainingCompleteStatus = stuTrainingWithBLOBs.getExpTrainingCompleteStatus();
|
|
|
|
|
// expTrainingScore = BigDecimal.valueOf(100).subtract(stuTrainingDto.getExpTrainingDefautRule().multiply(BigDecimal.valueOf(expTrainingCompleteStatus)));
|
|
|
|
|
// if (expTrainingScore.compareTo(BigDecimal.valueOf(0)) < 0) {
|
|
|
|
|
// expTrainingScore = BigDecimal.valueOf(0);
|
|
|
|
|
// }
|
|
|
|
|
// stuTrainingDto.setCaseStuScore(expTrainingScore.multiply(stuTrainingDto.getExpTrainingWeight().divide(BigDecimal.valueOf(100), 2, BigDecimal.ROUND_HALF_UP)));
|
|
|
|
|
// } else {
|
|
|
|
|
// stuTrainingDto.setCaseStuScore(expTrainingScore);
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// TrainingReport trainingReport = trainingReportMapper.selectByPrimaryKey(stuTrainingWithBLOBs.getReportId());
|
|
|
|
|
// //设置报告相关数据
|
|
|
|
|
// if (trainingReport == null || trainingReport.getTeacherScore() == null) {
|
|
|
|
|
// stuTrainingDto.setReportCompleteStatus("未提交");
|
|
|
|
|
// stuTrainingDto.setReportScore(null);
|
|
|
|
|
// } else {
|
|
|
|
|
// stuTrainingDto.setReportCompleteStatus("已提交");
|
|
|
|
|
// stuTrainingDto.setReportScore(trainingReport.getTeacherScore());
|
|
|
|
|
// }
|
|
|
|
|
// return stuTrainingDto;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public StuTrainingDto getScoreByChapterId(String schoolId, String systemOwner, StuTrainingWithBLOBs stuTrainingWithBLOBs, StuTrainingDto stuTrainingDto, SysThreeCatalog sysCourseChapter) {
|
|
|
|
|
SysWeightExample sysWeightExample = new SysWeightExample();
|
|
|
|
|
sysWeightExample.createCriteria().andCourseIdEqualTo(sysCourseChapter.getTwoId())
|
|
|
|
|
.andSchoolIdEqualTo(schoolId)
|
|
|
|
|
.andSystemOwnerEqualTo(systemOwner);
|
|
|
|
|
|
|
|
|
|
List<SysWeight> sysWeights = sysWeightMapper.selectByExample(sysWeightExample);
|
|
|
|
|
if (!sysWeights.isEmpty()) {
|
|
|
|
|
SysWeight sysWeight = sysWeights.get(0);
|
|
|
|
|
BeanUtils.copyProperties(sysWeight, stuTrainingDto); // 提取权重数据
|
|
|
|
|
} else {
|
|
|
|
|
setDefaultWeights(stuTrainingDto);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BeanUtils.copyProperties(stuTrainingWithBLOBs, stuTrainingDto); // 完成情况和得分
|
|
|
|
|
|
|
|
|
|
// 计算各模块得分
|
|
|
|
|
calculateModuleScores(stuTrainingWithBLOBs, stuTrainingDto);
|
|
|
|
|
|
|
|
|
|
// 设置报告相关数据
|
|
|
|
|
setReportData(stuTrainingDto, stuTrainingWithBLOBs.getReportId());
|
|
|
|
|
|
|
|
|
|
return stuTrainingDto;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void setDefaultWeights(StuTrainingDto stuTrainingDto) {
|
|
|
|
|
stuTrainingDto.setKnowledgeSummaryDefaultRule(BigDecimal.valueOf(60));
|
|
|
|
|
stuTrainingDto.setResourceLearningDefaultRule(BigDecimal.valueOf(60));
|
|
|
|
|
stuTrainingDto.setLearningEvalDefaultRule(BigDecimal.valueOf(10));
|
|
|
|
|
stuTrainingDto.setExpTrainingDefautRule(BigDecimal.valueOf(2));
|
|
|
|
|
stuTrainingDto.setKnowledgeSummaryWeight(BigDecimal.valueOf(5));
|
|
|
|
|
stuTrainingDto.setResourceLearningWeight(BigDecimal.valueOf(5));
|
|
|
|
|
stuTrainingDto.setLearningEvalWeight(BigDecimal.valueOf(20));
|
|
|
|
|
stuTrainingDto.setExpTrainingWeight(BigDecimal.valueOf(60));
|
|
|
|
|
stuTrainingDto.setReportWeight(BigDecimal.valueOf(10));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void calculateModuleScores(StuTrainingWithBLOBs stuTrainingWithBLOBs, StuTrainingDto stuTrainingDto) {
|
|
|
|
|
stuTrainingDto.setKnowledgeSummaryScore(calculateScore(
|
|
|
|
|
stuTrainingDto.getKnowledgeSummaryDefaultRule(),
|
|
|
|
|
stuTrainingDto.getKnowledgeSummaryWeight(),
|
|
|
|
|
stuTrainingWithBLOBs.getKnowledgeSummaryCompleteStatus()
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
stuTrainingDto.setResourceLearningScore(calculateScore(
|
|
|
|
|
stuTrainingDto.getResourceLearningDefaultRule(),
|
|
|
|
|
stuTrainingDto.getResourceLearningWeight(),
|
|
|
|
|
stuTrainingWithBLOBs.getResourceLearningCompleteStatus()
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
stuTrainingDto.setLearningEvalScore(calculateEvaluationScore(
|
|
|
|
|
stuTrainingDto.getLearningEvalDefaultRule(),
|
|
|
|
|
stuTrainingDto.getLearningEvalWeight(),
|
|
|
|
|
stuTrainingWithBLOBs.getLearningEvalCompleteStatus()
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
stuTrainingDto.setCaseStuScore(calculateEvaluationScore(
|
|
|
|
|
stuTrainingDto.getExpTrainingDefautRule(),
|
|
|
|
|
stuTrainingDto.getExpTrainingWeight(),
|
|
|
|
|
stuTrainingWithBLOBs.getExpTrainingCompleteStatus()
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private BigDecimal calculateScore(BigDecimal defaultRule, BigDecimal weight, Integer completeStatus) {
|
|
|
|
|
if (completeStatus != null && completeStatus > 0) {
|
|
|
|
|
BigDecimal score = defaultRule.add(BigDecimal.valueOf((completeStatus - 1) * 10));
|
|
|
|
|
score = score.min(BigDecimal.valueOf(100)); // 确保分数不超过100
|
|
|
|
|
return score.multiply(weight.divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP));
|
|
|
|
|
}
|
|
|
|
|
return BigDecimal.ZERO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private BigDecimal calculateEvaluationScore(BigDecimal defaultRule, BigDecimal weight, Integer completeStatus) {
|
|
|
|
|
if (completeStatus != null) {
|
|
|
|
|
BigDecimal score = BigDecimal.valueOf(100).subtract(defaultRule.multiply(BigDecimal.valueOf(completeStatus)));
|
|
|
|
|
return score.max(BigDecimal.ZERO).multiply(weight.divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP));
|
|
|
|
|
}
|
|
|
|
|
return BigDecimal.ZERO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void setReportData(StuTrainingDto stuTrainingDto, String reportId) {
|
|
|
|
|
TrainingReport trainingReport = trainingReportMapper.selectByPrimaryKey(reportId);
|
|
|
|
|
if (trainingReport == null || trainingReport.getTeacherScore() == null) {
|
|
|
|
|
stuTrainingDto.setReportCompleteStatus("未提交");
|
|
|
|
|
stuTrainingDto.setReportScore(null);
|
|
|
|
|
} else {
|
|
|
|
|
stuTrainingDto.setReportCompleteStatus("已提交");
|
|
|
|
|
stuTrainingDto.setReportScore(trainingReport.getTeacherScore());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|