Commit 57dbbfae0af89b9a986e857e0eb677909b92a51b
1 parent
d9066087
添加向量库
Showing
3 changed files
with
17 additions
and
17 deletions
src/main/java/com/xly/service/XlyErpService.java
| @@ -684,17 +684,17 @@ public class XlyErpService { | @@ -684,17 +684,17 @@ public class XlyErpService { | ||
| 684 | } | 684 | } |
| 685 | //采用表格形式显示明细、...详情、...记录、...列表、...清单 | 685 | //采用表格形式显示明细、...详情、...记录、...列表、...清单 |
| 686 | String resultExplain = StrUtil.EMPTY; | 686 | String resultExplain = StrUtil.EMPTY; |
| 687 | - if(retrunMarkdownType(userInput) ){ | ||
| 688 | - List<Map<String, String>> titles = getMarkdownTableTitleWithSql(sqlResult); | ||
| 689 | - resultExplain = buildMarkdownTableWithStream(sqlResult, titles); | ||
| 690 | - }else { | ||
| 691 | - resultExplain = aiAgent.explainSqlResult( | ||
| 692 | - userId, | ||
| 693 | - userInput, | ||
| 694 | - cleanSql, | ||
| 695 | - tableStruct, | ||
| 696 | - resultJson); | ||
| 697 | - } | 687 | +// if(retrunMarkdownType(userInput) ){ |
| 688 | +// List<Map<String, String>> titles = getMarkdownTableTitleWithSql(sqlResult); | ||
| 689 | +// resultExplain = buildMarkdownTableWithStream(sqlResult, titles); | ||
| 690 | +// }else { | ||
| 691 | + resultExplain = aiAgent.explainSqlResult( | ||
| 692 | + userId, | ||
| 693 | + userInput, | ||
| 694 | + cleanSql, | ||
| 695 | + tableStruct, | ||
| 696 | + resultJson); | ||
| 697 | +// } | ||
| 698 | return resultExplain; | 698 | return resultExplain; |
| 699 | } | 699 | } |
| 700 | 700 |
src/main/java/com/xly/thread/AiUserAgentQuestionThread.java
| @@ -55,7 +55,7 @@ public class AiUserAgentQuestionThread implements Runnable { | @@ -55,7 +55,7 @@ public class AiUserAgentQuestionThread implements Runnable { | ||
| 55 | String sKey = sSceneId+"_"+sMethodId +"_"+sQuestion; | 55 | String sKey = sSceneId+"_"+sMethodId +"_"+sQuestion; |
| 56 | // SqlValidateUtil.getsKey( sSceneId, sMethodId, SqlValidateUtil.getsQuestion(session.getSUserQuestionList())); | 56 | // SqlValidateUtil.getsKey( sSceneId, sMethodId, SqlValidateUtil.getsQuestion(session.getSUserQuestionList())); |
| 57 | //存入向量库 不包含where 条件 | 57 | //存入向量库 不包含where 条件 |
| 58 | - if(!SqlWhereHelper.hasWhereCondition(sSqlContent)){ | 58 | + if(!SqlWhereHelper.hasWhereButNoCompareOperators(sSqlContent)){ |
| 59 | aiGlobalAgentQuestionSqlEmitterService.addAiGlobalAgentQuestionSqlEmitter(sKey,data,sQuestion,sSqlContent,cachType,"ai_global_agent_question_sql"); | 59 | aiGlobalAgentQuestionSqlEmitterService.addAiGlobalAgentQuestionSqlEmitter(sKey,data,sQuestion,sSqlContent,cachType,"ai_global_agent_question_sql"); |
| 60 | } | 60 | } |
| 61 | //调用数据库插入数据库 | 61 | //调用数据库插入数据库 |
src/main/java/com/xly/util/SqlWhereHelper.java
| @@ -23,7 +23,7 @@ public class SqlWhereHelper { | @@ -23,7 +23,7 @@ public class SqlWhereHelper { | ||
| 23 | Statement statement = CCJSqlParserUtil.parse(sql); | 23 | Statement statement = CCJSqlParserUtil.parse(sql); |
| 24 | if (statement instanceof Select) { | 24 | if (statement instanceof Select) { |
| 25 | Select select = (Select) statement; | 25 | Select select = (Select) statement; |
| 26 | - return select.getPlainSelect() != null && select.getPlainSelect().getWhere() != null; | 26 | + return(select.getPlainSelect() != null && select.getPlainSelect().getWhere() != null); |
| 27 | } | 27 | } |
| 28 | if (statement instanceof Update) { | 28 | if (statement instanceof Update) { |
| 29 | Update update = (Update) statement; | 29 | Update update = (Update) statement; |
| @@ -72,18 +72,18 @@ public class SqlWhereHelper { | @@ -72,18 +72,18 @@ public class SqlWhereHelper { | ||
| 72 | 72 | ||
| 73 | // 禁止出现的条件符号/关键字 | 73 | // 禁止出现的条件符号/关键字 |
| 74 | boolean hasEq = upper.contains("="); | 74 | boolean hasEq = upper.contains("="); |
| 75 | - boolean hasGt = upper.contains(">"); | ||
| 76 | - boolean hasLt = upper.contains("<"); | 75 | + boolean hasGt = upper.contains(">") && !upper.contains("<>"); |
| 76 | + boolean hasLt = upper.contains("<") && !upper.contains("<>"); | ||
| 77 | boolean hasIn = upper.contains(" IN "); | 77 | boolean hasIn = upper.contains(" IN "); |
| 78 | boolean hasExists = upper.contains(" EXISTS "); | 78 | boolean hasExists = upper.contains(" EXISTS "); |
| 79 | 79 | ||
| 80 | // 只要有任何一个,就返回 false | 80 | // 只要有任何一个,就返回 false |
| 81 | if (hasEq || hasGt || hasLt || hasIn || hasExists) { | 81 | if (hasEq || hasGt || hasLt || hasIn || hasExists) { |
| 82 | - return false; | 82 | + return true; |
| 83 | } | 83 | } |
| 84 | 84 | ||
| 85 | // 有 WHERE 且 无等值/区间/大小/IN/EXISTS → 返回 true | 85 | // 有 WHERE 且 无等值/区间/大小/IN/EXISTS → 返回 true |
| 86 | - return true; | 86 | + return false; |
| 87 | } | 87 | } |
| 88 | 88 | ||
| 89 | // ===================== 你原来的方法不动 ===================== | 89 | // ===================== 你原来的方法不动 ===================== |