From c5243f3521fc014b4e2649789d16ca1f3b7e849d Mon Sep 17 00:00:00 2001
From: 秦芳睿 <1425609123@qq.com>
Date: 星期六, 22 三月 2025 00:27:54 +0800
Subject: [PATCH] 1

---
 JAVA/SMTAIServer/src/main/java/com/smtaiserver/smtaiserver/core/SMTAIServerApp.java |   65 ++++++++++++++++++++++++++++++--
 1 files changed, 60 insertions(+), 5 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..edef209 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
@@ -1,6 +1,7 @@
 package com.smtaiserver.smtaiserver.core;
 
 import java.io.*;
+import java.net.URLEncoder;
 import java.sql.Connection;
 import java.sql.DriverManager;
 import java.util.ArrayList;
@@ -22,7 +23,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;
@@ -146,7 +146,7 @@
 	
 	protected Map<String, SMTSSEBroadcastChat>	_mapUser2SMTSSEBroadcastChat = new HashMap<>();
 
-	
+	public static final String GET_WORKFLOWS = "http://localhost:5678/api/v1/workflows?";
 	private static Pattern					_patGroupStep = Pattern.compile("(\\d+)\\s*(minutes|hours|days|months|years|month|hour|year|day|minute)");
 	private static Pattern					_patGlobalMacro = Pattern.compile("\\{\\{\\{([\\w\\.]+)\\}\\}\\}");
 	private static Logger 					_logger = LogManager.getLogger(SMTQwenApp.class);
@@ -236,7 +236,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 +303,7 @@
 		_serverEncache.getMapThemeDefMap();
 		_serverEncache.getAttachTableDefMap();
 		_serverEncache.getAttachMetricDefMap();
+		_serverEncache.getQwenAgentManager();
 	}
 	
 	public SMTMapTableDef getMapTableDef(String tableId) throws Exception
@@ -1249,7 +1250,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 +1273,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 +1288,57 @@
 			_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);
+		}
+	}
+	public static String buildUrl(String active, String tags, String name, String projectId, String excludePinnedData, int limit) throws UnsupportedEncodingException {
+		// 浣跨敤Map鏉ュ瓨鍌ㄥ弬鏁�
+		Map<String, String> params = new HashMap<>();
+		params.put("active", active);
+		params.put("tags", tags);
+		params.put("name", name != null ? URLEncoder.encode(name, "UTF-8") : null);
+		params.put("projectId", projectId);
+		params.put("excludePinnedData", excludePinnedData);
+		params.put("limit", String.valueOf(limit));
+
+		// 鍩烘湰URL
+		StringBuilder urlBuilder = new StringBuilder(GET_WORKFLOWS);
+
+		// 閬嶅巻map骞舵瀯寤篣RL
+		for (Map.Entry<String, String> entry : params.entrySet()) {
+			if (entry.getValue() != null) {
+				urlBuilder.append(entry.getKey())
+						.append("=")
+						.append(entry.getValue())
+						.append("&");
+			}
+		}
+		// 鍘婚櫎鏈�鍚庝竴涓浣欑殑&绗﹀彿
+		String requestUrl = urlBuilder.toString();
+		if (requestUrl.endsWith("&")) {
+			requestUrl = requestUrl.substring(0, requestUrl.length() - 1);
+		}
+		return requestUrl;
+	}
+	public static List<String> extractParts(String input, Pattern pattern) {
+		Matcher matcher = pattern.matcher(input);
+		List<String> results = new ArrayList<>();
+		while (matcher.find()) {
+			results.add(matcher.group(1)); // 鎻愬彇绗竴涓崟鑾风粍鍐呭
+		}
+		return results;
+	}
 }

--
Gitblit v1.9.3