fix: AI评分后教师端成绩列表延迟~24小时才更新——重评claim的快照BINARY长文本比对失效导致重评被静默跳过,移除该条件(快照变化已在Java侧判断);AI评分落库后异步重建本教学班stu_rank当日快照

main
chenyuan 13 hours ago
parent de02726c97
commit e5a2bd740f

@ -20,6 +20,7 @@ import com.sztzjy.linkCommerce.mapper.TeachingClassStudentMapper;
import com.sztzjy.linkCommerce.mapper.TrainingTaskMapper; import com.sztzjy.linkCommerce.mapper.TrainingTaskMapper;
import com.sztzjy.linkCommerce.mapper.TrainingTaskClassConfigMapper; import com.sztzjy.linkCommerce.mapper.TrainingTaskClassConfigMapper;
import com.sztzjy.linkCommerce.service.AiTrainingEvaluationService; import com.sztzjy.linkCommerce.service.AiTrainingEvaluationService;
import com.sztzjy.linkCommerce.service.ScoreRankService;
import com.sztzjy.linkCommerce.service.TrainingKnowledgeService; import com.sztzjy.linkCommerce.service.TrainingKnowledgeService;
import com.sztzjy.linkCommerce.training.knowledge.EffectiveTrainingTaskContent; import com.sztzjy.linkCommerce.training.knowledge.EffectiveTrainingTaskContent;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -35,6 +36,7 @@ import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.CompletableFuture;
@Slf4j @Slf4j
@Service @Service
@ -63,6 +65,8 @@ public class AiTrainingEvaluationServiceImpl implements AiTrainingEvaluationServ
public StudentTrainingAnswerMapper studentTrainingAnswerMapper; public StudentTrainingAnswerMapper studentTrainingAnswerMapper;
@Autowired @Autowired
public TeachingClassStudentMapper teachingClassStudentMapper; public TeachingClassStudentMapper teachingClassStudentMapper;
@Autowired
public ScoreRankService scoreRankService;
@Autowired(required = false) @Autowired(required = false)
public TrainingTaskClassConfigMapper trainingTaskClassConfigMapper; public TrainingTaskClassConfigMapper trainingTaskClassConfigMapper;
@Autowired(required = false) @Autowired(required = false)
@ -129,6 +133,7 @@ public class AiTrainingEvaluationServiceImpl implements AiTrainingEvaluationServ
EvaluationContext context = resolveContext(taskKey, user, true); EvaluationContext context = resolveContext(taskKey, user, true);
AiTrainingEvaluation evaluation = getOrCreate(context, user); AiTrainingEvaluation evaluation = getOrCreate(context, user);
if (PROCESSING.equals(evaluation.getAssessmentStatus()) && !isProcessingTimedOut(evaluation)) { if (PROCESSING.equals(evaluation.getAssessmentStatus()) && !isProcessingTimedOut(evaluation)) {
log.info("AI assessment still processing, evaluationId={}", evaluation.getId());
return toView(evaluation); return toView(evaluation);
} }
String answerSnapshot = answerSnapshot(context.answer); String answerSnapshot = answerSnapshot(context.answer);
@ -145,6 +150,8 @@ public class AiTrainingEvaluationServiceImpl implements AiTrainingEvaluationServ
? aiTrainingEvaluationMapper.claimReassessment(evaluation.getId(), evaluation.getAssessmentAnswerSnapshot(), new Date()) ? aiTrainingEvaluationMapper.claimReassessment(evaluation.getId(), evaluation.getAssessmentAnswerSnapshot(), new Date())
: aiTrainingEvaluationMapper.claimAssessment(evaluation.getId(), new Date()); : aiTrainingEvaluationMapper.claimAssessment(evaluation.getId(), new Date());
if (claimed != 1) { if (claimed != 1) {
log.info("AI assessment claim skipped, evaluationId={}, reassessment={}, claimed={}",
evaluation.getId(), reassessment, claimed);
return currentView(context, user); return currentView(context, user);
} }
@ -171,6 +178,9 @@ public class AiTrainingEvaluationServiceImpl implements AiTrainingEvaluationServ
completed.setAssessmentCompletedAt(completedAt); completed.setAssessmentCompletedAt(completedAt);
completed.setUpdateTime(completedAt); completed.setUpdateTime(completedAt);
completeAssessmentAndWriteScore(completed, context.answer.getId(), score, completedAt); completeAssessmentAndWriteScore(completed, context.answer.getId(), score, completedAt);
// 教师端成绩列表读的是 stu_rank 每日快照(凌晨1点定时重建),
// 不在这里立即刷新本班快照,新 AI 分数要等次日才会出现在教师端。
refreshScoreRankAfterAssessment(user, context.teachingClassId);
completed.setHelpStatus(evaluation.getHelpStatus()); completed.setHelpStatus(evaluation.getHelpStatus());
completed.setAssessmentStatus(SUCCEEDED); completed.setAssessmentStatus(SUCCEEDED);
return toView(completed); return toView(completed);
@ -215,6 +225,26 @@ public class AiTrainingEvaluationServiceImpl implements AiTrainingEvaluationServ
}); });
} }
/**
* AI 分数落库后立即重建本教学班的 stu_rank 当日快照(与每日凌晨定时重建同一套逻辑),
* 教师端成绩列表马上能看到新分数。异步执行且失败只记日志:排名刷新失败不能影响评分结果。
*/
private void refreshScoreRankAfterAssessment(JwtUser user, String teachingClassId) {
String schoolId = user == null ? null : user.getSchoolId();
if (scoreRankService == null || StringUtils.isAnyBlank(schoolId, teachingClassId)) {
return;
}
CompletableFuture.runAsync(() -> {
try {
if (!scoreRankService.doRankTeachingClass(schoolId, teachingClassId)) {
scoreRankService.doRankOne(schoolId);
}
} catch (RuntimeException e) {
log.warn("AI assessment score rank refresh failed, teachingClassId={}", teachingClassId, e);
}
});
}
private AiTrainingEvaluation getOrCreate(EvaluationContext context, JwtUser user) { private AiTrainingEvaluation getOrCreate(EvaluationContext context, JwtUser user) {
AiTrainingEvaluation evaluation = aiTrainingEvaluationMapper.findByStudentClassAndTask( AiTrainingEvaluation evaluation = aiTrainingEvaluationMapper.findByStudentClassAndTask(
user.getUserId(), context.teachingClassId, context.task.getId()); user.getUserId(), context.teachingClassId, context.task.getId());

@ -78,7 +78,6 @@
SET assessment_status = 'PROCESSING', assessment_error_message = NULL, update_time = #{updateTime,jdbcType=TIMESTAMP} SET assessment_status = 'PROCESSING', assessment_error_message = NULL, update_time = #{updateTime,jdbcType=TIMESTAMP}
WHERE id = #{id,jdbcType=VARCHAR} WHERE id = #{id,jdbcType=VARCHAR}
AND assessment_status = 'SUCCEEDED' AND assessment_status = 'SUCCEEDED'
AND (BINARY assessment_answer_snapshot <=> BINARY #{expectedAnswerSnapshot,jdbcType=LONGVARCHAR})
</update> </update>
<update id="completeHelp" parameterType="com.sztzjy.linkCommerce.entity.AiTrainingEvaluation"> <update id="completeHelp" parameterType="com.sztzjy.linkCommerce.entity.AiTrainingEvaluation">

Loading…
Cancel
Save