Browse Source

申述审批

master
luogw 2 months ago
parent
commit
3435fa3be3
  1. 8
      src/main/java/com/project/appeal/application/Impl/AppealApplicationImpl.java
  2. 17
      src/main/java/com/project/appeal/domain/dto/AppealDTO.java
  3. 15
      src/main/java/com/project/appeal/domain/dto/AppealExportDTO.java
  4. 6
      src/main/java/com/project/appeal/domain/entity/AppealEntity.java
  5. 5
      src/main/java/com/project/appeal/domain/param/AppealParam.java
  6. 73
      src/main/java/com/project/appeal/domain/service/Impl/CheckAppealDomainServiceImpl.java
  7. 52
      src/main/java/com/project/appeal/domain/service/Impl/SaveAppealDomainServiceImpl.java
  8. 49
      src/main/java/com/project/appeal/domain/service/Impl/SearchAppealDomainServiceImpl.java
  9. 5
      src/main/java/com/project/exam/domain/entity/ExamRecordEntity.java
  10. 10
      src/main/java/com/project/exam/domain/service/impl/BuildExamRecordDomainServiceImpl.java
  11. 13
      src/main/java/com/project/exam/mapper/ExamRecordMapper.java
  12. 2
      src/main/java/com/project/information/mapper/ProductLineMapper.java
  13. 3
      src/main/java/com/project/statistics/domain/service/impl/SaveSaveErrorProneStatisticsDomainServiceImpl.java
  14. 3
      src/main/java/com/project/task/domain/service/impl/CandidateSearchTaskDomainServiceImpl.java
  15. 2
      src/main/java/com/project/task/mapper/TaskMapper.java

8
src/main/java/com/project/appeal/application/Impl/AppealApplicationImpl.java

@ -75,10 +75,10 @@ public class AppealApplicationImpl implements AppealApplication {
if (dto.getId() != null) { if (dto.getId() != null) {
exportDTO.setId(String.valueOf(dto.getId())); exportDTO.setId(String.valueOf(dto.getId()));
} }
// 格式化操作时间为字符串 // 格式化操作时间为字符串,V1.1去掉
if (dto.getUpdateTime() != null) { // if (dto.getUpdateTime() != null) {
exportDTO.setUpdateTime(sdf.format(dto.getUpdateTime())); // exportDTO.setUpdateTime(sdf.format(dto.getUpdateTime()));
} // }
appealExportDTOList.add(exportDTO); appealExportDTOList.add(exportDTO);
} }

17
src/main/java/com/project/appeal/domain/dto/AppealDTO.java

@ -1,18 +1,8 @@
package com.project.appeal.domain.dto; package com.project.appeal.domain.dto;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.project.base.domain.dto.BaseDTO; import com.project.base.domain.dto.BaseDTO;
import com.project.base.domain.entity.BaseEntity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.Comment;
import java.util.List; import java.util.List;
@ -37,4 +27,9 @@ public class AppealDTO extends BaseDTO {
private Integer status = 1; private Integer status = 1;
private String remark; private String remark;
private String reason; private String reason;
// V1.1 新增:题目分数
private Double score;
private String scoreStr;
// V1.1 新增:修改后得分
private Double revisedScore;
} }

15
src/main/java/com/project/appeal/domain/dto/AppealExportDTO.java

@ -8,14 +8,16 @@ public class AppealExportDTO{
@ExcelProperty("ID") @ExcelProperty("ID")
private String id; private String id;
@ExcelProperty("关联子产品线") /*V1.1去掉*/
private String subLineName; // @ExcelProperty("关联子产品线")
// private String subLineName;
@ExcelProperty("用户名") @ExcelProperty("用户名")
private String username; private String username;
@ExcelProperty("知识点") /*V1.1去掉*/
private String kpContentsStr; // @ExcelProperty("知识点")
// private String kpContentsStr;
@ExcelProperty("题目") @ExcelProperty("题目")
private String questionContent; private String questionContent;
@ -29,6 +31,7 @@ public class AppealExportDTO{
@ExcelProperty("申诉备注") @ExcelProperty("申诉备注")
private String remark; private String remark;
@ExcelProperty(value = "操作时间") /*V1.1去掉*/
private String updateTime; // @ExcelProperty(value = "操作时间")
// private String updateTime;
} }

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

@ -63,4 +63,10 @@ public class AppealEntity extends BaseEntity {
@Column(name = "reason",columnDefinition = "varchar(600) comment '审批理由'") @Column(name = "reason",columnDefinition = "varchar(600) comment '审批理由'")
private String reason; private String reason;
// V1.1 新增:用于存储审批通过后,修改得分
@Comment("修改后得分")
@Column(name = "revised_score")
@TableField("revised_score")
private Double revisedScore;
} }

