From 26f9c2d2e5e85dc446ba38fae881e2c8ce6277e8 Mon Sep 17 00:00:00 2001 From: luoweijian <1329394916@qq.com> Date: Sat, 21 Mar 2026 09:32:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=96=87=E6=A1=A3=E8=81=9A?= =?UTF-8?q?=E7=B1=BB=E5=AE=9E=E4=BD=93=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../KnowledgePointApplicationServiceImpl.java | 14 ++++++++++ .../dto/KnowledgePointStatisticsDTO.java | 3 +++ .../domain/dto/ProductLineDTO.java | 7 +++++ ...isticsKnowledgePointDomainServiceImpl.java | 12 +++++++++ ...tTreeListProductLineDomainServiceImpl.java | 27 +++++++++++++++++++ .../UploadInformationDomainServiceImpl.java | 14 +--------- .../impl/AlgorithmApplicationServiceImpl.java | 2 +- .../impl/SaveClusterDomainServiceImpl.java | 8 ++++++ 8 files changed, 73 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/project/information/application/impl/KnowledgePointApplicationServiceImpl.java b/src/main/java/com/project/information/application/impl/KnowledgePointApplicationServiceImpl.java index 2f60c9b..80ad13f 100644 --- a/src/main/java/com/project/information/application/impl/KnowledgePointApplicationServiceImpl.java +++ b/src/main/java/com/project/information/application/impl/KnowledgePointApplicationServiceImpl.java @@ -1,10 +1,12 @@ package com.project.information.application.impl; +import cn.hutool.core.collection.CollUtil; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import com.project.base.domain.result.Result; import com.project.information.application.KnowledgePointApplicationService; +import com.project.information.domain.dto.KnowledgePointDTO; import com.project.information.domain.dto.KnowledgePointStatisticsDTO; import com.project.information.domain.entity.InformationEntity; import com.project.information.domain.entity.KnowledgePointEntity; @@ -13,6 +15,7 @@ import com.project.information.domain.service.GetStatisticsKnowledgePointDomainS import com.project.information.domain.service.InformationBaseService; import com.project.information.domain.service.KnowledgePointBaseService; import com.project.information.utils.MinIoUtils; +import com.project.interaction.application.AlgorithmApplicationService; import lombok.extern.slf4j.Slf4j; import org.apache.commons.compress.utils.IOUtils; import org.apache.commons.lang3.ObjectUtils; @@ -60,6 +63,9 @@ public class KnowledgePointApplicationServiceImpl implements KnowledgePointAppli @Value("${analysis.url:/word/parse}") private String analysisUrl; + @Autowired + private AlgorithmApplicationService algorithmApplicationService; + @Override public Result getStatistics(Long subLineId) throws Exception { return getStatisticsKnowledgePointDomainService.getStatistics(subLineId); @@ -85,6 +91,14 @@ public class KnowledgePointApplicationServiceImpl implements KnowledgePointAppli // 失败更新状态 updateStatusInformation(null, InformationParseStatusEnum.Fail.getValue(), id); } + // 聚类 + List list = knowledgePointBaseService.lambdaQuery() + .eq(KnowledgePointEntity::getInformationId, id).list().stream() + .map(entity -> entity.toDTO(KnowledgePointDTO::new)).toList(); + if (CollUtil.isNotEmpty(list)) { + algorithmApplicationService.postToClusteringByInformationId(id , list); + } + } } diff --git a/src/main/java/com/project/information/domain/dto/KnowledgePointStatisticsDTO.java b/src/main/java/com/project/information/domain/dto/KnowledgePointStatisticsDTO.java index d6fdfeb..ddc5158 100644 --- a/src/main/java/com/project/information/domain/dto/KnowledgePointStatisticsDTO.java +++ b/src/main/java/com/project/information/domain/dto/KnowledgePointStatisticsDTO.java @@ -19,4 +19,7 @@ public class KnowledgePointStatisticsDTO { * 关联文档idList */ private List relatedDocumentList; + + private Integer clusterSizeOverOneNum = 0; + } 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 5b0b5bd..4f37732 100644 --- a/src/main/java/com/project/information/domain/dto/ProductLineDTO.java +++ b/src/main/java/com/project/information/domain/dto/ProductLineDTO.java @@ -20,4 +20,11 @@ public class ProductLineDTO extends BaseDTO { private List childrenList = new ArrayList<>(); + private Integer documentNum = 0; + + private Boolean hasDocument = Boolean.TRUE; + + + private Boolean existInProgress = Boolean.FALSE; + } diff --git a/src/main/java/com/project/information/domain/service/impl/GetStatisticsKnowledgePointDomainServiceImpl.java b/src/main/java/com/project/information/domain/service/impl/GetStatisticsKnowledgePointDomainServiceImpl.java index 0d61ce7..86baac3 100644 --- a/src/main/java/com/project/information/domain/service/impl/GetStatisticsKnowledgePointDomainServiceImpl.java +++ b/src/main/java/com/project/information/domain/service/impl/GetStatisticsKnowledgePointDomainServiceImpl.java @@ -1,11 +1,14 @@ package com.project.information.domain.service.impl; +import cn.hutool.core.collection.CollUtil; import com.project.base.domain.exception.BusinessErrorException; import com.project.base.domain.result.Result; import com.project.information.domain.dto.KnowledgePointStatisticsDTO; import com.project.information.domain.entity.InformationEntity; +import com.project.information.domain.entity.KnowledgeClusterEntity; import com.project.information.domain.service.GetStatisticsKnowledgePointDomainService; import com.project.information.domain.service.InformationBaseService; +import com.project.information.domain.service.KnowledgeClusterBaseService; import com.project.information.mapper.KnowledgePointMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -19,6 +22,8 @@ public class GetStatisticsKnowledgePointDomainServiceImpl implements GetStatisti private KnowledgePointMapper knowledgePointMapper; @Autowired private InformationBaseService informationBaseService; + @Autowired + private KnowledgeClusterBaseService knowledgeClusterBaseService; @Override public Result getStatistics(Long subLineId) throws Exception { KnowledgePointStatisticsDTO dto = knowledgePointMapper.selectBySubLineId(subLineId); @@ -29,6 +34,13 @@ public class GetStatisticsKnowledgePointDomainServiceImpl implements GetStatisti .eq(InformationEntity::getSubLineId, subLineId).list() .stream().map(InformationEntity::getId).toList(); dto.setRelatedDocumentList(relatedDocumentList); + + + if (CollUtil.isNotEmpty(relatedDocumentList)) { + dto.setClusterSizeOverOneNum(knowledgeClusterBaseService.lambdaQuery() + .in(KnowledgeClusterEntity::getInformationId, relatedDocumentList) + .gt(KnowledgeClusterEntity::getClusterSize, 1).count().intValue());; + } return Result.success(dto); } } 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 ef65a08..3e85a92 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 @@ -7,10 +7,16 @@ import com.project.base.domain.exception.BusinessErrorException; import com.project.base.domain.result.Result; 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.ProductLineEntity; +import com.project.information.domain.enums.InformationParseStatusEnum; 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.ProductLineBaseService; +import com.project.information.mapper.InformationMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -22,6 +28,12 @@ import java.util.stream.Collectors; public class GetTreeListProductLineDomainServiceImpl implements GetTreeListProductLineDomainService { @Autowired private ProductLineBaseService productLineBaseService; + + @Autowired + private InformationBaseService informationBaseService; + + @Autowired + private KnowledgeClusterBaseService knowledgeClusterBaseService; @Override public Result> treeList(ProductLineParam param){ LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); @@ -31,6 +43,21 @@ public class GetTreeListProductLineDomainServiceImpl implements GetTreeListProdu List res = productLineBaseService.list(queryWrapper) .stream().map(entity -> entity.toDTO(ProductLineDTO::new)) .collect(Collectors.toList()); + for (ProductLineDTO productLineDTO : res) { + if (!productLineDTO.getLeaf()) { + continue; + } + Long count = informationBaseService.lambdaQuery() + .eq(InformationEntity::getSubLineId, productLineDTO.getId()) + .count(); + productLineDTO.setDocumentNum(count.intValue()); + productLineDTO.setHasDocument(count > 0); + Long inProgressCount = informationBaseService.lambdaQuery() + .eq(InformationEntity::getSubLineId, productLineDTO.getId()) + .eq(InformationEntity::getParseStatus, InformationParseStatusEnum.InProgress.getValue()) + .count(); + productLineDTO.setExistInProgress(inProgressCount > 0); + } return Result.success(TreeUtils.buildLongTree(res , ProductLineDTO::getId , ProductLineDTO::getParentId , ProductLineDTO::setChildrenList)); diff --git a/src/main/java/com/project/information/domain/service/impl/UploadInformationDomainServiceImpl.java b/src/main/java/com/project/information/domain/service/impl/UploadInformationDomainServiceImpl.java index 75ba246..22fedbb 100644 --- a/src/main/java/com/project/information/domain/service/impl/UploadInformationDomainServiceImpl.java +++ b/src/main/java/com/project/information/domain/service/impl/UploadInformationDomainServiceImpl.java @@ -146,19 +146,7 @@ public class UploadInformationDomainServiceImpl implements UploadInformationDoma //发起解析文档知识点 knowledgePointApplicationService.parse(fileMap); - // 聚类 - for (Map.Entry entry : fileMap.entrySet()) { - Long informationId = entry.getKey(); - List list = knowledgePointBaseService.lambdaQuery() - .eq(KnowledgePointEntity::getInformationId, informationId).list().stream() - .map(entity -> entity.toDTO(KnowledgePointDTO::new)).toList(); - if (CollUtil.isNotEmpty(list)) { - algorithmApplicationService.postToClusteringByInformationId(informationId , list); - } - InformationEntity byId = informationBaseService.getById(informationId); - byId.setParseStatus(InformationParseStatusEnum.Success.getValue()); - informationBaseService.updateById(byId); - } + return Result.success(String.format("上传成功:【%s】" , String.join("," , successFiles))); } diff --git a/src/main/java/com/project/interaction/application/impl/AlgorithmApplicationServiceImpl.java b/src/main/java/com/project/interaction/application/impl/AlgorithmApplicationServiceImpl.java index 38a2f1b..0e96ade 100644 --- a/src/main/java/com/project/interaction/application/impl/AlgorithmApplicationServiceImpl.java +++ b/src/main/java/com/project/interaction/application/impl/AlgorithmApplicationServiceImpl.java @@ -36,7 +36,7 @@ public class AlgorithmApplicationServiceImpl implements AlgorithmApplicationServ @Override public void postToClusteringByInformationId(Long informationId, List kpList) { - + postToClusteringDomainService.postToClusteringByInformationId(informationId , kpList); } @Override diff --git a/src/main/java/com/project/interaction/domain/service/impl/SaveClusterDomainServiceImpl.java b/src/main/java/com/project/interaction/domain/service/impl/SaveClusterDomainServiceImpl.java index 484153c..3845049 100644 --- a/src/main/java/com/project/interaction/domain/service/impl/SaveClusterDomainServiceImpl.java +++ b/src/main/java/com/project/interaction/domain/service/impl/SaveClusterDomainServiceImpl.java @@ -3,8 +3,11 @@ package com.project.interaction.domain.service.impl; import cn.hutool.core.collection.CollUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.project.information.domain.dto.KnowledgePointDTO; +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.enums.InformationParseStatusEnum; +import com.project.information.domain.service.InformationBaseService; import com.project.information.domain.service.KnowledgeClusterBaseService; import com.project.information.domain.service.KnowledgePointBaseService; import com.project.interaction.domain.dto.ClusterCallbackDTO; @@ -50,6 +53,8 @@ public class SaveClusterDomainServiceImpl implements SaveClusterDomainService { private final Integer ROUND_NUM = 2; + @Autowired + private InformationBaseService informationBaseService; @Override public void saveClusterByInformationId(Long informationId, List clusters) throws Exception { @@ -78,6 +83,9 @@ public class SaveClusterDomainServiceImpl implements SaveClusterDomainService { // 批量插入 knowledgePointBaseService.updateBatchById(kpList); } + InformationEntity byId = informationBaseService.getById(informationId); + byId.setParseStatus(InformationParseStatusEnum.Success.getValue()); + informationBaseService.updateById(byId); } @Override