From 10b88a7ff17caf92f3d4e8a550c1085a70c2517a Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期四, 28 五月 2026 17:43:26 +0800
Subject: [PATCH] Merge dev_New_pro into dev_山西_晋和园_pro
---
src/main/java/com/ruoyi/ai/controller/FinancialAiController.java | 59 ++++++++++++++++++++++++++++++++++++-----------------------
1 files changed, 36 insertions(+), 23 deletions(-)
diff --git a/src/main/java/com/ruoyi/ai/controller/SalesAiController.java b/src/main/java/com/ruoyi/ai/controller/FinancialAiController.java
similarity index 67%
rename from src/main/java/com/ruoyi/ai/controller/SalesAiController.java
rename to src/main/java/com/ruoyi/ai/controller/FinancialAiController.java
index c3a569b..9465d5a 100644
--- a/src/main/java/com/ruoyi/ai/controller/SalesAiController.java
+++ b/src/main/java/com/ruoyi/ai/controller/FinancialAiController.java
@@ -1,7 +1,7 @@
package com.ruoyi.ai.controller;
-import com.ruoyi.ai.assistant.SalesAgent;
-import com.ruoyi.ai.assistant.SalesIntentExecutor;
+import com.ruoyi.ai.assistant.FinancialAgent;
+import com.ruoyi.ai.assistant.FinancialIntentExecutor;
import com.ruoyi.ai.bean.ChatForm;
import com.ruoyi.ai.context.AiSessionUserContext;
import com.ruoyi.ai.service.AiChatSessionService;
@@ -24,32 +24,38 @@
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;
+import java.time.LocalDate;
+import java.time.ZoneId;
+import java.time.format.DateTimeFormatter;
import java.util.List;
-@Tag(name = "閿�鍞姪鎵嬫櫤鑳戒綋")
+@Tag(name = "璐㈠姟鏅鸿兘浣�")
@RestController
-@RequestMapping("/sales-ai")
-public class SalesAiController extends BaseController {
+@RequestMapping("/financial-ai")
+public class FinancialAiController extends BaseController {
- private final SalesAgent salesAgent;
- private final SalesIntentExecutor salesIntentExecutor;
+ private static final DateTimeFormatter CURRENT_DATE_FMT = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+ private static final ZoneId CHINA_ZONE_ID = ZoneId.of("Asia/Shanghai");
+
+ private final FinancialAgent financialAgent;
+ private final FinancialIntentExecutor financialIntentExecutor;
private final AiSessionUserContext aiSessionUserContext;
private final MongoChatMemoryStore mongoChatMemoryStore;
private final AiChatSessionService aiChatSessionService;
- public SalesAiController(SalesAgent salesAgent,
- SalesIntentExecutor salesIntentExecutor,
- AiSessionUserContext aiSessionUserContext,
- MongoChatMemoryStore mongoChatMemoryStore,
- AiChatSessionService aiChatSessionService) {
- this.salesAgent = salesAgent;
- this.salesIntentExecutor = salesIntentExecutor;
+ public FinancialAiController(FinancialAgent financialAgent,
+ FinancialIntentExecutor financialIntentExecutor,
+ AiSessionUserContext aiSessionUserContext,
+ MongoChatMemoryStore mongoChatMemoryStore,
+ AiChatSessionService aiChatSessionService) {
+ this.financialAgent = financialAgent;
+ this.financialIntentExecutor = financialIntentExecutor;
this.aiSessionUserContext = aiSessionUserContext;
this.mongoChatMemoryStore = mongoChatMemoryStore;
this.aiChatSessionService = aiChatSessionService;
}
- @Operation(summary = "閿�鍞姪鎵嬪璇�")
+ @Operation(summary = "璐㈠姟鏅鸿兘浣撳璇�")
@PostMapping(value = "/chat", produces = "text/stream;charset=utf-8")
public Flux<String> chat(@RequestBody ChatForm chatForm) {
if (!StringUtils.hasText(chatForm.getMemoryId())) {
@@ -66,7 +72,7 @@
aiSessionUserContext.bind(memoryId, loginUser);
aiChatSessionService.touchSession(memoryId, loginUser, userMessage);
- String directResponse = salesIntentExecutor.tryExecute(memoryId, userMessage);
+ String directResponse = financialIntentExecutor.tryExecute(memoryId, userMessage);
if (StringUtils.isNotEmpty(directResponse)) {
mongoChatMemoryStore.appendMessages(
memoryId,
@@ -77,7 +83,7 @@
}
if (isBusinessDataIntent(userMessage)) {
- String noGuessResponse = "鏈瘑鍒埌鍙墽琛岀殑鏁版嵁鏌ヨ鏉′欢銆備负淇濊瘉缁撴灉鍑嗙‘锛屽綋鍓嶄笉浼氭帹娴嬫垨缂栭�犳暟鎹紝璇疯ˉ鍏呮槑纭椂闂磋寖鍥淬�佸鎴锋垨鍗曞彿鍚庡啀鏌ヨ銆�";
+ String noGuessResponse = "鏈瘑鍒埌鍙墽琛岀殑鏁版嵁鏌ヨ鏉′欢銆備负淇濊瘉缁撴灉鍑嗙‘锛屽綋鍓嶄笉浼氭帹娴嬫垨缂栭�犳暟鎹紝璇疯ˉ鍏呮槑纭椂闂磋寖鍥淬�佸鎴枫�佷緵搴斿晢鎴栧崟鍙峰悗鍐嶆煡璇€��";
mongoChatMemoryStore.appendMessages(
memoryId,
List.of(UserMessage.from(userMessage), AiMessage.from(noGuessResponse))
@@ -86,28 +92,32 @@
return Flux.just(noGuessResponse);
}
- return salesAgent.chat(memoryId, userMessage)
+ return financialAgent.chat(memoryId, userMessage, currentDateForPrompt())
.doOnComplete(() -> aiChatSessionService.refreshSessionStats(memoryId, loginUser))
.doOnError(ex -> aiChatSessionService.refreshSessionStats(memoryId, loginUser));
}
- @Operation(summary = "閿�鍞姪鎵嬩細璇濆垪琛�")
+ @Operation(summary = "璐㈠姟鏅鸿兘浣撲細璇濆垪琛�")
@GetMapping("/history/sessions")
public AjaxResult listSessions() {
return success(aiChatSessionService.listCurrentUserSessions(SecurityUtils.getLoginUser()));
}
- @Operation(summary = "閿�鍞姪鎵嬩細璇濇秷鎭�")
+ @Operation(summary = "璐㈠姟鏅鸿兘浣撲細璇濇秷鎭�")
@GetMapping("/history/messages/{memoryId}")
public AjaxResult listMessages(@PathVariable String memoryId) {
return success(aiChatSessionService.listCurrentUserMessages(memoryId, SecurityUtils.getLoginUser()));
}
- @Operation(summary = "鍒犻櫎閿�鍞姪鎵嬩細璇�")
+ @Operation(summary = "鍒犻櫎璐㈠姟鏅鸿兘浣撲細璇�")
@DeleteMapping("/history/{memoryId}")
public AjaxResult deleteSession(@PathVariable String memoryId) {
aiSessionUserContext.remove(memoryId);
return toAjax(aiChatSessionService.deleteCurrentUserSession(memoryId, SecurityUtils.getLoginUser()));
+ }
+
+ private String currentDateForPrompt() {
+ return LocalDate.now(CHINA_ZONE_ID).format(CURRENT_DATE_FMT);
}
private boolean isBusinessDataIntent(String message) {
@@ -116,8 +126,11 @@
}
String text = message.trim();
return containsAny(text,
- "鏌ヨ", "鏌ョ湅", "缁熻", "鍒嗘瀽", "寤鸿", "瀹㈡埛妗f", "绉佹捣", "鍏捣",
- "閿�鍞姤浠�", "閿�鍞彴璐�", "閿�鍞��璐�", "瀹㈡埛寰�鏉�", "鍙戣揣鍙拌处", "鍥炴", "鎶ヤ环", "椋庨櫓");
+ "鏌ヨ", "鏌ョ湅", "缁熻", "鍒嗘瀽", "寤鸿", "鎴愭湰鏍哥畻", "浜у搧鎴愭湰", "宸ュ簭鎴愭湰",
+ "璁㈠崟鍒╂鼎", "浜忔崯璁㈠崟", "浣庡埄娑�", "搴撳瓨璧勯噾", "搴撳瓨绉帇", "鍛嗘粸搴撳瓨",
+ "鐜伴噾娴�", "鍥炴椋庨櫓", "浠樻鍘嬪姏", "璧勯噾缂哄彛", "搴旀敹", "搴斾粯",
+ "寮傚父棰勮", "缁忚惀寮傚父", "椋庨櫓棰勮", "椹鹃┒鑸�", "缁忚惀鐪嬫澘", "缁忚惀鎬昏",
+ "鏃ユ姤", "鍛ㄦ姤", "缁忚惀鎶ュ憡", "鍒嗘瀽鎶ュ憡", "涓氳储铻嶅悎", "鍙e緞", "鎸囨爣瑙i噴");
}
private boolean containsAny(String text, String... keywords) {
--
Gitblit v1.9.3