6 changed files with 132 additions and 1 deletions
			
			
		@ -0,0 +1,13 @@ | 
				
			|||||||
 | 
					package com.hnac.gglm.bigmodel.business.service; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.hnac.gglm.bigmodel.maintenance.dto.KnowledgeData; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.List; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/** | 
				
			||||||
 | 
					 * @Author: ypj | 
				
			||||||
 | 
					 * @Date: 2024/9/20 15:04 | 
				
			||||||
 | 
					 */ | 
				
			||||||
 | 
					public interface KnowledgeDataService { | 
				
			||||||
 | 
					    List<KnowledgeData> listKnowledgeData(); | 
				
			||||||
 | 
					} | 
				
			||||||
@ -0,0 +1,49 @@ | 
				
			|||||||
 | 
					package com.hnac.gglm.bigmodel.business.service.impl; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.alibaba.fastjson.JSONObject; | 
				
			||||||
 | 
					import com.baomidou.dynamic.datasource.annotation.DS; | 
				
			||||||
 | 
					import com.fasterxml.jackson.core.JsonProcessingException; | 
				
			||||||
 | 
					import com.fasterxml.jackson.databind.JsonNode; | 
				
			||||||
 | 
					import com.fasterxml.jackson.databind.ObjectMapper; | 
				
			||||||
 | 
					import com.hnac.gglm.bigmodel.business.service.KnowledgeDataService; | 
				
			||||||
 | 
					import com.hnac.gglm.bigmodel.maintenance.dto.KnowledgeData; | 
				
			||||||
 | 
					import com.hnac.gglm.bigmodel.maintenance.mapper.KnowledgeFileFragmentMapper; | 
				
			||||||
 | 
					import lombok.AllArgsConstructor; | 
				
			||||||
 | 
					import lombok.extern.slf4j.Slf4j; | 
				
			||||||
 | 
					import org.springframework.stereotype.Service; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.ArrayList; | 
				
			||||||
 | 
					import java.util.List; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/** | 
				
			||||||
 | 
					 * @Author: ypj | 
				
			||||||
 | 
					 * @Date: 2024/9/20 15:04 | 
				
			||||||
 | 
					 */ | 
				
			||||||
 | 
					@Service | 
				
			||||||
 | 
					@Slf4j | 
				
			||||||
 | 
					@AllArgsConstructor | 
				
			||||||
 | 
					@DS("hznlm") | 
				
			||||||
 | 
					public class KnowledgeDataServiceImpl implements KnowledgeDataService { | 
				
			||||||
 | 
					    KnowledgeFileFragmentMapper knowledgeFileFragmentMapper; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override | 
				
			||||||
 | 
					    public List<KnowledgeData> listKnowledgeData() { | 
				
			||||||
 | 
					        List<KnowledgeData> resourceList = knowledgeFileFragmentMapper.listKnowledgeData(); | 
				
			||||||
 | 
					        List<KnowledgeData> resultList = new ArrayList<>(); | 
				
			||||||
 | 
					        for (KnowledgeData item : resourceList) { | 
				
			||||||
 | 
					            String question = item.getDocQs(); | 
				
			||||||
 | 
					            List<String> questionList = JSONObject.parseArray(question, String.class); | 
				
			||||||
 | 
					            for (String q : questionList) { | 
				
			||||||
 | 
					                KnowledgeData data = new KnowledgeData(); | 
				
			||||||
 | 
					                data.setDocId(item.getDocId()); | 
				
			||||||
 | 
					                data.setDocContent(item.getDocContent()); | 
				
			||||||
 | 
					                data.setDocPageIndex(item.getDocPageIndex()); | 
				
			||||||
 | 
					                data.setDocQs(q); | 
				
			||||||
 | 
					                data.setArea(item.getArea()); | 
				
			||||||
 | 
					                data.setLevel(item.getLevel()); | 
				
			||||||
 | 
					                resultList.add(data); | 
				
			||||||
 | 
					            } | 
				
			||||||
 | 
					        } | 
				
			||||||
 | 
					        return resultList; | 
				
			||||||
 | 
					    } | 
				
			||||||
 | 
					} | 
				
			||||||