5
src/main/java/com/project/appeal/domain/param/AppealParam.java

@ -9,4 +9,9 @@ public class AppealParam extends BaseParam {
public Long lineId; public Long lineId;
public Long businessId; public Long businessId;
public String subLineName; public String subLineName;
// V1.1 新增
// 考试任务ID
public Long taskId;
// 申诉人用户名
public String username;
} }

73
src/main/java/com/project/appeal/domain/service/Impl/CheckAppealDomainServiceImpl.java

@ -12,10 +12,16 @@ import com.project.base.domain.exception.MissingParameterException;
import com.project.base.domain.exception.PermissionErrorException; import com.project.base.domain.exception.PermissionErrorException;
import com.project.ding.domain.enums.UserRoleEnum; import com.project.ding.domain.enums.UserRoleEnum;
import com.project.ding.utils.SecurityUtils; import com.project.ding.utils.SecurityUtils;
import com.project.question.domain.entity.QuestionEntity;
import com.project.question.domain.service.QuestionBaseService;
import com.project.task.domain.entity.TaskEntity;
import com.project.task.domain.enums.QuestionTypeEnum;
import com.project.task.domain.service.TaskBaseService;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.List; import java.util.List;
@Service @Service
@ -23,32 +29,40 @@ public class CheckAppealDomainServiceImpl implements CheckAppealDomainService {
@Autowired @Autowired
private AppealBaseService appealBaseService; private AppealBaseService appealBaseService;
@Autowired
private QuestionBaseService questionBaseService;
@Autowired
private TaskBaseService taskBaseService;
@Override @Override
public void checkDto(AppealDTO appealDTO) { public void checkDto(AppealDTO appealDTO) {
if (ObjectUtil.isEmpty(appealDTO.getId()) && ObjectUtil.isEmpty(appealDTO.getExamId())){ //申述
if (ObjectUtil.isEmpty(appealDTO.getId())){
if (ObjectUtil.isNull(appealDTO.getExamId())){
throw new MissingParameterException("缺少考试ID"); throw new MissingParameterException("缺少考试ID");
} }
if (ObjectUtil.isEmpty(appealDTO.getId()) && ObjectUtil.isEmpty(appealDTO.getQuestionId())){ if (ObjectUtil.isNull(appealDTO.getQuestionId())){
throw new MissingParameterException("缺少题目ID"); throw new MissingParameterException("缺少题目ID");
} }
if (ObjectUtil.isEmpty(appealDTO.getId()) && StringUtils.isBlank(appealDTO.getUserAnswer())){ if (StringUtils.isBlank(appealDTO.getUserAnswer())){
throw new MissingParameterException("缺少用户答案"); throw new MissingParameterException("缺少用户答案");
} }
if (ObjectUtil.isEmpty(appealDTO.getId()) && StringUtils.isBlank(appealDTO.getRemark())){ if (ObjectUtil.isNull(appealDTO.getTaskId())){
throw new MissingParameterException("缺少申诉理由"); throw new MissingParameterException("缺少考试任务");
} }
TaskEntity task = taskBaseService.getById(appealDTO.getTaskId());
if (ObjectUtil.isEmpty(appealDTO.getId()) && !appealDTO.getStatus().equals(AppealStatusEnum.PENDING_REVIEW.getValue())){ if (ObjectUtil.isNull(task)){
throw new BusinessErrorException("申诉状态错误"); throw new MissingParameterException("考试任务不存在");
} }
if (ObjectUtil.isNotEmpty(appealDTO.getId()) && appealDTO.getStatus().equals(AppealStatusEnum.PENDING_REVIEW.getValue())){ if (StringUtils.isBlank(appealDTO.getRemark())){
throw new BusinessErrorException("申诉状态错误"); throw new MissingParameterException("缺少申诉理由");
} }
if (!appealDTO.getStatus().equals(AppealStatusEnum.PENDING_REVIEW.getValue()) && StringUtils.isBlank(appealDTO.getReason())){ if (!appealDTO.getStatus().equals(AppealStatusEnum.PENDING_REVIEW.getValue())){
throw new BusinessErrorException("缺少审批意见"); throw new BusinessErrorException("申诉状态错误");
} }
//校验题目是否以申诉过 //校验题目是否以申诉过
if (ObjectUtil.isEmpty(appealDTO.getId()) ){
QueryWrapper<AppealEntity> entityQueryWrapper = new QueryWrapper<>(); QueryWrapper<AppealEntity> entityQueryWrapper = new QueryWrapper<>();
entityQueryWrapper.eq("exam_id", appealDTO.getExamId()); entityQueryWrapper.eq("exam_id", appealDTO.getExamId());
entityQueryWrapper.eq("question_id", appealDTO.getQuestionId()); entityQueryWrapper.eq("question_id", appealDTO.getQuestionId());
@ -57,21 +71,48 @@ public class CheckAppealDomainServiceImpl implements CheckAppealDomainService {
throw new BusinessErrorException("题目已申诉"); throw new BusinessErrorException("题目已申诉");
} }
} }
//审批
if (ObjectUtil.isNotEmpty(appealDTO.getId()) ){
if(appealDTO.getStatus().equals(AppealStatusEnum.PENDING_REVIEW.getValue())) {
throw new BusinessErrorException("申诉状态错误");
}
//校验当前数据是否以审批 //校验当前数据是否以审批
if (ObjectUtil.isNotEmpty(appealDTO.getId())){
AppealEntity entity = appealBaseService.getById(appealDTO.getId()); AppealEntity entity = appealBaseService.getById(appealDTO.getId());
if (!entity.getStatus().equals(AppealStatusEnum.PENDING_REVIEW.getValue())){ if (!entity.getStatus().equals(AppealStatusEnum.PENDING_REVIEW.getValue())){
throw new BusinessErrorException("题目已审批"); throw new BusinessErrorException("题目已审批");
} }
}
//权限校验 //权限校验
if (ObjectUtil.isNotEmpty(appealDTO.getId()) && !appealDTO.getStatus().equals(AppealStatusEnum.PENDING_REVIEW.getValue())){ if (!appealDTO.getStatus().equals(AppealStatusEnum.PENDING_REVIEW.getValue())){
//校验权限 //校验权限
List<String> userRoles = SecurityUtils.getUserRoles(); List<String> userRoles = SecurityUtils.getUserRoles();
if(!userRoles.stream().anyMatch(UserRoleEnum.ROLE_ADMIN.name()::equals)){ if(!userRoles.stream().anyMatch(UserRoleEnum.ROLE_ADMIN.name()::equals)){
throw new PermissionErrorException(); throw new PermissionErrorException();
} }
} }
if(StringUtils.isBlank(appealDTO.getReason())){
throw new BusinessErrorException("缺少审批意见");
}
// 简答题审批通过必须填写修改后得分,且不能超过题目分值
if (appealDTO.getStatus().equals(AppealStatusEnum.PASS_REVIEW.getValue())) {
QuestionEntity question = questionBaseService.getById(entity.getQuestionId());
if (question != null && QuestionTypeEnum.SHORT_ANSWER.getValue().equals(question.getQuestionType())) {
if (appealDTO.getRevisedScore() == null || new BigDecimal(appealDTO.getRevisedScore()).compareTo(BigDecimal.ZERO) <= 0) {
throw new BusinessErrorException("简答题审批通过必须填写修改后得分或得分必须大于0");
}
TaskEntity task = taskBaseService.getById(entity.getTaskId());
if (task == null){
throw new BusinessErrorException("考试任务不存在");
}
if (appealDTO.getRevisedScore().compareTo(task.getShortAnswerScore()) > 0) {
throw new BusinessErrorException("修改后得分不能大于简答题分值");
}
}
}
}
} }
} }

