Commit 4f782e6c2424024bc1612a8b8dea187a3536a644
1 parent
bd3fdf6c
1111
Showing
2 changed files
with
5 additions
and
1 deletions
src/main/java/com/xly/agent/DynamicTableNl2SqlAiAgent.java
| ... | ... | @@ -38,6 +38,7 @@ public interface DynamicTableNl2SqlAiAgent { |
| 38 | 38 | 【业务场景表结构信息】 |
| 39 | 39 | 涉及表名:{{tableNames}}(多表用,分隔,需关联时请按规范使用JOIN) |
| 40 | 40 | 表结构详情:{{tableStruct}}(多表请标注表名+字段,格式:表名(字段1:类型,字段2:类型,主键/外键)) |
| 41 | + 当前时间:{{sDataNow}} | |
| 41 | 42 | 【用户需求】 |
| 42 | 43 | {{userInput}} |
| 43 | 44 | 请根据上述表结构+通用规则,生成符合要求的MySQL SELECT语句: |
| ... | ... | @@ -45,6 +46,7 @@ public interface DynamicTableNl2SqlAiAgent { |
| 45 | 46 | String generateMysqlSql(@MemoryId String userId, |
| 46 | 47 | @V("tableNames") String tableNames, |
| 47 | 48 | @V("tableStruct") String tableStruct, |
| 49 | + @V("sDataNow") String sDataNow, | |
| 48 | 50 | @V("userInput") String userInput); |
| 49 | 51 | |
| 50 | 52 | /** | ... | ... |
src/main/java/com/xly/service/XlyErpService.java
| 1 | 1 | package com.xly.service; |
| 2 | 2 | |
| 3 | +import cn.hutool.core.date.DateUtil; | |
| 3 | 4 | import cn.hutool.core.util.ObjectUtil; |
| 4 | 5 | import cn.hutool.core.util.StrUtil; |
| 5 | 6 | import cn.hutool.db.Session; |
| ... | ... | @@ -245,7 +246,8 @@ public class XlyErpService { |
| 245 | 246 | String tableNames = session.getCurrentTool().getSInputTabelName(); |
| 246 | 247 | // "订单表:viw_salsalesorder,客户信息表:elecustomer,结算方式表:sispayment,产品表(无单价,无金额,无数量):viw_product_sort,销售人员表:viw_sissalesman_depart"; |
| 247 | 248 | String tableStruct = session.getCurrentTool().getSStructureMemo(); |
| 248 | - String rawSql = aiDynamicTableNl2SqlAiAgent.generateMysqlSql(userId,tableNames,tableStruct,userInput); | |
| 249 | + String sDataNow = DateUtil.now(); | |
| 250 | + String rawSql = aiDynamicTableNl2SqlAiAgent.generateMysqlSql(userId,tableNames,tableStruct,sDataNow,userInput); | |
| 249 | 251 | if (rawSql == null || rawSql.trim().isEmpty()) { |
| 250 | 252 | throw new SqlGenerateException("AI服务生成SQL失败,返回结果为空"); |
| 251 | 253 | } | ... | ... |