Browse Source

bug修复

master
luogw 2 months ago
parent
commit
cacb6bcd3c
  1. 2
      src/main/java/com/project/appeal/domain/entity/AppealEntity.java
  2. 2
      src/main/java/com/project/exam/domain/dto/ExamRecordDTO.java
  3. 4
      src/main/java/com/project/exam/domain/entity/ExamRecordEntity.java
  4. 4
      src/main/java/com/project/exam/domain/job/ShortAnswerScoringJob.java
  5. 13
      src/main/java/com/project/exam/domain/service/impl/BuildExamRecordDomainServiceImpl.java
  6. 1
      src/main/java/com/project/exam/domain/service/strategy/ClassicPaperStrategy.java
  7. 3
      src/main/java/com/project/task/domain/service/impl/CandidateSearchTaskDomainServiceImpl.java

2
src/main/java/com/project/appeal/domain/entity/AppealEntity.java

@ -45,7 +45,7 @@ public class AppealEntity extends BaseEntity {
@Column(name = "task_id" , columnDefinition="bigint(20) comment '考试任务id'") @Column(name = "task_id" , columnDefinition="bigint(20) comment '考试任务id'")
private Long taskId; private Long taskId;
@Column(name = "user_answer",columnDefinition = "varchar(255) comment '用户答案'") @Column(name = "user_answer",columnDefinition = "text comment '用户答案'")
@TableField("user_answer") @TableField("user_answer")
private String userAnswer; private String userAnswer;

2
src/main/java/com/project/exam/domain/dto/ExamRecordDTO.java

@ -78,8 +78,10 @@ public class ExamRecordDTO extends BaseDTO {
private String appealReason; private String appealReason;
// 该题分值 // 该题分值
private Double score; private Double score;
private String scoreStr;
// 用户得分 // 用户得分
private Double userScore; private Double userScore;
private String userScoreStr;
// V1.1 新增:AI评分(简答题实际得分) // V1.1 新增:AI评分(简答题实际得分)
private Double aiScore; private Double aiScore;
// V1.1 新增:AI评语 // V1.1 新增:AI评语

4
src/main/java/com/project/exam/domain/entity/ExamRecordEntity.java

@ -139,7 +139,9 @@ public class ExamRecordEntity extends BaseEntity {
dto.setAnswerSnapshotDTOList(dtoList); dto.setAnswerSnapshotDTOList(dtoList);
} }
//转成string类型,如果是整数则不显示小数部分,如果是小数则保留两位小数 //转成string类型,如果是整数则不显示小数部分,如果是小数则保留两位小数
String scoreStr = ObjectUtil.isNull(dto.getScore()) ? "0" : NumberFormat.getInstance().format(dto.getScore()); Double score = dto.getScore();
String scoreStr = score == null ? "0" :
score == score.longValue() ? String.valueOf(score.longValue()) : String.format("%.2f", score);
dto.setScoreStr(scoreStr); dto.setScoreStr(scoreStr);
} }
return result; return result;

4
src/main/java/com/project/exam/domain/job/ShortAnswerScoringJob.java

