四合一语料解析增加入参
This commit is contained in:
@@ -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.IntelligentCustomerService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.rocketmq.common.message.MessageExt;
|
||||
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
|
||||
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.cloud.context.config.annotation.RefreshScope;
|
||||
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;
|
||||
|
||||
/**
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -89,13 +89,13 @@ public class IntelligentCustomerServiceImpl implements IntelligentCustomerServic
|
||||
|
||||
RunMaskingRuleInput runMaskingRuleInput = new RunMaskingRuleInput();
|
||||
runMaskingRuleInput.setDataMaskingRules(maskingRuleItems);
|
||||
String yuliao = StringUtils.isNotEmpty(fourInOneRequestDTO.getRelationCorpusContent())?fourInOneRequestDTO.getRelationCorpusContent().concat(" \n ").concat(fourInOneRequestDTO.getWorkOrderContent()):fourInOneRequestDTO.getWorkOrderContent();
|
||||
|
||||
Map<String, Object> inputMap = new HashMap();
|
||||
DiFyReq diFyImageReq = new DiFyReq();
|
||||
diFyImageReq.setUser(ConstantStr.INTELLIGENT_CUSTOMER_4IN1);
|
||||
diFyImageReq.setFlowId(fourInOneToken);
|
||||
inputMap.put("yuliao", yuliao);
|
||||
inputMap.put("workOrderContent", fourInOneRequestDTO.getWorkOrderContent());
|
||||
inputMap.put("relationCorpusContent", fourInOneRequestDTO.getRelationCorpusContent());
|
||||
inputMap.put("laiyuan",fourInOneRequestDTO.getWorkOrderSource());
|
||||
diFyImageReq.setInputs(inputMap);
|
||||
|
||||
@@ -104,37 +104,43 @@ public class IntelligentCustomerServiceImpl implements IntelligentCustomerServic
|
||||
log.info("runDify execDifyFlow {}",execDifyFlow);
|
||||
if(null != execDifyFlow && execDifyFlow.get("status").equals("succeeded")){
|
||||
|
||||
JSONObject textJsonObject = execDifyFlow.getJSONObject("outputs").getJSONObject("text");
|
||||
// JSONObject consult = textJsonObject.getJSONObject("answer"); // 咨询
|
||||
ConsultDTO consultDTO = new ConsultDTO();
|
||||
consultDTO.setOrderType(fourInOneMqServiceFilter(IntelligentCustomerTypeEnum.CONSULT.getCode(),textJsonObject.getString("工单类别")));
|
||||
consultDTO.setProblemDescription(textJsonObject.getString("问题描述"));
|
||||
consultDTO.setContactSex(textJsonObject.getString("工单联系人性别"));
|
||||
consultDTO.setContactName(textJsonObject.getString("工单联系人姓名"));
|
||||
consultDTO.setContactTelephone(textJsonObject.getString("工单联系电话"));
|
||||
|
||||
JSONObject complainObject = execDifyFlow.getJSONObject("outputs").getJSONObject("text1");
|
||||
|
||||
JSONObject complain = complainObject.getJSONObject("answer"); // 投诉
|
||||
ComplainDTO complainDTO = new ComplainDTO();
|
||||
complainDTO.setComplainType(fourInOneMqServiceFilter(IntelligentCustomerTypeEnum.CONSULT_TYPE.getCode(),complain.getString("投诉类型")));
|
||||
complainDTO.setOrderType(fourInOneMqServiceFilter(IntelligentCustomerTypeEnum.COMPLAIN.getCode(),complain.getString("工单类别")));
|
||||
complainDTO.setComplainTitle(complain.getString("投诉主题"));
|
||||
complainDTO.setProblemDescription(complain.getString("问题描述"));
|
||||
complainDTO.setContactSex(consultDTO.getContactSex());
|
||||
complainDTO.setContactName(consultDTO.getContactName());
|
||||
complainDTO.setContactTelephone(consultDTO.getContactTelephone());
|
||||
FourInOneResponseDTO fourInOneResponseDTO = new FourInOneResponseDTO();
|
||||
String aiAnalysisRequestId = execDifyFlow.getString("aiAnalysisRequestId");
|
||||
fourInOneResponseDTO.setAiAnalysisRequestId(aiAnalysisRequestId);
|
||||
fourInOneResponseDTO.setComplain(complainDTO);
|
||||
fourInOneResponseDTO.setConsult(consultDTO);
|
||||
fourInOneResponseDTO.setWorkOrderId(fourInOneRequestDTO.getWorkOrderId());
|
||||
// 发送MQ
|
||||
String message = JSONObject.toJSONString(fourInOneResponseDTO);
|
||||
log.info("send mq {}",message);
|
||||
sendMq(message);
|
||||
String aiAnalysisRequestId = null;
|
||||
String message = null;
|
||||
try {
|
||||
JSONObject textJsonObject = execDifyFlow.getJSONObject("outputs").getJSONObject("text");
|
||||
if(textJsonObject.containsKey("answer")){
|
||||
textJsonObject = execDifyFlow.getJSONObject("outputs").getJSONObject("text").getJSONObject("answer"); // 投诉
|
||||
}
|
||||
ConsultDTO consultDTO = new ConsultDTO();
|
||||
consultDTO.setOrderType(fourInOneMqServiceFilter(IntelligentCustomerTypeEnum.CONSULT.getCode(),textJsonObject.getString("工单类别")));
|
||||
consultDTO.setProblemDescription(textJsonObject.getString("问题描述"));
|
||||
consultDTO.setContactSex(textJsonObject.getString("工单联系人性别"));
|
||||
consultDTO.setContactName(textJsonObject.getString("工单联系人姓名"));
|
||||
consultDTO.setContactTelephone(textJsonObject.getString("工单联系电话"));
|
||||
|
||||
JSONObject complainObject = execDifyFlow.getJSONObject("outputs").getJSONObject("text1");
|
||||
if(complainObject.containsKey("answer")){
|
||||
complainObject = execDifyFlow.getJSONObject("outputs").getJSONObject("text1").getJSONObject("answer"); // 投诉
|
||||
}
|
||||
ComplainDTO complainDTO = new ComplainDTO();
|
||||
complainDTO.setComplainType(fourInOneMqServiceFilter(IntelligentCustomerTypeEnum.CONSULT_TYPE.getCode(),complainObject.getString("投诉类型")));
|
||||
complainDTO.setOrderType(fourInOneMqServiceFilter(IntelligentCustomerTypeEnum.COMPLAIN.getCode(),complainObject.getString("工单类别")));
|
||||
complainDTO.setComplainTitle(complainObject.getString("投诉主题"));
|
||||
complainDTO.setProblemDescription(complainObject.getString("问题描述"));
|
||||
complainDTO.setContactSex(consultDTO.getContactSex());
|
||||
complainDTO.setContactName(consultDTO.getContactName());
|
||||
complainDTO.setContactTelephone(consultDTO.getContactTelephone());
|
||||
FourInOneResponseDTO fourInOneResponseDTO = new FourInOneResponseDTO();
|
||||
aiAnalysisRequestId = execDifyFlow.getString("aiAnalysisRequestId");
|
||||
fourInOneResponseDTO.setAiAnalysisRequestId(aiAnalysisRequestId);
|
||||
fourInOneResponseDTO.setComplain(complainDTO);
|
||||
fourInOneResponseDTO.setConsult(consultDTO);
|
||||
fourInOneResponseDTO.setWorkOrderId(fourInOneRequestDTO.getWorkOrderId());
|
||||
// 发送MQ
|
||||
message = JSONObject.toJSONString(fourInOneResponseDTO);
|
||||
log.info("send mq {}",message);
|
||||
sendMq(message);
|
||||
|
||||
if(StringUtils.isNotEmpty(fourInOneRequestDTO.getAiAnalysisRequestId())){
|
||||
AiAnalysisErrors aiAnalysisErrors = new AiAnalysisErrors();
|
||||
aiAnalysisErrors.setAiAnalysisRequestId(aiAnalysisRequestId);
|
||||
@@ -144,7 +150,7 @@ public class IntelligentCustomerServiceImpl implements IntelligentCustomerServic
|
||||
aiAnalysisRequestLogsService.saveAiAnalysisRequestLogs(AiAnalysisRequestLogs.builder().aiAnalysisRequestId(execDifyFlow.getString("aiAnalysisRequestId")).businessResponse(message).build());
|
||||
|
||||
} catch (Exception e) {
|
||||
log.info(" 电话语料处理保存报告异常processItem:{} ", e);
|
||||
log.error("四合一语料解析返回数据JSON格式化异常 {}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user