diff --git a/src/main/java/com/sztzjy/linkCommerce/controller/stu/TeaScoreController.java b/src/main/java/com/sztzjy/linkCommerce/controller/stu/TeaScoreController.java index 9cecea3..5d3001a 100644 --- a/src/main/java/com/sztzjy/linkCommerce/controller/stu/TeaScoreController.java +++ b/src/main/java/com/sztzjy/linkCommerce/controller/stu/TeaScoreController.java @@ -441,6 +441,7 @@ public class TeaScoreController { rank.setCompletedTaskCount(0); rank.setTrainingProgress(null); rank.setTeacherScore(null); + rank.setAiAssessmentScore(null); continue; } List answers = studentTrainingAnswerMapper == null ? Collections.emptyList() @@ -454,6 +455,7 @@ public class TeaScoreController { .multiply(BigDecimal.valueOf(100)) .divide(BigDecimal.valueOf(totalTaskCount), 2, BigDecimal.ROUND_HALF_UP)); rank.setTeacherScore(calculateTeacherScore(classId, allocations, answersByTaskKey)); + rank.setAiAssessmentScore(calculateAiAssessmentScore(classId, allocations, answersByTaskKey)); } } @@ -551,6 +553,48 @@ public class TeaScoreController { if (!hasTeacherScore) { return null; } + return weightedSixModuleScore(classId, scoresByProject, comprehensiveParticipating); + } + + /** + * AI评测成绩:与教师评分同一套六项目加权口径,聚合各任务的 ai_assessment_score。 + * 直接读 student_training_answer(实时),AI 评分完成即可见于教师端。 + */ + private BigDecimal calculateAiAssessmentScore(String classId, List allocations, + Map answersByTaskKey) { + if (teacherScoreService == null || trainingTaskMapper == null) { + return null; + } + Map> scoresByProject = new HashMap<>(); + boolean hasAiScore = false; + boolean comprehensiveParticipating = false; + for (TaskAllocation allocation : allocations) { + if (allocation == null || StringUtils.isBlank(allocation.getModule())) { + continue; + } + if ("comprehensive-case-training".equals(allocation.getModule())) { + comprehensiveParticipating = true; + } + TrainingTask task = trainingTaskMapper.selectByTaskKey(allocation.getModule()); + if (task == null || StringUtils.isBlank(task.getProjectName())) { + continue; + } + StudentTrainingAnswer answer = answersByTaskKey.get(allocation.getModule()); + Integer taskScore = answer == null ? null : answer.getAiAssessmentScore(); + if (taskScore != null) { + hasAiScore = true; + } + scoresByProject.computeIfAbsent(task.getProjectName(), key -> new ArrayList<>()) + .add(taskScore == null ? BigDecimal.ZERO : BigDecimal.valueOf(taskScore)); + } + if (!hasAiScore) { + return null; + } + return weightedSixModuleScore(classId, scoresByProject, comprehensiveParticipating); + } + + private BigDecimal weightedSixModuleScore(String classId, Map> scoresByProject, + boolean comprehensiveParticipating) { TeachingClassScoreWeight weight = teacherScoreService.getOrCreateWeightForCalculation(classId); if (weight == null) { return null; diff --git a/src/main/java/com/sztzjy/linkCommerce/entity/StuRank.java b/src/main/java/com/sztzjy/linkCommerce/entity/StuRank.java index 7dfe7fe..dd1e822 100644 --- a/src/main/java/com/sztzjy/linkCommerce/entity/StuRank.java +++ b/src/main/java/com/sztzjy/linkCommerce/entity/StuRank.java @@ -52,6 +52,9 @@ public class StuRank { @ApiModelProperty(notes = "老师人工评分(查询时从教学班评分表读取)") private BigDecimal teacherScore; + @ApiModelProperty(notes = "AI评测成绩(查询时按教学班任务聚合各任务ai_assessment_score,不落库)") + private BigDecimal aiAssessmentScore; + @ApiModelProperty(notes = "市场需求挖掘分数") private BigDecimal scqxwjScore; @@ -200,6 +203,14 @@ public class StuRank { this.teacherScore = teacherScore; } + public BigDecimal getAiAssessmentScore() { + return aiAssessmentScore; + } + + public void setAiAssessmentScore(BigDecimal aiAssessmentScore) { + this.aiAssessmentScore = aiAssessmentScore; + } + public BigDecimal getScqxwjScore() { return scqxwjScore; }