|
|
@@ -7,6 +7,8 @@ import cn.hutool.json.JSONUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
import com.fasterxml.jackson.databind.JsonNode;
|
|
|
@@ -14,21 +16,33 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.fs.common.core.domain.R;
|
|
|
import com.fs.common.core.domain.entity.SysDictData;
|
|
|
import com.fs.common.utils.DateUtils;
|
|
|
-import com.fs.crm.domain.CrmCustomerAnalyze;
|
|
|
-import com.fs.crm.domain.CrmCustomerChatMessage;
|
|
|
+import com.fs.common.utils.DictUtils;
|
|
|
+import com.fs.common.utils.spring.SpringUtils;
|
|
|
+import com.fs.crm.domain.*;
|
|
|
+import com.fs.crm.dto.CrmCustomerAiAutoTagVo;
|
|
|
import com.fs.crm.mapper.CrmCustomerAnalyzeMapper;
|
|
|
+import com.fs.crm.mapper.CrmCustomerMapper;
|
|
|
import com.fs.crm.param.PolishingScriptParam;
|
|
|
import com.fs.crm.service.ICrmCustomerAnalyzeService;
|
|
|
+import com.fs.crm.service.ICrmCustomerPropertyTemplateService;
|
|
|
import com.fs.crm.utils.CrmCustomerAiTagUtil;
|
|
|
+import com.fs.crm.vo.CrmCustomerAiTagVo;
|
|
|
+import com.fs.crm.vo.QwCustomerAiTagVo;
|
|
|
+import com.fs.qw.domain.QwExternalAiAnalyze;
|
|
|
+import com.fs.qw.mapper.QwCustomerPropertyMapper;
|
|
|
+import com.fs.qw.mapper.QwExternalAiAnalyzeMapper;
|
|
|
+import com.fs.qw.param.audit.QwAiTagGainParam;
|
|
|
import com.fs.system.mapper.SysDictDataMapper;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
+import java.util.stream.Stream;
|
|
|
|
|
|
/**
|
|
|
* 客户聊天记录分析Service业务层处理
|
|
|
@@ -42,6 +56,13 @@ public class CrmCustomerAnalyzeServiceImpl extends ServiceImpl<CrmCustomerAnalyz
|
|
|
private static final Logger log = LoggerFactory.getLogger(CrmCustomerAnalyzeServiceImpl.class);
|
|
|
@Autowired
|
|
|
private SysDictDataMapper sysDictDataMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private QwExternalAiAnalyzeMapper qwExternalAiAnalyzeMapper;
|
|
|
+ @Qualifier("qwCustomerPropertyMapper")
|
|
|
+ @Autowired
|
|
|
+ private QwCustomerPropertyMapper qwCustomerPropertyMapper;
|
|
|
+
|
|
|
/**
|
|
|
* 查询客户聊天记录分析
|
|
|
*
|
|
|
@@ -307,7 +328,7 @@ public class CrmCustomerAnalyzeServiceImpl extends ServiceImpl<CrmCustomerAnalyz
|
|
|
}
|
|
|
|
|
|
|
|
|
- private static Long getScore(String level) {
|
|
|
+ private 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;
|
|
|
@@ -575,13 +596,340 @@ public class CrmCustomerAnalyzeServiceImpl extends ServiceImpl<CrmCustomerAnalyz
|
|
|
return baseMapper.updateCustomerPortrait(crmCustomerAnalyze);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public String aiGeneratedCustomerPortraitQw(QwExternalAiAnalyze qwExternalAiAnalyze, String dataJson, Long logId) {
|
|
|
+ Map<String, Object> stringObjectMap = buildRequestParamQw(qwExternalAiAnalyze, dataJson);
|
|
|
+ stringObjectMap.put("modelType", "客户画像");
|
|
|
+// log.info("请求参数:{}", stringObjectMap);
|
|
|
+ R aiResponse = CrmCustomerAiTagUtil.callAiService(stringObjectMap, logId, OTHER_KEY);
|
|
|
+// System.out.println(aiResponse);
|
|
|
+ String result = "";
|
|
|
+ try {
|
|
|
+ result = Objects.requireNonNull(responseAnalyze(aiResponse, "userInfo")).toString();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Integer updateQwAnalyzeByCustomerId(QwExternalAiAnalyze qwExternalAiAnalyze) {
|
|
|
+ return baseMapper.updateAiAnalyze(qwExternalAiAnalyze);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String aiCommunicationSummaryQw(QwExternalAiAnalyze qwExternalAiAnalyze, String dataJson, Long logId) {
|
|
|
+ Map<String, Object> stringObjectMap = buildRequestParamQw(qwExternalAiAnalyze, dataJson);
|
|
|
+ stringObjectMap.put("modelType", "沟通总结");
|
|
|
+// log.info("请求参数:{}", stringObjectMap);
|
|
|
+ R aiResponse = CrmCustomerAiTagUtil.callAiService(stringObjectMap, logId, OTHER_KEY);
|
|
|
+// System.out.println(aiResponse);
|
|
|
+ String result = "";
|
|
|
+ try {
|
|
|
+ JsonNode userInfo = responseAnalyze(aiResponse, "userInfo");
|
|
|
+ assert userInfo != null;
|
|
|
+ result = userInfo.get("沟通总结").asText();
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("获取沟通总结失败", e);
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String aiCommunicationAbstractQw(QwExternalAiAnalyze qwExternalAiAnalyze, String dataJson, Long logId) {
|
|
|
+ Map<String, Object> stringObjectMap = buildRequestParamQw(qwExternalAiAnalyze, dataJson);
|
|
|
+ stringObjectMap.put("modelType", "沟通摘要");
|
|
|
+ stringObjectMap.remove("userInfo");
|
|
|
+ HashMap<String, String> map = MapUtil.of("沟通摘要", "");
|
|
|
+ stringObjectMap.put("userInfo", map);
|
|
|
+// log.info("请求参数:{}", stringObjectMap);
|
|
|
+ R aiResponse = CrmCustomerAiTagUtil.callAiService(stringObjectMap, logId, OTHER_KEY);
|
|
|
+// System.out.println(aiResponse);
|
|
|
+ String result = "";
|
|
|
+ try {
|
|
|
+ JsonNode userInfo = responseAnalyze(aiResponse, "userInfo");
|
|
|
+ assert userInfo != null;
|
|
|
+ result = userInfo.get("沟通摘要").asText();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Long aiAttritionLevelQw(QwExternalAiAnalyze qwExternalAiAnalyze, String dataJson, Long logId) {
|
|
|
+ Map<String, Object> stringObjectMap = buildRequestParamQw(qwExternalAiAnalyze, dataJson);
|
|
|
+ stringObjectMap.put("modelType","流失风险等级");
|
|
|
+ stringObjectMap.remove("userInfo");
|
|
|
+ HashMap<String, String> map = MapUtil.of("流失风险等级", "");
|
|
|
+ stringObjectMap.put("userInfo", map);
|
|
|
+// log.info("请求参数:{}", stringObjectMap);
|
|
|
+ R aiResponse = CrmCustomerAiTagUtil.callAiService(stringObjectMap, logId, OTHER_KEY);
|
|
|
+// System.out.println(aiResponse);
|
|
|
+ Long result = 0L;
|
|
|
+ try {
|
|
|
+ JsonNode userInfo = responseAnalyze(aiResponse, "userInfo");
|
|
|
+ assert userInfo != null;
|
|
|
+ result = getScore(userInfo.path("流失风险等级").asText());
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String aiCustomerFocusQw(QwExternalAiAnalyze qwExternalAiAnalyze, String dataJson, Long logId) {
|
|
|
+ Map<String, Object> stringObjectMap = buildRequestParamQw(qwExternalAiAnalyze, dataJson);
|
|
|
+ stringObjectMap.put("modelType","客户关注点");
|
|
|
+ stringObjectMap.remove("userInfo");
|
|
|
+ HashMap<String, String> map = MapUtil.of("客户关注点", "");
|
|
|
+ stringObjectMap.put("userInfo", map);
|
|
|
+// log.info("请求参数:{}", stringObjectMap);
|
|
|
+ R aiResponse = CrmCustomerAiTagUtil.callAiService(stringObjectMap, logId, OTHER_KEY);
|
|
|
+// System.out.println(aiResponse);
|
|
|
+ String result = "";
|
|
|
+ try {
|
|
|
+ JsonNode userInfo = responseAnalyze(aiResponse, "userInfo");
|
|
|
+ assert userInfo != null;
|
|
|
+ result = userInfo.path("客户关注点").asText();
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String aiIntentionDegreeQw(QwExternalAiAnalyze qwExternalAiAnalyze, String dataJson, Long logId) {
|
|
|
+ Map<String, Object> stringObjectMap = buildRequestParamQw(qwExternalAiAnalyze, dataJson);
|
|
|
+ stringObjectMap.put("modelType","客户意向度");
|
|
|
+ stringObjectMap.remove("userInfo");
|
|
|
+ HashMap<String, String> map = MapUtil.of("客户意向度", "");
|
|
|
+ stringObjectMap.put("userInfo", map);
|
|
|
+// log.info("请求参数:{}", stringObjectMap);
|
|
|
+ R aiResponse = CrmCustomerAiTagUtil.callAiService(stringObjectMap, logId, OTHER_KEY);
|
|
|
+// System.out.println(aiResponse);
|
|
|
+ String result = "";
|
|
|
+ try {
|
|
|
+ JsonNode userInfo = responseAnalyze(aiResponse, "userInfo");
|
|
|
+ assert userInfo != null;
|
|
|
+ result = userInfo.get("客户意向度").asText();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public R qwAiTagGain(QwAiTagGainParam param) {
|
|
|
+ QwExternalAiAnalyze qwExternalAiAnalyze = qwExternalAiAnalyzeMapper.selectOne(new LambdaQueryWrapper<QwExternalAiAnalyze>()
|
|
|
+ .eq(QwExternalAiAnalyze::getExternalUserId, param.getExternalUserId()).eq(QwExternalAiAnalyze::getCorpId, param.getCorpId())
|
|
|
+ .eq(QwExternalAiAnalyze::getQwUserId, param.getQwUserId()).orderByDesc(QwExternalAiAnalyze::getCreateTime).last("limit 1"));
|
|
|
+ if (ObjectUtil.isEmpty(qwExternalAiAnalyze))return R.error("客户ai分析信息不存在");
|
|
|
+ Map<String, Object> stringObjectMap = buildRequestParam(param.getTradeType(), qwExternalAiAnalyze);
|
|
|
+ R aiResponse = CrmCustomerAiTagUtil.callAiService(stringObjectMap, qwExternalAiAnalyze.getSessionId(),OTHER_KEY);
|
|
|
+ List<QwCustomerAiTagVo> results = parseAiResponse(aiResponse, qwExternalAiAnalyze);
|
|
|
+ if (!results.isEmpty()){
|
|
|
+ qwCustomerPropertyMapper.insertBatch(results);
|
|
|
+ }
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ private static List<QwCustomerAiTagVo> parseAiResponse(R aiResponse, QwExternalAiAnalyze analyze) {
|
|
|
+ if (aiResponse == null || !Integer.valueOf(200).equals(aiResponse.get("code"))) {
|
|
|
+ throw new RuntimeException("AI响应异常: " +
|
|
|
+ (aiResponse != null ? aiResponse.get("msg") : "响应为空"));
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Map<String, String>> tagInfos = CrmCustomerAiTagUtil.extractTagInfos(JSONUtil.toJsonStr(aiResponse));
|
|
|
+ if (CollectionUtils.isEmpty(tagInfos)) {
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+
|
|
|
+ return tagInfos.stream()
|
|
|
+ .map(tag -> buildTagVo(tag, analyze))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ private static QwCustomerAiTagVo buildTagVo(Map<String, String> tag, QwExternalAiAnalyze analyze) {
|
|
|
+ QwCustomerAiTagVo vo = new QwCustomerAiTagVo();
|
|
|
+ vo.setExternalUserId(analyze.getExternalUserId()).setQwUserId(analyze.getQwUserId()).setCorpId(analyze.getCorpId())
|
|
|
+ .setPropertyId(tag.get("id")).setPropertyName(tag.get("name")).setPropertyValue(tag.get("value"));
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
+
|
|
|
+ private static Map<String, Object> buildRequestParam(String tradeType, QwExternalAiAnalyze analyze) {
|
|
|
+ Map<String, Object> requestParam = new HashMap<>();
|
|
|
+ // 获取各类数据
|
|
|
+ String tradeName = getDictLabel(tradeType);
|
|
|
+ Map<String, Object> tags = getTags(tradeType);
|
|
|
+ requestParam.put("history",analyze.getAiChatRecord());
|
|
|
+ Map<String, Object> userInfo = getUserInfo(analyze);
|
|
|
+ // 合并数据
|
|
|
+ Stream.of(tags, userInfo)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .forEach(requestParam::putAll);
|
|
|
+ // 设置其他参数
|
|
|
+ requestParam.put("tradeName", tradeName);
|
|
|
+ requestParam.put("tradeType", tradeType);
|
|
|
+ requestParam.put("tagInfos", Collections.emptyList());
|
|
|
+ requestParam.put("isRepository", "");
|
|
|
+ requestParam.put("userContent", "");
|
|
|
+ requestParam.put("aiContent", "");
|
|
|
+ requestParam.put("likeRatio", "");
|
|
|
+ requestParam.put("modelType","ai标签");
|
|
|
+
|
|
|
+ return requestParam;
|
|
|
+ }
|
|
|
+ private static Map<String, Object> getUserInfo(QwExternalAiAnalyze analyze) {
|
|
|
+
|
|
|
+ if (ObjectUtil.isEmpty(analyze))throw new RuntimeException("客户信息不存在");
|
|
|
+ HashMap<String, String> userInfo = new HashMap<String, String>();
|
|
|
+ List<SysDictData> portraits = SpringUtils.getBean(SysDictDataMapper.class).selectDictDataByType(AI_PORTRAIT);
|
|
|
+ List<String> dictValue = portraits.stream().map(SysDictData::getDictValue).collect(Collectors.toList());
|
|
|
+ if (analyze.getCustomerPortraitJson()!= null && !analyze.getCustomerPortraitJson().isEmpty()){
|
|
|
+ Map<String, String> portraitList = JSON.parseObject(
|
|
|
+ analyze.getCustomerPortraitJson(),
|
|
|
+ new cn.hutool.core.lang.TypeReference<Map<String, String>>() {}
|
|
|
+ );
|
|
|
+ portraitList.keySet().removeIf(k -> k.matches(".*[a-zA-Z].*"));
|
|
|
+ userInfo.putAll(portraitList);
|
|
|
+ }else {
|
|
|
+ dictValue.forEach(o->{
|
|
|
+ userInfo.put(o, "");
|
|
|
+ });
|
|
|
+ }
|
|
|
+ HashMap<String, Object> result = new HashMap<>();
|
|
|
+ result.put("userInfo", userInfo);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ private static Map<String, Object> getTags(String tradeType) {
|
|
|
+ List<CrmCustomerPropertyTemplate> templates = SpringUtils.getBean(ICrmCustomerPropertyTemplateService.class).getBaseMapper().selectList(new LambdaQueryWrapper<CrmCustomerPropertyTemplate>().eq(
|
|
|
+ CrmCustomerPropertyTemplate::getTradeType, tradeType
|
|
|
+ ));
|
|
|
+ if (ObjectUtil.isEmpty(templates)) throw new RuntimeException("该行业无标签模板");
|
|
|
+ ArrayList<Map<String, String>> tags = new ArrayList<>();//标签及提示词
|
|
|
+ templates.forEach(o -> {
|
|
|
+ Map<String, String> tag = com.fs.hisapi.util.MapUtil.convertToMap(new CrmCustomerAiAutoTagVo(String.valueOf(o.getId()), o.getName(), o.getAiHint()));
|
|
|
+ tags.add(tag);
|
|
|
+ });
|
|
|
+ HashMap<String, Object> resultMap = new HashMap<>();
|
|
|
+ resultMap.put("tags", tags);
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
+ private static final String TRADE_TYPE = "trade_type";
|
|
|
+
|
|
|
+ private static String getDictLabel(String tradeType) {
|
|
|
+ List<SysDictData> tradeTypeDict = DictUtils.getDictCache(TRADE_TYPE);
|
|
|
+ String dictLabel;
|
|
|
+ if (ObjectUtil.isEmpty(tradeTypeDict)) {
|
|
|
+ dictLabel = DictUtils.getDictLabel(TRADE_TYPE, tradeType);
|
|
|
+ } else {
|
|
|
+ Map<String, String> collect = tradeTypeDict.stream().collect(Collectors.toMap(SysDictData::getDictValue,
|
|
|
+ SysDictData::getDictLabel, (v1, v2) -> v1)
|
|
|
+ );
|
|
|
+ dictLabel = collect.get(tradeType);
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isEmpty(dictLabel)) {
|
|
|
+ throw new RuntimeException("字典中不存在该行业");
|
|
|
+ } else return dictLabel;
|
|
|
+ }
|
|
|
+ private Map<String, Object> buildRequestParamAiTag(Long customerId, String tradeType, String communication) {
|
|
|
+ Map<String, Object> requestParam = new HashMap<>();
|
|
|
+ requestParam.put("customerId", customerId);
|
|
|
+ requestParam.put("tradeType", tradeType);
|
|
|
+ requestParam.put("communication", communication);
|
|
|
+ return requestParam;
|
|
|
+ }
|
|
|
+
|
|
|
+ private JsonNode responseAnalyze(R aiResponse,String analyseKey) throws JsonProcessingException {
|
|
|
+ JsonNode rootS = mapper.readTree(JSONUtil.toJsonStr(aiResponse));
|
|
|
+ JsonNode choices = rootS.path("data").path("choices");
|
|
|
+
|
|
|
+ if (choices.isArray() && choices.size() > 0) {
|
|
|
+ JsonNode contentNode = choices.get(0).path("message").path("content");
|
|
|
+
|
|
|
+ if (contentNode.isTextual()) {
|
|
|
+ String contentStr = contentNode.asText();
|
|
|
+ // 将content字符串解析为JsonNode
|
|
|
+ JsonNode contentArray = mapper.readTree(contentStr);
|
|
|
+
|
|
|
+ if (contentArray.isArray() && contentArray.size() > 1) {
|
|
|
+ JsonNode secondElement = contentArray.get(1);
|
|
|
+ JsonNode textNode = secondElement.path("text");
|
|
|
+
|
|
|
+ if (!textNode.isMissingNode()) {
|
|
|
+ JsonNode contentInnerNode = textNode.path("content");
|
|
|
+
|
|
|
+ if (contentInnerNode.isTextual()) {
|
|
|
+ String innerJsonStr = contentInnerNode.asText();
|
|
|
+ JsonNode innerJson = mapper.readTree(innerJsonStr);
|
|
|
+ JsonNode userInfo = innerJson.path(analyseKey);
|
|
|
+ return userInfo;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ private Map<String, Object> buildRequestParamQw(QwExternalAiAnalyze qwExternalAiAnalyze, String dataJson) {
|
|
|
+ Map<String, Object> requestParam = new HashMap<>();
|
|
|
+
|
|
|
+ // 获取各类数据
|
|
|
+ Map<String, Object> userInfo = getUserInfoQw(qwExternalAiAnalyze);
|
|
|
+ String likeRatio ="";
|
|
|
+ if (!userInfo.isEmpty()){
|
|
|
+ likeRatio = (String) userInfo.remove("likeRatio");
|
|
|
+ }
|
|
|
+ // 合并数据
|
|
|
+ requestParam.put("history",dataJson);
|
|
|
+ requestParam.putAll(userInfo);
|
|
|
+
|
|
|
+ // 设置其他参数
|
|
|
+ requestParam.put("tagInfos", Collections.emptyList());
|
|
|
+ requestParam.put("isRepository", "");
|
|
|
+ requestParam.put("userContent", "");
|
|
|
+ requestParam.put("aiContent", "");
|
|
|
+ requestParam.put("likeRatio", likeRatio);
|
|
|
+
|
|
|
+ return requestParam;
|
|
|
+ }
|
|
|
+
|
|
|
+ private Map<String, Object> getUserInfoQw(QwExternalAiAnalyze qwExternalAiAnalyze) {
|
|
|
+ QwExternalAiAnalyze crmCustomerAnalyze = baseMapper.selectLatestQwAnalyze(qwExternalAiAnalyze);
|
|
|
+ if (ObjectUtil.isEmpty(crmCustomerAnalyze))throw new RuntimeException("客户信息不存在");
|
|
|
+ HashMap<String, String> userInfo = new HashMap<String, String>();
|
|
|
+ List<SysDictData> portraits = sysDictDataMapper.selectDictDataByType(AI_PORTRAIT);
|
|
|
+ List<String> dictValue = portraits.stream().map(SysDictData::getDictValue).collect(Collectors.toList());
|
|
|
+
|
|
|
+ if (crmCustomerAnalyze.getCustomerPortraitJson()!= null && !crmCustomerAnalyze.getCustomerPortraitJson().isEmpty()){
|
|
|
+ Map<String, String> portraitList = JSON.parseObject(
|
|
|
+ crmCustomerAnalyze.getCustomerPortraitJson(),
|
|
|
+ new TypeReference<Map<String, String>>() {}
|
|
|
+ );
|
|
|
+ userInfo.putAll(portraitList);
|
|
|
+
|
|
|
+ }else {
|
|
|
+ dictValue.forEach(o->{
|
|
|
+ userInfo.put(o, "");
|
|
|
+ });
|
|
|
+ }
|
|
|
+ HashMap<String, Object> result = new HashMap<>();
|
|
|
+ result.put("userInfo", userInfo);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
private Map<String, Object> buildRequestParam(Long customerId,
|
|
|
String communication) {
|
|
|
Map<String, Object> requestParam = new HashMap<>();
|
|
|
|
|
|
// 获取各类数据
|
|
|
- HashMap<String, Object> history = new HashMap<>();
|
|
|
- history.put("history", communication);
|
|
|
Map<String, Object> userInfo = getUserInfo(customerId);
|
|
|
String likeRatio ="";
|
|
|
if (!userInfo.isEmpty()){
|
|
|
@@ -604,10 +952,8 @@ public class CrmCustomerAnalyzeServiceImpl extends ServiceImpl<CrmCustomerAnalyz
|
|
|
CrmCustomerAnalyze crmCustomerAnalyze = baseMapper.selectLatestOne(customerId);
|
|
|
if (ObjectUtil.isEmpty(crmCustomerAnalyze))throw new RuntimeException("客户信息不存在");
|
|
|
HashMap<String, String> userInfo = new HashMap<String, String>();
|
|
|
-// userInfo.put("name", crmCustomerAnalyze.getCustomerName()==null?"" : crmCustomerAnalyze.getCustomerName());
|
|
|
List<SysDictData> portraits = sysDictDataMapper.selectDictDataByType(AI_PORTRAIT);
|
|
|
List<String> dictValue = portraits.stream().map(SysDictData::getDictValue).collect(Collectors.toList());
|
|
|
-// Map<String, String> portraitMap = portraits.stream().collect(Collectors.toMap(SysDictData::getDictValue, SysDictData::getDictLabel));
|
|
|
|
|
|
if (crmCustomerAnalyze.getCustomerPortraitJson()!= null && !crmCustomerAnalyze.getCustomerPortraitJson().isEmpty()){
|
|
|
Map<String, String> portraitList = JSON.parseObject(
|