作者 dong

Revert "知识库列表没有进行分页,问题库列表没有及进行分页处理,存入问题库增加重复校验,日志管理增加回答方式,是否存入问题库,五个需要已实现"

This reverts commit c3b74ccd.
正在显示 13 个修改的文件 包含 35 行增加212 行删除
@@ -12,11 +12,8 @@ import org.jeecg.common.api.vo.Result; @@ -12,11 +12,8 @@ import org.jeecg.common.api.vo.Result;
12 import org.jeecg.common.aspect.annotation.AutoLog; 12 import org.jeecg.common.aspect.annotation.AutoLog;
13 import org.jeecg.common.system.base.controller.JeecgController; 13 import org.jeecg.common.system.base.controller.JeecgController;
14 import org.jeecg.common.system.query.QueryGenerator; 14 import org.jeecg.common.system.query.QueryGenerator;
15 -import org.jeecg.modules.airag.app.config.DataSourceConfig;  
16 import org.jeecg.modules.airag.app.entity.AiragLog; 15 import org.jeecg.modules.airag.app.entity.AiragLog;
17 -import org.jeecg.modules.airag.app.entity.QuestionEmbedding;  
18 import org.jeecg.modules.airag.app.service.IAiragLogService; 16 import org.jeecg.modules.airag.app.service.IAiragLogService;
19 -import org.jeecg.modules.airag.app.service.IQuestionEmbeddingService;  
20 import org.jeecg.modules.airag.llm.entity.AiragKnowledge; 17 import org.jeecg.modules.airag.llm.entity.AiragKnowledge;
21 import org.jeecg.modules.airag.llm.entity.AiragModel; 18 import org.jeecg.modules.airag.llm.entity.AiragModel;
22 import org.jeecg.modules.airag.llm.service.IAiragModelService; 19 import org.jeecg.modules.airag.llm.service.IAiragModelService;
@@ -27,7 +24,10 @@ import org.springframework.web.servlet.ModelAndView; @@ -27,7 +24,10 @@ import org.springframework.web.servlet.ModelAndView;
27 import javax.servlet.http.HttpServletRequest; 24 import javax.servlet.http.HttpServletRequest;
28 import javax.servlet.http.HttpServletResponse; 25 import javax.servlet.http.HttpServletResponse;
29 import java.sql.SQLException; 26 import java.sql.SQLException;
30 -import java.util.*; 27 +import java.util.Arrays;
  28 +import java.util.HashMap;
  29 +import java.util.List;
  30 +import java.util.Map;