52
src/main/java/com/project/appeal/domain/service/Impl/SaveAppealDomainServiceImpl.java

@ -98,9 +98,9 @@ public class SaveAppealDomainServiceImpl implements SaveAppealDomainService {
//更新申诉状态 //更新申诉状态
examRecordMapper.updateHasAppealed(index, examRecordDTO.getId()); examRecordMapper.updateHasAppealed(index, examRecordDTO.getId());
return Result.success(appealDTO); return Result.success(appealDTO);
}else if(appealDTO.getStatus().equals(AppealStatusEnum.PASS_REVIEW.getValue()) && !questionSnapshotDTO.getIsRight()){ }else if(appealDTO.getStatus().equals(AppealStatusEnum.PASS_REVIEW.getValue()) && !Boolean.TRUE.equals(questionSnapshotDTO.getIsRight())){
//审批通过需要加分 //审批通过需要加分
calculateScore(appealDTO, examRecordDTO, questionSnapshotDTO.getType()); calculateScore(appealDTO, examRecord, index, questionSnapshotDTO.getType());
} }
//通知用户 //通知用户
dingUtil.sendWorkNotice(appealDTO); dingUtil.sendWorkNotice(appealDTO);
@ -111,27 +111,45 @@ public class SaveAppealDomainServiceImpl implements SaveAppealDomainService {
/** /**
* 计算分数审批通过需要加分 * 计算分数审批通过需要加分
*/ */
public void calculateScore(AppealDTO appealDTO, ExamRecordDTO examRecordDTO,int type) { public void calculateScore(AppealDTO appealDTO, ExamRecordEntity examRecord, int index, int type) {
//审批通过需要加分 TaskEntity taskEntity = taskMapper.getTaskByTaskUserId(examRecord.getTaskUserId());
TaskEntity taskEntity = taskMapper.getTaskByTaskUserId(examRecordDTO.getTaskUserId());
List<ExamRecordEntity.QuestionSnapshot> snapshots = examRecord.getAnswerSnapshot();
ExamRecordEntity.QuestionSnapshot snapshot = snapshots.get(index);
QuestionTypeEnum questionType = QuestionTypeEnum.findByValue(type); QuestionTypeEnum questionType = QuestionTypeEnum.findByValue(type);
if (questionType == null) { if (questionType == null) {
throw new BusinessErrorException("不支持的题目类型:" + type); throw new BusinessErrorException("不支持的题目类型:" + type);
} }
Double questionScore = switch (questionType) {
case SINGLE_CHOICE-> taskEntity.getSingleChoiceScore(); BigDecimal scoreChange;
case MULTIPLE_CHOICE -> taskEntity.getMultipleChoiceScore(); switch (questionType) {
case TRUE_FALSE -> taskEntity.getTrueFalseScore(); case SINGLE_CHOICE -> scoreChange = BigDecimal.valueOf(taskEntity.getSingleChoiceScore());
case MULTIPLE_CHOICE -> scoreChange = BigDecimal.valueOf(taskEntity.getMultipleChoiceScore());
case TRUE_FALSE -> scoreChange = BigDecimal.valueOf(taskEntity.getTrueFalseScore());
case SHORT_ANSWER -> {
Double revisedScore = appealDTO.getRevisedScore();
double originalAiScore = snapshot.getAiScore() == null ? 0D : snapshot.getAiScore();
//判断简答题是否得满分
if (taskEntity.getShortAnswerScore() != null) {
snapshot.setIsRight(BigDecimal.valueOf(revisedScore)
.compareTo(BigDecimal.valueOf(taskEntity.getShortAnswerScore())) >= 0);
}
scoreChange = BigDecimal.valueOf(revisedScore).subtract(BigDecimal.valueOf(originalAiScore));
}
default -> throw new BusinessErrorException("不支持的题目类型:" + type); default -> throw new BusinessErrorException("不支持的题目类型:" + type);
}; }
if (questionType != QuestionTypeEnum.SHORT_ANSWER) {
snapshot.setIsRight(true);
}
//总分+单题分数 //总分+分数变化
BigDecimal score = BigDecimal.valueOf(questionScore).add(BigDecimal.valueOf(examRecordDTO.getScore())).setScale(2, RoundingMode.HALF_UP); BigDecimal score = BigDecimal.valueOf(examRecord.getScore()).add(scoreChange).setScale(2, RoundingMode.HALF_UP);
//判断是否考试通过,且是否需要修改当前考试结果 //判断是否考试通过,且是否需要修改当前考试结果
BigDecimal passScoreBig = taskEntity.getPassScore() == null ? BigDecimal.ZERO : new BigDecimal(taskEntity.getPassScore()); BigDecimal passScoreBig = taskEntity.getPassScore() == null ? BigDecimal.ZERO : new BigDecimal(taskEntity.getPassScore());
boolean isNeedUpdate = score.compareTo(passScoreBig) >= 0 && !examRecordDTO.getPass(); boolean isNeedUpdate = score.compareTo(passScoreBig) >= 0 && !examRecord.getPass();
if (isNeedUpdate){ if (isNeedUpdate){
//更新考试结果 //更新考试结果
taskUserMapper.update( taskUserMapper.update(
@ -141,13 +159,15 @@ public class SaveAppealDomainServiceImpl implements SaveAppealDomainService {
.eq(TaskUserEntity::getTaskId, taskEntity.getId()) .eq(TaskUserEntity::getTaskId, taskEntity.getId())
.set(TaskUserEntity::getStatus, 2) .set(TaskUserEntity::getStatus, 2)
); );
examRecord.setPass(true);
} }
if(score.compareTo(new BigDecimal(100)) > 0){ if(score.compareTo(new BigDecimal(100)) > 0){
score = new BigDecimal(100); score = new BigDecimal(100);
}; }
//保存 examRecord.setScore(score.doubleValue());
examRecordMapper.updateScore(score.doubleValue(),examRecordDTO.getId(),isNeedUpdate); examRecord.setAnswerSnapshot(snapshots);
examRecordMapper.updateById(examRecord);
} }
} }

