调整画像mq,添加备注
This commit is contained in:
@@ -93,4 +93,29 @@ public class QiWeiCorpusJob {
|
||||
}
|
||||
|
||||
|
||||
@XxlJob("dccCorpusFailRetryForPortrait")
|
||||
@PostMapping("dccCorpusFailRetryForPortrait")
|
||||
public ResultMsg dccCorpusFailRetryForPortrait(@RequestBody String paramJson) {
|
||||
try {
|
||||
// 获取任务参数
|
||||
String param = XxlJobHelper.getJobParam();
|
||||
if(StringUtils.isEmpty(param)){
|
||||
param = paramJson;
|
||||
}
|
||||
// 执行业务逻辑
|
||||
XxlJobHelper.log("dccCorpusFailRetry任务参数: {}", param);
|
||||
List<AicorpusTelephoneDTO> corpusDtoList = tmTelephoneCorpusMapper.queryTelephoneCorpusBySourceIds( Arrays.asList(param.split(",")));
|
||||
corpusDtoList.stream().forEach(item->
|
||||
{
|
||||
corpusPortraitService.portraitDcc(item);
|
||||
}
|
||||
);
|
||||
} catch (Exception e) {
|
||||
log.error("processMessageByTask 定时任务补偿处理消息异常",e.getMessage());
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return ResultMsg.ok();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.volvo.ai.analytic.center.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.huaweicloud.sdk.eg.v1.model.CloudEvents;
|
||||
import com.volvo.ai.analytic.center.dto.corpus.AicorpusTelephoneDTO;
|
||||
@@ -14,6 +15,7 @@ import com.volvo.ai.analytic.center.dto.resp.ResultDTO;
|
||||
import com.volvo.ai.analytic.center.entity.*;
|
||||
import com.volvo.ai.analytic.center.enums.BizEnum;
|
||||
import com.volvo.ai.analytic.center.enums.BusinessTypeEnum;
|
||||
import com.volvo.ai.analytic.center.enums.CategoryEnum;
|
||||
import com.volvo.ai.analytic.center.feign.CompetingBrandsClient;
|
||||
import com.volvo.ai.analytic.center.mapper.TmOdsVdqwMessagearchivingMapper;
|
||||
import com.volvo.ai.analytic.center.service.*;
|
||||
@@ -98,32 +100,71 @@ public class CorpusPortraitServiceImpl implements CorpusPortraitService {
|
||||
diFyImageReq.setUser(ConstantStr.corpus_user);
|
||||
diFyImageReq.setFlowId(dccToken);
|
||||
|
||||
|
||||
String chatContent = tmTelephoneCorpusService.processChatSegments(aicorpusTelephone.getDisplay(), maskingRuleItems);
|
||||
if (chatContent == null) {
|
||||
JSONObject jsonObject = JSONObject.parseObject( aicorpusTelephone.getDisplay());
|
||||
JSONArray segments = jsonObject.getJSONArray("segments");
|
||||
Long audioDuration = jsonObject.getLong("audio_duration"); // 毫秒
|
||||
if(audioDuration/1000 <=10){
|
||||
log.info("电话语料时长小于10秒,不进行dify处理");
|
||||
return;
|
||||
}
|
||||
if (segments == null || segments.isEmpty()) {
|
||||
log.info("电话语料内容segments为空,不进行dify处理");
|
||||
return;
|
||||
}
|
||||
// 遍历 segments
|
||||
StringBuffer chatList = new StringBuffer();
|
||||
segments.stream()
|
||||
.map(segment -> (JSONObject) segment)
|
||||
.forEach(segment -> {
|
||||
JSONObject result = segment.getJSONObject("result");
|
||||
String text = result.getString("text");
|
||||
JSONObject analysisInfo = result.getJSONObject("analysis_info");
|
||||
String role = analysisInfo.getString("role");
|
||||
String title="";
|
||||
if(role.equals("AGENT")){
|
||||
title="顾问";
|
||||
}else{
|
||||
title="客户";
|
||||
}
|
||||
// 拼接 role 和 text
|
||||
String chat = title + ": " + text;
|
||||
runMaskingRuleInput.setOldStr(chat);
|
||||
String corpusChat = dataMaskingRuleService.runMaskingRule(runMaskingRuleInput);
|
||||
chatList.append(corpusChat).append("\n");
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
ZonedDateTime zonedDateTime = ZonedDateTime.parse(JSONObject.parseObject(aicorpusTelephone.getDisplay()).getString("start_time"));
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
String formattedDateStartTime = zonedDateTime.format(formatter);
|
||||
inputMap.put("chat", chatContent);
|
||||
inputMap.put("chat", chatList);
|
||||
inputMap.put("recordId", aicorpusTelephone.getSourceId());
|
||||
inputMap.put("communicateDate", formattedDateStartTime);
|
||||
inputMap.put("brand",getBrand());
|
||||
inputMap.put("brandSeries",getSeriesByBrandId());
|
||||
inputMap.put("customerFlowId", aicorpusTelephone.getSourceId());
|
||||
|
||||
diFyImageReq.setInputs(inputMap);
|
||||
|
||||
CorpusReportDTO corpusReportDTO = new CorpusReportDTO();
|
||||
corpusReportDTO.setCorpusTime(formattedDateStartTime);
|
||||
corpusReportDTO.setRecordId(aicorpusTelephone.getSourceId());
|
||||
corpusReportDTO.setAnalysisScene(2l);
|
||||
|
||||
|
||||
// 获取配置
|
||||
JSONObject execDifyFlow = diFyService.executeDifyFlow(diFyImageReq, BusinessTypeEnum.CORPUS_PORTRAIT_DCC.getCode(), JSONObject.toJSONString(corpusReportDTO), aicorpusTelephone.getAiAnalysisRequestId());
|
||||
log.info("runDify execDifyFlow {}", execDifyFlow);
|
||||
String aiAnalysisRequestId = execDifyFlow.getString("aiAnalysisRequestId");
|
||||
if (null != execDifyFlow && execDifyFlow.get("status").equals("succeeded")) {
|
||||
JSONObject text = execDifyFlow.getJSONObject("outputs");
|
||||
// huaWeiService.sendEvent(setCloudEvents(aiAnalysisRequestId, text.toJSONString(), "DCC"), ltoChannelId);
|
||||
// 发送MQ
|
||||
log.info("send mq ,DCC语料,画像场景 {}", text);
|
||||
tmTelephoneCorpusService.sendMq( BusinessTypeEnum.CORPUS_PORTRAIT_DCC.getCode(), text.toJSONString());
|
||||
|
||||
huaWeiService.sendEvent(setCloudEvents(aiAnalysisRequestId, text.toJSONString(), "DCC"), ltoChannelId);
|
||||
aiAnalysisRequestLogsService.saveAiAnalysisRequestLogs(AiAnalysisRequestLogs.builder().aiAnalysisRequestId(execDifyFlow.getString("aiAnalysisRequestId")).businessResponse(text.toJSONString()).build());
|
||||
}
|
||||
|
||||
@@ -223,7 +264,10 @@ public class CorpusPortraitServiceImpl implements CorpusPortraitService {
|
||||
if (null != execDifyFlow && execDifyFlow.get("status").equals("succeeded")) {
|
||||
JSONObject text = execDifyFlow.getJSONObject("outputs");
|
||||
|
||||
huaWeiService.sendEvent(setCloudEvents(aiAnalysisRequestId, text.toJSONString(),"QIWEI"),ltoChannelId);
|
||||
// huaWeiService.sendEvent(setCloudEvents(aiAnalysisRequestId, text.toJSONString(),"QIWEI"),ltoChannelId);
|
||||
log.info("send mq ,企微语料,画像场景 {}", text);
|
||||
tmTelephoneCorpusService.sendMq( BusinessTypeEnum.CORPUS_PORTRAIT_QIWEI.getCode(), text.toJSONString());
|
||||
|
||||
aiAnalysisRequestLogsService.saveAiAnalysisRequestLogs(AiAnalysisRequestLogs.builder().aiAnalysisRequestId(execDifyFlow.getString("aiAnalysisRequestId")).businessResponse(text.toJSONString()).build());
|
||||
}
|
||||
|
||||
@@ -270,7 +314,9 @@ public class CorpusPortraitServiceImpl implements CorpusPortraitService {
|
||||
if (null != execDifyFlow && execDifyFlow.get("status").equals("succeeded")) {
|
||||
JSONObject text = execDifyFlow.getJSONObject("outputs");
|
||||
|
||||
huaWeiService.sendEvent(setCloudEvents(aiAnalysisRequestId, text.toJSONString(),"NAMEPLATE"),ltoChannelId);
|
||||
// huaWeiService.sendEvent(setCloudEvents(aiAnalysisRequestId, text.toJSONString(),"NAMEPLATE"),ltoChannelId);
|
||||
log.info("send mq ,铭牌语料,画像场景 {}", text);
|
||||
tmTelephoneCorpusService.sendMq( BusinessTypeEnum.CORPUS_PORTRAIT_NAMEPLATE.getCode(), text.toJSONString());
|
||||
|
||||
aiAnalysisRequestLogsService.saveAiAnalysisRequestLogs(AiAnalysisRequestLogs.builder().aiAnalysisRequestId(execDifyFlow.getString("aiAnalysisRequestId")).businessResponse(text.toJSONString()).build());
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ public class TmTelephoneCorpusServiceImpl extends ServiceImpl<TmTelephoneCorpusM
|
||||
@Resource
|
||||
private RocketMQTemplate rocketMqTemplate;
|
||||
|
||||
@Value("${rocketmq.producer.corpus.topic}")
|
||||
@Value("${rocketmq.producer.corpus.topic}") //实际字符; ai_corpus_report_topic
|
||||
private String topic;
|
||||
@Value("${dify.corpus.telephoneToken}")
|
||||
private String telephoneToken;
|
||||
@@ -322,6 +322,7 @@ public class TmTelephoneCorpusServiceImpl extends ServiceImpl<TmTelephoneCorpusM
|
||||
|
||||
@Override
|
||||
public void sendMq(String tag, String message) {
|
||||
log.info("RocketMQ主题和标签: "+topic+":"+ tag);
|
||||
rocketMqTemplate.asyncSend(topic+":"+ tag, MessageBuilder.withPayload(message).build(),
|
||||
new SendCallback() {
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user