|
|
@ -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")) |
|
|
|