四合一语料解析增加入参

This commit is contained in:
zren25
2025-04-07 17:44:21 +08:00
parent 42030322eb
commit ad39e8cb63
2 changed files with 39 additions and 52 deletions

View File

@@ -7,7 +7,6 @@ import com.volvo.ai.analytic.center.dto.req.FourInOneRequestDTO;
import com.volvo.ai.analytic.center.service.AiAnalysisRequestLogsService; import com.volvo.ai.analytic.center.service.AiAnalysisRequestLogsService;
import com.volvo.ai.analytic.center.service.IntelligentCustomerService; import com.volvo.ai.analytic.center.service.IntelligentCustomerService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.rocketmq.common.message.MessageExt; import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener; import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener; import org.apache.rocketmq.spring.core.RocketMQListener;
@@ -15,8 +14,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope; import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
/** /**
@@ -67,21 +64,5 @@ public class IntelligentCustomerMqConsumer implements RocketMQListener<MessageEx
@PostMapping("intelligentCustomerMqConsumer")
public void intelligentCustomerMqConsumer(@RequestBody String message) {
long startTime = System.currentTimeMillis();
try {
log.info("intelligentCustomerMqConsumer 当前线程: {}, 线程ID: {}", Thread.currentThread().getName(), Thread.currentThread().getId());
log.info("IntelligentCustomerMqConsumer message: " + message);
FourInOneRequestDTO fourRequestDTO = objectMapper.readValue(message, FourInOneRequestDTO.class);
if(null != fourRequestDTO && StringUtils.isNotEmpty(fourRequestDTO.getWorkOrderContent()) && StringUtils.isNotEmpty(fourRequestDTO.getWorkOrderSource())){
intelligentCustomerService.fourInOneMqService(fourRequestDTO);
log.info("FourInOneRequestDTO处理完成耗时{}", System.currentTimeMillis() - startTime);
}
} catch (JsonProcessingException e) {
log.info(" dcc mq 处理失败:{}", e.getMessage());
}
}
} }

View File

@@ -89,13 +89,13 @@ public class IntelligentCustomerServiceImpl implements IntelligentCustomerServic
RunMaskingRuleInput runMaskingRuleInput = new RunMaskingRuleInput(); RunMaskingRuleInput runMaskingRuleInput = new RunMaskingRuleInput();
runMaskingRuleInput.setDataMaskingRules(maskingRuleItems); runMaskingRuleInput.setDataMaskingRules(maskingRuleItems);
String yuliao = StringUtils.isNotEmpty(fourInOneRequestDTO.getRelationCorpusContent())?fourInOneRequestDTO.getRelationCorpusContent().concat(" \n ").concat(fourInOneRequestDTO.getWorkOrderContent()):fourInOneRequestDTO.getWorkOrderContent();
Map<String, Object> inputMap = new HashMap(); Map<String, Object> inputMap = new HashMap();
DiFyReq diFyImageReq = new DiFyReq(); DiFyReq diFyImageReq = new DiFyReq();
diFyImageReq.setUser(ConstantStr.INTELLIGENT_CUSTOMER_4IN1); diFyImageReq.setUser(ConstantStr.INTELLIGENT_CUSTOMER_4IN1);
diFyImageReq.setFlowId(fourInOneToken); diFyImageReq.setFlowId(fourInOneToken);
inputMap.put("yuliao", yuliao); inputMap.put("workOrderContent", fourInOneRequestDTO.getWorkOrderContent());
inputMap.put("relationCorpusContent", fourInOneRequestDTO.getRelationCorpusContent());
inputMap.put("laiyuan",fourInOneRequestDTO.getWorkOrderSource()); inputMap.put("laiyuan",fourInOneRequestDTO.getWorkOrderSource());
diFyImageReq.setInputs(inputMap); diFyImageReq.setInputs(inputMap);
@@ -104,8 +104,13 @@ public class IntelligentCustomerServiceImpl implements IntelligentCustomerServic
log.info("runDify execDifyFlow {}",execDifyFlow); log.info("runDify execDifyFlow {}",execDifyFlow);
if(null != execDifyFlow && execDifyFlow.get("status").equals("succeeded")){ if(null != execDifyFlow && execDifyFlow.get("status").equals("succeeded")){
String aiAnalysisRequestId = null;
String message = null;
try {
JSONObject textJsonObject = execDifyFlow.getJSONObject("outputs").getJSONObject("text"); JSONObject textJsonObject = execDifyFlow.getJSONObject("outputs").getJSONObject("text");
// JSONObject consult = textJsonObject.getJSONObject("answer"); // 咨询 if(textJsonObject.containsKey("answer")){
textJsonObject = execDifyFlow.getJSONObject("outputs").getJSONObject("text").getJSONObject("answer"); // 投诉
}
ConsultDTO consultDTO = new ConsultDTO(); ConsultDTO consultDTO = new ConsultDTO();
consultDTO.setOrderType(fourInOneMqServiceFilter(IntelligentCustomerTypeEnum.CONSULT.getCode(),textJsonObject.getString("工单类别"))); consultDTO.setOrderType(fourInOneMqServiceFilter(IntelligentCustomerTypeEnum.CONSULT.getCode(),textJsonObject.getString("工单类别")));
consultDTO.setProblemDescription(textJsonObject.getString("问题描述")); consultDTO.setProblemDescription(textJsonObject.getString("问题描述"));
@@ -114,27 +119,28 @@ public class IntelligentCustomerServiceImpl implements IntelligentCustomerServic
consultDTO.setContactTelephone(textJsonObject.getString("工单联系电话")); consultDTO.setContactTelephone(textJsonObject.getString("工单联系电话"));
JSONObject complainObject = execDifyFlow.getJSONObject("outputs").getJSONObject("text1"); JSONObject complainObject = execDifyFlow.getJSONObject("outputs").getJSONObject("text1");
if(complainObject.containsKey("answer")){
JSONObject complain = complainObject.getJSONObject("answer"); // 投诉 complainObject = execDifyFlow.getJSONObject("outputs").getJSONObject("text1").getJSONObject("answer"); // 投诉
}
ComplainDTO complainDTO = new ComplainDTO(); ComplainDTO complainDTO = new ComplainDTO();
complainDTO.setComplainType(fourInOneMqServiceFilter(IntelligentCustomerTypeEnum.CONSULT_TYPE.getCode(),complain.getString("投诉类型"))); complainDTO.setComplainType(fourInOneMqServiceFilter(IntelligentCustomerTypeEnum.CONSULT_TYPE.getCode(),complainObject.getString("投诉类型")));
complainDTO.setOrderType(fourInOneMqServiceFilter(IntelligentCustomerTypeEnum.COMPLAIN.getCode(),complain.getString("工单类别"))); complainDTO.setOrderType(fourInOneMqServiceFilter(IntelligentCustomerTypeEnum.COMPLAIN.getCode(),complainObject.getString("工单类别")));
complainDTO.setComplainTitle(complain.getString("投诉主题")); complainDTO.setComplainTitle(complainObject.getString("投诉主题"));
complainDTO.setProblemDescription(complain.getString("问题描述")); complainDTO.setProblemDescription(complainObject.getString("问题描述"));
complainDTO.setContactSex(consultDTO.getContactSex()); complainDTO.setContactSex(consultDTO.getContactSex());
complainDTO.setContactName(consultDTO.getContactName()); complainDTO.setContactName(consultDTO.getContactName());
complainDTO.setContactTelephone(consultDTO.getContactTelephone()); complainDTO.setContactTelephone(consultDTO.getContactTelephone());
FourInOneResponseDTO fourInOneResponseDTO = new FourInOneResponseDTO(); FourInOneResponseDTO fourInOneResponseDTO = new FourInOneResponseDTO();
String aiAnalysisRequestId = execDifyFlow.getString("aiAnalysisRequestId"); aiAnalysisRequestId = execDifyFlow.getString("aiAnalysisRequestId");
fourInOneResponseDTO.setAiAnalysisRequestId(aiAnalysisRequestId); fourInOneResponseDTO.setAiAnalysisRequestId(aiAnalysisRequestId);
fourInOneResponseDTO.setComplain(complainDTO); fourInOneResponseDTO.setComplain(complainDTO);
fourInOneResponseDTO.setConsult(consultDTO); fourInOneResponseDTO.setConsult(consultDTO);
fourInOneResponseDTO.setWorkOrderId(fourInOneRequestDTO.getWorkOrderId()); fourInOneResponseDTO.setWorkOrderId(fourInOneRequestDTO.getWorkOrderId());
// 发送MQ // 发送MQ
String message = JSONObject.toJSONString(fourInOneResponseDTO); message = JSONObject.toJSONString(fourInOneResponseDTO);
log.info("send mq {}",message); log.info("send mq {}",message);
sendMq(message); sendMq(message);
try {
if(StringUtils.isNotEmpty(fourInOneRequestDTO.getAiAnalysisRequestId())){ if(StringUtils.isNotEmpty(fourInOneRequestDTO.getAiAnalysisRequestId())){
AiAnalysisErrors aiAnalysisErrors = new AiAnalysisErrors(); AiAnalysisErrors aiAnalysisErrors = new AiAnalysisErrors();
aiAnalysisErrors.setAiAnalysisRequestId(aiAnalysisRequestId); aiAnalysisErrors.setAiAnalysisRequestId(aiAnalysisRequestId);
@@ -144,7 +150,7 @@ public class IntelligentCustomerServiceImpl implements IntelligentCustomerServic
aiAnalysisRequestLogsService.saveAiAnalysisRequestLogs(AiAnalysisRequestLogs.builder().aiAnalysisRequestId(execDifyFlow.getString("aiAnalysisRequestId")).businessResponse(message).build()); aiAnalysisRequestLogsService.saveAiAnalysisRequestLogs(AiAnalysisRequestLogs.builder().aiAnalysisRequestId(execDifyFlow.getString("aiAnalysisRequestId")).businessResponse(message).build());
} catch (Exception e) { } catch (Exception e) {
log.info(" 电话语料处理保存报告异常processItem{} ", e); log.error("四合一语料解析返回数据JSON格式化异常 {}", e);
} }
} }
} }