From 2b66259ce096acedfbef751199dab50076b1c571 Mon Sep 17 00:00:00 2001
From: huminmin <mac@MacBook-Pro.local>
Date: 星期三, 27 五月 2026 11:10:11 +0800
Subject: [PATCH] Merge branch 'dev_New_pro' of http://114.132.189.42:9002/r/product-inventory-management-after into dev_New_pro
---
src/main/java/com/ruoyi/ai/assistant/FinancialIntentExecutor.java | 76 +++++++++++++++++++++++--------------
1 files changed, 47 insertions(+), 29 deletions(-)
diff --git a/src/main/java/com/ruoyi/ai/assistant/FinancialIntentExecutor.java b/src/main/java/com/ruoyi/ai/assistant/FinancialIntentExecutor.java
index 9afadff..f402fc2 100644
--- a/src/main/java/com/ruoyi/ai/assistant/FinancialIntentExecutor.java
+++ b/src/main/java/com/ruoyi/ai/assistant/FinancialIntentExecutor.java
@@ -14,9 +14,10 @@
public class FinancialIntentExecutor {
private static final DateTimeFormatter DATE_FMT = DateTimeFormatter.ofPattern("yyyy-MM-dd");
- private static final Pattern LIMIT_PATTERN = Pattern.compile("(鍓峾鏈�杩�)?\\s*(\\d{1,2})\\s*鏉�");
+ private static final Pattern LIMIT_PATTERN = Pattern.compile("(?:鍓峾鏈�杩憒灞曠ず|杩斿洖)?\\s*(\\d{1,2})\\s*(?:鏉涓獆鍚�)");
private static final Pattern DATE_PATTERN = Pattern.compile("(\\d{4}-\\d{2}-\\d{2})");
- private static final Pattern RELATIVE_DAY_PATTERN = Pattern.compile("(杩憒鏈�杩�)?\\s*(\\d{1,3})\\s*澶�");
+ private static final Pattern RELATIVE_DAY_PATTERN = Pattern.compile("(?:杩憒鏈�杩�)\\s*(\\d{1,3})\\s*澶�");
+ private static final Pattern FUTURE_MONTH_PATTERN = Pattern.compile("(?:鏈潵|鍚庣画|鎺ヤ笅鏉�)\\s*(\\d{1,2})\\s*(?:涓�)?鏈�");
private final FinancialAgentTools financialAgentTools;
@@ -42,18 +43,18 @@
String endDate = dateRange.endDate();
String timeRange = dateRange.label();
- if (containsAny(text, "鎴愭湰鏍哥畻", "浜у搧鎴愭湰", "宸ュ簭鎴愭湰", "浜哄伐鎴愭湰", "鎶樻棫", "鏉愭枡鎹熻��")) {
+ if (containsAny(text, "鎴愭湰鏍哥畻", "浜у搧鎴愭湰", "宸ュ簭鎴愭湰", "浜哄伐鎴愭湰", "鎶樻棫", "鏉愭枡鎹熻��", "鎴愭湰鏈�楂�")) {
return financialAgentTools.calculateIntelligentCost(memoryId, startDate, endDate, timeRange, keyword, limit);
}
- if (containsAny(text, "鍒╂鼎鍒嗘瀽", "璁㈠崟鍒╂鼎", "浜忔崯璁㈠崟", "浣庡埄娑�",
- "鏈�璧氶挶瀹㈡埛", "鍝釜瀹㈡埛鏈�璧氶挶", "瀹㈡埛鏈�璧氶挶", "鍒╂鼎鏈�楂樺鎴�", "鍒╂鼎璐$尞鏈�楂樺鎴�", "鍒╂鼎涓嬮檷")) {
+ if (containsAny(text, "鍒╂鼎鍒嗘瀽", "璁㈠崟鍒╂鼎", "浜忔崯璁㈠崟", "浣庡埄娑�", "鏈�璧氶挶瀹㈡埛", "鍝釜瀹㈡埛鏈�璧氶挶",
+ "瀹㈡埛鏈�璧氶挶", "鍒╂鼎鏈�楂樺鎴�", "鍒╂鼎璐$尞鏈�楂�", "鍒╂鼎涓嬮檷")) {
return financialAgentTools.analyzeOrderProfit(memoryId, startDate, endDate, timeRange, keyword, limit);
}
if (containsAny(text, "搴撳瓨璧勯噾", "搴撳瓨绉帇", "鍛嗘粸搴撳瓨", "璧勯噾鍗犵敤", "鍛ㄨ浆鐜�", "搴撳瓨鍛ㄨ浆")) {
return financialAgentTools.analyzeInventoryCapital(memoryId, startDate, endDate, timeRange, keyword, limit);
}
if (containsAny(text, "鐜伴噾娴�", "鍥炴椋庨櫓", "浠樻鍘嬪姏", "璧勯噾缂哄彛", "搴旀敹", "搴斾粯", "鍥炴棰勬祴")) {
- return financialAgentTools.forecastCashFlow(memoryId, startDate, endDate, timeRange, limit);
+ return financialAgentTools.forecastCashFlow(memoryId, startDate, endDate, timeRange, extractForecastMonths(text));
}
if (containsAny(text, "寮傚父棰勮", "缁忚惀寮傚父", "椋庨櫓棰勮", "鎴愭湰寮傚父", "鍒╂鼎寮傚父", "鍥炴寮傚父", "璁㈠崟椋庨櫓")) {
return financialAgentTools.detectBusinessAnomalies(memoryId, startDate, endDate, timeRange, limit);
@@ -73,30 +74,35 @@
private String tryExecuteQuickPrompt(String memoryId, String text) {
String normalized = normalizeForMatch(text);
+ if ("鐢熸垚鏈懆缁忚惀鍛ㄦ姤鍒╂鼎涓庣幇閲戞祦".equals(normalized) || "鐢熸垚鏈懆缁忚惀鍛ㄦ姤".equals(normalized) || "鐢熸垚鍛ㄦ姤".equals(normalized)) {
+ DateRange range = weekRange();
+ return financialAgentTools.generateOperationReport(memoryId, range.startDate(), range.endDate(), range.label(), "weekly");
+ }
+ if ("鍒嗘瀽鏈湀鍒╂鼎涓嬮檷鍘熷洜".equals(normalized)) {
+ DateRange range = monthRange();
+ return financialAgentTools.analyzeOrderProfit(memoryId, range.startDate(), range.endDate(), range.label(), null, null);
+ }
+ if ("杩�30澶╁摢涓鎴峰埄娑﹁础鐚渶楂�".equals(normalized)) {
+ DateRange range = recentDaysRange(30);
+ return financialAgentTools.analyzeOrderProfit(memoryId, range.startDate(), range.endDate(), range.label(), null, null);
+ }
if ("鏌ョ湅鏈湀缁忚惀椹鹃┒鑸�".equals(normalized) || "鏌ョ湅缁忚惀椹鹃┒鑸�".equals(normalized)) {
DateRange range = monthRange();
return financialAgentTools.getBusinessCockpit(memoryId, range.startDate(), range.endDate(), range.label());
}
- if ("鏌ヨ杩�30澶╀簭鎹熻鍗�".equals(normalized) || "鍝釜璁㈠崟浜忔崯".equals(normalized)) {
+ if ("鏌ヨ杩�30澶╀簭鎹熻鍗�".equals(normalized)) {
DateRange range = recentDaysRange(30);
- return financialAgentTools.analyzeOrderProfit(memoryId, range.startDate(), range.endDate(), range.label(), null, 20);
+ return financialAgentTools.analyzeOrderProfit(memoryId, range.startDate(), range.endDate(), range.label(), null, null);
}
- if ("鐢熸垚鏈懆缁忚惀鍛ㄦ姤".equals(normalized) || "鐢熸垚鍛ㄦ姤".equals(normalized)) {
- DateRange range = weekRange();
- return financialAgentTools.generateOperationReport(memoryId, range.startDate(), range.endDate(), range.label(), "weekly");
+ if ("鍒嗘瀽杩�30澶╁簱瀛樿祫閲戝崰鐢�".equals(normalized)) {
+ DateRange range = recentDaysRange(30);
+ return financialAgentTools.analyzeInventoryCapital(memoryId, range.startDate(), range.endDate(), range.label(), null, null);
}
- if ("涓轰粈涔堝埄娑︿笅闄�".equals(normalized)) {
- DateRange range = monthRange();
- return financialAgentTools.analyzeOrderProfit(memoryId, range.startDate(), range.endDate(), range.label(), null, 20);
+ if ("棰勬祴鏈潵3涓湀鐜伴噾娴�".equals(normalized)) {
+ return financialAgentTools.forecastCashFlow(memoryId, null, null, null, 3);
}
- if ("鍝釜瀹㈡埛鏈�璧氶挶".equals(normalized)
- || "鏈�杩戝摢涓鎴锋渶璧氶挶".equals(normalized)
- || "鏈湀鍝釜瀹㈡埛鏈�璧氶挶".equals(normalized)
- || "杩�30澶╁摢涓鎴锋渶璧氶挶".equals(normalized)
- || "鍝釜瀹㈡埛鍒╂鼎鏈�楂�".equals(normalized)
- || "鍝釜瀹㈡埛鍒╂鼎璐$尞鏈�楂�".equals(normalized)) {
- DateRange range = extractDateRange(text);
- return financialAgentTools.analyzeOrderProfit(memoryId, range.startDate(), range.endDate(), range.label(), null, 20);
+ if ("鍝釜宸ュ簭鎴愭湰鏈�楂�".equals(normalized)) {
+ return financialAgentTools.calculateIntelligentCost(memoryId, null, null, null, null, null);
}
return null;
}
@@ -112,7 +118,12 @@
private Integer extractLimit(String text) {
Matcher matcher = LIMIT_PATTERN.matcher(text);
- return matcher.find() ? Integer.parseInt(matcher.group(2)) : 10;
+ return matcher.find() ? Integer.parseInt(matcher.group(1)) : null;
+ }
+
+ private Integer extractForecastMonths(String text) {
+ Matcher matcher = FUTURE_MONTH_PATTERN.matcher(text);
+ return matcher.find() ? Integer.parseInt(matcher.group(1)) : null;
}
private DateRange extractDateRange(String text) {
@@ -128,7 +139,7 @@
if (text.contains("涓婃湀")) {
return lastMonthRange();
}
- if (text.contains("鏈勾") || text.contains("浠婂勾")) {
+ if (text.contains("浠婂勾") || text.contains("鏈勾")) {
return yearRange();
}
if (text.contains("鏈懆")) {
@@ -136,17 +147,17 @@
}
Matcher relativeDayMatcher = RELATIVE_DAY_PATTERN.matcher(text);
if (relativeDayMatcher.find()) {
- int days = Integer.parseInt(relativeDayMatcher.group(2));
+ int days = Integer.parseInt(relativeDayMatcher.group(1));
return recentDaysRange(days);
}
- return new DateRange(null, null, "杩�30澶�");
+ return new DateRange(null, null, null);
}
private DateRange buildDateRange(String start, String end, String label) {
LocalDate startDate = parseDate(start);
LocalDate endDate = parseDate(end);
if (startDate == null || endDate == null) {
- return new DateRange(null, null, "杩�30澶�");
+ return new DateRange(null, null, null);
}
if (startDate.isAfter(endDate)) {
LocalDate temp = startDate;
@@ -200,7 +211,11 @@
if (!StringUtils.hasText(text)) {
return "";
}
- return text.replace("锛�", "")
+ return text.replace("锛�", "")
+ .replace("锛�", "")
+ .replace("(", "")
+ .replace(")", "")
+ .replace("锛�", "")
.replace(",", "")
.replace("銆�", "")
.replace(".", "")
@@ -218,13 +233,16 @@
private String extractKeyword(String text) {
String cleaned = text
+ .replaceAll("\\d{4}-\\d{2}-\\d{2}", "")
+ .replaceAll("(?:杩憒鏈�杩�)\\s*\\d{1,3}\\s*澶�", "")
+ .replaceAll("(?:鍓峾鏈�杩憒灞曠ず|杩斿洖)?\\s*\\d{1,2}\\s*(?:鏉涓獆鍚�)", "")
.replace("鏌ヨ", "")
.replace("鏌ョ湅", "")
.replace("鐪嬩笅", "")
.replace("鐪嬬湅", "")
.replace("甯垜", "")
.replace("璇�", "")
- .replace("涓�涓�", "")
+ .replace("涓�涓�", "")
.replace("涓轰粈涔�", "")
.replace("鍝釜瀹㈡埛鏈�璧氶挶", "")
.replace("鏈�杩戝摢涓鎴锋渶璧氶挶", "")
--
Gitblit v1.9.3