49
src/main/java/com/project/appeal/domain/service/Impl/SearchAppealDomainServiceImpl.java

@ -1,6 +1,6 @@
package com.project.appeal.domain.service.Impl; package com.project.appeal.domain.service.Impl;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
@ -13,14 +13,13 @@ import com.project.appeal.mapper.AppealMapper;
import com.project.base.domain.result.PageResult; import com.project.base.domain.result.PageResult;
import com.project.base.domain.result.Result; import com.project.base.domain.result.Result;
import com.project.base.domain.utils.PageConverter; import com.project.base.domain.utils.PageConverter;
import com.project.information.domain.entity.KnowledgePointEntity;
import com.project.information.domain.service.KnowledgePointBaseService;
import com.project.information.mapper.ProductLineMapper; import com.project.information.mapper.ProductLineMapper;
import com.project.question.domain.entity.QuestionEntity; import com.project.question.domain.entity.QuestionEntity;
import com.project.question.domain.entity.TaskKnowledgePointEntity; import com.project.question.domain.entity.TaskKnowledgePointEntity;
import com.project.question.domain.service.QuestionBaseService; import com.project.question.domain.service.QuestionBaseService;
import com.project.question.domain.service.TaskKnowledgePointBaseService; import com.project.question.domain.service.TaskKnowledgePointBaseService;
import com.project.task.domain.dto.TaskDTO; import com.project.task.domain.dto.TaskDTO;
import com.project.task.domain.enums.QuestionTypeEnum;
import com.project.task.mapper.TaskMapper; import com.project.task.mapper.TaskMapper;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -28,6 +27,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import java.text.NumberFormat;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -50,22 +50,30 @@ public class SearchAppealDomainServiceImpl implements SearchAppealDomainService
public Result<PageResult<AppealDTO>> list(AppealParam appealParam) { public Result<PageResult<AppealDTO>> list(AppealParam appealParam) {
QueryWrapper<AppealEntity> appealEntityQueryWrapper = new QueryWrapper<>(); QueryWrapper<AppealEntity> appealEntityQueryWrapper = new QueryWrapper<>();
IPage<AppealDTO> appealDTOIPage = new Page<>(); IPage<AppealDTO> appealDTOIPage = new Page<>();
Map<Long, String> taskIdToSubLineNameMap = new HashMap<>(); Map<Long, Object[]> taskIdToLineAndCountMap = new HashMap<>();
if (appealParam.getTaskId() != null) {
appealEntityQueryWrapper.eq("task_id", appealParam.getTaskId());
}
if (StringUtils.isNotBlank(appealParam.getUsername())) {
appealEntityQueryWrapper.like("username", appealParam.getUsername());
}
appealEntityQueryWrapper.orderByDesc("create_time"); appealEntityQueryWrapper.orderByDesc("create_time");
if (appealParam.getBusinessId() == null && appealParam.getLineId() == null && appealParam.getSubLineId() == null && StringUtils.isBlank(appealParam.getSubLineName())) { if (appealParam.getBusinessId() == null && appealParam.getLineId() == null && appealParam.getSubLineId() == null && StringUtils.isBlank(appealParam.getSubLineName())) {
Page<AppealEntity> appealEntityPage = appealMapper.selectPage(PageConverter.toMpPage(appealParam), appealEntityQueryWrapper); Page<AppealEntity> appealEntityPage = appealMapper.selectPage(PageConverter.toMpPage(appealParam), appealEntityQueryWrapper);
appealDTOIPage = appealEntityPage.convert(entity -> entity.toDTO(AppealDTO::new)); appealDTOIPage = appealEntityPage.convert(entity -> entity.toDTO(AppealDTO::new));
//查询产品线相关的考试任务 //查询产品线相关的考试任务
Set<Long> taskIdSet = appealDTOIPage.getRecords().stream().map(appealDTO -> appealDTO.getTaskId()).collect(Collectors.toSet()); Set<Long> taskIdSet = appealDTOIPage.getRecords().stream().map(AppealDTO::getTaskId).collect(Collectors.toSet());
if (!CollectionUtils.isEmpty(taskIdSet)){ if (!CollectionUtils.isEmpty(taskIdSet)){
List<TaskDTO> taskByIds = productLineMapper.getSubLineByTaskIDS(taskIdSet); List<TaskDTO> taskByIds = productLineMapper.getSubLineByTaskIDS(taskIdSet);
taskIdToSubLineNameMap = taskByIds.stream().collect(Collectors.toMap(TaskDTO::getId, TaskDTO::getSubLineName)); taskIdToLineAndCountMap = taskByIds.stream().collect(Collectors.toMap(TaskDTO::getId, taskDTO -> new Object[]{taskDTO.getSubLineName(),taskDTO.getShortAnswerScore()}));
} }
}else{ }else{
//查询产品线相关的考试任务 //查询产品线相关的考试任务
List<TaskDTO> taskByAppealParam = taskMapper.getTaskByAppealParam(appealParam.getSubLineId(),appealParam.getLineId(),appealParam.getBusinessId(),appealParam.getSubLineName()); List<TaskDTO> taskByAppealParam = taskMapper.getTaskByAppealParam(appealParam.getSubLineId(),appealParam.getLineId(),appealParam.getBusinessId(),appealParam.getSubLineName());
taskIdToSubLineNameMap = taskByAppealParam.stream().collect(Collectors.toMap(TaskDTO::getId, TaskDTO::getSubLineName)); taskIdToLineAndCountMap = taskByAppealParam.stream().collect(Collectors.toMap(TaskDTO::getId, taskDTO -> new Object[]{taskDTO.getSubLineName(),taskDTO.getShortAnswerScore()}));
if (!CollectionUtils.isEmpty(taskByAppealParam)){ if (!CollectionUtils.isEmpty(taskByAppealParam)){
//查询申诉列表 //查询申诉列表
@ -74,7 +82,7 @@ public class SearchAppealDomainServiceImpl implements SearchAppealDomainService
appealDTOIPage = appealEntityPage.convert(entity -> entity.toDTO(AppealDTO::new)); appealDTOIPage = appealEntityPage.convert(entity -> entity.toDTO(AppealDTO::new));
} }
} }
appealDTOIPage.setRecords(buildDTO(appealDTOIPage.getRecords(),taskIdToSubLineNameMap)); appealDTOIPage.setRecords(buildDTO(appealDTOIPage.getRecords(),taskIdToLineAndCountMap));
return Result.page(appealDTOIPage); return Result.page(appealDTOIPage);
} }
@ -82,7 +90,7 @@ public class SearchAppealDomainServiceImpl implements SearchAppealDomainService
/** /**
* 构建返回实体 * 构建返回实体
*/ */
private List<AppealDTO> buildDTO(List<AppealDTO> appealDTOList,Map<Long, String> taskIdToSubLineNameMap){ private List<AppealDTO> buildDTO(List<AppealDTO> appealDTOList,Map<Long, Object[]> taskIdToLineAndCountMap){
if (CollectionUtils.isEmpty(appealDTOList)){ if (CollectionUtils.isEmpty(appealDTOList)){
return appealDTOList; return appealDTOList;
} }
@ -90,10 +98,10 @@ public class SearchAppealDomainServiceImpl implements SearchAppealDomainService
//获取题目信息 //获取题目信息
Set<Long> questionIdList = appealDTOList.stream() Set<Long> questionIdList = appealDTOList.stream()
.filter(appealDTO -> ObjectUtils.isNotEmpty(appealDTO.getExamId())) .filter(appealDTO -> ObjectUtils.isNotEmpty(appealDTO.getExamId()))
.map(appealDTO -> appealDTO.getQuestionId()) .map(AppealDTO::getQuestionId)
.collect(Collectors.toSet()); .collect(Collectors.toSet());
Map<Long, QuestionEntity> questionEntityMap = questionBaseService.listByIds(questionIdList).stream() Map<Long, QuestionEntity> questionEntityMap = questionBaseService.listByIds(questionIdList).stream()
.collect(Collectors.toMap(questionEntity -> questionEntity.getId(), questionEntity -> questionEntity)); .collect(Collectors.toMap(QuestionEntity::getId, questionEntity -> questionEntity));
//知识点拼接和填充题目相关信息 //知识点拼接和填充题目相关信息
Set<Long> kpIdSet = new HashSet<>(); Set<Long> kpIdSet = new HashSet<>();
@ -102,7 +110,22 @@ public class SearchAppealDomainServiceImpl implements SearchAppealDomainService
QuestionEntity questionEntity = questionEntityMap.get(appealDTO.getQuestionId()); QuestionEntity questionEntity = questionEntityMap.get(appealDTO.getQuestionId());
QuestionEntity.QuestionDetail questionDetail = questionEntity.getQuestionDetail(); QuestionEntity.QuestionDetail questionDetail = questionEntity.getQuestionDetail();
appealDTO.setSubLineName(taskIdToSubLineNameMap.get(appealDTO.getTaskId())); Object[] lineCountArr = taskIdToLineAndCountMap.get(appealDTO.getTaskId());
// 兜底默认值
String subLineName = "";
Double score = 0D;
if (lineCountArr != null && lineCountArr.length >= 2) {
subLineName = ObjectUtil.isNull(lineCountArr[0]) ? "" : (String) lineCountArr[0];
if (QuestionTypeEnum.SHORT_ANSWER.getValue().equals(questionEntity.getQuestionType())) {
score = ObjectUtil.isNull(lineCountArr[1]) ? 0D : (Double) lineCountArr[1];
}
}
appealDTO.setSubLineName(subLineName);
appealDTO.setScore(score);
// 格式化去除千分位、整数无小数点,统一工具格式化
String scoreStr = score == score.longValue() ? String.valueOf(score.longValue()) : String.format("%.2f", score);
appealDTO.setScoreStr(scoreStr);
appealDTO.setQuestionContent(questionDetail.getQuestionContent()); appealDTO.setQuestionContent(questionDetail.getQuestionContent());
appealDTO.setKpIdList(questionEntity.getKpIdList()); appealDTO.setKpIdList(questionEntity.getKpIdList());
kpIdSet.addAll(questionEntity.getKpIdList()); kpIdSet.addAll(questionEntity.getKpIdList());
@ -144,7 +167,7 @@ public class SearchAppealDomainServiceImpl implements SearchAppealDomainService
List<Long> kpIdList = Optional.ofNullable(appealDTO.getKpIdList()).orElse(Collections.emptyList()); List<Long> kpIdList = Optional.ofNullable(appealDTO.getKpIdList()).orElse(Collections.emptyList());
String kpContentStr = kpIdList.stream() String kpContentStr = kpIdList.stream()
.filter(kpId -> kpIdToEntityMap.containsKey(kpId)) .filter(kpIdToEntityMap::containsKey)
.map(kpId -> kpIdToEntityMap.get(kpId).getContent()) .map(kpId -> kpIdToEntityMap.get(kpId).getContent())
.filter(StringUtils::isNotBlank) .filter(StringUtils::isNotBlank)
.map(content -> content.replaceAll(KEY_VALUE_PATTERN, "$1:$2")) .map(content -> content.replaceAll(KEY_VALUE_PATTERN, "$1:$2"))

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

@ -2,6 +2,7 @@ package com.project.exam.domain.entity;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
@ -17,8 +18,6 @@ import org.hibernate.annotations.JdbcTypeCode;
import org.hibernate.type.SqlTypes; import org.hibernate.type.SqlTypes;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.NumberFormat; import java.text.NumberFormat;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -129,7 +128,7 @@ public class ExamRecordEntity extends BaseEntity {
dto.setAnswerSnapshotDTOList(dtoList); dto.setAnswerSnapshotDTOList(dtoList);
} }
//转成string类型,如果是整数则不显示小数部分,如果是小数则保留两位小数 //转成string类型,如果是整数则不显示小数部分,如果是小数则保留两位小数
String scoreStr = dto.getScore() == null ? "0" : NumberFormat.getInstance().format(dto.getScore()); String scoreStr = ObjectUtil.isNull(dto.getScore()) ? "0" : NumberFormat.getInstance().format(dto.getScore());
dto.setScoreStr(scoreStr); dto.setScoreStr(scoreStr);
} }
return result; return result;

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

