|
@@ -1,6 +1,7 @@
|
|
|
package com.fs.crm.service.impl;
|
|
package com.fs.crm.service.impl;
|
|
|
|
|
|
|
|
import cn.hutool.core.lang.TypeReference;
|
|
import cn.hutool.core.lang.TypeReference;
|
|
|
|
|
+import cn.hutool.core.map.MapUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
@@ -21,7 +22,7 @@ import com.fs.system.mapper.SysDictDataMapper;
|
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.scheduling.annotation.Async;
|
|
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
@@ -113,15 +114,16 @@ public class CrmCustomerAnalyzeServiceImpl extends ServiceImpl<CrmCustomerAnalyz
|
|
|
}
|
|
}
|
|
|
private static final String AI_PORTRAIT = "crm_ai_portrait";
|
|
private static final String AI_PORTRAIT = "crm_ai_portrait";
|
|
|
private static final ObjectMapper mapper = new ObjectMapper();
|
|
private static final ObjectMapper mapper = new ObjectMapper();
|
|
|
|
|
+ @Value("${crm.customer.ai.Key:mygpt-qZllJOSsaKw51T8D1Ug20aGJWcEPlC9OoR5kOKLQ8G9dsCeW3xa2m}")
|
|
|
|
|
+ private String OTHER_KEY;
|
|
|
//ai获取客户画像
|
|
//ai获取客户画像
|
|
|
@Override
|
|
@Override
|
|
|
- @Async
|
|
|
|
|
public void aiGeneratedCustomerPortrait(Long customerId, String dataJson,Long logId) {
|
|
public void aiGeneratedCustomerPortrait(Long customerId, String dataJson,Long logId) {
|
|
|
Map<String, Object> stringObjectMap = buildRequestParam(customerId, dataJson);
|
|
Map<String, Object> stringObjectMap = buildRequestParam(customerId, dataJson);
|
|
|
stringObjectMap.put("modelType","客户画像");
|
|
stringObjectMap.put("modelType","客户画像");
|
|
|
log.info("请求参数:{}", stringObjectMap);
|
|
log.info("请求参数:{}", stringObjectMap);
|
|
|
- R aiResponse = CrmCustomerAiTagUtil.callAiService(stringObjectMap, logId);
|
|
|
|
|
-
|
|
|
|
|
|
|
+ R aiResponse = CrmCustomerAiTagUtil.callAiService(stringObjectMap, logId,OTHER_KEY);
|
|
|
|
|
+// System.out.println(aiResponse);
|
|
|
JSONObject root = JSON.parseObject(JSONUtil.toJsonStr(aiResponse));
|
|
JSONObject root = JSON.parseObject(JSONUtil.toJsonStr(aiResponse));
|
|
|
|
|
|
|
|
// 获取 data.responseData
|
|
// 获取 data.responseData
|
|
@@ -159,18 +161,17 @@ public class CrmCustomerAnalyzeServiceImpl extends ServiceImpl<CrmCustomerAnalyz
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- @Async
|
|
|
|
|
public void aiCommunicationSummary(Long customerId, String dataJson, Long logId) {
|
|
public void aiCommunicationSummary(Long customerId, String dataJson, Long logId) {
|
|
|
Map<String, Object> stringObjectMap = buildRequestParam(customerId, dataJson);
|
|
Map<String, Object> stringObjectMap = buildRequestParam(customerId, dataJson);
|
|
|
stringObjectMap.put("modelType","沟通总结");
|
|
stringObjectMap.put("modelType","沟通总结");
|
|
|
log.info("请求参数:{}", stringObjectMap);
|
|
log.info("请求参数:{}", stringObjectMap);
|
|
|
- R aiResponse = CrmCustomerAiTagUtil.callAiService(stringObjectMap, logId);
|
|
|
|
|
|
|
+ R aiResponse = CrmCustomerAiTagUtil.callAiService(stringObjectMap, logId,OTHER_KEY);
|
|
|
JSONObject root = JSON.parseObject(JSONUtil.toJsonStr(aiResponse));
|
|
JSONObject root = JSON.parseObject(JSONUtil.toJsonStr(aiResponse));
|
|
|
- System.out.println(aiResponse);
|
|
|
|
|
|
|
+// System.out.println(aiResponse);
|
|
|
// 获取 data.responseData
|
|
// 获取 data.responseData
|
|
|
JSONArray responseData = root.getJSONObject("data").getJSONArray("responseData");
|
|
JSONArray responseData = root.getJSONObject("data").getJSONArray("responseData");
|
|
|
|
|
|
|
|
- JSONArray summary = null;
|
|
|
|
|
|
|
+ JSONObject summary = null;
|
|
|
|
|
|
|
|
// 遍历 responseData
|
|
// 遍历 responseData
|
|
|
for (int i = 0; i < responseData.size(); i++) {
|
|
for (int i = 0; i < responseData.size(); i++) {
|
|
@@ -185,40 +186,40 @@ public class CrmCustomerAnalyzeServiceImpl extends ServiceImpl<CrmCustomerAnalyz
|
|
|
if ("AI".equals(historyItem.getString("obj"))) {
|
|
if ("AI".equals(historyItem.getString("obj"))) {
|
|
|
String valueStr = historyItem.getString("value");
|
|
String valueStr = historyItem.getString("value");
|
|
|
JSONObject valueObj = JSON.parseObject(valueStr);
|
|
JSONObject valueObj = JSON.parseObject(valueStr);
|
|
|
- summary = valueObj.getJSONArray("tagInfos");
|
|
|
|
|
|
|
+ summary = valueObj.getJSONObject("userInfo");
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
if (summary != null) break;
|
|
if (summary != null) break;
|
|
|
}
|
|
}
|
|
|
- StringBuilder summaryText = new StringBuilder();
|
|
|
|
|
- if (summary!= null && !summary.isEmpty()) {
|
|
|
|
|
- for (int i = 0; i < summary.size(); i++) {
|
|
|
|
|
- summaryText.append(summary.get(i)).append(",");
|
|
|
|
|
- }
|
|
|
|
|
- summaryText.delete(summaryText.length()-1,summaryText.length());
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if (!summary.isEmpty() ) {
|
|
|
|
|
+ String summaryText = summary.getString("沟通总结");
|
|
|
CrmCustomerAnalyze crmCustomerAnalyze = new CrmCustomerAnalyze();
|
|
CrmCustomerAnalyze crmCustomerAnalyze = new CrmCustomerAnalyze();
|
|
|
crmCustomerAnalyze.setCustomerId(customerId);
|
|
crmCustomerAnalyze.setCustomerId(customerId);
|
|
|
- crmCustomerAnalyze.setCommunicationSummary(summaryText.toString());
|
|
|
|
|
|
|
+ crmCustomerAnalyze.setCommunicationSummary(summaryText);
|
|
|
baseMapper.updateCustomerPortrait(crmCustomerAnalyze);
|
|
baseMapper.updateCustomerPortrait(crmCustomerAnalyze);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- @Async
|
|
|
|
|
public void aiCommunicationAbstract(Long customerId, String dataJson, Long logId) {
|
|
public void aiCommunicationAbstract(Long customerId, String dataJson, Long logId) {
|
|
|
Map<String, Object> stringObjectMap = buildRequestParam(customerId, dataJson);
|
|
Map<String, Object> stringObjectMap = buildRequestParam(customerId, dataJson);
|
|
|
stringObjectMap.put("modelType","沟通摘要");
|
|
stringObjectMap.put("modelType","沟通摘要");
|
|
|
|
|
+ stringObjectMap.remove("userInfo");
|
|
|
|
|
+ HashMap<String, String> map = MapUtil.of("沟通摘要", "");
|
|
|
|
|
+ stringObjectMap.put("userInfo", map);
|
|
|
log.info("请求参数:{}", stringObjectMap);
|
|
log.info("请求参数:{}", stringObjectMap);
|
|
|
|
|
|
|
|
- R aiResponse = CrmCustomerAiTagUtil.callAiService(stringObjectMap, logId);
|
|
|
|
|
|
|
+ R aiResponse = CrmCustomerAiTagUtil.callAiService(stringObjectMap, logId,OTHER_KEY);
|
|
|
JSONObject root = JSON.parseObject(JSONUtil.toJsonStr(aiResponse));
|
|
JSONObject root = JSON.parseObject(JSONUtil.toJsonStr(aiResponse));
|
|
|
|
|
+// System.out.println(aiResponse);
|
|
|
|
|
|
|
|
// 获取 data.responseData
|
|
// 获取 data.responseData
|
|
|
JSONArray responseData = root.getJSONObject("data").getJSONArray("responseData");
|
|
JSONArray responseData = root.getJSONObject("data").getJSONArray("responseData");
|
|
|
|
|
|
|
|
- String summary = null;
|
|
|
|
|
|
|
+ JSONObject summary = null;
|
|
|
|
|
|
|
|
// 遍历 responseData
|
|
// 遍历 responseData
|
|
|
for (int i = 0; i < responseData.size(); i++) {
|
|
for (int i = 0; i < responseData.size(); i++) {
|
|
@@ -233,7 +234,7 @@ public class CrmCustomerAnalyzeServiceImpl extends ServiceImpl<CrmCustomerAnalyz
|
|
|
if ("AI".equals(historyItem.getString("obj"))) {
|
|
if ("AI".equals(historyItem.getString("obj"))) {
|
|
|
String valueStr = historyItem.getString("value");
|
|
String valueStr = historyItem.getString("value");
|
|
|
JSONObject valueObj = JSON.parseObject(valueStr);
|
|
JSONObject valueObj = JSON.parseObject(valueStr);
|
|
|
- summary = valueObj.getString("userContent");
|
|
|
|
|
|
|
+ summary = valueObj.getJSONObject("userInfo");
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -243,25 +244,28 @@ public class CrmCustomerAnalyzeServiceImpl extends ServiceImpl<CrmCustomerAnalyz
|
|
|
if (summary != null){
|
|
if (summary != null){
|
|
|
CrmCustomerAnalyze c = new CrmCustomerAnalyze();
|
|
CrmCustomerAnalyze c = new CrmCustomerAnalyze();
|
|
|
c.setCustomerId(customerId);
|
|
c.setCustomerId(customerId);
|
|
|
- c.setCommunicationAbstract(summary);
|
|
|
|
|
|
|
+ c.setCommunicationAbstract(summary.getString("沟通摘要"));
|
|
|
baseMapper.updateCustomerPortrait(c);
|
|
baseMapper.updateCustomerPortrait(c);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- @Async
|
|
|
|
|
public void aiAttritionLevel(Long customerId, String dataJson, Long logId) {
|
|
public void aiAttritionLevel(Long customerId, String dataJson, Long logId) {
|
|
|
Map<String, Object> stringObjectMap = buildRequestParam(customerId, dataJson);
|
|
Map<String, Object> stringObjectMap = buildRequestParam(customerId, dataJson);
|
|
|
stringObjectMap.put("modelType","流失风险等级");
|
|
stringObjectMap.put("modelType","流失风险等级");
|
|
|
|
|
+ stringObjectMap.remove("userInfo");
|
|
|
|
|
+ HashMap<String, String> map = MapUtil.of("流失风险等级", "");
|
|
|
|
|
+ stringObjectMap.put("userInfo", map);
|
|
|
log.info("请求参数:{}", stringObjectMap);
|
|
log.info("请求参数:{}", stringObjectMap);
|
|
|
|
|
|
|
|
- R aiResponse = CrmCustomerAiTagUtil.callAiService(stringObjectMap, logId);
|
|
|
|
|
|
|
+ R aiResponse = CrmCustomerAiTagUtil.callAiService(stringObjectMap, logId,OTHER_KEY);
|
|
|
JSONObject root = JSON.parseObject(JSONUtil.toJsonStr(aiResponse));
|
|
JSONObject root = JSON.parseObject(JSONUtil.toJsonStr(aiResponse));
|
|
|
|
|
+// System.out.println(aiResponse);
|
|
|
|
|
|
|
|
// 获取 data.responseData
|
|
// 获取 data.responseData
|
|
|
JSONArray responseData = root.getJSONObject("data").getJSONArray("responseData");
|
|
JSONArray responseData = root.getJSONObject("data").getJSONArray("responseData");
|
|
|
|
|
|
|
|
- String summary = null;
|
|
|
|
|
|
|
+ JSONObject summary = null;
|
|
|
|
|
|
|
|
// 遍历 responseData
|
|
// 遍历 responseData
|
|
|
for (int i = 0; i < responseData.size(); i++) {
|
|
for (int i = 0; i < responseData.size(); i++) {
|
|
@@ -276,33 +280,50 @@ public class CrmCustomerAnalyzeServiceImpl extends ServiceImpl<CrmCustomerAnalyz
|
|
|
if ("AI".equals(historyItem.getString("obj"))) {
|
|
if ("AI".equals(historyItem.getString("obj"))) {
|
|
|
String valueStr = historyItem.getString("value");
|
|
String valueStr = historyItem.getString("value");
|
|
|
JSONObject valueObj = JSON.parseObject(valueStr);
|
|
JSONObject valueObj = JSON.parseObject(valueStr);
|
|
|
- summary = valueObj.getString("tagInfos");
|
|
|
|
|
|
|
+ summary = valueObj.getJSONObject("userInfo");
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- if (summary != null) break;
|
|
|
|
|
|
|
+ if (summary != null && !summary.isEmpty()) break;
|
|
|
}
|
|
}
|
|
|
- if (summary != null){
|
|
|
|
|
- //todo 响应处理
|
|
|
|
|
|
|
+ if (summary != null && !summary.isEmpty()){
|
|
|
|
|
+ String level = summary.getString("流失风险等级");
|
|
|
|
|
+
|
|
|
|
|
+ CrmCustomerAnalyze c = new CrmCustomerAnalyze();
|
|
|
|
|
+ c.setCustomerId(customerId);
|
|
|
|
|
+ c.setAttritionLevel(getScore(level));
|
|
|
|
|
+ baseMapper.updateCustomerPortrait(c);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+ private static Long getScore(String level) {
|
|
|
|
|
+ if ("十分满意".equals(level) || "满意".equals(level) || "A".equals(level) || "B".equals(level)) return 1L;
|
|
|
|
|
+ if ("基本满意".equals(level) || "C".equals(level)) return 2L;
|
|
|
|
|
+ if ("不满意".equals(level) || "D".equals(level)) return 3L;
|
|
|
|
|
+ if ("十分不满意".equals(level) || "E".equals(level)) return 4L;
|
|
|
|
|
+ return 0L; // 未知
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
- @Async
|
|
|
|
|
public void aiCustomerFocus(Long customerId, String dataJson, Long logId) {
|
|
public void aiCustomerFocus(Long customerId, String dataJson, Long logId) {
|
|
|
Map<String, Object> stringObjectMap = buildRequestParam(customerId, dataJson);
|
|
Map<String, Object> stringObjectMap = buildRequestParam(customerId, dataJson);
|
|
|
stringObjectMap.put("modelType","客户关注点");
|
|
stringObjectMap.put("modelType","客户关注点");
|
|
|
|
|
+ stringObjectMap.remove("userInfo");
|
|
|
|
|
+ HashMap<String, String> map = MapUtil.of("客户关注点", "");
|
|
|
|
|
+ stringObjectMap.put("userInfo", map);
|
|
|
log.info("请求参数:{}", stringObjectMap);
|
|
log.info("请求参数:{}", stringObjectMap);
|
|
|
|
|
|
|
|
- R aiResponse = CrmCustomerAiTagUtil.callAiService(stringObjectMap, logId);
|
|
|
|
|
- System.out.println(aiResponse);
|
|
|
|
|
|
|
+ R aiResponse = CrmCustomerAiTagUtil.callAiService(stringObjectMap, logId,OTHER_KEY);
|
|
|
|
|
+// System.out.println(aiResponse);
|
|
|
JSONObject root = JSON.parseObject(JSONUtil.toJsonStr(aiResponse));
|
|
JSONObject root = JSON.parseObject(JSONUtil.toJsonStr(aiResponse));
|
|
|
|
|
|
|
|
// 获取 data.responseData
|
|
// 获取 data.responseData
|
|
|
JSONArray responseData = root.getJSONObject("data").getJSONArray("responseData");
|
|
JSONArray responseData = root.getJSONObject("data").getJSONArray("responseData");
|
|
|
|
|
|
|
|
- JSONArray summary = null;
|
|
|
|
|
|
|
+ JSONObject summary = null;
|
|
|
|
|
|
|
|
// 遍历 responseData
|
|
// 遍历 responseData
|
|
|
for (int i = 0; i < responseData.size(); i++) {
|
|
for (int i = 0; i < responseData.size(); i++) {
|
|
@@ -317,22 +338,17 @@ public class CrmCustomerAnalyzeServiceImpl extends ServiceImpl<CrmCustomerAnalyz
|
|
|
if ("AI".equals(historyItem.getString("obj"))) {
|
|
if ("AI".equals(historyItem.getString("obj"))) {
|
|
|
String valueStr = historyItem.getString("value");
|
|
String valueStr = historyItem.getString("value");
|
|
|
JSONObject valueObj = JSON.parseObject(valueStr);
|
|
JSONObject valueObj = JSON.parseObject(valueStr);
|
|
|
- summary = valueObj.getJSONArray("userContent");
|
|
|
|
|
|
|
+ summary = valueObj.getJSONObject("userInfo");
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- if (summary != null) break;
|
|
|
|
|
|
|
+ if (summary != null && !summary.isEmpty()) break;
|
|
|
}
|
|
}
|
|
|
- if (summary != null){
|
|
|
|
|
- List<String> list = new ArrayList<String>();
|
|
|
|
|
- summary.forEach(o->{
|
|
|
|
|
- JSONObject jsonObject = (JSONObject) o;
|
|
|
|
|
- list.add(jsonObject.getString("tagName"));
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ if (summary != null && !summary.isEmpty()){
|
|
|
CrmCustomerAnalyze crmCustomerAnalyze = new CrmCustomerAnalyze();
|
|
CrmCustomerAnalyze crmCustomerAnalyze = new CrmCustomerAnalyze();
|
|
|
crmCustomerAnalyze.setCustomerId(customerId);
|
|
crmCustomerAnalyze.setCustomerId(customerId);
|
|
|
- crmCustomerAnalyze.setCustomerFocusJson(list.toString());
|
|
|
|
|
|
|
+ crmCustomerAnalyze.setCustomerFocusJson(summary.getString("客户关注点"));
|
|
|
baseMapper.updateCustomerPortrait(crmCustomerAnalyze);
|
|
baseMapper.updateCustomerPortrait(crmCustomerAnalyze);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -342,7 +358,8 @@ public class CrmCustomerAnalyzeServiceImpl extends ServiceImpl<CrmCustomerAnalyz
|
|
|
Map<String, Object> requestParam = new HashMap<>();
|
|
Map<String, Object> requestParam = new HashMap<>();
|
|
|
requestParam.put("history", param.getContent());
|
|
requestParam.put("history", param.getContent());
|
|
|
requestParam.put("modelType","话术润色");
|
|
requestParam.put("modelType","话术润色");
|
|
|
- requestParam.putAll(param.getPortrait());
|
|
|
|
|
|
|
+ HashMap<String, Map<String, String>> userInfo = MapUtil.of("userInfo", param.getPortrait());
|
|
|
|
|
+ requestParam.putAll(userInfo);
|
|
|
|
|
|
|
|
// 设置其他参数
|
|
// 设置其他参数
|
|
|
requestParam.put("tagInfos", Collections.emptyList());
|
|
requestParam.put("tagInfos", Collections.emptyList());
|
|
@@ -350,26 +367,49 @@ public class CrmCustomerAnalyzeServiceImpl extends ServiceImpl<CrmCustomerAnalyz
|
|
|
requestParam.put("userContent", "");
|
|
requestParam.put("userContent", "");
|
|
|
requestParam.put("aiContent", "");
|
|
requestParam.put("aiContent", "");
|
|
|
requestParam.put("likeRatio", "");
|
|
requestParam.put("likeRatio", "");
|
|
|
- R aiResponse = CrmCustomerAiTagUtil.callAiService(requestParam, Long.valueOf(param.getChatId()));
|
|
|
|
|
- System.out.println(aiResponse);
|
|
|
|
|
|
|
+ R aiResponse = CrmCustomerAiTagUtil.callAiService(requestParam, Long.valueOf(param.getChatId()),OTHER_KEY);
|
|
|
|
|
+// System.out.println(aiResponse);
|
|
|
|
|
+ JSONObject root = JSON.parseObject(JSONUtil.toJsonStr(aiResponse));
|
|
|
|
|
+ JSONArray responseData = root.getJSONObject("data").getJSONArray("responseData");
|
|
|
|
|
+
|
|
|
|
|
+// 遍历 responseData
|
|
|
|
|
+ for (int i = 0; i < responseData.size(); i++) {
|
|
|
|
|
+ JSONObject node = responseData.getJSONObject(i);
|
|
|
|
|
+ JSONArray historyPreview = node.getJSONArray("historyPreview");
|
|
|
|
|
+
|
|
|
|
|
+ if (historyPreview != null) {
|
|
|
|
|
+ for (int j = 0; j < historyPreview.size(); j++) {
|
|
|
|
|
+ JSONObject historyItem = historyPreview.getJSONObject(j);
|
|
|
|
|
+
|
|
|
|
|
+ // 找到 obj 为 "AI" 的项
|
|
|
|
|
+ if ("AI".equals(historyItem.getString("obj"))) {
|
|
|
|
|
+ String valueStr = historyItem.getString("value");
|
|
|
|
|
+ JSONObject valueObj = JSON.parseObject(valueStr);
|
|
|
|
|
+ return valueObj.getString("aiContent");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
return "";
|
|
return "";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- @Async
|
|
|
|
|
public void aiIntentionDegree(Long customerId, String dataJson, Long logId) {
|
|
public void aiIntentionDegree(Long customerId, String dataJson, Long logId) {
|
|
|
Map<String, Object> stringObjectMap = buildRequestParam(customerId, dataJson);
|
|
Map<String, Object> stringObjectMap = buildRequestParam(customerId, dataJson);
|
|
|
stringObjectMap.put("modelType","客户意向度");
|
|
stringObjectMap.put("modelType","客户意向度");
|
|
|
|
|
+ stringObjectMap.remove("userInfo");
|
|
|
|
|
+ HashMap<String, String> map = MapUtil.of("客户意向度", "");
|
|
|
|
|
+ stringObjectMap.put("userInfo", map);
|
|
|
log.info("请求参数:{}", stringObjectMap);
|
|
log.info("请求参数:{}", stringObjectMap);
|
|
|
|
|
|
|
|
- R aiResponse = CrmCustomerAiTagUtil.callAiService(stringObjectMap, logId);
|
|
|
|
|
- System.out.println(aiResponse);
|
|
|
|
|
|
|
+ R aiResponse = CrmCustomerAiTagUtil.callAiService(stringObjectMap, logId,OTHER_KEY);
|
|
|
|
|
+// System.out.println(aiResponse);
|
|
|
JSONObject root = JSON.parseObject(JSONUtil.toJsonStr(aiResponse));
|
|
JSONObject root = JSON.parseObject(JSONUtil.toJsonStr(aiResponse));
|
|
|
|
|
|
|
|
// 获取 data.responseData
|
|
// 获取 data.responseData
|
|
|
JSONArray responseData = root.getJSONObject("data").getJSONArray("responseData");
|
|
JSONArray responseData = root.getJSONObject("data").getJSONArray("responseData");
|
|
|
|
|
|
|
|
- String summary = null;
|
|
|
|
|
|
|
+ JSONObject summary = null;
|
|
|
|
|
|
|
|
// 遍历 responseData
|
|
// 遍历 responseData
|
|
|
for (int i = 0; i < responseData.size(); i++) {
|
|
for (int i = 0; i < responseData.size(); i++) {
|
|
@@ -384,17 +424,17 @@ public class CrmCustomerAnalyzeServiceImpl extends ServiceImpl<CrmCustomerAnalyz
|
|
|
if ("AI".equals(historyItem.getString("obj"))) {
|
|
if ("AI".equals(historyItem.getString("obj"))) {
|
|
|
String valueStr = historyItem.getString("value");
|
|
String valueStr = historyItem.getString("value");
|
|
|
JSONObject valueObj = JSON.parseObject(valueStr);
|
|
JSONObject valueObj = JSON.parseObject(valueStr);
|
|
|
- summary = valueObj.getString("userIntent");
|
|
|
|
|
|
|
+ summary = valueObj.getJSONObject("userInfo");
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- if (summary != null) break;
|
|
|
|
|
|
|
+ if (summary != null && !summary.isEmpty()) break;
|
|
|
}
|
|
}
|
|
|
- if (summary != null) {
|
|
|
|
|
|
|
+ if (summary != null && !summary.isEmpty()) {
|
|
|
CrmCustomerAnalyze crmCustomerAnalyze = new CrmCustomerAnalyze();
|
|
CrmCustomerAnalyze crmCustomerAnalyze = new CrmCustomerAnalyze();
|
|
|
crmCustomerAnalyze.setCustomerId(customerId);
|
|
crmCustomerAnalyze.setCustomerId(customerId);
|
|
|
- crmCustomerAnalyze.setIntentionDegree(summary);
|
|
|
|
|
|
|
+ crmCustomerAnalyze.setIntentionDegree(summary.getString("客户意向度"));
|
|
|
baseMapper.updateCustomerPortrait(crmCustomerAnalyze);
|
|
baseMapper.updateCustomerPortrait(crmCustomerAnalyze);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -437,9 +477,9 @@ public class CrmCustomerAnalyzeServiceImpl extends ServiceImpl<CrmCustomerAnalyz
|
|
|
requestParam.put("modelType","客户意向度");
|
|
requestParam.put("modelType","客户意向度");
|
|
|
log.info("请求参数:{}", requestParam);
|
|
log.info("请求参数:{}", requestParam);
|
|
|
|
|
|
|
|
- R aiResponse = CrmCustomerAiTagUtil.callAiService(requestParam, chatId);
|
|
|
|
|
|
|
+ R aiResponse = CrmCustomerAiTagUtil.callAiService(requestParam, chatId,OTHER_KEY);
|
|
|
JSONObject root = JSON.parseObject(JSONUtil.toJsonStr(aiResponse));
|
|
JSONObject root = JSON.parseObject(JSONUtil.toJsonStr(aiResponse));
|
|
|
-
|
|
|
|
|
|
|
+// System.out.println(aiResponse);
|
|
|
// 获取 data.responseData
|
|
// 获取 data.responseData
|
|
|
JSONArray responseData = root.getJSONObject("data").getJSONArray("responseData");
|
|
JSONArray responseData = root.getJSONObject("data").getJSONArray("responseData");
|
|
|
|
|
|
|
@@ -463,9 +503,9 @@ public class CrmCustomerAnalyzeServiceImpl extends ServiceImpl<CrmCustomerAnalyz
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- if (summary != null) break;
|
|
|
|
|
|
|
+ if (summary != null && !summary.isEmpty()) break;
|
|
|
}
|
|
}
|
|
|
- if (summary != null) {
|
|
|
|
|
|
|
+ if (summary != null && !summary.isEmpty()) {
|
|
|
return summary;
|
|
return summary;
|
|
|
}
|
|
}
|
|
|
return null;
|
|
return null;
|