测试controller
This commit is contained in:
@@ -158,6 +158,26 @@
|
||||
<version>1.0.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.rocketmq</groupId>
|
||||
<artifactId>rocketmq-spring-boot-starter</artifactId>
|
||||
<version>2.2.3</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.apache.rocketmq</groupId>
|
||||
<artifactId>rocketmq-client</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.rocketmq</groupId>
|
||||
<artifactId>rocketmq-client</artifactId>
|
||||
<version>5.0.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.volvo.ai.analytic.center.controller;
|
||||
|
||||
import com.volvo.ai.analytic.center.constant.Constant;
|
||||
import com.volvo.ai.analytic.center.dto.req.RunMaskingRuleInput;
|
||||
import com.volvo.ai.analytic.center.entity.DataMaskingRule;
|
||||
import com.volvo.ai.analytic.center.service.DataMaskingRuleService;
|
||||
import com.volvo.common.core.util.ResultMsg;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@Api(tags = "脱敏类API")
|
||||
@RequestMapping("/dataMasking")
|
||||
@Slf4j
|
||||
public class DataMaskingController {
|
||||
|
||||
@Autowired
|
||||
private DataMaskingRuleService dataMaskingRuleService;
|
||||
|
||||
@PostMapping("/runMaskingRule")
|
||||
@ApiOperation(value = "执行文字脱敏")
|
||||
public ResultMsg<String> runMaskingRule(@RequestBody String contentStr) {
|
||||
log.info("输入需要脱敏的文字信息为 {}", contentStr);
|
||||
List<DataMaskingRule> maskingRuleItems = dataMaskingRuleService.getDataMaskingRuleListByApplicationChannel(Constant.CHANNEL_DCC);
|
||||
if (CollectionUtils.isEmpty(maskingRuleItems)){
|
||||
log.info("没有找到脱敏规则");
|
||||
return ResultMsg.failed("没有找到脱敏规则");
|
||||
}
|
||||
log.info("开始脱敏 {}", contentStr);
|
||||
RunMaskingRuleInput runMaskingRuleInput = new RunMaskingRuleInput();
|
||||
runMaskingRuleInput.setOldStr(contentStr);
|
||||
runMaskingRuleInput.setDataMaskingRules(maskingRuleItems);
|
||||
String summaryText = dataMaskingRuleService.runMaskingRule(runMaskingRuleInput);
|
||||
log.info("脱敏结果 {}", summaryText);
|
||||
return ResultMsg.ok(summaryText);
|
||||
}
|
||||
}
|
||||
@@ -13,8 +13,11 @@ 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 lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@@ -23,14 +26,10 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author wmm
|
||||
* @since 2023-03-14
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "社区配置表API", description ="社区配置表")
|
||||
@Api(tags = "测试类API")
|
||||
@RequestMapping("/test")
|
||||
@Slf4j
|
||||
public class TestController {
|
||||
|
||||
@Autowired
|
||||
@@ -42,27 +41,22 @@ public class TestController {
|
||||
@Autowired
|
||||
private MqMessageRecordService mqMessageRecordService;
|
||||
|
||||
@PostMapping("/runWorkflows")
|
||||
@ApiOperation(value = "测试Dify")
|
||||
public ResultMsg<Object> runWorkflows() {
|
||||
Map<String, Object> record = new HashMap<>();
|
||||
record.put("record","(1)语音电话(2024-11-09 12:10:57)客服:哎,哎,姚先生,你好打扰到您了,蹦蹦沃沃赛练呢。客户:喂你好。客服:哎,对对,小明那个昨天看了车不要着急走,今天可有时间到店来接待您试驾感受一下呢。客户:我现在已经开工了,我现在没时间过去啊。客服:好的,那等你忙完这段时间好吧。客户:好的,好的,好的好,再见啊。客服:好,那这边先不打扰您,哎,好,再见。");
|
||||
Map<String, Object> 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));
|
||||
}
|
||||
@Value("${service.dify.user}")
|
||||
private String user;
|
||||
|
||||
@Value("${service.dify.flowId}")
|
||||
private String flowId;
|
||||
|
||||
|
||||
@PostMapping("/runWorkflows2")
|
||||
@ApiOperation(value = "测试Dify")
|
||||
public ResultMsg<Object> runWorkflows2() {
|
||||
String summaryText = "(1)语音电话(2024-11-09 12:10:57)客服:哎,哎,姚先生,你好打扰到您了,蹦蹦沃沃赛练呢。客户:喂你好。客服:哎,对对,小明那个昨天看了车不要着急走,今天可有时间到店来接待您试驾感受一下呢。客户:我现在已经开工了,我现在没时间过去啊。客服:好的,那等你忙完这段时间好吧。客户:好的,好的,好的好,再见啊。客服:好,那这边先不打扰您,哎,好,再见。";
|
||||
public ResultMsg<Object> runWorkflows2(@RequestBody String contentStr) {
|
||||
//"(1)语音电话(2024-11-09 12:10:57)客服:哎,哎,姚先生,你好打扰到您了,蹦蹦沃沃赛练呢。客户:喂你好。客服:哎,对对,小明那个昨天看了车不要着急走,今天可有时间到店来接待您试驾感受一下呢。客户:我现在已经开工了,我现在没时间过去啊。客服:好的,那等你忙完这段时间好吧。客户:好的,好的,好的好,再见啊。客服:好,那这边先不打扰您,哎,好,再见。";
|
||||
Map<String, Object> record = new HashMap<>();
|
||||
record.put("record",summaryText);
|
||||
record.put("record",contentStr);
|
||||
DiFyReq diFyReq = new DiFyReq();
|
||||
diFyReq.setUser("voc");
|
||||
diFyReq.setFlowId("app-MVGxogM08CDCg7jMo7GNF6eS");
|
||||
diFyReq.setUser(user);
|
||||
diFyReq.setFlowId(flowId);
|
||||
diFyReq.setInputs(record);
|
||||
Object difyResult = diFyService.getDiFyObject(diFyReq);
|
||||
JSONObject dify = JSONObject.parseObject(difyResult.toString());
|
||||
@@ -72,60 +66,25 @@ public class TestController {
|
||||
|
||||
@PostMapping("/runWorkflows3")
|
||||
@ApiOperation(value = "测试Dify")
|
||||
public ResultMsg<Object> runWorkflows3() {
|
||||
|
||||
List<CallItem> 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);
|
||||
public ResultMsg<Object> runWorkflows3(@RequestBody String contentStr) {
|
||||
//[{"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"}]
|
||||
log.info("contentStr {}", contentStr);
|
||||
List<CallItem> callList = JSON.parseArray(contentStr, CallItem.class);
|
||||
DiffDefeatanAlysis input = new DiffDefeatanAlysis();
|
||||
input.setCallList(callList);
|
||||
DiffDefeatAnalyseOutputResult diffDefeatAnalyseOutputResult = mqMessageRecordService.processChatRecord(input);
|
||||
|
||||
return ResultMsg.ok("");
|
||||
return ResultMsg.ok(diffDefeatAnalyseOutputResult);
|
||||
}
|
||||
|
||||
@PostMapping("/runWorkflows4")
|
||||
@ApiOperation(value = "测试Dify")
|
||||
public ResultMsg<Object> runWorkflows4() {
|
||||
public ResultMsg<Object> runWorkflows4(@RequestBody String contentStr) {
|
||||
|
||||
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);
|
||||
//{"formId": "123456789","sinceType": 2,"subSinceType": 51,"data": {"businessId": "123456789","vdqwUserId": "XX","vdqwCustomerId": "uuid","defeatTime": "2024-10-27 08:09:09","callList": [{"sessionId": "123456789","sourceId": "123456789","audioTime": "2024-10-27 08:09:09","audioBillsec": 1800}, {"sessionId": "123456789","sourceId": "123456789","audioTime": "2024-10-27 08:09:09","audioBillsec": 1800}]} }
|
||||
//{"formId": "123456789","sinceType": 2,"subSinceType": 52,"data": {"businessId": "123456789", "approveCode": "10001", "approveResult": "审批通过", "approveOpinion": "" } }
|
||||
log.info("contentStr {}", contentStr);
|
||||
boolean result = mqMessageRecordService.processMessageByMQ(contentStr);
|
||||
return ResultMsg.ok(result);
|
||||
}
|
||||
|
||||
@PostMapping("/runWorkflows5")
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.volvo.ai.analytic.center.mq;
|
||||
|
||||
import com.volvo.ai.analytic.center.service.MqMessageRecordService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.rocketmq.common.message.MessageExt;
|
||||
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
|
||||
import org.apache.rocketmq.spring.core.RocketMQListener;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
@RocketMQMessageListener(consumerGroup = "${rocketmq.consumer.group}",
|
||||
topic = "${rocketmq.consumer.topic}",
|
||||
enableMsgTrace = true)
|
||||
public class LtoMessageConsumer implements RocketMQListener<MessageExt>{
|
||||
|
||||
@Autowired
|
||||
private MqMessageRecordService mqMessageRecordService;
|
||||
|
||||
@Override
|
||||
public void onMessage(MessageExt messageExt) {
|
||||
log.info("Received message: " + messageExt);
|
||||
mqMessageRecordService.processMessageByMQ(new String(messageExt.getBody()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
//package com.volvo.ai.analytic.center.mq;
|
||||
//
|
||||
//
|
||||
//import com.volvo.ai.analytic.center.constant.Constant;
|
||||
//import com.volvo.ai.analytic.center.service.MqMessageRecordService;
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
////import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//
|
||||
//@Slf4j
|
||||
//@Component
|
||||
//public class MessageListener {
|
||||
//
|
||||
// /* @Autowired
|
||||
// private MqMessageRecordService mqMessageRecordService;
|
||||
//
|
||||
// //默认情况下,当使用@RabbitListener注解时,消息确认模式通常是自动的(AcknowledgeMode.AUTO)可以在yaml文件中更改,
|
||||
// // 消息一旦被消费者接收并处理完成(即方法执行完成),就会自动发送ack确认给RabbitMQ。
|
||||
// @RabbitListener(queues = Constant.rabbitMqFormQueue)
|
||||
// public void onMessage(String message) {
|
||||
// log.info("Received message: " + message);
|
||||
// boolean result = mqMessageRecordService.processMessageByMQ(message);
|
||||
// }*/
|
||||
//}
|
||||
@@ -1,25 +0,0 @@
|
||||
package com.volvo.ai.analytic.center.rabbitMq;
|
||||
|
||||
|
||||
import com.volvo.ai.analytic.center.constant.Constant;
|
||||
import com.volvo.ai.analytic.center.service.MqMessageRecordService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
//import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class MessageListener {
|
||||
|
||||
/* @Autowired
|
||||
private MqMessageRecordService mqMessageRecordService;
|
||||
|
||||
//默认情况下,当使用@RabbitListener注解时,消息确认模式通常是自动的(AcknowledgeMode.AUTO)可以在yaml文件中更改,
|
||||
// 消息一旦被消费者接收并处理完成(即方法执行完成),就会自动发送ack确认给RabbitMQ。
|
||||
@RabbitListener(queues = Constant.rabbitMqFormQueue)
|
||||
public void onMessage(String message) {
|
||||
log.info("Received message: " + message);
|
||||
boolean result = mqMessageRecordService.processMessageByMQ(message);
|
||||
}*/
|
||||
}
|
||||
@@ -19,6 +19,7 @@ import com.volvo.ai.analytic.center.service.DiffdefeatApproveService;
|
||||
import com.volvo.ai.analytic.center.service.MqMessageRecordService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
//import org.springframework.amqp.core.AmqpTemplate;
|
||||
import org.apache.rocketmq.spring.core.RocketMQTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
@@ -50,12 +51,18 @@ public class MqMessageRecordServiceImpl extends ServiceImpl<MqMessageRecordMappe
|
||||
@Autowired
|
||||
private JdbcTemplate clickhouseJdbcTemplate;
|
||||
|
||||
@Autowired
|
||||
private RocketMQTemplate rocketMQTemplate;
|
||||
|
||||
@Value("${service.dify.user}")
|
||||
private String user;
|
||||
|
||||
@Value("${service.dify.flowId}")
|
||||
private String flowId;
|
||||
|
||||
@Value("${rocketmq.producer.topic}")
|
||||
private String topic;
|
||||
|
||||
/**
|
||||
* 处理Mq消息
|
||||
* @param message 消息具体内容
|
||||
@@ -167,9 +174,6 @@ public class MqMessageRecordServiceImpl extends ServiceImpl<MqMessageRecordMappe
|
||||
public DiffDefeatAnalyseOutputResult processChatRecord(DiffDefeatanAlysis input) {
|
||||
DiffDefeatAnalyseOutput output = new DiffDefeatAnalyseOutput();
|
||||
StringBuffer contentStr = new StringBuffer();
|
||||
//获取脱敏配置信息
|
||||
List<DataMaskingRule> maskingRuleItems = dataMaskingRuleService.getDataMaskingRuleListByApplicationChannel(Constant.CHANNEL_DCC);
|
||||
|
||||
List<DiffDefeatCorpuItem> curDiffDefeatCorpItems = new ArrayList<>();
|
||||
// 根据SourceId查询通话信息
|
||||
List<String> sourceIds = Optional.ofNullable(input.getCallList()).map(list -> list.stream().map(CallItem::getSourceId).collect(Collectors.toList())).orElse(Collections.emptyList());
|
||||
@@ -273,6 +277,9 @@ public class MqMessageRecordServiceImpl extends ServiceImpl<MqMessageRecordMappe
|
||||
output.setResultStr(HandleStatusEnum.ANALYSIS_CONTENT_EMPTY.getMessage());
|
||||
return new DiffDefeatAnalyseOutputResult(output, contentStr.toString());
|
||||
}
|
||||
//获取脱敏配置信息
|
||||
List<DataMaskingRule> maskingRuleItems = dataMaskingRuleService.getDataMaskingRuleListByApplicationChannel(Constant.CHANNEL_DCC);
|
||||
|
||||
log.info("开始脱敏 {}", contentStr);
|
||||
RunMaskingRuleInput runMaskingRuleInput = new RunMaskingRuleInput();
|
||||
runMaskingRuleInput.setOpinionId(input.getBusinessId());
|
||||
@@ -463,6 +470,7 @@ public class MqMessageRecordServiceImpl extends ServiceImpl<MqMessageRecordMappe
|
||||
rabbitMqToData.setData(curDiffDefeatCallback);
|
||||
String callbackInput = JSONObject.toJSONString(rabbitMqToData);
|
||||
// rabbitTemplate.convertAndSend(Constant.rabbitToFormQueue, callbackInput);
|
||||
rocketMQTemplate.syncSend(topic, callbackInput);
|
||||
log.info("发送回调MQ完成: {}", callbackInput);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,3 +53,13 @@ service:
|
||||
url: https://artera-uat.digitalvolvo.com
|
||||
user: voc
|
||||
flowId: app-MVGxogM08CDCg7jMo7GNF6eS
|
||||
|
||||
rocketmq:
|
||||
# name-server: 10.37.125.142:8100;10.37.125.147:8100
|
||||
name-server: 10.37.158.123:8100
|
||||
consumer:
|
||||
group: xx
|
||||
topic: xx
|
||||
producer:
|
||||
group: xx
|
||||
topic: xx
|
||||
Reference in New Issue
Block a user