diff --git a/src/main/java/com/project/information/domain/dto/ProductLineDTO.java b/src/main/java/com/project/information/domain/dto/ProductLineDTO.java index ee100c5..f142240 100644 --- a/src/main/java/com/project/information/domain/dto/ProductLineDTO.java +++ b/src/main/java/com/project/information/domain/dto/ProductLineDTO.java @@ -25,6 +25,9 @@ public class ProductLineDTO extends BaseDTO { private Boolean hasDocument = Boolean.TRUE; + /** + * 该子产品线下是否存在待解析资料 + */ private Boolean existInProgress = Boolean.FALSE; /** @@ -33,4 +36,11 @@ public class ProductLineDTO extends BaseDTO { */ private Boolean existPendingReview = Boolean.FALSE; + /** + * 该子产品线下是否存在未完成聚类的文件 + * 已解析成功、有知识点但 clusterId 为空的知识点视为未完成聚类 + * 没有知识点的文件不参与判断 + */ + private Boolean existClusteringIncomplete = Boolean.FALSE; + } diff --git a/src/main/java/com/project/information/domain/service/impl/GetTreeListProductLineDomainServiceImpl.java b/src/main/java/com/project/information/domain/service/impl/GetTreeListProductLineDomainServiceImpl.java index 204c260..a304b8f 100644 --- a/src/main/java/com/project/information/domain/service/impl/GetTreeListProductLineDomainServiceImpl.java +++ b/src/main/java/com/project/information/domain/service/impl/GetTreeListProductLineDomainServiceImpl.java @@ -1,5 +1,6 @@ package com.project.information.domain.service.impl; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -9,6 +10,7 @@ import com.project.base.domain.utils.TreeUtils; import com.project.information.domain.dto.ProductLineDTO; import com.project.information.domain.entity.InformationEntity; import com.project.information.domain.entity.KnowledgeClusterEntity; +import com.project.information.domain.entity.KnowledgePointEntity; import com.project.information.domain.entity.ProductLineEntity; import com.project.information.domain.enums.DraftStatusEnum; import com.project.information.domain.enums.InformationParseStatusEnum; @@ -16,12 +18,15 @@ import com.project.information.domain.param.ProductLineParam; import com.project.information.domain.service.GetTreeListProductLineDomainService; import com.project.information.domain.service.InformationBaseService; import com.project.information.domain.service.KnowledgeClusterBaseService; +import com.project.information.domain.service.KnowledgePointBaseService; import com.project.information.domain.service.ProductLineBaseService; import com.project.information.mapper.InformationMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.Collections; import java.util.List; +import java.util.Map; import java.util.Objects; import java.util.stream.Collectors; @@ -34,7 +39,7 @@ public class GetTreeListProductLineDomainServiceImpl implements GetTreeListProdu private InformationBaseService informationBaseService; @Autowired - private KnowledgeClusterBaseService knowledgeClusterBaseService; + private KnowledgePointBaseService knowledgePointBaseService; @Override public Result> treeList(ProductLineParam param){ return Result.success(buildTree(param)); @@ -73,6 +78,35 @@ public class GetTreeListProductLineDomainServiceImpl implements GetTreeListProdu .eq(InformationEntity::getDraftStatus, DraftStatusEnum.PENDING.getValue()) .count(); productLineDTO.setExistPendingReview(pendingCount > 0); + + // 查询聚类完成和审核完成情况:该子产品线下已解析成功的文件中, + // 有知识点但未分配簇的文件视为未完成聚类,没有知识点的文件除外 + List successFiles = informationBaseService.lambdaQuery() + .eq(InformationEntity::getSubLineId, productLineDTO.getId()) + .eq(InformationEntity::getParseStatus, InformationParseStatusEnum.Success.getValue()) + .eq(InformationEntity::getDraftStatus, DraftStatusEnum.APPROVED.getValue()) + .list(); + if (CollUtil.isNotEmpty(successFiles)) { + List fileIds = successFiles.stream().map(InformationEntity::getId).toList(); + List allKps = knowledgePointBaseService.lambdaQuery() + .in(KnowledgePointEntity::getInformationId, fileIds) + .list(); + Map> kpsByFile = allKps.stream() + .collect(Collectors.groupingBy(KnowledgePointEntity::getInformationId)); + + boolean hasClusteringIncomplete = false; + for (Long fileId : fileIds) { + List fileKps = kpsByFile.getOrDefault(fileId, Collections.emptyList()); + if (fileKps.isEmpty()) { + continue; // 没有知识点的文件不参与判断 + } + if (fileKps.stream().anyMatch(kp -> kp.getClusterId() == null)) { + hasClusteringIncomplete = true; + break; + } + } + productLineDTO.setExistClusteringIncomplete(hasClusteringIncomplete); + } } return TreeUtils.buildLongTree(res , ProductLineDTO::getId , ProductLineDTO::getParentId , ProductLineDTO::setChildrenList);