From ad39e8cb63f824b748a4c31574c83cec05b2afc4 Mon Sep 17 00:00:00 2001 From: zren25 Date: Mon, 7 Apr 2025 17:44:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=9B=E5=90=88=E4=B8=80=E8=AF=AD=E6=96=99?= =?UTF-8?q?=E8=A7=A3=E6=9E=90=E5=A2=9E=E5=8A=A0=E5=85=A5=E5=8F=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mq/IntelligentCustomerMqConsumer.java | 19 ----- .../impl/IntelligentCustomerServiceImpl.java | 72 ++++++++++--------- 2 files changed, 39 insertions(+), 52 deletions(-) diff --git a/ai-analytic-center-biz/src/main/java/com/volvo/ai/analytic/center/mq/IntelligentCustomerMqConsumer.java b/ai-analytic-center-biz/src/main/java/com/volvo/ai/analytic/center/mq/IntelligentCustomerMqConsumer.java index 62c76b3..810e874 100644 --- a/ai-analytic-center-biz/src/main/java/com/volvo/ai/analytic/center/mq/IntelligentCustomerMqConsumer.java +++ b/ai-analytic-center-biz/src/main/java/com/volvo/ai/analytic/center/mq/IntelligentCustomerMqConsumer.java @@ -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 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); } } }