Browse Source

add:知识库问题数据接口

zhongwei
luyie 2 months ago
parent
commit
239e81a812
  1. 12
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/controller/VectorDataController.java
  2. 13
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/service/KnowledgeDataService.java
  3. 49
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/service/impl/KnowledgeDataServiceImpl.java
  4. 36
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/dto/KnowledgeData.java
  5. 4
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/mapper/KnowledgeFileFragmentMapper.java
  6. 19
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/mapper/KnowledgeFileFragmentMapper.xml

12
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/controller/VectorDataController.java

@ -1,8 +1,10 @@
package com.hnac.gglm.bigmodel.business.controller;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.gglm.bigmodel.business.service.KnowledgeDataService;
import com.hnac.gglm.bigmodel.business.service.VectorDataService;
import com.hnac.gglm.bigmodel.business.vo.DeviceModelData;
import com.hnac.gglm.bigmodel.maintenance.dto.KnowledgeData;
import com.hnac.hzinfo.api.annotation.ApiInterface;
import com.hnac.hzinfo.sdk.v5.device.dto.DeviceAttrInfoDTO;
import com.hnac.hzinfo.sdk.v5.model.vo.ModelAttrVO;
@ -31,7 +33,7 @@ import java.util.List;
public class VectorDataController {
private final VectorDataService vectorDataService;
private final KnowledgeDataService knowledgeDataService;
@GetMapping("/getModelAttributeData")
@ApiOperation(value = "获取模型属性数据")
@ -73,4 +75,12 @@ public class VectorDataController {
public R<List<DeviceAttrInfoDTO>> getDeviceAttr( ) {
return R.data(vectorDataService.getDeviceAttr());
}
@GetMapping("/listKnowledgeData")
@ApiOperation(value = "获取知识库数据")
@ApiOperationSupport(order = 5)
@ApiInterface
public R<List<KnowledgeData>> listKnowledgeData() {
return R.data(knowledgeDataService.listKnowledgeData());
}
}

13
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/service/KnowledgeDataService.java

@ -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();
}

49
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/service/impl/KnowledgeDataServiceImpl.java

@ -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;
}
}

36
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/dto/KnowledgeData.java

@ -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;
}

4
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/mapper/KnowledgeFileFragmentMapper.java

@ -1,11 +1,15 @@
package com.hnac.gglm.bigmodel.maintenance.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hnac.gglm.bigmodel.maintenance.dto.KnowledgeData;
import com.hnac.gglm.bigmodel.maintenance.entity.KnowledgeFileFragment;
import java.util.List;
/**
* @Author: ypj
* @Date: 2024/9/11 10:49
*/
public interface KnowledgeFileFragmentMapper extends BaseMapper<KnowledgeFileFragment> {
List<KnowledgeData> listKnowledgeData();
}

19
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/mapper/KnowledgeFileFragmentMapper.xml

@ -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…
Cancel
Save