@ -20,6 +20,7 @@ import com.project.task.mapper.TaskMapper;
import com.project.task.mapper.TaskUserMapper; import com.project.task.mapper.TaskUserMapper;
import com.project.task.domain.service.TaskBaseService; import com.project.task.domain.service.TaskBaseService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
@ -185,7 +186,7 @@ public class ShortAnswerScoringJob {
AiScoringRequestDTO request = new AiScoringRequestDTO(); AiScoringRequestDTO request = new AiScoringRequestDTO();
request.setProducts(products); request.setProducts(products);
request.setQuestion(snapshot.getQuestionContent()); request.setQuestion(snapshot.getQuestionContent());
request.setUserAnswer(snapshot.getUserAnswer()); request.setUserAnswer(StringUtils.isBlank(snapshot.getUserAnswer()) ? "" : snapshot.getUserAnswer());
List<String> options = new ArrayList<>(); List<String> options = new ArrayList<>();
if (question != null && question.getQuestionDetail() != null if (question != null && question.getQuestionDetail() != null
&& question.getQuestionDetail().getScoringPoints() != null) { && question.getQuestionDetail().getScoringPoints() != null) {
@ -234,6 +235,7 @@ public class ShortAnswerScoringJob {
snapshot.setAiComment(comment.toString()); snapshot.setAiComment(comment.toString());
snapshot.setHitPoints(hitPoints); snapshot.setHitPoints(hitPoints);
snapshot.setScoringStatus(ExamRecordScoringStatusEnum.COMPLETED.getValue()); snapshot.setScoringStatus(ExamRecordScoringStatusEnum.COMPLETED.getValue());
snapshot.setIsRight(aiScore >= shortAnswerScore);
log.info(">>> [简答题评分任务] 评分完成, questionId={}, shortAnswerScore={}, totalPoints={}, hitPoints={}, aiScore={}", log.info(">>> [简答题评分任务] 评分完成, questionId={}, shortAnswerScore={}, totalPoints={}, hitPoints={}, aiScore={}",
snapshot.getQuestionId(), shortAnswerScore, totalPoints, hitPoints, aiScore); snapshot.getQuestionId(), shortAnswerScore, totalPoints, hitPoints, aiScore);

13
src/main/java/com/project/exam/domain/service/impl/BuildExamRecordDomainServiceImpl.java

@ -43,19 +43,27 @@ public class BuildExamRecordDomainServiceImpl implements BuildExamRecordDomainSe
if (QuestionTypeEnum.SINGLE_CHOICE.getValue().equals(answerSnapshotDTO.getType())) { if (QuestionTypeEnum.SINGLE_CHOICE.getValue().equals(answerSnapshotDTO.getType())) {
answerSnapshotDTO.setScore(dto.getTaskDTO().getSingleChoiceScore()); answerSnapshotDTO.setScore(dto.getTaskDTO().getSingleChoiceScore());
answerSnapshotDTO.setScoreStr(buildeScore(dto.getTaskDTO().getSingleChoiceScore()));
answerSnapshotDTO.setUserScore(BooleanUtil.isTrue(answerSnapshotDTO.getIsRight()) ? answerSnapshotDTO.setUserScore(BooleanUtil.isTrue(answerSnapshotDTO.getIsRight()) ?
dto.getTaskDTO().getSingleChoiceScore() : 0); dto.getTaskDTO().getSingleChoiceScore() : 0);
answerSnapshotDTO.setUserScoreStr(buildeScore(answerSnapshotDTO.getUserScore()));
} else if (QuestionTypeEnum.TRUE_FALSE.getValue().equals(answerSnapshotDTO.getType())) { } else if (QuestionTypeEnum.TRUE_FALSE.getValue().equals(answerSnapshotDTO.getType())) {
answerSnapshotDTO.setScore(dto.getTaskDTO().getTrueFalseScore()); answerSnapshotDTO.setScore(dto.getTaskDTO().getTrueFalseScore());
answerSnapshotDTO.setScoreStr(buildeScore(dto.getTaskDTO().getTrueFalseScore()));
answerSnapshotDTO.setUserScore(BooleanUtil.isTrue(answerSnapshotDTO.getIsRight()) ? answerSnapshotDTO.setUserScore(BooleanUtil.isTrue(answerSnapshotDTO.getIsRight()) ?
dto.getTaskDTO().getTrueFalseScore() : 0); dto.getTaskDTO().getTrueFalseScore() : 0);
answerSnapshotDTO.setUserScoreStr(buildeScore(answerSnapshotDTO.getUserScore()));
} else if (QuestionTypeEnum.MULTIPLE_CHOICE.getValue().equals(answerSnapshotDTO.getType())){ } else if (QuestionTypeEnum.MULTIPLE_CHOICE.getValue().equals(answerSnapshotDTO.getType())){
answerSnapshotDTO.setScore(dto.getTaskDTO().getMultipleChoiceScore()); answerSnapshotDTO.setScore(dto.getTaskDTO().getMultipleChoiceScore());
answerSnapshotDTO.setScoreStr(buildeScore(dto.getTaskDTO().getMultipleChoiceScore()));
answerSnapshotDTO.setUserScore(BooleanUtil.isTrue(answerSnapshotDTO.getIsRight()) ? answerSnapshotDTO.setUserScore(BooleanUtil.isTrue(answerSnapshotDTO.getIsRight()) ?
dto.getTaskDTO().getMultipleChoiceScore() : 0); dto.getTaskDTO().getMultipleChoiceScore() : 0);
answerSnapshotDTO.setUserScoreStr(buildeScore(answerSnapshotDTO.getUserScore()));
}else{ }else{
answerSnapshotDTO.setScore(dto.getTaskDTO().getShortAnswerScore()); answerSnapshotDTO.setScore(dto.getTaskDTO().getShortAnswerScore());
answerSnapshotDTO.setScoreStr(buildeScore(dto.getTaskDTO().getShortAnswerScore()));
answerSnapshotDTO.setUserScore(answerSnapshotDTO.getAiScore()); answerSnapshotDTO.setUserScore(answerSnapshotDTO.getAiScore());
answerSnapshotDTO.setUserScoreStr(buildeScore(answerSnapshotDTO.getUserScore()));
} }
answerSnapshotDTO.setTypeText(Try.of(() -> answerSnapshotDTO.setTypeText(Try.of(() ->
QuestionTypeEnum.findByValue(answerSnapshotDTO.getType()).getDescription()) QuestionTypeEnum.findByValue(answerSnapshotDTO.getType()).getDescription())
@ -99,10 +107,15 @@ public class BuildExamRecordDomainServiceImpl implements BuildExamRecordDomainSe
if (QuestionTypeEnum.SHORT_ANSWER.getValue().equals(answerSnapshotDTO.getType()) if (QuestionTypeEnum.SHORT_ANSWER.getValue().equals(answerSnapshotDTO.getType())
&& AppealStatusEnum.PASS_REVIEW.getValue().equals(appeal.getStatus())) { && AppealStatusEnum.PASS_REVIEW.getValue().equals(appeal.getStatus())) {
answerSnapshotDTO.setUserScore(appeal.getRevisedScore()); answerSnapshotDTO.setUserScore(appeal.getRevisedScore());
answerSnapshotDTO.setUserScoreStr(buildeScore(appeal.getRevisedScore()));
} }
} }
} }
}); });
return dto; return dto;
} }
private String buildeScore(Double score){
return score == score.longValue() ? String.valueOf(score.longValue()) : String.format("%.2f", score);
}
} }

