|
@@ -3,11 +3,15 @@ package cn.iocoder.yudao.module.ai.dal.mysql.knowledge;
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
|
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
|
|
+import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX;
|
|
|
import cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.segment.AiKnowledgeSegmentPageReqVO;
|
|
|
+import cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.segment.AiKnowledgeSegmentProcessRespVO;
|
|
|
import cn.iocoder.yudao.module.ai.dal.dataobject.knowledge.AiKnowledgeSegmentDO;
|
|
|
+import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|
|
import org.apache.ibatis.annotations.Mapper;
|
|
|
|
|
|
import java.util.List;
|
|
|
+import java.util.Collection;
|
|
|
|
|
|
/**
|
|
|
* AI 知识库分片 Mapper
|
|
@@ -37,4 +41,15 @@ public interface AiKnowledgeSegmentMapper extends BaseMapperX<AiKnowledgeSegment
|
|
|
.orderByDesc(AiKnowledgeSegmentDO::getId));
|
|
|
}
|
|
|
|
|
|
+ default List<AiKnowledgeSegmentProcessRespVO> selectProcessList(Collection<Long> documentIds) {
|
|
|
+ MPJLambdaWrapper<AiKnowledgeSegmentDO> wrapper = new MPJLambdaWrapperX<AiKnowledgeSegmentDO>()
|
|
|
+ .selectAs(AiKnowledgeSegmentDO::getDocumentId, AiKnowledgeSegmentProcessRespVO::getDocumentId)
|
|
|
+ .selectCount(AiKnowledgeSegmentDO::getId, "count")
|
|
|
+ .select("COUNT(CASE WHEN vector_id > '" + AiKnowledgeSegmentDO.VECTOR_ID_EMPTY
|
|
|
+ + "' THEN 1 ELSE NULL END) AS embeddingCount")
|
|
|
+ .in(AiKnowledgeSegmentDO::getDocumentId, documentIds)
|
|
|
+ .groupBy(AiKnowledgeSegmentDO::getDocumentId);
|
|
|
+ return selectJoinList(AiKnowledgeSegmentProcessRespVO.class, wrapper);
|
|
|
+ }
|
|
|
+
|
|
|
}
|