@ -49,10 +49,13 @@ public class BuildExamRecordDomainServiceImpl implements BuildExamRecordDomainSe
answerSnapshotDTO.setScore(dto.getTaskDTO().getTrueFalseScore()); answerSnapshotDTO.setScore(dto.getTaskDTO().getTrueFalseScore());
answerSnapshotDTO.setUserScore(BooleanUtil.isTrue(answerSnapshotDTO.getIsRight()) ? answerSnapshotDTO.setUserScore(BooleanUtil.isTrue(answerSnapshotDTO.getIsRight()) ?
dto.getTaskDTO().getTrueFalseScore() : 0); dto.getTaskDTO().getTrueFalseScore() : 0);
} else { } else if (QuestionTypeEnum.MULTIPLE_CHOICE.getValue().equals(answerSnapshotDTO.getType())){
answerSnapshotDTO.setScore(dto.getTaskDTO().getMultipleChoiceScore()); answerSnapshotDTO.setScore(dto.getTaskDTO().getMultipleChoiceScore());
answerSnapshotDTO.setUserScore(BooleanUtil.isTrue(answerSnapshotDTO.getIsRight()) ? answerSnapshotDTO.setUserScore(BooleanUtil.isTrue(answerSnapshotDTO.getIsRight()) ?
dto.getTaskDTO().getMultipleChoiceScore() : 0); dto.getTaskDTO().getMultipleChoiceScore() : 0);
}else{
answerSnapshotDTO.setScore(dto.getTaskDTO().getShortAnswerScore());
answerSnapshotDTO.setUserScore(answerSnapshotDTO.getAiScore());
} }
answerSnapshotDTO.setTypeText(Try.of(() -> answerSnapshotDTO.setTypeText(Try.of(() ->
QuestionTypeEnum.findByValue(answerSnapshotDTO.getType()).getDescription()) QuestionTypeEnum.findByValue(answerSnapshotDTO.getType()).getDescription())
@ -89,6 +92,11 @@ public class BuildExamRecordDomainServiceImpl implements BuildExamRecordDomainSe
answerSnapshotDTO.setAppealStatus(appeal.getStatus()); answerSnapshotDTO.setAppealStatus(appeal.getStatus());
answerSnapshotDTO.setAppealStatusText(AppealStatusEnum.getDescByValue(appeal.getStatus())); answerSnapshotDTO.setAppealStatusText(AppealStatusEnum.getDescByValue(appeal.getStatus()));
answerSnapshotDTO.setAppealReason(appeal.getReason()); answerSnapshotDTO.setAppealReason(appeal.getReason());
//如果是简答题,且审批通过,需要填充修改后的用户得分
if (QuestionTypeEnum.SHORT_ANSWER.getValue().equals(answerSnapshotDTO.getType())
&& AppealStatusEnum.PASS_REVIEW.getValue().equals(appeal.getStatus())) {
answerSnapshotDTO.setUserScore(appeal.getRevisedScore());
}
} }
} }
}); });