1
src/main/java/com/project/exam/domain/service/strategy/ClassicPaperStrategy.java

@ -124,6 +124,7 @@ public class ClassicPaperStrategy implements PaperAssemblyStrategy {
examRecordDTO.setTaskUserId(taskUser.getId()); examRecordDTO.setTaskUserId(taskUser.getId());
examRecordDTO.setTaskId(taskId); examRecordDTO.setTaskId(taskId);
examRecordDTO.setTaskName(task.getName()); examRecordDTO.setTaskName(task.getName());
examRecordDTO.setStartTime(new Date());
examRecordDTO.setAnswerSnapshotDTOList(snapshotDTOList); examRecordDTO.setAnswerSnapshotDTOList(snapshotDTOList);
// 9. 保存考试记录(通过 taskUserId 关联) // 9. 保存考试记录(通过 taskUserId 关联)

3
src/main/java/com/project/task/domain/service/impl/CandidateSearchTaskDomainServiceImpl.java

@ -201,7 +201,8 @@ public class CandidateSearchTaskDomainServiceImpl implements CandidateSearchTask
ExamRecordEntity examRecordEntity = examRecordMapper.selectById(taskUserEntity.getLastRecordId()); ExamRecordEntity examRecordEntity = examRecordMapper.selectById(taskUserEntity.getLastRecordId());
dto.setLastRecordScore(examRecordEntity.getScore()); dto.setLastRecordScore(examRecordEntity.getScore());
//转成string类型,如果是整数则不显示小数部分,如果是小数则保留两位小数 //转成string类型,如果是整数则不显示小数部分,如果是小数则保留两位小数
String lastRecordScoreStr = ObjectUtil.isNull(examRecordEntity.getScore()) ? "0" : NumberFormat.getInstance().format(examRecordEntity.getScore()); String lastRecordScoreStr = examRecordEntity.getScore() == null ? "0" :
examRecordEntity.getScore() == examRecordEntity.getScore().longValue() ? String.valueOf(examRecordEntity.getScore().longValue()) : String.format("%.2f", examRecordEntity.getScore());
dto.setLastRecordScoreStr(lastRecordScoreStr); dto.setLastRecordScoreStr(lastRecordScoreStr);
} }
dto.setTotalScore((int) Math.floor(entity.getTotalScore())); dto.setTotalScore((int) Math.floor(entity.getTotalScore()));

Loading…
Cancel
Save