|
|
|
@ -65,20 +65,11 @@ public class SaveAppealDomainServiceImpl implements SaveAppealDomainService { |
|
|
|
appealBaseService.saveOrUpdate(entity); |
|
|
|
appealDTO = appealBaseService.getById(entity.getId()).toDTO(AppealDTO::new); |
|
|
|
|
|
|
|
//如果审核通过,需要为用户加分
|
|
|
|
if (!appealDTO.getStatus().equals(AppealStatusEnum.PASS_REVIEW.getValue())) { |
|
|
|
//审核拒绝,发送工作通知消息,告知用户
|
|
|
|
if (appealDTO.getStatus().equals(AppealStatusEnum.REFUSE_REVIEW.getValue())) { |
|
|
|
dingUtil.sendWorkNotice(appealDTO); |
|
|
|
} |
|
|
|
return Result.success(appealDTO); |
|
|
|
} |
|
|
|
|
|
|
|
ExamRecordEntity examRecord = examRecordMapper.selectById(appealDTO.getExamId()); |
|
|
|
if (examRecord == null){ |
|
|
|
throw new BusinessErrorException("用户未该场考试"); |
|
|
|
} |
|
|
|
//找到题目相关信息,获取该类型题目分数
|
|
|
|
//找到题目相关信息
|
|
|
|
ExamRecordDTO examRecordDTO = examRecord.toDTO(ExamRecordDTO::new); |
|
|
|
List<ExamRecordDTO.QuestionSnapshotDTO> answerSnapshotDTOList = examRecordDTO.getAnswerSnapshotDTOList(); |
|
|
|
ExamRecordDTO.QuestionSnapshotDTO questionSnapshotDTO = null; |
|
|
|
@ -98,11 +89,33 @@ public class SaveAppealDomainServiceImpl implements SaveAppealDomainService { |
|
|
|
throw new BusinessErrorException("题目不存在"); |
|
|
|
} |
|
|
|
|
|
|
|
TaskEntity taskEntity = taskMapper.getTaskByTaskUserId(examRecord.getTaskUserId()); |
|
|
|
appealDTO.setQuestionContent(questionSnapshotDTO.getQuestionContent()); |
|
|
|
|
|
|
|
if (appealDTO.getStatus().equals(AppealStatusEnum.PENDING_REVIEW.getValue())) { |
|
|
|
//更新申诉状态
|
|
|
|
examRecordMapper.updateHasAppealed(index, examRecordDTO.getId()); |
|
|
|
}else if(appealDTO.getStatus().equals(AppealStatusEnum.PASS_REVIEW.getValue())){ |
|
|
|
//审批通过需要加分
|
|
|
|
calculateScore(appealDTO, examRecordDTO, questionSnapshotDTO.getType()); |
|
|
|
return Result.success(appealDTO); |
|
|
|
} |
|
|
|
|
|
|
|
//通知用户
|
|
|
|
dingUtil.sendWorkNotice(appealDTO); |
|
|
|
|
|
|
|
return Result.success(appealDTO); |
|
|
|
} |
|
|
|
|
|
|
|
QuestionTypeEnum questionType = QuestionTypeEnum.findByValue(questionSnapshotDTO.getType()); |
|
|
|
/** |
|
|
|
* 计算分数(审批通过需要加分) |
|
|
|
*/ |
|
|
|
public void calculateScore(AppealDTO appealDTO, ExamRecordDTO examRecordDTO,int type) { |
|
|
|
//审批通过需要加分
|
|
|
|
TaskEntity taskEntity = taskMapper.getTaskByTaskUserId(examRecordDTO.getTaskUserId()); |
|
|
|
|
|
|
|
QuestionTypeEnum questionType = QuestionTypeEnum.findByValue(type); |
|
|
|
if (questionType == null) { |
|
|
|
throw new BusinessErrorException("不支持的题目类型:" + questionSnapshotDTO.getType()); |
|
|
|
throw new BusinessErrorException("不支持的题目类型:" + type); |
|
|
|
} |
|
|
|
Double questionScore = switch (questionType) { |
|
|
|
case SINGLE_CHOICE-> taskEntity.getSingleChoiceScore(); |
|
|
|
@ -126,11 +139,11 @@ public class SaveAppealDomainServiceImpl implements SaveAppealDomainService { |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
//保存
|
|
|
|
examRecordMapper.updateScore(index,score.doubleValue(),examRecord.getId()); |
|
|
|
//通知用户
|
|
|
|
dingUtil.sendWorkNotice(appealDTO); |
|
|
|
if(score.compareTo(new BigDecimal(100)) > 0){ |
|
|
|
score = new BigDecimal(100); |
|
|
|
}; |
|
|
|
|
|
|
|
return Result.success(appealDTO); |
|
|
|
//保存
|
|
|
|
examRecordMapper.updateScore(score.doubleValue(),examRecordDTO.getId()); |
|
|
|
} |
|
|
|
} |
|
|
|
|