From 2f83e6c961888e462b308223dfccbb679e6d9cd4 Mon Sep 17 00:00:00 2001 From: xusd <330628789@qq.com> Date: Thu, 26 Jun 2025 17:55:20 +0800 Subject: [PATCH] feature:增加市民编号,增加AI问答 --- dyh-service/dyh-sys/src/main/java/cn/huge/module/ai/AiChatController.java | 26 ++++++++++++++++---------- 1 files changed, 16 insertions(+), 10 deletions(-) diff --git a/dyh-service/dyh-sys/src/main/java/cn/huge/module/ai/AiChatController.java b/dyh-service/dyh-sys/src/main/java/cn/huge/module/ai/AiChatController.java index 6420519..b0b75fd 100644 --- a/dyh-service/dyh-sys/src/main/java/cn/huge/module/ai/AiChatController.java +++ b/dyh-service/dyh-sys/src/main/java/cn/huge/module/ai/AiChatController.java @@ -1,5 +1,6 @@ package cn.huge.module.ai; +import cn.huge.base.common.bo.R; import cn.huge.base.common.utils.HttpClientUtils; import cn.huge.base.common.utils.ReturnFailUtils; import cn.huge.base.common.utils.ReturnSucUtils; @@ -9,6 +10,7 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -19,13 +21,14 @@ import java.util.Map; @RestController -@RequestMapping("/api/ai/chat") +@RequestMapping("/api/web/ai/chat") +@Slf4j public class AiChatController { private String url = "http://10.202.1.102:9002/"; @PostMapping("/risk") - public String risk(@RequestBody AiRequestVo aiRequestVo) { + public R<String> risk(@RequestBody AiRequestVo aiRequestVo) { String postUrl = url + "v1/workflows/run"; initHead("Bearer app-8ylvZOHf2fOgTGfe28MYtHDD"); String s = ""; @@ -40,18 +43,19 @@ if (data != null) { JSONObject outputs = data.getJSONObject("outputs"); if (outputs != null) { - JSONArray result = outputs.getJSONArray("result"); - if (result != null && result.size() > 0) { - return result.getJSONObject(0).getString("is_risk_ai"); + JSONObject body = outputs.getJSONObject("body"); + if (body != null) { + return R.ok(body.getJSONObject("data").getString("is_risk_ai")); } } } } - return "0"; + log.info("xsd:{}", object); + return R.ok("0"); } @PostMapping("/chat") - public AiBodyDto chat(@RequestBody AiRequestVo aiRequestVo) { + public R<AiBodyDto> chat(@RequestBody AiRequestVo aiRequestVo) { String postUrl = url + "v1/chat-messages"; String s = ""; AiBodyDto aiBodyDto = new AiBodyDto(); @@ -67,11 +71,12 @@ aiBodyDto.setAnswer(answer); aiBodyDto.setConversationId(conversation_id); } - return aiBodyDto; + log.info("xsd:{}", aiBodyDto); + return R.ok(aiBodyDto); } @PostMapping("/strategy") - public AiBodyDto strategy(@RequestBody AiRequestVo aiRequestVo) { + public R<AiBodyDto> strategy(@RequestBody AiRequestVo aiRequestVo) { String postUrl = url + "v1/workflows/run"; String s = ""; AiBodyDto aiBodyDto = new AiBodyDto(); @@ -91,7 +96,8 @@ } } } - return aiBodyDto; + log.info("xsd:{}", aiBodyDto); + return R.ok(aiBodyDto); } private Map<String, String> initHead(String token) { -- Gitblit v1.8.0