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..ba92427 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); @@ -83,8 +89,16 @@ public class KnowledgePointApplicationServiceImpl implements KnowledgePointAppli } catch (Exception e) { log.error("解析异常, ID:{}", id, e); // 失败更新状态 - updateStatusInformation(null, InformationParseStatusEnum.Fail.getValue(), id); + updateStatusInformation(null, InformationParseStatusEnum.Success.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..63bed00 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,11 @@ public class SaveClusterDomainServiceImpl implements SaveClusterDomainService { // 批量插入 knowledgePointBaseService.updateBatchById(kpList); } + Thread.sleep(60000); + + InformationEntity byId = informationBaseService.getById(informationId); + byId.setParseStatus(InformationParseStatusEnum.Success.getValue()); + informationBaseService.updateById(byId); } @Override @@ -130,7 +140,7 @@ public class SaveClusterDomainServiceImpl implements SaveClusterDomainService { produceDTOList.add(buildDTO(kp.getId() , QuestionSourceTypeEnum.Single_Concept, (int) Math.ceil(targetNum * questionTypeMap.get(QuestionTypeEnum.TRUE_FALSE.name())), (int) Math.ceil(targetNum * questionTypeMap.get(QuestionTypeEnum.SINGLE_CHOICE.name())), - (int) Math.ceil(targetNum * questionTypeMap.get(QuestionTypeEnum.MULTIPLE_CHOICE.name())))); + 0)); } if (clusterEntity.getClusterSize() > 1) { // 簇生成目标量 diff --git a/src/main/java/com/project/question/domain/service/impl/QuestionInventoryDomainServiceImpl.java b/src/main/java/com/project/question/domain/service/impl/QuestionInventoryDomainServiceImpl.java index 95b07fe..f67bf9d 100644 --- a/src/main/java/com/project/question/domain/service/impl/QuestionInventoryDomainServiceImpl.java +++ b/src/main/java/com/project/question/domain/service/impl/QuestionInventoryDomainServiceImpl.java @@ -1,5 +1,6 @@ package com.project.question.domain.service.impl; +import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.project.base.domain.result.Result; import com.project.question.domain.entity.TaskKnowledgeClusterEntity; @@ -57,6 +58,9 @@ public class QuestionInventoryDomainServiceImpl implements QuestionInventoryDoma new LambdaQueryWrapper().eq(TaskKnowledgePointEntity::getTaskId , taskId)); for (TaskKnowledgePointEntity kp : kpList) { for (QuestionTypeEnum questionType : QuestionTypeEnum.values()) { + if (QuestionTypeEnum.MULTIPLE_CHOICE.equals(questionType)) { + continue; + } checkAndProduce(kp.getId() , questionType , watermark , targetLine); } } @@ -65,6 +69,9 @@ public class QuestionInventoryDomainServiceImpl implements QuestionInventoryDoma new LambdaQueryWrapper().eq(TaskKnowledgeClusterEntity::getTaskId, taskId)); for (TaskKnowledgeClusterEntity cluster : clusterList) { + if (cluster.getClusterSize() < 2) { + continue; + } int w = cluster.getClusterSize(); // 簇水位线: 1.0 * U * W int clusterWatermark = watermark * w; @@ -97,6 +104,9 @@ public class QuestionInventoryDomainServiceImpl implements QuestionInventoryDoma new LambdaQueryWrapper().eq(TaskKnowledgePointEntity::getTaskId , taskId)); for (TaskKnowledgePointEntity kp : kpList) { for (QuestionTypeEnum questionType : QuestionTypeEnum.values()) { + if (QuestionTypeEnum.MULTIPLE_CHOICE.equals(questionType)) { + continue; + } int currentStock = questionKpMapper.countAvailableByKp(kp.getId(), questionType.getValue()); if (currentStock < watermark){ flage = false; @@ -109,6 +119,9 @@ public class QuestionInventoryDomainServiceImpl implements QuestionInventoryDoma new LambdaQueryWrapper().eq(TaskKnowledgeClusterEntity::getTaskId, taskId)); for (TaskKnowledgeClusterEntity cluster : clusterList) { + if (cluster.getClusterSize() < 2) { + continue; + } int w = cluster.getClusterSize(); // 簇水位线: 1.0 * U * W int clusterWatermark = watermark * w;