31 31
32 /** 32 /**
33 * @Description: 日志管理 33 * @Description: 日志管理
@@ -45,13 +45,7 @@ public class AiragLogController extends JeecgController<AiragLog, IAiragLogServi @@ -45,13 +45,7 @@ public class AiragLogController extends JeecgController<AiragLog, IAiragLogServi
45 45
46 @Autowired 46 @Autowired
47 private IAiragModelService airagModelService; 47 private IAiragModelService airagModelService;
48 - @Autowired  
49 - private DataSourceConfig dataSourceConfig;  
50 -  
51 - @Autowired  
52 - private IQuestionEmbeddingService questionEmbeddingService;  
53 -  
54 - /** 48 + /**
55 * 分页列表查询 49 * 分页列表查询
56 * 50 *
57 * @param airagLog 51 * @param airagLog
@@ -67,8 +61,6 @@ public class AiragLogController extends JeecgController<AiragLog, IAiragLogServi @@ -67,8 +61,6 @@ public class AiragLogController extends JeecgController<AiragLog, IAiragLogServi
67 @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, 61 @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
68 @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, 62 @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
69 HttpServletRequest req) { 63 HttpServletRequest req) {
70 -  
71 -  
72 QueryWrapper<AiragLog> queryWrapper = QueryGenerator.initQueryWrapper(airagLog, req.getParameterMap()); 64 QueryWrapper<AiragLog> queryWrapper = QueryGenerator.initQueryWrapper(airagLog, req.getParameterMap());
73 Page<AiragLog> page = new Page<AiragLog>(pageNo, pageSize); 65 Page<AiragLog> page = new Page<AiragLog>(pageNo, pageSize);
74 // IPage<AiragLog> pageList = airagLogService.page(page, queryWrapper); 66 // IPage<AiragLog> pageList = airagLogService.page(page, queryWrapper);
@@ -135,15 +127,6 @@ public class AiragLogController extends JeecgController<AiragLog, IAiragLogServi @@ -135,15 +127,6 @@ public class AiragLogController extends JeecgController<AiragLog, IAiragLogServi
135 @RequiresPermissions("airaglog:airag_log:saveToQuestionLibrary") 127 @RequiresPermissions("airaglog:airag_log:saveToQuestionLibrary")
136 @PostMapping(value = "/saveToQuestionLibrary") 128 @PostMapping(value = "/saveToQuestionLibrary")
137 public Result<String> saveToQuestionLibrary(@RequestBody AiragLog airagLog) { 129 public Result<String> saveToQuestionLibrary(@RequestBody AiragLog airagLog) {
138 - QuestionEmbedding questionEmbedding = new QuestionEmbedding();  
139 - questionEmbedding.setQuestion(airagLog.getQuestion());  
140 - List<QuestionEmbedding> list = questionEmbeddingService.findQuestion(questionEmbedding);  
141 - for (QuestionEmbedding questionEmbedding1 : list){  
142 - if(questionEmbedding1.getQuestion().equals(airagLog.getQuestion())){  
143 - return Result.error("问题库已有相同问题,不可存入");  
144 - }  
145 - }  
146 - airagLog.setIsStorage(1);  
147 airagLogService.saveToQuestionLibrary(airagLog); 130 airagLogService.saveToQuestionLibrary(airagLog);
148 return Result.OK("存入问题库成功!"); 131 return Result.OK("存入问题库成功!");
149 } 132 }
@@ -59,14 +59,19 @@ public class EmbeddingsController { @@ -59,14 +59,19 @@ public class EmbeddingsController {
59 //@AutoLog(value = "Embeddings-分页列表查询") 59 //@AutoLog(value = "Embeddings-分页列表查询")
60 @Operation(summary = "Embeddings-分页列表查询") 60 @Operation(summary = "Embeddings-分页列表查询")
61 @GetMapping(value = "/list") 61 @GetMapping(value = "/list")
62 - public Result<Page<Embeddings>> queryPageList(Embeddings embeddings, 62 + public Result<IPage<Embeddings>> queryPageList(Embeddings embeddings,
63 @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, 63 @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
64 @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, 64 @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
65 HttpServletRequest req) throws NoSuchFieldException, IllegalAccessException, SQLException { 65 HttpServletRequest req) throws NoSuchFieldException, IllegalAccessException, SQLException {
66 //Response<Embedding> embedding = aiModelUtils.getEmbedding("1925730210204721154", "33333"); 66 //Response<Embedding> embedding = aiModelUtils.getEmbedding("1925730210204721154", "33333");
67 67
68 - Page<Embeddings> records = embeddingsService.findAll(embeddings,pageNo,pageSize);  
69 - return Result.OK(records); 68 + List<Embeddings> records = embeddingsService.findAll(embeddings);
  69 + for (Embeddings record : records) {
  70 + System.out.println("record = " + record);
  71 + }
  72 + Page<Embeddings> page = new Page<Embeddings>(pageNo, pageSize);
  73 + page.setRecords(records);
  74 + return Result.OK(page);
70 } 75 }
71 /** 76 /**
72 * 查询知识库ID 77 * 查询知识库ID
1 package org.jeecg.modules.airag.app.controller; 1 package org.jeecg.modules.airag.app.controller;
2 2
3 -import com.baomidou.mybatisplus.extension.plugins.pagination.Page;  
4 import dev.langchain4j.internal.Json; 3 import dev.langchain4j.internal.Json;
5 import lombok.extern.slf4j.Slf4j; 4 import lombok.extern.slf4j.Slf4j;
6 import org.apache.commons.lang3.StringUtils; 5 import org.apache.commons.lang3.StringUtils;
7 import org.jeecg.common.api.vo.Result; 6 import org.jeecg.common.api.vo.Result;
  7 +import org.jeecg.modules.airag.app.entity.AiragLog;
8 import org.jeecg.modules.airag.app.entity.QuestionEmbedding; 8 import org.jeecg.modules.airag.app.entity.QuestionEmbedding;
9 import org.jeecg.modules.airag.app.service.IQuestionEmbeddingService; 9 import org.jeecg.modules.airag.app.service.IQuestionEmbeddingService;
10 import org.jeecg.modules.airag.app.utils.JsonUtils; 10 import org.jeecg.modules.airag.app.utils.JsonUtils;
11 import org.jeecg.modules.airag.llm.entity.AiragKnowledge; 11 import org.jeecg.modules.airag.llm.entity.AiragKnowledge;
  12 +import org.jeecg.modules.airag.llm.entity.AiragModel;
12 import org.jeecg.modules.airag.llm.service.IAiragKnowledgeService; 13 import org.jeecg.modules.airag.llm.service.IAiragKnowledgeService;
13 import org.springframework.beans.factory.annotation.Autowired; 14 import org.springframework.beans.factory.annotation.Autowired;
14 import org.springframework.transaction.annotation.Transactional; 15 import org.springframework.transaction.annotation.Transactional;
@@ -16,6 +17,7 @@ import org.springframework.web.bind.annotation.*; @@ -16,6 +17,7 @@ import org.springframework.web.bind.annotation.*;
16 import org.springframework.web.multipart.MultipartFile; 17 import org.springframework.web.multipart.MultipartFile;
17 18
18 import java.util.HashMap; 19 import java.util.HashMap;
  20 +import java.util.List;
19 import java.util.Map; 21 import java.util.Map;
20 import java.util.stream.Collectors; 22 import java.util.stream.Collectors;
21 23
@@ -29,13 +31,13 @@ public class QuestionEmbeddingController { @@ -29,13 +31,13 @@ public class QuestionEmbeddingController {
29 private IAiragKnowledgeService airagKnowledgeService; 31 private IAiragKnowledgeService airagKnowledgeService;
30 32
31 @GetMapping("/list") 33 @GetMapping("/list")
32 - public Result<Page<QuestionEmbedding>> findAll(QuestionEmbedding questionEmbedding, @RequestParam(defaultValue = "1") int pageNo, @RequestParam(defaultValue = "10") int pageSize) {  
33 - Page<QuestionEmbedding> page = questionEmbeddingService.findAll(questionEmbedding,pageNo,pageSize); 34 + public Result<List<QuestionEmbedding>> findAll(QuestionEmbedding questionEmbedding) {
  35 + List<QuestionEmbedding> list = questionEmbeddingService.findAll(questionEmbedding);
34 Map<String, String> airagKnowledgeMap = airagKnowledgeService.list() 36 Map<String, String> airagKnowledgeMap = airagKnowledgeService.list()
35 .stream() 37 .stream()
36 .collect(Collectors.toMap(AiragKnowledge::getId, AiragKnowledge::getName)); 38 .collect(Collectors.toMap(AiragKnowledge::getId, AiragKnowledge::getName));
37 39
38 - page.getRecords().forEach(item -> { 40 + list.forEach(item -> {
39 String metadata = item.getMetadata(); 41 String metadata = item.getMetadata();
40 if (StringUtils.isNotBlank(metadata)) { 42 if (StringUtils.isNotBlank(metadata)) {
41 Map<String, String> jsonMap = JsonUtils.jsonUtils(metadata); 43 Map<String, String> jsonMap = JsonUtils.jsonUtils(metadata);
@@ -46,7 +48,8 @@ public class QuestionEmbeddingController { @@ -46,7 +48,8 @@ public class QuestionEmbeddingController {
46 } 48 }
47 49
48 }); 50 });
49 - return Result.OK(page); 51 +
  52 + return Result.OK(list);
50 } 53 }
51 54
52 @GetMapping("/queryById") 55 @GetMapping("/queryById")
@@ -77,32 +77,8 @@ public class AiragLog implements Serializable { @@ -77,32 +77,8 @@ public class AiragLog implements Serializable {
77 @Excel(name = "模型ID", width = 15) 77 @Excel(name = "模型ID", width = 15)
78 @Schema(description = "模型ID") 78 @Schema(description = "模型ID")
79 private String modelId; 79 private String modelId;
80 - /**  
81 - * 回答方式  
82 - */  
83 - @Excel(name = "回答方式", width = 15)  
84 - @TableField("answer_type")  
85 - @Schema(description = "回答方式:1:问题库回答 2:模型回答 3:未命中")  
86 - private int answerType;  
87 - /**  
88 - * 回答方式  
89 - */  
90 - @Excel(name = "是否存入问题库", width = 15)  
91 - @TableField("is_storage")  
92 - @Schema(description = "是否存入问题库 0:否 1:是")  
93 - private int isStorage;  
94 80
95 // 新增:临时字段(非数据库字段) 81 // 新增:临时字段(非数据库字段)
96 @TableField(exist = false) // MyBatis-Plus 标记该字段不存在于数据库表中 82 @TableField(exist = false) // MyBatis-Plus 标记该字段不存在于数据库表中
97 private String name; 83 private String name;
98 -  
99 - // 新增:临时字段(非数据库字段)  
100 - @TableField(exist = false) // MyBatis-Plus 标记该字段不存在于数据库表中  
101 - private String createTime_begin;  
102 - // 新增:临时字段(非数据库字段)  
103 - @TableField(exist = false) // MyBatis-Plus 标记该字段不存在于数据库表中  
104 - private String createTime_end;  
105 -  
106 - @TableField(exist = false) // MyBatis-Plus 标记该字段不存在于数据库表中  
107 - private String createTimeStr;  
108 } 84 }
@@ -18,7 +18,4 @@ public interface AiragLogMapper extends BaseMapper<AiragLog> { @@ -18,7 +18,4 @@ public interface AiragLogMapper extends BaseMapper<AiragLog> {
18 IPage<AiragLog> list1(@Param("param1")AiragLog airagLog, Page<AiragLog> page); 18 IPage<AiragLog> list1(@Param("param1")AiragLog airagLog, Page<AiragLog> page);
19 19
20 IPage<AiragLog> pageList(@Param("param1") AiragLog airagLog, Page<AiragLog> page); 20 IPage<AiragLog> pageList(@Param("param1") AiragLog airagLog, Page<AiragLog> page);
21 -  
22 - int updataIsStorage(@Param("param1") int isStorage);  
23 -  
24 } 21 }
@@ -3,7 +3,6 @@ package org.jeecg.modules.airag.app.mapper; @@ -3,7 +3,6 @@ package org.jeecg.modules.airag.app.mapper;
3 import ch.qos.logback.core.net.SyslogOutputStream; 3 import ch.qos.logback.core.net.SyslogOutputStream;
4 import cn.hutool.core.lang.generator.SnowflakeGenerator; 4 import cn.hutool.core.lang.generator.SnowflakeGenerator;
5 import com.alibaba.fastjson2.JSONObject; 5 import com.alibaba.fastjson2.JSONObject;
6 -import com.baomidou.mybatisplus.extension.plugins.pagination.Page;  
7 import com.fasterxml.jackson.core.JsonProcessingException; 6 import com.fasterxml.jackson.core.JsonProcessingException;
8 import com.fasterxml.jackson.core.type.TypeReference; 7 import com.fasterxml.jackson.core.type.TypeReference;
9 import com.fasterxml.jackson.databind.ObjectMapper; 8 import com.fasterxml.jackson.databind.ObjectMapper;
@@ -32,32 +31,22 @@ public class PgVectorMapper { @@ -32,32 +31,22 @@ public class PgVectorMapper {
32 } 31 }
33 32
34 // 查询所有向量记录 33 // 查询所有向量记录
35 - public Page<Embeddings> findAll(Embeddings embeddings,int pageNo,int pageSize) { 34 + public List<Embeddings> findAll(Embeddings embeddings) {
36 List<Embeddings> results = new ArrayList<>(); 35 List<Embeddings> results = new ArrayList<>();
37 StringBuilder sql = new StringBuilder("SELECT * FROM embeddings WHERE 1=1"); 36 StringBuilder sql = new StringBuilder("SELECT * FROM embeddings WHERE 1=1");
38 - StringBuilder countSql = new StringBuilder("SELECT COUNT(1) FROM embeddings WHERE 1=1");  
39 List<Object> params = new ArrayList<>(); // 存储参数值 37 List<Object> params = new ArrayList<>(); // 存储参数值
40 - List<Object> countParams = new ArrayList<>(); // 存储参数值  
41 38
42 // 动态构建查询条件 39 // 动态构建查询条件
43 if (StringUtils.isNotBlank(embeddings.getKnowledgeId())) { 40 if (StringUtils.isNotBlank(embeddings.getKnowledgeId())) {
44 sql.append(" AND metadata ->> 'knowledgeId' = ?"); 41 sql.append(" AND metadata ->> 'knowledgeId' = ?");
45 - countSql.append(" AND metadata ->> 'knowledgeId' = ?");  
46 params.add(embeddings.getKnowledgeId()); 42 params.add(embeddings.getKnowledgeId());
47 - countParams.add(embeddings.getKnowledgeId());  
48 } 43 }
49 44
50 if (StringUtils.isNotBlank(embeddings.getText())) { 45 if (StringUtils.isNotBlank(embeddings.getText())) {
51 sql.append(" AND text ILIKE ?"); // 使用 ILIKE 进行不区分大小写的模糊匹配 46 sql.append(" AND text ILIKE ?"); // 使用 ILIKE 进行不区分大小写的模糊匹配
52 - countSql.append(" AND text ILIKE ?"); // 使用 ILIKE 进行不区分大小写的模糊匹配  
53 params.add("%" + embeddings.getText() + "%"); 47 params.add("%" + embeddings.getText() + "%");
54 - countParams.add("%" + embeddings.getText() + "%");  
55 } 48 }
56 49
57 - // 添加分页  
58 - sql.append(" LIMIT ? OFFSET ?");  
59 - params.add(pageSize);  
60 - params.add((pageNo - 1) * pageSize);  
61 50
62 System.out.println("SQL: " + sql.toString()); 51 System.out.println("SQL: " + sql.toString());
63 52
@@ -78,31 +67,7 @@ public class PgVectorMapper { @@ -78,31 +67,7 @@ public class PgVectorMapper {
78 log.error("查询所有向量记录失败", e); 67 log.error("查询所有向量记录失败", e);
79 throw new RuntimeException("查询向量数据时发生数据库错误", e); 68 throw new RuntimeException("查询向量数据时发生数据库错误", e);
80 } 69 }
81 -  
82 -  
83 - // 执行计数查询  
84 - int total = 0;  
85 - try(Connection conn = getConnection();  
86 - PreparedStatement stmt = conn.prepareStatement(countSql.toString())){  
87 - // 设置参数值  
88 - for (int i = 0; i < countParams.size(); i++) {  
89 - stmt.setObject(i + 1, countParams.get(i));  
90 - }  
91 -  
92 - try (ResultSet rs = stmt.executeQuery()) {  
93 - if (rs.next()) {  
94 - total = rs.getInt(1); // 直接获取count值  
95 - }  
96 - }  
97 - } catch (SQLException e) {  
98 - log.error("查询记录总数失败", e);  
99 - throw new RuntimeException("查询记录总数时发生数据库错误", e);  
100 - }  
101 -  
102 - Page<Embeddings> page = new Page<>();  
103 - page.setRecords(results);  
104 - page.setTotal(total);  
105 - return page; 70 + return results;
106 } 71 }
107 72
108 // 根据ID查询单个向量记录 73 // 根据ID查询单个向量记录
@@ -2,7 +2,6 @@ package org.jeecg.modules.airag.app.mapper; @@ -2,7 +2,6 @@ package org.jeecg.modules.airag.app.mapper;
2 2
3 import cn.hutool.core.lang.generator.SnowflakeGenerator; 3 import cn.hutool.core.lang.generator.SnowflakeGenerator;
4 import com.alibaba.fastjson2.JSONObject; 4 import com.alibaba.fastjson2.JSONObject;
5 -import com.baomidou.mybatisplus.extension.plugins.pagination.Page;  
6 import com.fasterxml.jackson.core.JsonProcessingException; 5 import com.fasterxml.jackson.core.JsonProcessingException;
7 import com.fasterxml.jackson.core.type.TypeReference; 6 import com.fasterxml.jackson.core.type.TypeReference;
8 import com.fasterxml.jackson.databind.ObjectMapper; 7 import com.fasterxml.jackson.databind.ObjectMapper;
@@ -39,93 +38,22 @@ public class QuestionEmbeddingMapper { @@ -39,93 +38,22 @@ public class QuestionEmbeddingMapper {
39 } 38 }
40 39
41 // 查询所有记录 40 // 查询所有记录
42 - public Page<QuestionEmbedding> findAll(QuestionEmbedding questionEmbedding, int pageNo, int pageSize) { 41 + public List<QuestionEmbedding> findAll(QuestionEmbedding questionEmbedding) {
43 List<QuestionEmbedding> results = new ArrayList<>(); 42 List<QuestionEmbedding> results = new ArrayList<>();
44 StringBuilder sql = new StringBuilder("select * from question_embedding where 1 = 1"); 43 StringBuilder sql = new StringBuilder("select * from question_embedding where 1 = 1");
45 - StringBuilder countSql = new StringBuilder("select count(1) from question_embedding where 1 = 1");  
46 List<Object> params = new ArrayList<>(); 44 List<Object> params = new ArrayList<>();
47 - List<Object> countParams = new ArrayList<>();  
48 45
49 if (StringUtils.isNotBlank(questionEmbedding.getKnowledgeId())) { 46 if (StringUtils.isNotBlank(questionEmbedding.getKnowledgeId())) {
50 sql.append(" AND metadata ->> 'knowledgeId' = ?"); 47 sql.append(" AND metadata ->> 'knowledgeId' = ?");
51 - countSql.append(" AND metadata ->> 'knowledgeId' = ?");  
52 params.add(questionEmbedding.getKnowledgeId()); 48 params.add(questionEmbedding.getKnowledgeId());
53 - countParams.add(questionEmbedding.getKnowledgeId());  
54 } 49 }
55 if(StringUtils.isNotBlank(questionEmbedding.getQuestion())){ 50 if(StringUtils.isNotBlank(questionEmbedding.getQuestion())){
56 - sql.append(" AND question ILIKE ?"); // 使用 ILIKE 进行不区分大小写的模糊匹配  
57 - countSql.append(" AND question ILIKE ?"); // 使用 ILIKE 进行不区分大小写的模糊匹配  
58 - params.add("%" + questionEmbedding.getQuestion() + "%");  
59 - countParams.add("%" + questionEmbedding.getQuestion() + "%"); 51 + sql.append(" and question like '%").append(questionEmbedding.getQuestion()).append("%'");
60 } 52 }
61 53
62 if(StringUtils.isNotBlank(questionEmbedding.getAnswer())){ 54 if(StringUtils.isNotBlank(questionEmbedding.getAnswer())){
63 - sql.append(" AND answer ILIKE ?"); // 使用 ILIKE 进行不区分大小写的模糊匹配  
64 - countSql.append(" AND answer ILIKE ?"); // 使用 ILIKE 进行不区分大小写的模糊匹配  
65 - params.add("%" + questionEmbedding.getAnswer() + "%");  
66 - countParams.add("%" + questionEmbedding.getAnswer() + "%"); 55 + sql.append(" and answer like '%").append(questionEmbedding.getAnswer()).append("%'");
67 } 56 }
68 -  
69 - // 添加分页  
70 - sql.append(" LIMIT ? OFFSET ?");  
71 - params.add(pageSize);  
72 - params.add((pageNo - 1) * pageSize);  
73 -  
74 -  
75 - try(Connection conn = getConnection();  
76 - PreparedStatement stmt = conn.prepareStatement(sql.toString())){  
77 - // 设置参数值  
78 - for (int i = 0; i < params.size(); i++) {  
79 - stmt.setObject(i + 1, params.get(i));  
80 - }  
81 -  
82 - try (ResultSet rs = stmt.executeQuery()) {  
83 - while (rs.next()) {  
84 - results.add(mapRowToQuestionEmbedding(rs));  
85 - }  
86 - }  
87 - } catch (SQLException e) {  
88 - log.error("查询所有记录失败", e);  
89 - throw new RuntimeException("查询数据时发生数据库错误", e);  
90 - }  
91 -  
92 - // 执行计数查询  
93 - long total = 0;  
94 - try(Connection conn = getConnection();  
95 - PreparedStatement stmt = conn.prepareStatement(countSql.toString())){  
96 - // 设置参数值  
97 - for (int i = 0; i < countParams.size(); i++) {  
98 - stmt.setObject(i + 1, countParams.get(i));  
99 - }  
100 -  
101 - try (ResultSet rs = stmt.executeQuery()) {  
102 - if (rs.next()) {  
103 - total = rs.getLong(1); // 直接获取count值  
104 - }  
105 - }  
106 - } catch (SQLException e) {  
107 - log.error("查询记录总数失败", e);  
108 - throw new RuntimeException("查询记录总数时发生数据库错误", e);  
109 - }  
110 -  
111 - Page<QuestionEmbedding> page = new Page<>();  
112 - page.setRecords(results);  
113 - page.setTotal(total);  
114 - return page;  
115 - }  
116 -  
117 - // 查询所有记录  
118 - public List<QuestionEmbedding> findQuestion(QuestionEmbedding questionEmbedding) {  
119 - List<QuestionEmbedding> results = new ArrayList<>();  
120 - StringBuilder sql = new StringBuilder("select * from question_embedding where 1 = 1");  
121 - List<Object> params = new ArrayList<>();  
122 -  
123 - if(StringUtils.isNotBlank(questionEmbedding.getQuestion())){  
124 - sql.append(" AND question = ?"); // 使用 ILIKE 进行不区分大小写的模糊匹配  
125 - params.add(questionEmbedding.getQuestion());  
126 - }  
127 -  
128 -  
129 try(Connection conn = getConnection(); 57 try(Connection conn = getConnection();
130 PreparedStatement stmt = conn.prepareStatement(sql.toString())){ 58 PreparedStatement stmt = conn.prepareStatement(sql.toString())){
131 // 设置参数值 59 // 设置参数值
@@ -142,8 +70,6 @@ public class QuestionEmbeddingMapper { @@ -142,8 +70,6 @@ public class QuestionEmbeddingMapper {
142 log.error("查询所有记录失败", e); 70 log.error("查询所有记录失败", e);
143 throw new RuntimeException("查询数据时发生数据库错误", e); 71 throw new RuntimeException("查询数据时发生数据库错误", e);
144 } 72 }
145 -  
146 -  
147 return results; 73 return results;
148 } 74 }
149 75
@@ -9,35 +9,13 @@ @@ -9,35 +9,13 @@
9 </select> 9 </select>
10 10
11 <select id="pageList" resultType="org.jeecg.modules.airag.app.entity.AiragLog"> 11 <select id="pageList" resultType="org.jeecg.modules.airag.app.entity.AiragLog">
12 - select  
13 - id, create_by, create_time,  
14 - update_by, update_time, question,  
15 - answer, model_id, answer_type, is_storage  
16 - from airag_log 12 + select * from airag_log
17 where 1=1 13 where 1=1
18 - <if test="param1.isStorage != null and param1.isStorage != -1">  
19 - and is_storage = #{param1.isStorage}  
20 - </if>  
21 <if test="param1.name != '' and param1.name != null"> 14 <if test="param1.name != '' and param1.name != null">
22 and model_id = #{param1.name} 15 and model_id = #{param1.name}
23 </if> 16 </if>
24 <if test="param1.question != '' and param1.question != null"> 17 <if test="param1.question != '' and param1.question != null">
25 and question LIKE CONCAT('%', #{param1.question}, '%') 18 and question LIKE CONCAT('%', #{param1.question}, '%')
26 </if> 19 </if>
27 - <if test="param1.answerType != '' and param1.answerType != null">  
28 - and answer_type = #{param1.answerType}  
29 - </if>  
30 - <if test="param1.createTime_begin != '' and param1.createTime_begin != null and param1.createTime_end != null and param1.createTime_end != null">  
31 - and create_time between #{param1.createTime_begin} and #{param1.createTime_end}  
32 - </if>  
33 -  
34 -  
35 -  
36 -  
37 </select> 20 </select>
38 -  
39 - <update id="updataIsStorage">  
40 - update airag_log  
41 - set is_storage = #{isStorage}  
42 - </update>  
43 </mapper> 21 </mapper>
@@ -2,7 +2,6 @@ package org.jeecg.modules.airag.app.service; @@ -2,7 +2,6 @@ package org.jeecg.modules.airag.app.service;
2 2
3 //import org.jeecg.modules.demo.test.entity.Test; 3 //import org.jeecg.modules.demo.test.entity.Test;
4 4
5 -import com.baomidou.mybatisplus.extension.plugins.pagination.Page;  
6 import org.jeecg.modules.airag.app.entity.Embeddings; 5 import org.jeecg.modules.airag.app.entity.Embeddings;
7 6
8 import java.util.List; 7 import java.util.List;
@@ -15,7 +14,7 @@ import java.util.List; @@ -15,7 +14,7 @@ import java.util.List;
15 */ 14 */
16 public interface IEmbeddingsService { 15 public interface IEmbeddingsService {
17 16
18 - Page<Embeddings> findAll(Embeddings embeddings,int pageNo,int pageSize); 17 + List<Embeddings> findAll(Embeddings embeddings);
19 int deleteById(String id); 18 int deleteById(String id);
20 int insert(Embeddings record); 19 int insert(Embeddings record);
21 int update(Embeddings record); 20 int update(Embeddings record);
1 package org.jeecg.modules.airag.app.service; 1 package org.jeecg.modules.airag.app.service;
2 2
3 -import com.baomidou.mybatisplus.extension.plugins.pagination.Page;  
4 import org.jeecg.common.api.vo.Result; 3 import org.jeecg.common.api.vo.Result;
5 import org.jeecg.modules.airag.app.entity.QuestionEmbedding; 4 import org.jeecg.modules.airag.app.entity.QuestionEmbedding;
6 import org.springframework.web.multipart.MultipartFile; 5 import org.springframework.web.multipart.MultipartFile;
@@ -8,8 +7,7 @@ import org.springframework.web.multipart.MultipartFile; @@ -8,8 +7,7 @@ import org.springframework.web.multipart.MultipartFile;
8 import java.util.List; 7 import java.util.List;
9 8
10 public interface IQuestionEmbeddingService { 9 public interface IQuestionEmbeddingService {
11 - Page<QuestionEmbedding> findAll(QuestionEmbedding questionEmbedding, Integer pageNo, Integer pageSize);  
12 - List<QuestionEmbedding> findQuestion(QuestionEmbedding questionEmbedding); 10 + List<QuestionEmbedding> findAll(QuestionEmbedding questionEmbedding);
13 QuestionEmbedding findById(String id); 11 QuestionEmbedding findById(String id);
14 int insert(QuestionEmbedding record); 12 int insert(QuestionEmbedding record);
15 int update(QuestionEmbedding record); 13 int update(QuestionEmbedding record);
@@ -56,9 +56,9 @@ public class AiragLogServiceImpl extends ServiceImpl<AiragLogMapper, AiragLog> i @@ -56,9 +56,9 @@ public class AiragLogServiceImpl extends ServiceImpl<AiragLogMapper, AiragLog> i
56 QuestionEmbedding questionEmbedding = new QuestionEmbedding(); 56 QuestionEmbedding questionEmbedding = new QuestionEmbedding();
57 questionEmbedding.setQuestion(log.getQuestion()); 57 questionEmbedding.setQuestion(log.getQuestion());
58 questionEmbedding.setAnswer(log.getAnswer()); 58 questionEmbedding.setAnswer(log.getAnswer());
59 - questionEmbeddingMapper.insert(questionEmbedding);  
60 - airagLogMapper.updataIsStorage(log.getIsStorage());  
61 59
  60 +
  61 + questionEmbeddingMapper.insert(questionEmbedding);
62 } 62 }
63 63
64 @Override 64 @Override
1 package org.jeecg.modules.airag.app.service.impl; 1 package org.jeecg.modules.airag.app.service.impl;
2 2
3 -import com.baomidou.mybatisplus.extension.plugins.pagination.Page;  
4 import org.jeecg.modules.airag.app.entity.Embeddings; 3 import org.jeecg.modules.airag.app.entity.Embeddings;
5 import org.jeecg.modules.airag.app.mapper.PgVectorMapper; 4 import org.jeecg.modules.airag.app.mapper.PgVectorMapper;
6 import org.jeecg.modules.airag.app.service.IEmbeddingsService; 5 import org.jeecg.modules.airag.app.service.IEmbeddingsService;
@@ -21,8 +20,8 @@ public class IEmbeddingsServiceImpl implements IEmbeddingsService { @@ -21,8 +20,8 @@ public class IEmbeddingsServiceImpl implements IEmbeddingsService {
21 private PgVectorMapper pgVectorMapper; 20 private PgVectorMapper pgVectorMapper;
22 21
23 @Override 22 @Override
24 - public Page<Embeddings> findAll(Embeddings embeddings, int pageNo, int pageSize) {  
25 - return pgVectorMapper.findAll(embeddings,pageNo,pageSize); 23 + public List<Embeddings> findAll(Embeddings embeddings) {
  24 + return pgVectorMapper.findAll(embeddings);
26 } 25 }
27 26
28 public int deleteById(String id) { 27 public int deleteById(String id) {
1 package org.jeecg.modules.airag.app.service.impl; 1 package org.jeecg.modules.airag.app.service.impl;
2 2
3 -import com.baomidou.mybatisplus.extension.plugins.pagination.Page;  
4 import org.apache.poi.hwpf.usermodel.CharacterRun; 3 import org.apache.poi.hwpf.usermodel.CharacterRun;
5 import org.apache.poi.hwpf.HWPFDocument; 4 import org.apache.poi.hwpf.HWPFDocument;
6 import org.apache.poi.hwpf.usermodel.Paragraph; 5 import org.apache.poi.hwpf.usermodel.Paragraph;
@@ -65,13 +64,8 @@ public class QuestionEmbeddingServiceImpl implements IQuestionEmbeddingService { @@ -65,13 +64,8 @@ public class QuestionEmbeddingServiceImpl implements IQuestionEmbeddingService {
65 private static final Pattern UUID_PATTERN = Pattern.compile("_[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"); 64 private static final Pattern UUID_PATTERN = Pattern.compile("_[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}");
66 65
67 @Override 66 @Override
68 - public Page<QuestionEmbedding> findAll(QuestionEmbedding questionEmbedding, Integer pageNo, Integer pageSize) {  
69 - return questionEmbeddingMapper.findAll(questionEmbedding,pageNo,pageSize);  
70 - }  
71 -  
72 - @Override  
73 - public List<QuestionEmbedding> findQuestion(QuestionEmbedding questionEmbedding) {  
74 - return questionEmbeddingMapper.findQuestion(questionEmbedding); 67 + public List<QuestionEmbedding> findAll(QuestionEmbedding questionEmbedding) {
  68 + return questionEmbeddingMapper.findAll(questionEmbedding);
75 } 69 }
76 70
77 @Override 71 @Override