From e7c60afd56e8a46dac2111283108b718398c7d2a Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期一, 25 五月 2026 16:27:47 +0800
Subject: [PATCH] refactor(approve): 重构审批业务状态同步逻辑
---
src/main/java/com/ruoyi/ai/assistant/ManufacturingIntentExecutor.java | 136 +++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 136 insertions(+), 0 deletions(-)
diff --git a/src/main/java/com/ruoyi/ai/assistant/ManufacturingIntentExecutor.java b/src/main/java/com/ruoyi/ai/assistant/ManufacturingIntentExecutor.java
new file mode 100644
index 0000000..e9d9396
--- /dev/null
+++ b/src/main/java/com/ruoyi/ai/assistant/ManufacturingIntentExecutor.java
@@ -0,0 +1,136 @@
+package com.ruoyi.ai.assistant;
+
+import com.ruoyi.ai.tools.ManufacturingAgentTools;
+import org.springframework.stereotype.Component;
+import org.springframework.util.StringUtils;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+@Component
+public class ManufacturingIntentExecutor {
+
+ private static final Pattern LIMIT_PATTERN = Pattern.compile("(鍓峾鏈�杩�)?(\\d{1,2})鏉�");
+ private static final Pattern DATE_PATTERN = Pattern.compile("(\\d{4}-\\d{2}-\\d{2})");
+
+ private final ManufacturingAgentTools manufacturingAgentTools;
+
+ public ManufacturingIntentExecutor(ManufacturingAgentTools manufacturingAgentTools) {
+ this.manufacturingAgentTools = manufacturingAgentTools;
+ }
+
+ public String tryExecute(String memoryId, String message) {
+ if (!StringUtils.hasText(message)) {
+ return null;
+ }
+ String text = message.trim();
+ String keyword = extractKeyword(text);
+ Integer limit = extractLimit(text);
+ String startDate = extractStartDate(text);
+ String endDate = extractEndDate(text);
+
+ if (containsAny(text, "棰勮", "鍛婅", "椋庨櫓", "鎻愰啋")) {
+ return manufacturingAgentTools.getWarningBoard(memoryId, startDate, endDate, text);
+ }
+ if (containsAny(text, "鍒嗘瀽", "缁熻", "瓒嬪娍", "鐪嬫澘", "鎶ヨ〃", "鎬昏")) {
+ return manufacturingAgentTools.analyzeFactory(memoryId, startDate, endDate, text);
+ }
+ if (containsAny(text, "鍔�", "澶勭悊", "娲惧伐", "瀹夋帓", "闂幆", "璺熻繘", "澶勭疆")) {
+ return manufacturingAgentTools.planActions(memoryId, text);
+ }
+
+ if (containsAny(text, "鐢熶骇鐜板満", "鐜板満", "杞﹂棿")) {
+ return manufacturingAgentTools.queryDomain(memoryId, "site", keyword, limit, startDate, endDate, text);
+ }
+ if (containsAny(text, "璁″垝", "鎺掍骇", "mps")) {
+ return manufacturingAgentTools.queryDomain(memoryId, "plan", keyword, limit, startDate, endDate, text);
+ }
+ if (containsAny(text, "宸ュ崟", "浣滀笟鍗�", "浠诲姟鍗�", "浠诲姟")) {
+ return manufacturingAgentTools.queryDomain(memoryId, "workorder", keyword, limit, startDate, endDate, text);
+ }
+ if (containsAny(text, "璁惧", "缁翠慨", "淇濆吇", "鏁呴殰")) {
+ return manufacturingAgentTools.queryDomain(memoryId, "device", keyword, limit, startDate, endDate, text);
+ }
+ if (containsAny(text, "璐ㄩ噺", "璐ㄦ", "涓嶅悎鏍�", "妫�楠�")) {
+ return manufacturingAgentTools.queryDomain(memoryId, "quality", keyword, limit, startDate, endDate, text);
+ }
+ if (containsAny(text, "鐗╂枡", "搴撳瓨", "搴撲綅", "鍏ュ簱", "鍑哄簱")) {
+ return manufacturingAgentTools.queryDomain(memoryId, "material", keyword, limit, startDate, endDate, text);
+ }
+ if (containsAny(text, "寮傚父", "渚嬪", "鍋忓樊")) {
+ return manufacturingAgentTools.queryDomain(memoryId, "exception", keyword, limit, startDate, endDate, text);
+ }
+ return null;
+ }
+
+ private boolean containsAny(String text, String... keywords) {
+ for (String keyword : keywords) {
+ if (text.toLowerCase().contains(keyword.toLowerCase())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private Integer extractLimit(String text) {
+ Matcher matcher = LIMIT_PATTERN.matcher(text);
+ return matcher.find() ? Integer.parseInt(matcher.group(2)) : 10;
+ }
+
+ private String extractStartDate(String text) {
+ Matcher matcher = DATE_PATTERN.matcher(text);
+ return matcher.find() ? matcher.group(1) : null;
+ }
+
+ private String extractEndDate(String text) {
+ Matcher matcher = DATE_PATTERN.matcher(text);
+ if (!matcher.find()) {
+ return null;
+ }
+ return matcher.find() ? matcher.group(1) : null;
+ }
+
+ private String extractKeyword(String text) {
+ String cleaned = text
+ .replace("鏌ヨ", "")
+ .replace("鏌ョ湅", "")
+ .replace("甯垜", "")
+ .replace("璇�", "")
+ .replace("涓�涓�", "")
+ .replace("鎵�鏈�", "")
+ .replace("鍏ㄩ儴", "")
+ .replace("浠婂勾", "")
+ .replace("鏈勾", "")
+ .replace("鍘诲勾", "")
+ .replace("鏈湀", "")
+ .replace("涓婃湀", "")
+ .replace("鏈懆", "")
+ .replace("涓婂懆", "")
+ .replace("浠婂ぉ", "")
+ .replace("鏄ㄥぉ", "")
+ .replace("杩�30澶�", "")
+ .replace("杩�7澶�", "")
+ .replace("杩�15澶�", "")
+ .replace("杩�60澶�", "")
+ .replace("鏈�杩�30澶�", "")
+ .replace("鏈�杩�7澶�", "")
+ .replace("鏈�杩�15澶�", "")
+ .replace("鏈�杩�60澶�", "")
+ .replace("鐢熶骇鐜板満", "")
+ .replace("鐜板満", "")
+ .replace("鐢熶骇宸ュ崟", "")
+ .replace("鐢熶骇", "")
+ .replace("璁″垝", "")
+ .replace("鎺掍骇", "")
+ .replace("宸ュ崟", "")
+ .replace("璁惧", "")
+ .replace("璐ㄩ噺", "")
+ .replace("鐗╂枡", "")
+ .replace("搴撳瓨", "")
+ .replace("寮傚父", "")
+ .replace("鍓�10鏉�", "")
+ .replace("鏈�杩�10鏉�", "")
+ .trim();
+ return cleaned.length() >= 2 ? cleaned : null;
+ }
+}
--
Gitblit v1.9.3