31 changed files with 778 additions and 83 deletions
@ -0,0 +1,20 @@ |
|||||
|
package com.project.appeal.application; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
import com.project.appeal.domain.dto.AppealDTO; |
||||
|
import com.project.appeal.domain.param.AppealParam; |
||||
|
import com.project.base.domain.result.Result; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
public interface AppealApplication { |
||||
|
/** |
||||
|
* 保存或修改申诉 |
||||
|
*/ |
||||
|
Result<AppealDTO> saveOrUpdate(AppealDTO appealDTO); |
||||
|
|
||||
|
/** |
||||
|
* 查询申诉列表 |
||||
|
*/ |
||||
|
Result<IPage<AppealDTO>> list(AppealParam appealParam); |
||||
|
} |
||||
@ -0,0 +1,41 @@ |
|||||
|
package com.project.appeal.application.Impl; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
import com.project.appeal.application.AppealApplication; |
||||
|
import com.project.appeal.domain.dto.AppealDTO; |
||||
|
import com.project.appeal.domain.param.AppealParam; |
||||
|
import com.project.appeal.domain.service.CheckAppealDomainService; |
||||
|
import com.project.appeal.domain.service.SaveAppealDomainService; |
||||
|
import com.project.appeal.domain.service.SearchAppealDomainService; |
||||
|
import com.project.base.domain.result.Result; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
@Service |
||||
|
public class AppealApplicationImpl implements AppealApplication { |
||||
|
@Autowired |
||||
|
private SaveAppealDomainService saveAppealDomainService; |
||||
|
@Autowired |
||||
|
private CheckAppealDomainService checkAppealDomainService; |
||||
|
@Autowired |
||||
|
private SearchAppealDomainService searchAppealDomainService; |
||||
|
|
||||
|
/** |
||||
|
* 保存申诉 |
||||
|
*/ |
||||
|
@Override |
||||
|
public Result<AppealDTO> saveOrUpdate(AppealDTO appealDTO) { |
||||
|
checkAppealDomainService.checkDto(appealDTO); |
||||
|
return saveAppealDomainService.saveOrUpdate(appealDTO); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 查询申诉列表 |
||||
|
*/ |
||||
|
@Override |
||||
|
public Result<IPage<AppealDTO>> list(AppealParam appealParam) { |
||||
|
return searchAppealDomainService.list(appealParam); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,31 @@ |
|||||
|
package com.project.appeal.controller; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
import com.project.appeal.application.AppealApplication; |
||||
|
import com.project.appeal.domain.dto.AppealDTO; |
||||
|
import com.project.appeal.domain.param.AppealParam; |
||||
|
import com.project.base.domain.result.Result; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 申诉模块 |
||||
|
*/ |
||||
|
@RequestMapping("/api/admin/appeal") |
||||
|
@RestController |
||||
|
public class AppealController { |
||||
|
@Autowired |
||||
|
private AppealApplication appealApplication; |
||||
|
|
||||
|
@PostMapping("saveOrUpdate") |
||||
|
public Result<AppealDTO> saveOrUpdate(@RequestBody AppealDTO appealDTO){ |
||||
|
return appealApplication.saveOrUpdate(appealDTO); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("list") |
||||
|
public Result<IPage<AppealDTO>> list(AppealParam appealParam){ |
||||
|
return appealApplication.list(appealParam); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,36 @@ |
|||||
|
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.entity.BaseEntity; |
||||
|
import jakarta.persistence.Column; |
||||
|
import jakarta.persistence.Entity; |
||||
|
import jakarta.persistence.Id; |
||||
|
import jakarta.persistence.Table; |
||||
|
import lombok.Data; |
||||
|
import lombok.EqualsAndHashCode; |
||||
|
import org.hibernate.annotations.Comment; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
@Data |
||||
|
public class AppealDTO extends BaseDTO { |
||||
|
private Long id; |
||||
|
private String userId; |
||||
|
private String userName; |
||||
|
private Long examId; |
||||
|
private Long taskId; |
||||
|
private String subLineName;//关联子产品线
|
||||
|
private Long questionId; |
||||
|
private String questionContent; //题干
|
||||
|
private String kpContentsStr; //知识点文本
|
||||
|
private List<Long> kpIdList; |
||||
|
private String rightAnswer;//正确答案
|
||||
|
private String userAnswer;//用户答案
|
||||
|
private Integer status = 1; |
||||
|
private String remark; |
||||
|
private String reason; |
||||
|
} |
||||
@ -0,0 +1,58 @@ |
|||||
|
package com.project.appeal.domain.entity; |
||||
|
|
||||
|
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.entity.BaseEntity; |
||||
|
import jakarta.persistence.*; |
||||
|
import lombok.Data; |
||||
|
import lombok.EqualsAndHashCode; |
||||
|
import org.hibernate.annotations.Comment; |
||||
|
|
||||
|
@Data |
||||
|
@Table(name = "evaluator_appeal", |
||||
|
indexes = {@Index(name = "Idx_task_id" , columnList = "task_id"), |
||||
|
@Index(name = "Idx_question_id" , columnList = "question_id")}) |
||||
|
@Entity |
||||
|
@TableName(value = "evaluator_appeal") |
||||
|
@EqualsAndHashCode(callSuper = true) |
||||
|
public class AppealEntity extends BaseEntity { |
||||
|
@TableId(value = "id" , type = IdType.ASSIGN_ID) |
||||
|
@Id |
||||
|
private Long id; |
||||
|
|
||||
|
@TableField("user_id") |
||||
|
@Column(name = "user_id" , columnDefinition="varchar(50) comment '用户id'") |
||||
|
private String userId; |
||||
|
|
||||
|
@Column(name = "username" , columnDefinition="varchar(50) comment '用户名称'") |
||||
|
private String username; |
||||
|
|
||||
|
@TableField("exam_id") |
||||
|
@Column(name = "exam_id" , columnDefinition="bigint(20) comment '考试id'") |
||||
|
private Long examId; |
||||
|
|
||||
|
@TableField("task_id") |
||||
|
@Column(name = "task_id" , columnDefinition="bigint(20) comment '考试任务id'") |
||||
|
private Long taskId; |
||||
|
|
||||
|
@Column(name = "user_answer",columnDefinition = "varchar(255) comment '用户答案'") |
||||
|
@TableField("user_answer") |
||||
|
private Long userAnswer; |
||||
|
|
||||
|
@Column(name = "question_id") |
||||
|
@Comment("题目ID") |
||||
|
@TableField("question_id") |
||||
|
private Long questionId; |
||||
|
|
||||
|
@Column(name = "status") |
||||
|
@Comment("审批状态") |
||||
|
private Integer status; |
||||
|
|
||||
|
@Column(name = "remark",columnDefinition = "varchar(255) comment '申诉备注'") |
||||
|
private String remark; |
||||
|
|
||||
|
@Column(name = "reason",columnDefinition = "varchar(255) comment '审批理由'") |
||||
|
private String reason; |
||||
|
} |
||||
@ -0,0 +1,16 @@ |
|||||
|
package com.project.appeal.domain.enums; |
||||
|
|
||||
|
import com.project.base.domain.enums.HasValueEnum; |
||||
|
import lombok.Getter; |
||||
|
import lombok.RequiredArgsConstructor; |
||||
|
|
||||
|
@Getter |
||||
|
@RequiredArgsConstructor |
||||
|
public enum StatusEnum implements HasValueEnum<Integer> { |
||||
|
PENDING_REVIEW(1,"待审核"), |
||||
|
PASS_REVIEW(2,"审核通过"), |
||||
|
REFUSE_REVIEW(3,"审核拒绝"); |
||||
|
|
||||
|
private final Integer value; |
||||
|
private final String desc; |
||||
|
} |
||||
@ -0,0 +1,9 @@ |
|||||
|
package com.project.appeal.domain.param; |
||||
|
|
||||
|
import com.project.base.domain.param.BaseParam; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
@Data |
||||
|
public class AppealParam extends BaseParam { |
||||
|
public String subLineName; |
||||
|
} |
||||
@ -0,0 +1,7 @@ |
|||||
|
package com.project.appeal.domain.service; |
||||
|
|
||||
|
import com.project.appeal.domain.entity.AppealEntity; |
||||
|
import com.project.base.domain.service.IBaseService; |
||||
|
|
||||
|
public interface AppealBaseService extends IBaseService<AppealEntity> { |
||||
|
} |
||||
@ -0,0 +1,7 @@ |
|||||
|
package com.project.appeal.domain.service; |
||||
|
|
||||
|
import com.project.appeal.domain.dto.AppealDTO; |
||||
|
|
||||
|
public interface CheckAppealDomainService { |
||||
|
void checkDto(AppealDTO appealDTO); |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
package com.project.appeal.domain.service.Impl; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
|
import com.project.appeal.domain.entity.AppealEntity; |
||||
|
import com.project.appeal.domain.service.AppealBaseService; |
||||
|
import com.project.appeal.mapper.AppealMapper; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
@Service |
||||
|
public class AppealBaseServiceImpl extends ServiceImpl<AppealMapper, AppealEntity> implements AppealBaseService { |
||||
|
} |
||||
@ -0,0 +1,45 @@ |
|||||
|
package com.project.appeal.domain.service.Impl; |
||||
|
|
||||
|
import cn.hutool.core.util.ObjectUtil; |
||||
|
import com.project.appeal.domain.dto.AppealDTO; |
||||
|
import com.project.appeal.domain.service.CheckAppealDomainService; |
||||
|
import com.project.base.domain.exception.BusinessErrorException; |
||||
|
import com.project.base.domain.exception.MissingParameterException; |
||||
|
import org.apache.commons.lang3.StringUtils; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
@Service |
||||
|
public class CheckAppealDomainServiceImpl implements CheckAppealDomainService { |
||||
|
@Override |
||||
|
public void checkDto(AppealDTO appealDTO) { |
||||
|
if (ObjectUtil.isEmpty(appealDTO.getExamId())){ |
||||
|
throw new MissingParameterException("缺少考试ID"); |
||||
|
} |
||||
|
|
||||
|
if (ObjectUtil.isEmpty(appealDTO.getUserId())){ |
||||
|
throw new MissingParameterException("缺少用户ID"); |
||||
|
} |
||||
|
|
||||
|
if (StringUtils.isBlank(appealDTO.getUserName())){ |
||||
|
throw new MissingParameterException("缺少用户名称"); |
||||
|
} |
||||
|
|
||||
|
if (ObjectUtil.isEmpty(appealDTO.getQuestionContent())){ |
||||
|
throw new MissingParameterException("缺少题目ID"); |
||||
|
} |
||||
|
|
||||
|
if (StringUtils.isBlank(appealDTO.getUserAnswer())){ |
||||
|
throw new MissingParameterException("缺少用户答案"); |
||||
|
} |
||||
|
|
||||
|
if (StringUtils.isBlank(appealDTO.getRemark())){ |
||||
|
throw new MissingParameterException("缺少申诉理由"); |
||||
|
} |
||||
|
if (ObjectUtil.isEmpty(appealDTO.getId()) && appealDTO.getStatus() != 1){ |
||||
|
throw new BusinessErrorException("申诉状态错误"); |
||||
|
} |
||||
|
if (ObjectUtil.isNotEmpty(appealDTO.getId()) && appealDTO.getStatus() == 1){ |
||||
|
throw new BusinessErrorException("申诉状态错误"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,95 @@ |
|||||
|
package com.project.appeal.domain.service.Impl; |
||||
|
|
||||
|
import com.project.appeal.domain.dto.AppealDTO; |
||||
|
import com.project.appeal.domain.entity.AppealEntity; |
||||
|
import com.project.appeal.domain.service.AppealBaseService; |
||||
|
import com.project.appeal.domain.service.SaveAppealDomainService; |
||||
|
import com.project.base.domain.exception.BusinessErrorException; |
||||
|
import com.project.base.domain.result.Result; |
||||
|
import com.project.exam.domain.dto.ExamRecordDTO; |
||||
|
import com.project.exam.domain.entity.ExamRecordEntity; |
||||
|
import com.project.exam.domain.service.ExamRecordBaseService; |
||||
|
import com.project.task.domain.entity.TaskEntity; |
||||
|
import com.project.task.mapper.TaskMapper; |
||||
|
import org.redisson.mapreduce.Collector; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import java.math.BigDecimal; |
||||
|
import java.math.RoundingMode; |
||||
|
import java.util.ArrayList; |
||||
|
import java.util.List; |
||||
|
import java.util.Optional; |
||||
|
import java.util.stream.Collectors; |
||||
|
|
||||
|
@Service |
||||
|
public class SaveAppealDomainServiceImpl implements SaveAppealDomainService { |
||||
|
@Autowired |
||||
|
private AppealBaseService appealBaseService; |
||||
|
@Autowired |
||||
|
private ExamRecordBaseService examRecordBaseService; |
||||
|
@Autowired |
||||
|
private TaskMapper taskMapper; |
||||
|
|
||||
|
|
||||
|
@Override |
||||
|
public Result<AppealDTO> saveOrUpdate(AppealDTO appealDTO) { |
||||
|
AppealEntity entity = appealDTO.toEntity(AppealEntity::new); |
||||
|
appealBaseService.saveOrUpdate(entity); |
||||
|
|
||||
|
//如果审核通过,需要为用户加分
|
||||
|
if (appealDTO.getStatus() != 2){ |
||||
|
return Result.success(appealDTO); |
||||
|
} |
||||
|
|
||||
|
ExamRecordEntity examRecord = examRecordBaseService.getById(appealDTO.getExamId()); |
||||
|
if (examRecord == null){ |
||||
|
throw new BusinessErrorException("用户未该场考试"); |
||||
|
} |
||||
|
//找到题目相关信息,获取该类型题目分数
|
||||
|
ExamRecordDTO examRecordDTO = examRecord.toDTO(ExamRecordDTO::new); |
||||
|
|
||||
|
ExamRecordDTO.QuestionSnapshotDTO questionSnapshotDTO = null; |
||||
|
Optional<? extends ExamRecordDTO.QuestionSnapshotDTO> optionalDTO = examRecordDTO.getAnswerSnapshotDTOList().stream() |
||||
|
.filter(answerSnapshotDTO -> appealDTO.getQuestionId() != null |
||||
|
&& appealDTO.getQuestionId().equals(answerSnapshotDTO.getQuestionId())) |
||||
|
.findFirst(); |
||||
|
if (optionalDTO.isPresent()) { |
||||
|
questionSnapshotDTO = optionalDTO.get(); |
||||
|
}else { |
||||
|
throw new BusinessErrorException("题目不存在"); |
||||
|
} |
||||
|
|
||||
|
//已申诉题目无法再申诉
|
||||
|
if(questionSnapshotDTO.getHasAppealed()){ |
||||
|
throw new BusinessErrorException("题目已申诉"); |
||||
|
} |
||||
|
|
||||
|
TaskEntity taskEntity = taskMapper.getTaskByTaskUserId(examRecord.getTaskUserId()); |
||||
|
|
||||
|
Double questionScore = switch (questionSnapshotDTO.getType()) { |
||||
|
case 1 -> taskEntity.getSingleChoiceScore(); |
||||
|
case 2 -> taskEntity.getMultipleChoiceScore(); |
||||
|
case 3 -> taskEntity.getTrueFalseScore(); |
||||
|
default -> throw new IllegalArgumentException( |
||||
|
"不支持的题目类型:" + questionSnapshotDTO.getType() |
||||
|
); |
||||
|
}; |
||||
|
|
||||
|
//总分+单题分数
|
||||
|
BigDecimal score = BigDecimal.valueOf(questionScore).add(BigDecimal.valueOf(examRecordDTO.getScore())).setScale(2, RoundingMode.HALF_UP); |
||||
|
examRecord.setScore(score.doubleValue()); |
||||
|
|
||||
|
questionSnapshotDTO.setHasAppealed(true); |
||||
|
List<ExamRecordDTO.QuestionSnapshotDTO> questionSnapshotDTOList = examRecordDTO.getAnswerSnapshotDTOList().stream() |
||||
|
.filter(answerSnapshotDTO -> !appealDTO.getQuestionId().equals(answerSnapshotDTO.getQuestionId())) |
||||
|
.collect(Collectors.toCollection(ArrayList::new)); |
||||
|
questionSnapshotDTOList.add(questionSnapshotDTO); |
||||
|
examRecordDTO.setAnswerSnapshotDTOList(questionSnapshotDTOList); |
||||
|
|
||||
|
//保存
|
||||
|
examRecordBaseService.save(examRecordDTO.toEntity(ExamRecordEntity::new)); |
||||
|
|
||||
|
return Result.success(appealDTO); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,119 @@ |
|||||
|
package com.project.appeal.domain.service.Impl; |
||||
|
|
||||
|
import cn.hutool.json.JSONUtil; |
||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
|
import com.project.appeal.domain.dto.AppealDTO; |
||||
|
import com.project.appeal.domain.entity.AppealEntity; |
||||
|
import com.project.appeal.domain.param.AppealParam; |
||||
|
import com.project.appeal.domain.service.AppealBaseService; |
||||
|
import com.project.appeal.domain.service.SearchAppealDomainService; |
||||
|
import com.project.appeal.mapper.AppealMapper; |
||||
|
import com.project.base.domain.result.Result; |
||||
|
import com.project.base.domain.utils.PageConverter; |
||||
|
import com.project.exam.domain.entity.ExamRecordEntity; |
||||
|
import com.project.exam.domain.service.ExamRecordBaseService; |
||||
|
import com.project.information.domain.dto.InformationDTO; |
||||
|
import com.project.information.domain.entity.KnowledgePointEntity; |
||||
|
import com.project.information.domain.service.KnowledgePointBaseService; |
||||
|
import com.project.question.domain.entity.QuestionEntity; |
||||
|
import com.project.question.domain.service.QuestionBaseService; |
||||
|
import com.project.task.domain.dto.TaskDTO; |
||||
|
import com.project.task.mapper.TaskMapper; |
||||
|
import org.apache.commons.lang3.ObjectUtils; |
||||
|
import org.apache.commons.lang3.StringUtils; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.util.CollectionUtils; |
||||
|
|
||||
|
import java.util.*; |
||||
|
import java.util.stream.Collectors; |
||||
|
|
||||
|
@Service |
||||
|
public class SearchAppealDomainServiceImpl implements SearchAppealDomainService { |
||||
|
@Autowired |
||||
|
private AppealMapper appealMapper; |
||||
|
@Autowired |
||||
|
private QuestionBaseService questionBaseService; |
||||
|
@Autowired |
||||
|
private TaskMapper taskMapper; |
||||
|
@Autowired |
||||
|
private KnowledgePointBaseService knowledgePointBaseService; |
||||
|
|
||||
|
@Override |
||||
|
public Result<IPage<AppealDTO>> list(AppealParam appealParam) { |
||||
|
QueryWrapper<AppealEntity> appealEntityQueryWrapper = new QueryWrapper<>(); |
||||
|
IPage<AppealDTO> appealDTOIPage = new Page<>(); |
||||
|
Map<Long, String> taskIdToSubLineNameMap = Map.of(); |
||||
|
if (StringUtils.isBlank(appealParam.getSubLineName())){ |
||||
|
Page<AppealEntity> appealEntityPage = appealMapper.selectPage(PageConverter.toMpPage(appealParam), appealEntityQueryWrapper); |
||||
|
appealDTOIPage = appealEntityPage.convert(entity -> entity.toDTO(AppealDTO::new)); |
||||
|
}else{ |
||||
|
//查询产品线相关的考试任务
|
||||
|
List<TaskDTO> taskBySubLineName = taskMapper.getTaskBySubLineName(appealParam.getSubLineName()); |
||||
|
taskIdToSubLineNameMap = taskBySubLineName.stream().collect(Collectors.toMap(TaskDTO::getId, TaskDTO::getName)); |
||||
|
|
||||
|
//查询申诉列表
|
||||
|
appealEntityQueryWrapper.in("task_id",taskBySubLineName.stream().map(TaskDTO::getId).collect(Collectors.toList())); |
||||
|
Page<AppealEntity> appealEntityPage = appealMapper.selectPage(PageConverter.toMpPage(appealParam), appealEntityQueryWrapper); |
||||
|
appealDTOIPage = appealEntityPage.convert(entity -> entity.toDTO(AppealDTO::new)); |
||||
|
} |
||||
|
appealDTOIPage.setRecords(buildDTO(appealDTOIPage.getRecords(),taskIdToSubLineNameMap)); |
||||
|
return Result.success(appealDTOIPage); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 构建返回实体 |
||||
|
*/ |
||||
|
private List<AppealDTO> buildDTO(List<AppealDTO> appealDTOList,Map<Long, String> taskIdToSubLineNameMap){ |
||||
|
if (CollectionUtils.isEmpty(appealDTOList)){ |
||||
|
return appealDTOList; |
||||
|
} |
||||
|
|
||||
|
//获取题目信息
|
||||
|
Set<Long> questionIdList = appealDTOList.stream() |
||||
|
.filter(appealDTO -> ObjectUtils.isNotEmpty(appealDTO.getExamId())) |
||||
|
.map(appealDTO -> appealDTO.getQuestionId()) |
||||
|
.collect(Collectors.toSet()); |
||||
|
Map<Long, QuestionEntity> questionEntityMap = questionBaseService.listByIds(questionIdList).stream() |
||||
|
.collect(Collectors.toMap(questionEntity -> questionEntity.getId(), questionEntity -> questionEntity)); |
||||
|
|
||||
|
//知识点拼接
|
||||
|
Set<Long> kpIdSet = new HashSet<>(); |
||||
|
appealDTOList.forEach(appealDTO -> { |
||||
|
if (questionEntityMap.containsKey(appealDTO.getQuestionId())){ |
||||
|
QuestionEntity questionEntity = questionEntityMap.get(appealDTO.getQuestionId()); |
||||
|
QuestionEntity.QuestionDetail questionDetail = questionEntity.getQuestionDetail(); |
||||
|
|
||||
|
appealDTO.setSubLineName(taskIdToSubLineNameMap.get(appealDTO.getTaskId())); |
||||
|
appealDTO.setQuestionContent(questionDetail.getQuestionContent()); |
||||
|
appealDTO.setRightAnswer(questionDetail.getRightAnswer()); |
||||
|
appealDTO.setKpIdList(questionEntity.getKpIdList()); |
||||
|
kpIdSet.addAll(questionEntity.getKpIdList()); |
||||
|
} |
||||
|
}); |
||||
|
|
||||
|
//查询知识点,构建知识点字段
|
||||
|
Map<Long, KnowledgePointEntity> kpIdToEntityMap = knowledgePointBaseService.listByIds(kpIdSet).stream() |
||||
|
.collect(Collectors.toMap( |
||||
|
KnowledgePointEntity::getId, |
||||
|
kpEntity -> kpEntity |
||||
|
)); |
||||
|
|
||||
|
appealDTOList.forEach(appealDTO -> { |
||||
|
List<Long> kpIdList = appealDTO.getKpIdList(); |
||||
|
|
||||
|
String kpContentStr = kpIdList.stream() |
||||
|
.filter(kpId -> kpIdToEntityMap.containsKey(kpId)) |
||||
|
.map(kpId -> kpIdToEntityMap.get(kpId).getContent()) |
||||
|
.filter(StringUtils::isNotBlank) |
||||
|
.collect(Collectors.joining(",")); |
||||
|
|
||||
|
appealDTO.setKpContentsStr(kpContentStr); |
||||
|
}); |
||||
|
|
||||
|
return appealDTOList; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,8 @@ |
|||||
|
package com.project.appeal.domain.service; |
||||
|
|
||||
|
import com.project.appeal.domain.dto.AppealDTO; |
||||
|
import com.project.base.domain.result.Result; |
||||
|
|
||||
|
public interface SaveAppealDomainService { |
||||
|
Result<AppealDTO> saveOrUpdate(AppealDTO appealDTO); |
||||
|
} |
||||
@ -0,0 +1,10 @@ |
|||||
|
package com.project.appeal.domain.service; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
import com.project.appeal.domain.dto.AppealDTO; |
||||
|
import com.project.appeal.domain.param.AppealParam; |
||||
|
import com.project.base.domain.result.Result; |
||||
|
|
||||
|
public interface SearchAppealDomainService { |
||||
|
Result<IPage<AppealDTO>> list(AppealParam appealParam); |
||||
|
} |
||||
@ -0,0 +1,14 @@ |
|||||
|
package com.project.appeal.mapper; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
import com.project.appeal.domain.dto.AppealDTO; |
||||
|
import com.project.appeal.domain.entity.AppealEntity; |
||||
|
import org.apache.ibatis.annotations.Mapper; |
||||
|
import org.apache.ibatis.annotations.Param; |
||||
|
import org.apache.ibatis.annotations.Select; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
@Mapper |
||||
|
public interface AppealMapper extends BaseMapper<AppealEntity> { |
||||
|
} |
||||
@ -0,0 +1,40 @@ |
|||||
|
package com.project.operation.config; |
||||
|
|
||||
|
import org.springframework.context.annotation.Bean; |
||||
|
import org.springframework.context.annotation.Configuration; |
||||
|
import org.springframework.scheduling.annotation.EnableAsync; |
||||
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; |
||||
|
|
||||
|
import java.util.concurrent.Executor; |
||||
|
import java.util.concurrent.ThreadPoolExecutor; |
||||
|
|
||||
|
/** |
||||
|
* 异步配置类:开启异步支持 + 自定义日志异步线程池 |
||||
|
*/ |
||||
|
@Configuration |
||||
|
@EnableAsync |
||||
|
public class AsyncConfig { |
||||
|
|
||||
|
/** |
||||
|
* 自定义日志异步线程池 |
||||
|
*/ |
||||
|
@Bean(name = "operationLogExecutor") |
||||
|
public Executor operationLogExecutor() { |
||||
|
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); |
||||
|
// 核心线程数(根据业务量调整)
|
||||
|
executor.setCorePoolSize(5); |
||||
|
// 最大线程数
|
||||
|
executor.setMaxPoolSize(20); |
||||
|
// 队列容量
|
||||
|
executor.setQueueCapacity(100); |
||||
|
// 线程前缀名(便于日志排查)
|
||||
|
executor.setThreadNamePrefix("operation-log-"); |
||||
|
// 线程空闲超时时间
|
||||
|
executor.setKeepAliveSeconds(60); |
||||
|
// 拒绝策略:队列满时由调用线程执行(避免日志丢失)
|
||||
|
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); |
||||
|
// 初始化线程池
|
||||
|
executor.initialize(); |
||||
|
return executor; |
||||
|
} |
||||
|
} |
||||
@ -1,9 +1,39 @@ |
|||||
package com.project.task.mapper; |
package com.project.task.mapper; |
||||
|
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
import com.project.task.domain.dto.TaskDTO; |
||||
import com.project.task.domain.entity.TaskEntity; |
import com.project.task.domain.entity.TaskEntity; |
||||
import org.apache.ibatis.annotations.Mapper; |
import org.apache.ibatis.annotations.Mapper; |
||||
|
import org.apache.ibatis.annotations.Select; |
||||
|
import org.springframework.data.repository.query.Param; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
@Mapper |
@Mapper |
||||
public interface TaskMapper extends BaseMapper<TaskEntity> { |
public interface TaskMapper extends BaseMapper<TaskEntity> { |
||||
|
|
||||
|
/** |
||||
|
* 根据关联表单ID,查询考试任务 |
||||
|
*/ |
||||
|
@Select({ |
||||
|
"SELECT t.* ", |
||||
|
"FROM evaluator_task t ", |
||||
|
"WHERE t.id = (", |
||||
|
" SELECT e.task_id ", |
||||
|
" FROM evaluator_task_user e ", |
||||
|
" WHERE e.id = #{taskUserId} ", |
||||
|
")" |
||||
|
}) |
||||
|
TaskEntity getTaskByTaskUserId(@Param("taskUserId") Long taskUserId); |
||||
|
|
||||
|
/** |
||||
|
* 查询考试任务 |
||||
|
*/ |
||||
|
@Select({ |
||||
|
"select e.id,l.name as subLineName" + |
||||
|
"from evaluator_task e " + |
||||
|
"LEFT join evaluator_product_line l on e.id = l.id" + |
||||
|
"where l.leaf = 1 and l.name LIKE CONCAT('%', #{subLineName}, '%')" |
||||
|
}) |
||||
|
List<TaskDTO> getTaskBySubLineName(@Param("subLineName") String subLineName); |
||||
} |
} |
||||
|
|||||
Loading…
Reference in new issue