Browse Source

Merge remote-tracking branch 'origin/master'

master
luogw 1 month ago
parent
commit
2199b5bf36
  1. 16
      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. 12
      src/main/java/com/project/interaction/domain/service/impl/SaveClusterDomainServiceImpl.java
  9. 13
      src/main/java/com/project/question/domain/service/impl/QuestionInventoryDomainServiceImpl.java

16
src/main/java/com/project/information/application/impl/KnowledgePointApplicationServiceImpl.java

@ -1,10 +1,12 @@
package com.project.information.application.impl; package com.project.information.application.impl;
import cn.hutool.core.collection.CollUtil;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.project.base.domain.result.Result; import com.project.base.domain.result.Result;
import com.project.information.application.KnowledgePointApplicationService; 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.dto.KnowledgePointStatisticsDTO;
import com.project.information.domain.entity.InformationEntity; import com.project.information.domain.entity.InformationEntity;
import com.project.information.domain.entity.KnowledgePointEntity; 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.InformationBaseService;
import com.project.information.domain.service.KnowledgePointBaseService; import com.project.information.domain.service.KnowledgePointBaseService;
import com.project.information.utils.MinIoUtils; import com.project.information.utils.MinIoUtils;
import com.project.interaction.application.AlgorithmApplicationService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.compress.utils.IOUtils; import org.apache.commons.compress.utils.IOUtils;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
@ -60,6 +63,9 @@ public class KnowledgePointApplicationServiceImpl implements KnowledgePointAppli
@Value("${analysis.url:/word/parse}") @Value("${analysis.url:/word/parse}")
private String analysisUrl; private String analysisUrl;
@Autowired
private AlgorithmApplicationService algorithmApplicationService;
@Override @Override
public Result<KnowledgePointStatisticsDTO> getStatistics(Long subLineId) throws Exception { public Result<KnowledgePointStatisticsDTO> getStatistics(Long subLineId) throws Exception {
return getStatisticsKnowledgePointDomainService.getStatistics(subLineId); return getStatisticsKnowledgePointDomainService.getStatistics(subLineId);
@ -83,8 +89,16 @@ public class KnowledgePointApplicationServiceImpl implements KnowledgePointAppli
} catch (Exception e) { } catch (Exception e) {
log.error("解析异常, ID:{}", id, e); log.error("解析异常, ID:{}", id, e);
// 失败更新状态 // 失败更新状态
updateStatusInformation(null, InformationParseStatusEnum.Fail.getValue(), id); updateStatusInformation(null, InformationParseStatusEnum.Success.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 * 关联文档idList
*/ */
private List<Long> relatedDocumentList; 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 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; 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.exception.BusinessErrorException;
import com.project.base.domain.result.Result; import com.project.base.domain.result.Result;
import com.project.information.domain.dto.KnowledgePointStatisticsDTO; import com.project.information.domain.dto.KnowledgePointStatisticsDTO;
import com.project.information.domain.entity.InformationEntity; 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.GetStatisticsKnowledgePointDomainService;
import com.project.information.domain.service.InformationBaseService; import com.project.information.domain.service.InformationBaseService;
import com.project.information.domain.service.KnowledgeClusterBaseService;
import com.project.information.mapper.KnowledgePointMapper; import com.project.information.mapper.KnowledgePointMapper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -19,6 +22,8 @@ public class GetStatisticsKnowledgePointDomainServiceImpl implements GetStatisti
private KnowledgePointMapper knowledgePointMapper; private KnowledgePointMapper knowledgePointMapper;
@Autowired @Autowired
private InformationBaseService informationBaseService; private InformationBaseService informationBaseService;
@Autowired
private KnowledgeClusterBaseService knowledgeClusterBaseService;
@Override @Override
public Result<KnowledgePointStatisticsDTO> getStatistics(Long subLineId) throws Exception { public Result<KnowledgePointStatisticsDTO> getStatistics(Long subLineId) throws Exception {
KnowledgePointStatisticsDTO dto = knowledgePointMapper.selectBySubLineId(subLineId); KnowledgePointStatisticsDTO dto = knowledgePointMapper.selectBySubLineId(subLineId);
@ -29,6 +34,13 @@ public class GetStatisticsKnowledgePointDomainServiceImpl implements GetStatisti
.eq(InformationEntity::getSubLineId, subLineId).list() .eq(InformationEntity::getSubLineId, subLineId).list()
.stream().map(InformationEntity::getId).toList(); .stream().map(InformationEntity::getId).toList();
dto.setRelatedDocumentList(relatedDocumentList); 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); 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.result.Result;
import com.project.base.domain.utils.TreeUtils; import com.project.base.domain.utils.TreeUtils;
import com.project.information.domain.dto.ProductLineDTO; 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.entity.ProductLineEntity;
import com.project.information.domain.enums.InformationParseStatusEnum;
import com.project.information.domain.param.ProductLineParam; import com.project.information.domain.param.ProductLineParam;
import com.project.information.domain.service.GetTreeListProductLineDomainService; 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.domain.service.ProductLineBaseService;
import com.project.information.mapper.InformationMapper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -22,6 +28,12 @@ import java.util.stream.Collectors;
public class GetTreeListProductLineDomainServiceImpl implements GetTreeListProductLineDomainService { public class GetTreeListProductLineDomainServiceImpl implements GetTreeListProductLineDomainService {
@Autowired @Autowired
private ProductLineBaseService productLineBaseService; private ProductLineBaseService productLineBaseService;
@Autowired
private InformationBaseService informationBaseService;
@Autowired
private KnowledgeClusterBaseService knowledgeClusterBaseService;
@Override @Override
public Result<List<ProductLineDTO>> treeList(ProductLineParam param){ public Result<List<ProductLineDTO>> treeList(ProductLineParam param){
LambdaQueryWrapper<ProductLineEntity> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<ProductLineEntity> queryWrapper = new LambdaQueryWrapper<>();
@ -31,6 +43,21 @@ public class GetTreeListProductLineDomainServiceImpl implements GetTreeListProdu
List<ProductLineDTO> res = productLineBaseService.list(queryWrapper) List<ProductLineDTO> res = productLineBaseService.list(queryWrapper)
.stream().map(entity -> entity.toDTO(ProductLineDTO::new)) .stream().map(entity -> entity.toDTO(ProductLineDTO::new))
.collect(Collectors.toList()); .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 , return Result.success(TreeUtils.buildLongTree(res , ProductLineDTO::getId , ProductLineDTO::getParentId ,
ProductLineDTO::setChildrenList)); 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); 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))); 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 @Override
public void postToClusteringByInformationId(Long informationId, List<KnowledgePointDTO> kpList) { public void postToClusteringByInformationId(Long informationId, List<KnowledgePointDTO> kpList) {
postToClusteringDomainService.postToClusteringByInformationId(informationId , kpList);
} }
@Override @Override

12
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 cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.project.information.domain.dto.KnowledgePointDTO; 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.KnowledgeClusterEntity;
import com.project.information.domain.entity.KnowledgePointEntity; 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.KnowledgeClusterBaseService;
import com.project.information.domain.service.KnowledgePointBaseService; import com.project.information.domain.service.KnowledgePointBaseService;
import com.project.interaction.domain.dto.ClusterCallbackDTO; import com.project.interaction.domain.dto.ClusterCallbackDTO;
@ -50,6 +53,8 @@ public class SaveClusterDomainServiceImpl implements SaveClusterDomainService {
private final Integer ROUND_NUM = 2; private final Integer ROUND_NUM = 2;
@Autowired
private InformationBaseService informationBaseService;
@Override @Override
public void saveClusterByInformationId(Long informationId, List<ClusterCallbackDTO.ClusterItem> clusters) throws Exception { public void saveClusterByInformationId(Long informationId, List<ClusterCallbackDTO.ClusterItem> clusters) throws Exception {
@ -78,6 +83,11 @@ public class SaveClusterDomainServiceImpl implements SaveClusterDomainService {
// 批量插入 // 批量插入
knowledgePointBaseService.updateBatchById(kpList); knowledgePointBaseService.updateBatchById(kpList);
} }
Thread.sleep(60000);
InformationEntity byId = informationBaseService.getById(informationId);
byId.setParseStatus(InformationParseStatusEnum.Success.getValue());
informationBaseService.updateById(byId);
} }
@Override @Override
@ -130,7 +140,7 @@ public class SaveClusterDomainServiceImpl implements SaveClusterDomainService {
produceDTOList.add(buildDTO(kp.getId() , QuestionSourceTypeEnum.Single_Concept, 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.TRUE_FALSE.name())),
(int) Math.ceil(targetNum * questionTypeMap.get(QuestionTypeEnum.SINGLE_CHOICE.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) { if (clusterEntity.getClusterSize() > 1) {
// 簇生成目标量 // 簇生成目标量

13
src/main/java/com/project/question/domain/service/impl/QuestionInventoryDomainServiceImpl.java

@ -1,5 +1,6 @@
package com.project.question.domain.service.impl; package com.project.question.domain.service.impl;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.project.base.domain.result.Result; import com.project.base.domain.result.Result;
import com.project.question.domain.entity.TaskKnowledgeClusterEntity; import com.project.question.domain.entity.TaskKnowledgeClusterEntity;
@ -57,6 +58,9 @@ public class QuestionInventoryDomainServiceImpl implements QuestionInventoryDoma
new LambdaQueryWrapper<TaskKnowledgePointEntity>().eq(TaskKnowledgePointEntity::getTaskId , taskId)); new LambdaQueryWrapper<TaskKnowledgePointEntity>().eq(TaskKnowledgePointEntity::getTaskId , taskId));
for (TaskKnowledgePointEntity kp : kpList) { for (TaskKnowledgePointEntity kp : kpList) {
for (QuestionTypeEnum questionType : QuestionTypeEnum.values()) { for (QuestionTypeEnum questionType : QuestionTypeEnum.values()) {
if (QuestionTypeEnum.MULTIPLE_CHOICE.equals(questionType)) {
continue;
}
checkAndProduce(kp.getId() , questionType , watermark , targetLine); checkAndProduce(kp.getId() , questionType , watermark , targetLine);
} }
} }
@ -65,6 +69,9 @@ public class QuestionInventoryDomainServiceImpl implements QuestionInventoryDoma
new LambdaQueryWrapper<TaskKnowledgeClusterEntity>().eq(TaskKnowledgeClusterEntity::getTaskId, taskId)); new LambdaQueryWrapper<TaskKnowledgeClusterEntity>().eq(TaskKnowledgeClusterEntity::getTaskId, taskId));
for (TaskKnowledgeClusterEntity cluster : clusterList) { for (TaskKnowledgeClusterEntity cluster : clusterList) {
if (cluster.getClusterSize() < 2) {
continue;
}
int w = cluster.getClusterSize(); int w = cluster.getClusterSize();
// 簇水位线: 1.0 * U * W // 簇水位线: 1.0 * U * W
int clusterWatermark = watermark * w; int clusterWatermark = watermark * w;
@ -97,6 +104,9 @@ public class QuestionInventoryDomainServiceImpl implements QuestionInventoryDoma
new LambdaQueryWrapper<TaskKnowledgePointEntity>().eq(TaskKnowledgePointEntity::getTaskId , taskId)); new LambdaQueryWrapper<TaskKnowledgePointEntity>().eq(TaskKnowledgePointEntity::getTaskId , taskId));
for (TaskKnowledgePointEntity kp : kpList) { for (TaskKnowledgePointEntity kp : kpList) {
for (QuestionTypeEnum questionType : QuestionTypeEnum.values()) { for (QuestionTypeEnum questionType : QuestionTypeEnum.values()) {
if (QuestionTypeEnum.MULTIPLE_CHOICE.equals(questionType)) {
continue;
}
int currentStock = questionKpMapper.countAvailableByKp(kp.getId(), questionType.getValue()); int currentStock = questionKpMapper.countAvailableByKp(kp.getId(), questionType.getValue());
if (currentStock < watermark){ if (currentStock < watermark){
flage = false; flage = false;
@ -109,6 +119,9 @@ public class QuestionInventoryDomainServiceImpl implements QuestionInventoryDoma
new LambdaQueryWrapper<TaskKnowledgeClusterEntity>().eq(TaskKnowledgeClusterEntity::getTaskId, taskId)); new LambdaQueryWrapper<TaskKnowledgeClusterEntity>().eq(TaskKnowledgeClusterEntity::getTaskId, taskId));
for (TaskKnowledgeClusterEntity cluster : clusterList) { for (TaskKnowledgeClusterEntity cluster : clusterList) {
if (cluster.getClusterSize() < 2) {
continue;
}
int w = cluster.getClusterSize(); int w = cluster.getClusterSize();
// 簇水位线: 1.0 * U * W // 簇水位线: 1.0 * U * W
int clusterWatermark = watermark * w; int clusterWatermark = watermark * w;

Loading…
Cancel
Save