|
@@ -38,7 +38,6 @@ import java.util.concurrent.CompletableFuture;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
import java.util.stream.Stream;
|
|
import java.util.stream.Stream;
|
|
|
|
|
|
|
|
-@Slf4j
|
|
|
|
|
@Component
|
|
@Component
|
|
|
public class CrmCustomerAiTagUtil {
|
|
public class CrmCustomerAiTagUtil {
|
|
|
|
|
|
|
@@ -57,7 +56,7 @@ public class CrmCustomerAiTagUtil {
|
|
|
APP_KEY = this.appKey;
|
|
APP_KEY = this.appKey;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public static List<CrmCustomerAiTagVo> getTag(CrmCustomerAiTagParam content) throws JsonProcessingException {
|
|
|
|
|
|
|
+ public static List<CrmCustomerAiTagVo> getCrmCustomerAiTag(CrmCustomerAiTagParam content) throws JsonProcessingException {
|
|
|
// 1. 参数校验
|
|
// 1. 参数校验
|
|
|
validateParams(content);
|
|
validateParams(content);
|
|
|
Long customerId = content.getCustomerId();
|
|
Long customerId = content.getCustomerId();
|
|
@@ -149,7 +148,7 @@ public class CrmCustomerAiTagUtil {
|
|
|
// 获取各类数据
|
|
// 获取各类数据
|
|
|
String tradeName = getDictLabel(tradeType);
|
|
String tradeName = getDictLabel(tradeType);
|
|
|
Map<String, Object> tags = getTags(tradeType);
|
|
Map<String, Object> tags = getTags(tradeType);
|
|
|
- Map<String, Object> history = getHistory(communication);
|
|
|
|
|
|
|
+ Map<String, Object> history = getHistory(communication,customerId.toString());
|
|
|
Map<String, Object> userInfo = getUserInfo(customerId);
|
|
Map<String, Object> userInfo = getUserInfo(customerId);
|
|
|
Map<String, Object> aiInfo = getAiInfo(communication.remove(0));
|
|
Map<String, Object> aiInfo = getAiInfo(communication.remove(0));
|
|
|
|
|
|
|
@@ -348,7 +347,7 @@ public class CrmCustomerAiTagUtil {
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private static Map<String, Object> getHistory(List<Map<String, Object>> communication) {
|
|
|
|
|
|
|
+ private static Map<String, Object> getHistory(List<Map<String, Object>> communication,String customerId) {
|
|
|
StringBuilder history = new StringBuilder();
|
|
StringBuilder history = new StringBuilder();
|
|
|
history.append("{");
|
|
history.append("{");
|
|
|
for (Map<String, Object> o :
|
|
for (Map<String, Object> o :
|
|
@@ -361,6 +360,22 @@ public class CrmCustomerAiTagUtil {
|
|
|
history.deleteCharAt(history.length() - 1).append("}");
|
|
history.deleteCharAt(history.length() - 1).append("}");
|
|
|
Map<String, Object> result = new HashMap<String, Object>();
|
|
Map<String, Object> result = new HashMap<String, Object>();
|
|
|
result.put("history", history);
|
|
result.put("history", history);
|
|
|
|
|
+ ArrayList<Map> maps = new ArrayList<>();
|
|
|
|
|
+ communication.forEach(o->{
|
|
|
|
|
+ String role = (String) o.get("role");
|
|
|
|
|
+ String content = (String) o.get("content");
|
|
|
|
|
+ if (content != null && !content.trim().isEmpty()) { // 过滤空内容
|
|
|
|
|
+ String roleTag = "user".equals(role) ? "user" : "ai";
|
|
|
|
|
+ Map<String, String> message = new HashMap<>();
|
|
|
|
|
+ message.put(roleTag, content);
|
|
|
|
|
+ maps.add(message);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ if (!maps.isEmpty()){
|
|
|
|
|
+ CrmCustomerInfo crmCustomerInfo = new CrmCustomerInfo();
|
|
|
|
|
+ crmCustomerInfo.setCustomerId(Long.valueOf(customerId)).setAiChatRecord(JSONUtil.toJsonStr(maps));
|
|
|
|
|
+ SpringUtils.getBean(CrmCustomerMapper.class).updateCrmCustomerInfo(crmCustomerInfo);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|