Browse Source

增加文档聚类实体类

master
luoweijian 1 month ago
parent
commit
26f9c2d2e5
  1. 14
      src/main/java/com/project/information/application/impl/KnowledgePointApplicationServiceImpl.java
  2. 3
      src/main/java/com/project/information/domain/dto/KnowledgePointStatisticsDTO.java
  3. 7
      src/main/java/com/project/information/domain/dto/ProductLineDTO.java
  4. 12
      src/main/java/com/project/information/domain/service/impl/GetStatisticsKnowledgePointDomainServiceImpl.java
  5. 27
      src/main/java/com/project/information/domain/service/impl/GetTreeListProductLineDomainServiceImpl.java
  6. 14
      src/main/java/com/project/information/domain/service/impl/UploadInformationDomainServiceImpl.java
  7. 2
      src/main/java/com/project/interaction/application/impl/AlgorithmApplicationServiceImpl.java
  8. 8
      src/main/java/com/project/interaction/domain/service/impl/SaveClusterDomainServiceImpl.java

14
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<KnowledgePointStatisticsDTO> 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<KnowledgePointDTO> list = knowledgePointBaseService.lambdaQuery()
.eq(KnowledgePointEntity::getInformationId, id).list().stream()
.map(entity -> entity.toDTO(KnowledgePointDTO::new)).toList();
if (CollUtil.isNotEmpty(list)) {
algorithmApplicationService.postToClusteringByInformationId(id , list);
}
}
}

3
src/main/java/com/project/information/domain/dto/KnowledgePointStatisticsDTO.java

@ -19,4 +19,7 @@ public class KnowledgePointStatisticsDTO {
* 关联文档idList
*/
private List<Long> relatedDocumentList;
private Integer clusterSizeOverOneNum = 0;
}

7
src/main/java/com/project/information/domain/dto/ProductLineDTO.java

@ -20,4 +20,11 @@ public class ProductLineDTO extends BaseDTO {
private List<ProductLineDTO> childrenList = new ArrayList<>();
private Integer documentNum = 0;
private Boolean hasDocument = Boolean.TRUE;
private Boolean existInProgress = Boolean.FALSE;
}

12
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<KnowledgePointStatisticsDTO> 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);
}
}

27
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<List<ProductLineDTO>> treeList(ProductLineParam param){
LambdaQueryWrapper<ProductLineEntity> queryWrapper = new LambdaQueryWrapper<>();
@ -31,6 +43,21 @@ public class GetTreeListProductLineDomainServiceImpl implements GetTreeListProdu
List<ProductLineDTO> 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));

14
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<Long, String> entry : fileMap.entrySet()) {
Long informationId = entry.getKey();
List<KnowledgePointDTO> 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)));
}

2
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<KnowledgePointDTO> kpList) {
postToClusteringDomainService.postToClusteringByInformationId(informationId , kpList);
}
@Override

8
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<ClusterCallbackDTO.ClusterItem> 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

Loading…
Cancel
Save