From 0b14e7755cf3a0d84124899f8a4ea55bafe003a2 Mon Sep 17 00:00:00 2001
From: 354798ggg <1074825718@qq.com>
Date: 星期四, 18 五月 2023 11:15:00 +0800
Subject: [PATCH] 文档检索代码清理

---
 src/main/java/com/product/lucene/service/LuceneService.java |   63 +------------------------------
 1 files changed, 3 insertions(+), 60 deletions(-)

diff --git a/src/main/java/com/product/lucene/service/LuceneService.java b/src/main/java/com/product/lucene/service/LuceneService.java
index ef6a94a..92465a5 100644
--- a/src/main/java/com/product/lucene/service/LuceneService.java
+++ b/src/main/java/com/product/lucene/service/LuceneService.java
@@ -5,10 +5,10 @@
 import com.product.core.dao.BaseDao;
 import com.product.core.entity.FieldSetEntity;
 import com.product.core.permission.PermissionService;
+import com.product.core.websocket.config.CmnConst;
 import com.product.lucene.util.FileUtils;
 import com.product.util.BaseUtil;
 
-import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.analysis.cn.smart.SmartChineseAnalyzer;
 import org.apache.lucene.document.*;
 import org.apache.lucene.index.IndexWriter;
@@ -95,7 +95,6 @@
 						indexWriter.addDocuments(docs);
 						indexWriter.commit();
 					} catch (IOException e) {
-						// TODO Auto-generated catch block
 						e.printStackTrace();
 					}
 				}
@@ -104,62 +103,6 @@
     	file.delete();
     }
     
-    
-/*    
-    public void createdIndex(FieldSetEntity fse) throws IOException {
-    	String function_uuid=fse.getString("function_uuid");
-    	String service_uuid=fse.getString("service_uuid");
-    	
-    	//鑾峰彇鍏ㄦ枃妫�绱㈤厤缃�
-    	FieldSetEntity fseConfig=baseDao.getFieldSetEntityByFilter("product_sys_document_search", "function_uuid=?", new Object[] {function_uuid}, false);
-    	if (fseConfig!=null) {
-			String table_uuid=fseConfig.getString("table_name");
-			String attachment_field=fseConfig.getString("attachment_file");
-			
-			//鑾峰彇缂撳瓨琛ㄩ厤缃�
-			FieldSetEntity fseTable=baseDao.getFieldSetEntity("product_sys_datamodel_table", table_uuid, false);
-			if (fseTable!=null) {
-				
-				//鑾峰彇鍘熸暟鎹�
-				FieldSetEntity fseService=baseDao.getFieldSetEntityBySQL("SELECT * FROM "+fseTable.getString("table_name")+" WHERE uuid=?", new Object[] {service_uuid}, false);
-				if (fseService!=null) {
-					
-					//鑾峰彇闄勪欢uuids
-					String attachments=fseService.getString(attachment_field);
-					if (!StringUtils.isEmpty(attachments)) {
-						
-						//閬嶅巻鑾峰彇闄勪欢淇℃伅
-						String [] attachment=attachments.split(",");
-						List<Document> docs=new ArrayList<>();
-						for (int i = 0; i < attachment.length; i++) {
-							
-							//鑾峰彇闄勪欢淇℃伅
-							FieldSetEntity fseAttachment=baseDao.getFieldSetEntity("product_sys_attachments", attachment[i], false);
-							if (fseAttachment!=null) {
-								//鑾峰彇闄勪欢
-								File file=fileManagerService.getFile(attachment[i]);
-								if (file!=null) {
-									//鐢熸垚绱㈠紩淇℃伅
-									Document doc=new Document();
-									doc.add(new StringField("uuid", attachment[i], Field.Store.YES));	//闄勪欢UUID
-									doc.add(new TextField("service_uuid", service_uuid, Field.Store.YES));	//涓氬姟UUID
-									doc.add(new TextField("function_uuid", function_uuid, Field.Store.YES));	//鍏卞棷閭d釜UUID
-									doc.add(new TextField("file_name", fseAttachment.getString("file_name"), Field.Store.YES));	//鏂囦欢鍚�
-									doc.add(new TextField("file_content", FileUtils.FileToString(file), Field.Store.YES));	//鏂囦欢鍐呭唴瀹�
-									docs.add(doc);
-								}
-								file.delete();
-							}
-						}
-						//鍐欏叆绱㈠紩
-						indexWriter.addDocuments(docs);
-						indexWriter.commit();
-					}
-				}
-			}
-		}
-    }
-*/    
     
     /**
      * 	鏂囨。妫�绱�
@@ -192,8 +135,6 @@
             
             //鍒嗛〉鏌ヨ鏂囨。
             TopDocs topDocs = searchByPage(fse.getInteger("cpage"), fse.getInteger("pagesize"), indexSearcher, query);
-            
-            
             
             ScoreDoc[] hits = topDocs.scoreDocs;
             for (int i = 0; i < hits.length; i++) {
@@ -244,6 +185,7 @@
     		
     		//鑾峰彇闄勪欢淇℃伅
     		FieldSetEntity fseAttachment=baseDao.getFieldSetEntity("product_sys_attachments", uuid, false);
+    		baseDao.loadPromptData(fseAttachment);
 			if (fseAttachment!=null) {
 				StringBuilder filter=new StringBuilder();
 				filter.append(fseAttachment.getString("attachment_data_field"));
@@ -287,6 +229,7 @@
 					json.put("title", fseService.getString(fseConfig.getString("title_field")));
 					json.put("function_name", fseFunction.getString("function_name"));
 				}
+				json.put("created_by", fseAttachment.getString(CmnConst.CREATED_BY));
 			}
 		}
     }

--
Gitblit v1.9.2