From ecde47d07ad23a9215717801c8a1e0484e9311b2 Mon Sep 17 00:00:00 2001 From: zhangfan Date: Mon, 23 Dec 2024 17:29:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95controller?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../center/controller/TestController.java | 138 ++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100644 ai-analytic-center-biz/src/main/java/com/volvo/ai/analytic/center/controller/TestController.java diff --git a/ai-analytic-center-biz/src/main/java/com/volvo/ai/analytic/center/controller/TestController.java b/ai-analytic-center-biz/src/main/java/com/volvo/ai/analytic/center/controller/TestController.java new file mode 100644 index 0000000..5825e18 --- /dev/null +++ b/ai-analytic-center-biz/src/main/java/com/volvo/ai/analytic/center/controller/TestController.java @@ -0,0 +1,138 @@ +package com.volvo.ai.analytic.center.controller; + + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.volvo.ai.analytic.center.dto.req.CallItem; +import com.volvo.ai.analytic.center.dto.req.DiFyReq; +import com.volvo.ai.analytic.center.dto.req.DiffDefeatanAlysis; +import com.volvo.ai.analytic.center.dto.resp.DiffDefeatAnalyseOutputResult; +import com.volvo.ai.analytic.center.feign.DiFyFeign; +import com.volvo.ai.analytic.center.service.DiFyService; +import com.volvo.ai.analytic.center.service.MqMessageRecordService; +import com.volvo.common.core.util.ResultMsg; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + +/** + * + * @author wmm + * @since 2023-03-14 + */ +@RestController +@Api(tags = "社区配置表API", description ="社区配置表") +@RequestMapping("/test") +public class TestController { + + @Autowired + private DiFyFeign diFyFeign; + + @Autowired + private DiFyService diFyService; + + @Autowired + private MqMessageRecordService mqMessageRecordService; + + @PostMapping("/runWorkflows") + @ApiOperation(value = "测试Dify") + public ResultMsg runWorkflows() { + Map record = new HashMap<>(); + record.put("record","(1)语音电话(2024-11-09 12:10:57)客服:哎,哎,姚先生,你好打扰到您了,蹦蹦沃沃赛练呢。客户:喂你好。客服:哎,对对,小明那个昨天看了车不要着急走,今天可有时间到店来接待您试驾感受一下呢。客户:我现在已经开工了,我现在没时间过去啊。客服:好的,那等你忙完这段时间好吧。客户:好的,好的,好的好,再见啊。客服:好,那这边先不打扰您,哎,好,再见。"); + Map map = new HashMap<>(); + map.put("inputs",record); + map.put("response_mode","blocking"); + map.put("user","abc-123"); + return ResultMsg.ok(diFyFeign.runWorkflows("Bearer app-MVGxogM08CDCg7jMo7GNF6eS",map)); + } + + @PostMapping("/runWorkflows2") + @ApiOperation(value = "测试Dify") + public ResultMsg runWorkflows2() { + String summaryText = "(1)语音电话(2024-11-09 12:10:57)客服:哎,哎,姚先生,你好打扰到您了,蹦蹦沃沃赛练呢。客户:喂你好。客服:哎,对对,小明那个昨天看了车不要着急走,今天可有时间到店来接待您试驾感受一下呢。客户:我现在已经开工了,我现在没时间过去啊。客服:好的,那等你忙完这段时间好吧。客户:好的,好的,好的好,再见啊。客服:好,那这边先不打扰您,哎,好,再见。"; + Map record = new HashMap<>(); + record.put("record",summaryText); + DiFyReq diFyReq = new DiFyReq(); + diFyReq.setUser("voc"); + diFyReq.setFlowId("app-MVGxogM08CDCg7jMo7GNF6eS"); + diFyReq.setInputs(record); + Object difyResult = diFyService.getDiFyObject(diFyReq); + JSONObject dify = JSONObject.parseObject(difyResult.toString()); + String resultStr = dify.getString("result").replace("\n", "").replaceAll(" ", ""); + return ResultMsg.ok(resultStr); + } + + @PostMapping("/runWorkflows3") + @ApiOperation(value = "测试Dify") + public ResultMsg runWorkflows3() { + + List callList = JSON.parseArray("[{\"sessionId\":\"1\",\"sourceId\":\"1\",\"audioTime\":\"2024-11-09 12:10:57\",\"audioBillsec\":\"10\"},{\"sessionId\":\"2\",\"sourceId\":\"2\",\"audioTime\":\"2024-11-09 12:11:57\",\"audioBillsec\":\"20\"}]", CallItem.class); + DiffDefeatanAlysis input = new DiffDefeatanAlysis(); + input.setCallList(callList); + DiffDefeatAnalyseOutputResult diffDefeatAnalyseOutputResult = mqMessageRecordService.processChatRecord(input); + + return ResultMsg.ok(""); + } + + @PostMapping("/runWorkflows4") + @ApiOperation(value = "测试Dify") + public ResultMsg runWorkflows4() { + + String input = "{\n" + + " \"formId\": \"123456789\",\n" + + " \"sinceType\": 2,\n" + + " \"subSinceType\": 51,\n" + + " \"data\": {\n" + + " \"businessId\": \"123456789\",\n" + + " \"vdqwUserId\": \"XX\",\n" + + " \"vdqwCustomerId\": \"uuid\",\n" + + " \"defeatTime\": \"2024-10-27 08:09:09\",\n" + + " \"callList\": [{\n" + + " \"sessionId\": \"123456789\",\n" + + " \"sourceId\": \"123456789\",\n" + + " \"audioTime\": \"2024-10-27 08:09:09\",\n" + + " \"audioBillsec\": 1800\n" + + " }, {\n" + + " \"sessionId\": \"123456789\",\n" + + " \"sourceId\": \"123456789\",\n" + + " \"audioTime\": \"2024-10-27 08:09:09\",\n" + + " \"audioBillsec\": 1800\n" + + " }]\n" + + " }\n" + + "}"; + boolean result = mqMessageRecordService.processMessageByMQ(input); + + String input2 = "{\n" + + "\n" + + " \"formId\": \"123456789\",\n" + + " \"sinceType\": 2,\n" + + " \"subSinceType\": 52,\n" + + " \"data\": {\n" + + " \"businessId\": \"123456789\",\n" + + "\n" + + " \"approveCode\": \"10001\",\n" + + " \"approveResult\": \"审批通过\",\n" + + " \"approveOpinion\": \"\"\n" + + " }\n" + + "}"; + boolean result2 = mqMessageRecordService.processMessageByMQ(input2); + + return ResultMsg.ok(result+"--"+result2); + } + + @PostMapping("/runWorkflows5") + @ApiOperation(value = "补偿处理消息") + public ResultMsg runWorkflows5() { + mqMessageRecordService.processMessageByTask(); + return ResultMsg.ok(""); + } +} +