13
src/main/java/com/project/exam/mapper/ExamRecordMapper.java

@ -20,19 +20,6 @@ public interface ExamRecordMapper extends BaseMapper<ExamRecordEntity> {
@Param("idx") int idx, @Param("idx") int idx,
@Param("answer") String answer); @Param("answer") String answer);
@Update("<script>" +
"UPDATE evaluator_exam_record SET " +
"score = #{score}, " +
"update_time = NOW() " +
"<if test=\"isNeedUpdate == true\">" +
", pass = true " +
"</if>" +
"WHERE id = #{id}" +
"</script>")
void updateScore(@Param("score") double score,
@Param("id") Long id,
@Param("isNeedUpdate") boolean isNeedUpdate);
@Update("UPDATE evaluator_exam_record SET " + @Update("UPDATE evaluator_exam_record SET " +
"answer_snapshot = JSON_SET(answer_snapshot, '$[${index}].hasAppealed', true), " + "answer_snapshot = JSON_SET(answer_snapshot, '$[${index}].hasAppealed', true), " +
"update_time = NOW() " + "update_time = NOW() " +

2
src/main/java/com/project/information/mapper/ProductLineMapper.java

@ -14,7 +14,7 @@ import java.util.Set;
public interface ProductLineMapper extends BaseMapper<ProductLineEntity> { public interface ProductLineMapper extends BaseMapper<ProductLineEntity> {
@Select({ @Select({
"<script>", "<script>",
"select t.id, e.name as subLineName ", "select t.id, e.name as subLineName,t.short_answer_score ",
"from evaluator_product_line e ", "from evaluator_product_line e ",
"inner join evaluator_task t on e.id = t.sub_line_id ", "inner join evaluator_task t on e.id = t.sub_line_id ",
"where t.id in ", "where t.id in ",

3
src/main/java/com/project/statistics/domain/service/impl/SaveSaveErrorProneStatisticsDomainServiceImpl.java

@ -3,7 +3,6 @@ package com.project.statistics.domain.service.impl;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.project.exam.domain.entity.ExamRecordEntity; import com.project.exam.domain.entity.ExamRecordEntity;
import com.project.question.domain.entity.QuestionEntity; import com.project.question.domain.entity.QuestionEntity;
import com.project.question.domain.entity.TaskKnowledgePointEntity; import com.project.question.domain.entity.TaskKnowledgePointEntity;
@ -62,7 +61,7 @@ public class SaveSaveErrorProneStatisticsDomainServiceImpl implements SaveErrorP
} }
TaskEntity task = taskBaseService.getById(taskId); TaskEntity task = taskBaseService.getById(taskId);
if (task == null){ if (Objects.isNull(task)){
throw new IllegalArgumentException("考试任务不存在,taskId: " + taskId); throw new IllegalArgumentException("考试任务不存在,taskId: " + taskId);
} }

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

@ -2,6 +2,7 @@ package com.project.task.domain.service.impl;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
@ -163,7 +164,7 @@ 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 = examRecordEntity.getScore() == null ? "0" : NumberFormat.getInstance().format(examRecordEntity.getScore()); String lastRecordScoreStr = ObjectUtil.isNull(examRecordEntity.getScore()) ? "0" : NumberFormat.getInstance().format(examRecordEntity.getScore());
dto.setLastRecordScoreStr(lastRecordScoreStr); dto.setLastRecordScoreStr(lastRecordScoreStr);
} }
dto.setTotalScore((int) Math.floor(entity.getTotalScore())); dto.setTotalScore((int) Math.floor(entity.getTotalScore()));

2
src/main/java/com/project/task/mapper/TaskMapper.java

@ -31,7 +31,7 @@ public interface TaskMapper extends BaseMapper<TaskEntity> {
*/ */
@Select({ @Select({
"<script>", "<script>",
"SELECT e.id, l.name AS subLineName ", "SELECT e.id, l.name AS subLineName,e.short_answer_score ",
"FROM evaluator_task e ", "FROM evaluator_task e ",
"LEFT JOIN evaluator_product_line l ON e.sub_line_id = l.id ", "LEFT JOIN evaluator_product_line l ON e.sub_line_id = l.id ",
"<where> ", "<where> ",

Loading…
Cancel
Save