@ -0,0 +1,36 @@ | 
				
			|||||||
 | 
					package com.hnac.gglm.bigmodel.maintenance.dto; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.baomidou.mybatisplus.annotation.TableField; | 
				
			||||||
 | 
					import io.swagger.annotations.ApiModel; | 
				
			||||||
 | 
					import io.swagger.annotations.ApiModelProperty; | 
				
			||||||
 | 
					import lombok.Data; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/** | 
				
			||||||
 | 
					 * @Author: ypj | 
				
			||||||
 | 
					 * @Date: 2024/9/20 15:07 | 
				
			||||||
 | 
					 */ | 
				
			||||||
 | 
					@Data | 
				
			||||||
 | 
					@ApiModel(value = "知识库文件分片信息", description = "知识库文件分片信息") | 
				
			||||||
 | 
					public class KnowledgeData { | 
				
			||||||
 | 
					    @ApiModelProperty("文档ID") | 
				
			||||||
 | 
					    @TableField("DOC_ID") | 
				
			||||||
 | 
					    private Long docId; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @ApiModelProperty("文档问题") | 
				
			||||||
 | 
					    @TableField("DOC_QS") | 
				
			||||||
 | 
					    private String docQs; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @ApiModelProperty("文档内容") | 
				
			||||||
 | 
					    @TableField("DOC_CONTENT") | 
				
			||||||
 | 
					    private String docContent; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @ApiModelProperty("文档页码") | 
				
			||||||
 | 
					    @TableField("DOC_PAGE_INDEX") | 
				
			||||||
 | 
					    private Integer docPageIndex; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @ApiModelProperty("知识库领域") | 
				
			||||||
 | 
					    private String area; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @ApiModelProperty("等级") | 
				
			||||||
 | 
					    private Integer level; | 
				
			||||||
 | 
					} | 
				
			||||||
@ -1,11 +1,15 @@ | 
				
			|||||||
package com.hnac.gglm.bigmodel.maintenance.mapper; | 
					package com.hnac.gglm.bigmodel.maintenance.mapper; | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | 
					import com.baomidou.mybatisplus.core.mapper.BaseMapper; | 
				
			||||||
 | 
					import com.hnac.gglm.bigmodel.maintenance.dto.KnowledgeData; | 
				
			||||||
import com.hnac.gglm.bigmodel.maintenance.entity.KnowledgeFileFragment; | 
					import com.hnac.gglm.bigmodel.maintenance.entity.KnowledgeFileFragment; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.List; | 
				
			||||||
 | 
					
 | 
				
			||||||
/** | 
					/** | 
				
			||||||
 * @Author: ypj | 
					 * @Author: ypj | 
				
			||||||
 * @Date: 2024/9/11 10:49 | 
					 * @Date: 2024/9/11 10:49 | 
				
			||||||
 */ | 
					 */ | 
				
			||||||
public interface KnowledgeFileFragmentMapper extends BaseMapper<KnowledgeFileFragment> { | 
					public interface KnowledgeFileFragmentMapper extends BaseMapper<KnowledgeFileFragment> { | 
				
			||||||
 | 
					    List<KnowledgeData> listKnowledgeData(); | 
				
			||||||
} | 
					} | 
				
			||||||
 | 
				
			|||||||
@ -0,0 +1,19 @@ | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8"?> | 
				
			||||||
 | 
					<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | 
				
			||||||
 | 
					<mapper namespace="com.hnac.gglm.bigmodel.maintenance.mapper.KnowledgeFileFragmentMapper"> | 
				
			||||||
 | 
					  <resultMap id="BaseResultMap" type="com.hnac.gglm.bigmodel.maintenance.entity.KnowledgeFileFragment"> | 
				
			||||||
 | 
					  </resultMap> | 
				
			||||||
 | 
					   | 
				
			||||||
 | 
					  <select id="listKnowledgeData" resultType="com.hnac.gglm.bigmodel.maintenance.dto.KnowledgeData"> | 
				
			||||||
 | 
					    SELECT | 
				
			||||||
 | 
					      `segment`.DOC_CONTENT, | 
				
			||||||
 | 
					      `segment`.DOC_ID, | 
				
			||||||
 | 
					      `segment`.DOC_QS, | 
				
			||||||
 | 
					      `segment`.DOC_PAGE_INDEX, | 
				
			||||||
 | 
					      `info`.AUTHORITY_CLASS AS `level`, | 
				
			||||||
 | 
					      `info`.DOMAIN AS `area` | 
				
			||||||
 | 
					    FROM | 
				
			||||||
 | 
					      knowledge_file_segment AS `segment` | 
				
			||||||
 | 
					        LEFT JOIN knowledge_file_info `info` ON `segment`.DOC_ID = `info`.ID | 
				
			||||||
 | 
					  </select> | 
				
			||||||
 | 
					</mapper> | 
				
			||||||
					Loading…
					
					
				
		Reference in new issue