From 9d7ddee9fae205fbca1e6aff2893967079003671 Mon Sep 17 00:00:00 2001
From: 秦芳睿 <1425609123@qq.com>
Date: 星期三, 12 三月 2025 10:34:13 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/file_Question' into file_Question

---
 JAVA/SMTAIServer/src/main/java/com/smtaiserver/smtaiserver/core/SMTAIServerApp.java |   26 ++++++++++++++++++++++----
 1 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/JAVA/SMTAIServer/src/main/java/com/smtaiserver/smtaiserver/core/SMTAIServerApp.java b/JAVA/SMTAIServer/src/main/java/com/smtaiserver/smtaiserver/core/SMTAIServerApp.java
index a760821..2c6dfb3 100644
--- a/JAVA/SMTAIServer/src/main/java/com/smtaiserver/smtaiserver/core/SMTAIServerApp.java
+++ b/JAVA/SMTAIServer/src/main/java/com/smtaiserver/smtaiserver/core/SMTAIServerApp.java
@@ -22,7 +22,6 @@
 import org.apache.pdfbox.text.PDFTextStripper;
 import org.apache.poi.hwpf.HWPFDocument;
 import org.apache.poi.hwpf.extractor.WordExtractor;
-import org.apache.poi.poifs.filesystem.FileMagic;
 import org.apache.poi.xwpf.extractor.XWPFWordExtractor;
 import org.apache.poi.xwpf.usermodel.XWPFDocument;
 import org.dom4j.Document;
@@ -236,7 +235,7 @@
 		Map<String, SMTMetricsDef> mapResult = mapMapMetrics.get(groupId);
 		
 		if(mapResult == null)
-			throw new Exception("can't find metrics group : " + groupId);
+			return new HashMap<String, SMTMetricsDef>();
 		
 		return mapResult;
 	}
@@ -303,6 +302,7 @@
 		_serverEncache.getMapThemeDefMap();
 		_serverEncache.getAttachTableDefMap();
 		_serverEncache.getAttachMetricDefMap();
+		_serverEncache.getQwenAgentManager();
 	}
 	
 	public SMTMapTableDef getMapTableDef(String tableId) throws Exception
@@ -1249,7 +1249,7 @@
 	/**
 	 * 鏂囦欢(word銆乸df)杞瑃xt
 	 */
-	public String fileTranslTxt(MultipartFile file) throws Exception {
+	public static String fileTranslTxt(MultipartFile file) throws Exception {
 		InputStream inputStream = file.getInputStream();
 		try (BufferedInputStream bis = new BufferedInputStream(file.getInputStream())) {
 			String mimeType = file.getContentType();
@@ -1272,6 +1272,10 @@
 							WordExtractor wordExtractor = new WordExtractor(doc);
 							return wordExtractor.getText();
 						}
+					case "text/plain":
+						_logger.info("鏂囦欢绫诲瀷鏄� TXT");
+						byte[] fileData = readAttachFile(file);
+                        return new String(fileData, "UTF-8");
 					default:
 						_logger.info("鏈煡鏂囦欢绫诲瀷: " + mimeType);
 						break;
@@ -1283,7 +1287,21 @@
 			_logger.error("鏂囦欢澶勭悊澶辫触: " + e.getMessage());
 			throw new Exception("鏂囦欢澶勭悊澶辫触: " + e.getMessage());
 		}
-		return null;
+		return "";
+	}
+	public static byte[] readAttachFile(MultipartFile file) throws Exception
+	{
+		InputStream is = file.getInputStream();
+		ByteArrayOutputStream bos = new ByteArrayOutputStream();
+		byte[] data = new byte[1024 * 1024];
+		while(true)
+		{
+			int size = is.read(data);
+			if(size <= 0)
+				return bos.toByteArray();
+
+			bos.write(data, 0, size);
+		}
 	}
 
 }

--
Gitblit v1.9.3