Commit cff9d5c5d0cb4d07bee3befdb73bfdf9eaa6cf03
1 parent
59ca8561
添加向量库
Showing
2 changed files
with
21 additions
and
6 deletions
src/main/java/com/xly/milvus/config/MilvusStartupValidator.java
| @@ -68,10 +68,10 @@ public class MilvusStartupValidator implements ApplicationRunner { | @@ -68,10 +68,10 @@ public class MilvusStartupValidator implements ApplicationRunner { | ||
| 68 | } | 68 | } |
| 69 | } | 69 | } |
| 70 | 70 | ||
| 71 | - log.info("✅ Milvus启动验证完成"); | 71 | + log.info("Milvus启动验证完成"); |
| 72 | 72 | ||
| 73 | } catch (Exception e) { | 73 | } catch (Exception e) { |
| 74 | - log.error("❌ Milvus启动验证失败: {}", e.getMessage(), e); | 74 | + log.error("Milvus启动验证失败: {}", e.getMessage(), e); |
| 75 | // 可以根据配置决定是否抛出异常 | 75 | // 可以根据配置决定是否抛出异常 |
| 76 | // throw new RuntimeException("Milvus验证失败", e); | 76 | // throw new RuntimeException("Milvus验证失败", e); |
| 77 | } | 77 | } |
src/main/java/com/xly/milvus/service/impl/MilvusServiceImpl.java
| @@ -144,16 +144,30 @@ public class MilvusServiceImpl implements MilvusService { | @@ -144,16 +144,30 @@ public class MilvusServiceImpl implements MilvusService { | ||
| 144 | **/ | 144 | **/ |
| 145 | public void addAiMilvusVectorRecord(String sInputTabelName,String tUpdateDate,String tUpdateDateUp) { | 145 | public void addAiMilvusVectorRecord(String sInputTabelName,String tUpdateDate,String tUpdateDateUp) { |
| 146 | //获取需要同步地数据 | 146 | //获取需要同步地数据 |
| 147 | + delAiMilvusVectorRecord(sInputTabelName); | ||
| 147 | Map<String,Object> dMap = new HashMap<>(); | 148 | Map<String,Object> dMap = new HashMap<>(); |
| 148 | dMap.put("sInputTabelName",sInputTabelName); | 149 | dMap.put("sInputTabelName",sInputTabelName); |
| 149 | - String sSql = "DELETE FROM ai_milvus_vector_record WHERE sInputTabelName = #{sInputTabelName}"; | ||
| 150 | - dynamicExeDbService.delSql(dMap,sSql); | ||
| 151 | dMap.put("tUpdateDate",tUpdateDate); | 150 | dMap.put("tUpdateDate",tUpdateDate); |
| 152 | dMap.put("tUpdateDateUp",tUpdateDateUp); | 151 | dMap.put("tUpdateDateUp",tUpdateDateUp); |
| 153 | - sSql = String.format("INSERT INTO ai_milvus_vector_record(sId,sInputTabelName,tUpdateDate,tUpdateDateUp)VALUES(newId(),#{sInputTabelName},#{tUpdateDate},#{tUpdateDateUp})"); | 152 | + String sSql = String.format("INSERT INTO ai_milvus_vector_record(sId,sInputTabelName,tUpdateDate,tUpdateDateUp)VALUES(newId(),#{sInputTabelName},#{tUpdateDate},#{tUpdateDateUp})"); |
| 154 | dynamicExeDbService.addSql(dMap,sSql); | 153 | dynamicExeDbService.addSql(dMap,sSql); |
| 155 | } | 154 | } |
| 156 | 155 | ||
| 156 | + /*** | ||
| 157 | + * @Author 钱豹 | ||
| 158 | + * @Date 22:32 2026/3/24 | ||
| 159 | + * @Param [sInputTabelName, tUpdateDate] | ||
| 160 | + * @return java.util.List<java.util.Map<java.lang.String,java.lang.Object>> | ||
| 161 | + * @Description 获取更新地数据 | ||
| 162 | + **/ | ||
| 163 | + public void delAiMilvusVectorRecord(String sInputTabelName) { | ||
| 164 | + //获取需要同步地数据 | ||
| 165 | + Map<String,Object> dMap = new HashMap<>(); | ||
| 166 | + dMap.put("sInputTabelName",sInputTabelName); | ||
| 167 | + String sSql = "DELETE FROM ai_milvus_vector_record WHERE sInputTabelName = #{sInputTabelName}"; | ||
| 168 | + dynamicExeDbService.delSql(dMap,sSql); | ||
| 169 | + } | ||
| 170 | + | ||
| 157 | 171 | ||
| 158 | /*** | 172 | /*** |
| 159 | * @Author 钱豹 | 173 | * @Author 钱豹 |
| @@ -595,7 +609,8 @@ public class MilvusServiceImpl implements MilvusService { | @@ -595,7 +609,8 @@ public class MilvusServiceImpl implements MilvusService { | ||
| 595 | milvusClient.dropCollection(DropCollectionReq.builder() | 609 | milvusClient.dropCollection(DropCollectionReq.builder() |
| 596 | .collectionName(collectionName) | 610 | .collectionName(collectionName) |
| 597 | .build()); | 611 | .build()); |
| 598 | - | 612 | + //删除对应的记录表 |
| 613 | + delAiMilvusVectorRecord(collectionName); | ||
| 599 | } | 614 | } |
| 600 | // 检查集合是否存在 | 615 | // 检查集合是否存在 |
| 601 | HasCollectionReq hasCollectionReq = HasCollectionReq.builder() | 616 | HasCollectionReq hasCollectionReq = HasCollectionReq.builder() |