优化老师端练习模式展示接口,调整综合得分逻辑

master
xiaoCJ 3 months ago
parent a62395529d
commit 83f934bcb5

@ -38,6 +38,6 @@ public class Constant {
public static final String THEORY = "理论考试模块";
public static final String RESOURCE = "资源中心模块";
public static final String API_URL = "http://120.79.54.255:8889";
// public static final String API_URL = "http://192.168.2.25:8889";
// public static final String API_URL = "http://192.168.2.19:8889";
}

@ -25,6 +25,16 @@ public class StuTrainingStepRecord {
@ApiModelProperty("学生答案")
private String stuAnswer;
private String threeId;
public String getThreeId() {
return threeId;
}
public void setThreeId(String threeId) {
this.threeId = threeId;
}
public String getRecordId() {
return recordId;
}

@ -29,6 +29,16 @@ public class TestTestSysCaseQuestionStepWithBLOBs extends TestSysCaseQuestionSte
@ApiModelProperty("练习答案原始数据")
private String practiceAnswerOriginal;
private String threeId;
public String getThreeId() {
return threeId;
}
public void setThreeId(String threeId) {
this.threeId = threeId;
}
public String getPracticeAnswer() {
return practiceAnswer;
}

@ -37,6 +37,7 @@ public class CaseApi {
private final static String deleteCaseStep = Constant.API_URL + "/api/tea/CaseApi/deleteCaseStep";
private final static String selectCaseStepDetails = Constant.API_URL + "/api/tea/CaseApi/selectCaseStepDetails";
private final static String selectCaseStepListBatchByIdListAndSort = Constant.API_URL + "/api/tea/CaseApi/selectCaseStepListBatchByIdListAndSort";
private final static String selectCaseStepListBatchByIdList = Constant.API_URL + "/api/tea/CaseApi/selectCaseStepListBatchByIdList";
private final static String selectAllStepBySystemOwner = Constant.API_URL + "/api/tea/CaseApi/selectAllStepBySystemOwner";
@ -91,8 +92,8 @@ public class CaseApi {
* local:
* rsapi:
*/
public static TestSysCaseQuestion selectCaseDetails(String caseId,String systemOwner) throws IOException {
String requestBody = "caseId=" + caseId+"&systemOwner="+systemOwner;
public static TestSysCaseQuestion selectCaseDetails(String caseId, String systemOwner) throws IOException {
String requestBody = "caseId=" + caseId + "&systemOwner=" + systemOwner;
JSONObject object = HttpUtils.sendPost(
selectCaseDetails,
requestBody);
@ -145,7 +146,7 @@ public class CaseApi {
* rsapi:Id
*/
public static List<TestSysCaseQuestion> selectCaseByCourseId(String courseId, String systemOwner, String schoolId) throws IOException {
String requestBody = "courseId=" + courseId+"&systemOwner="+systemOwner+"&schoolId="+schoolId;
String requestBody = "courseId=" + courseId + "&systemOwner=" + systemOwner + "&schoolId=" + schoolId;
JSONObject object = HttpUtils.sendPost(
selectCaseByCourseId,
requestBody);
@ -287,7 +288,7 @@ public class CaseApi {
* local:
*/
public static List<TestTestSysCaseQuestionStepWithBLOBs> selectCaseStepListBatchByIdListAndSort(String chapterId) throws IOException {
String requestBody="threeId="+chapterId;
String requestBody = "threeId=" + chapterId;
JSONObject object = HttpUtils.sendPost(
selectCaseStepListBatchByIdListAndSort,
requestBody);
@ -300,6 +301,17 @@ public class CaseApi {
return list;
}
public static List<TestTestSysCaseQuestionStepWithBLOBs> selectCaseStepListBatchByIdList(List<String> list) throws IOException {
Gson gson = new Gson();
JSONObject object = HttpUtils.sendPost(
selectCaseStepListBatchByIdList,
gson.toJson(list), "application/json", null);
Type listType = new TypeToken<List<TestTestSysCaseQuestionStepWithBLOBs>>() {
}.getType();
List<TestTestSysCaseQuestionStepWithBLOBs> resultList = gson.fromJson(object.get("respString").toString(), listType);
return resultList;
}
/**
*
*
@ -323,10 +335,10 @@ public class CaseApi {
*
* --questionOriginalcontentOriginal,Sort
*/
public static List<TestTestSysCaseQuestionStepWithBLOBs> getGradeReportCase(List<String> caseIdList, String schoolId,String systemOwner) throws IOException {
public static List<TestTestSysCaseQuestionStepWithBLOBs> getGradeReportCase(List<String> caseIdList, String schoolId, String systemOwner) throws IOException {
Gson gson = new Gson();
// 构建带有 schoolId 的 URL
String urlWithParams = getGradeReportCase + "?schoolId=" + URLEncoder.encode(schoolId, "UTF-8")+"&systemOwner="+ systemOwner;
String urlWithParams = getGradeReportCase + "?schoolId=" + URLEncoder.encode(schoolId, "UTF-8") + "&systemOwner=" + systemOwner;
JSONObject object = HttpUtils.sendPost(
urlWithParams,
gson.toJson(caseIdList), "application/json", null);
@ -345,7 +357,7 @@ public class CaseApi {
JSONObject object = HttpUtils.sendPost(
selectAllStepBySystemOwner,
requestBody);
if(object==null){
if (object == null) {
return null;
}
Gson gson = new GsonBuilder()

@ -164,7 +164,7 @@ public class StuScoreServiceImpl implements StuScoreService {
//3.记录表中所有ID得分之和
StuTrainingStepRecordExample example =new StuTrainingStepRecordExample();
example.createCriteria().andCaseStepIdIn(stepIdList);
example.createCriteria().andCaseStepIdIn(stepIdList).andUserIdEqualTo(stuTrainingWithBLOBs.getUserId());
List<StuTrainingStepRecord> stuTrainingStepRecords = trainingStepRecordMapper.selectByExampleWithBLOBs(example);
double stuTotalScore = stuTrainingStepRecords.stream() //学生总共得分

@ -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);

Loading…
Cancel
Save