Browse Source

bug修复

master
luogw 2 months ago
parent
commit
bef63662c9
  1. 4
      src/main/java/com/project/appeal/domain/service/Impl/SearchAppealDomainServiceImpl.java
  2. 4
      src/main/java/com/project/classicpaper/application/impl/ClassicCategoryApplicationServiceImpl.java
  3. 13
      src/main/java/com/project/information/mapper/ProductLineMapper.java
  4. 14
      src/main/java/com/project/task/mapper/TaskMapper.java

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

@ -41,8 +41,6 @@ public class SearchAppealDomainServiceImpl implements SearchAppealDomainService
private TaskMapper taskMapper; private TaskMapper taskMapper;
@Autowired @Autowired
private TaskKnowledgePointBaseService taskKnowledgePointBaseService; private TaskKnowledgePointBaseService taskKnowledgePointBaseService;
@Autowired
private ProductLineMapper productLineMapper;
private static final String KEY_VALUE_PATTERN = "\\{([^}]*)\\}\\:\\{([^}]*)\\}"; private static final String KEY_VALUE_PATTERN = "\\{([^}]*)\\}\\:\\{([^}]*)\\}";
@ -67,7 +65,7 @@ public class SearchAppealDomainServiceImpl implements SearchAppealDomainService
//查询产品线相关的考试任务 //查询产品线相关的考试任务
Set<Long> taskIdSet = appealDTOIPage.getRecords().stream().map(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 = taskMapper.getSubLineByTaskIDS(taskIdSet);
taskIdToLineAndCountMap = taskByIds.stream().collect(Collectors.toMap(TaskDTO::getId, taskDTO -> new Object[]{taskDTO.getSubLineName(),taskDTO.getShortAnswerScore()})); taskIdToLineAndCountMap = taskByIds.stream().collect(Collectors.toMap(TaskDTO::getId, taskDTO -> new Object[]{taskDTO.getSubLineName(),taskDTO.getShortAnswerScore()}));
} }
}else{ }else{

4
src/main/java/com/project/classicpaper/application/impl/ClassicCategoryApplicationServiceImpl.java

@ -74,12 +74,12 @@ public class ClassicCategoryApplicationServiceImpl implements ClassicCategoryApp
private void injectPaperSetCount(List<ClassicCategoryDTO> nodes, Map<Long, Integer> countMap) { private void injectPaperSetCount(List<ClassicCategoryDTO> nodes, Map<Long, Integer> countMap) {
for (ClassicCategoryDTO node : nodes) { for (ClassicCategoryDTO node : nodes) {
if (node.getChildrenList() != null && !node.getChildrenList().isEmpty()) { if (node.getChildrenList() != null && !node.getChildrenList().isEmpty()) {
// 一级分类:先递归处理子节点,再累加 // 一级分类:先递归处理子节点,再累加自身及子节点
injectPaperSetCount(node.getChildrenList(), countMap); injectPaperSetCount(node.getChildrenList(), countMap);
int sum = node.getChildrenList().stream() int sum = node.getChildrenList().stream()
.mapToInt(c -> c.getPaperSetCount() != null ? c.getPaperSetCount() : 0) .mapToInt(c -> c.getPaperSetCount() != null ? c.getPaperSetCount() : 0)
.sum(); .sum();
node.setPaperSetCount(sum); node.setPaperSetCount(sum + countMap.getOrDefault(node.getId(), 0));
} else { } else {
// 二级分类:直接取统计值 // 二级分类:直接取统计值
node.setPaperSetCount(countMap.getOrDefault(node.getId(), 0)); node.setPaperSetCount(countMap.getOrDefault(node.getId(), 0));

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

@ -15,17 +15,4 @@ public interface ProductLineMapper extends BaseMapper<ProductLineEntity> {
@Select("SELECT * FROM evaluator_product_line WHERE id = #{id}") @Select("SELECT * FROM evaluator_product_line WHERE id = #{id}")
ProductLineEntity selectByIdIncludeDeleted(@Param("id") Long id); ProductLineEntity selectByIdIncludeDeleted(@Param("id") Long id);
@Select({
"<script>",
"select t.id, e.name as subLineName,t.short_answer_score ",
"from evaluator_product_line e ",
"inner join evaluator_task t on e.id = t.sub_line_id ",
"where t.id in ",
"<foreach collection='taskIds' item='id' open='(' separator=',' close=')'>",
"#{id}",
"</foreach>",
"</script>"
})
List<TaskDTO> getSubLineByTaskIDS(@Param("taskIds") Set<Long> taskIds);
} }

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

@ -8,6 +8,7 @@ import org.apache.ibatis.annotations.Select;
import org.springframework.data.repository.query.Param; import org.springframework.data.repository.query.Param;
import java.util.List; import java.util.List;
import java.util.Set;
@Mapper @Mapper
public interface TaskMapper extends BaseMapper<TaskEntity> { public interface TaskMapper extends BaseMapper<TaskEntity> {
@ -55,4 +56,17 @@ public interface TaskMapper extends BaseMapper<TaskEntity> {
@Param("lineId") Long lineId, @Param("lineId") Long lineId,
@Param("businessId") Long businessId, @Param("businessId") Long businessId,
@Param("subLineName") String subLineName); @Param("subLineName") String subLineName);
@Select({
"<script>",
"select t.id, e.name as subLineName,t.short_answer_score ",
"from evaluator_task t ",
"left join evaluator_product_line e on e.id = t.sub_line_id ",
"where t.id in ",
"<foreach collection='taskIds' item='id' open='(' separator=',' close=')'>",
"#{id}",
"</foreach>",
"</script>"
})
List<TaskDTO> getSubLineByTaskIDS(@Param("taskIds") Set<Long> taskIds);
} }

Loading…
Cancel
Save