|
@@ -1,10 +1,9 @@
|
|
|
package com.fs.crm.utils;
|
|
package com.fs.crm.utils;
|
|
|
|
|
|
|
|
-import cn.hutool.core.collection.ListUtil;
|
|
|
|
|
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.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
import com.fasterxml.jackson.core.type.TypeReference;
|
|
import com.fasterxml.jackson.core.type.TypeReference;
|
|
@@ -12,9 +11,7 @@ import com.fasterxml.jackson.databind.JsonNode;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.fs.common.core.domain.R;
|
|
import com.fs.common.core.domain.R;
|
|
|
import com.fs.common.core.domain.entity.SysDictData;
|
|
import com.fs.common.core.domain.entity.SysDictData;
|
|
|
-import com.fs.common.exception.CustomException;
|
|
|
|
|
import com.fs.common.utils.DictUtils;
|
|
import com.fs.common.utils.DictUtils;
|
|
|
-import com.fs.common.utils.date.DateUtil;
|
|
|
|
|
import com.fs.common.utils.spring.SpringUtils;
|
|
import com.fs.common.utils.spring.SpringUtils;
|
|
|
import com.fs.config.ai.AiHostProper;
|
|
import com.fs.config.ai.AiHostProper;
|
|
|
import com.fs.crm.domain.CrmCustomer;
|
|
import com.fs.crm.domain.CrmCustomer;
|
|
@@ -30,7 +27,7 @@ import com.fs.crm.vo.CrmCustomerAiTagVo;
|
|
|
import com.fs.fastgptApi.param.ChatParam;
|
|
import com.fs.fastgptApi.param.ChatParam;
|
|
|
import com.fs.fastgptApi.service.ChatService;
|
|
import com.fs.fastgptApi.service.ChatService;
|
|
|
import com.fs.hisapi.util.MapUtil;
|
|
import com.fs.hisapi.util.MapUtil;
|
|
|
-import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
|
+import com.fs.system.mapper.SysDictDataMapper;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Qualifier;
|
|
import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
@@ -48,9 +45,10 @@ public class CrmCustomerAiTagUtil {
|
|
|
|
|
|
|
|
//行业字典名称
|
|
//行业字典名称
|
|
|
private static final String TRADE_TYPE = "trade_type";
|
|
private static final String TRADE_TYPE = "trade_type";
|
|
|
- @Value("${crm.customer.ai.key:mygpt-qZllJOSsaKw51T8D1Ug20aGJWcEPlC9OoR5kOKLQ8G9dsCeW3xa2m}")
|
|
|
|
|
|
|
+ @Value("${crm.customer.ai.key:mygpt-oPG2ifhnq0ODGioOBMUvMfOZGrtCykqw3oMeYLchdUDK5He6iNiactrhFWA0sID}")
|
|
|
private String appKey;
|
|
private String appKey;
|
|
|
private static final String CRM_AI_REDIS_KEY = "crm:AI:data:processing";
|
|
private static final String CRM_AI_REDIS_KEY = "crm:AI:data:processing";
|
|
|
|
|
+ private static final String AI_PORTRAIT = "crm_ai_portrait";
|
|
|
|
|
|
|
|
private static final ObjectMapper mapper = new ObjectMapper();
|
|
private static final ObjectMapper mapper = new ObjectMapper();
|
|
|
|
|
|
|
@@ -342,6 +340,8 @@ public class CrmCustomerAiTagUtil {
|
|
|
|
|
|
|
|
private static Map<String, Object> getUserInfo(Long customerId) {
|
|
private static Map<String, Object> getUserInfo(Long customerId) {
|
|
|
CrmCustomerMapper customerMapper = SpringUtils.getBean(CrmCustomerMapper.class);
|
|
CrmCustomerMapper customerMapper = SpringUtils.getBean(CrmCustomerMapper.class);
|
|
|
|
|
+ CrmCustomerAnalyzeMapper CrmCustomerAnalyzeMapper = SpringUtils.getBean(CrmCustomerAnalyzeMapper.class);
|
|
|
|
|
+
|
|
|
CrmCustomer crmCustomer = customerMapper.selectCrmCustomerById(customerId);
|
|
CrmCustomer crmCustomer = customerMapper.selectCrmCustomerById(customerId);
|
|
|
if (ObjectUtil.isEmpty(crmCustomer)) throw new RuntimeException("客户不存在");
|
|
if (ObjectUtil.isEmpty(crmCustomer)) throw new RuntimeException("客户不存在");
|
|
|
CrmCustomerInfo crmCustomerInfo = customerMapper.selectCrmCustomerInfoById(customerId);
|
|
CrmCustomerInfo crmCustomerInfo = customerMapper.selectCrmCustomerInfoById(customerId);
|
|
@@ -351,13 +351,23 @@ public class CrmCustomerAiTagUtil {
|
|
|
.setTalk("首次交流");
|
|
.setTalk("首次交流");
|
|
|
customerMapper.insertCrmCustomerInfo(crmCustomerInfo);
|
|
customerMapper.insertCrmCustomerInfo(crmCustomerInfo);
|
|
|
}
|
|
}
|
|
|
|
|
+ CrmCustomerAnalyze crmCustomerAnalyze = CrmCustomerAnalyzeMapper.selectLatestOne(customerId);
|
|
|
|
|
+ if (ObjectUtil.isEmpty(crmCustomerAnalyze))throw new RuntimeException("客户信息不存在");
|
|
|
HashMap<String, String> userInfo = new HashMap<String, String>();
|
|
HashMap<String, String> userInfo = new HashMap<String, String>();
|
|
|
- userInfo.put("name", crmCustomerInfo.getName()==null?"" : crmCustomerInfo.getName());
|
|
|
|
|
- userInfo.put("sex", crmCustomerInfo.getSex()==null?"" : crmCustomerInfo.getSex().toString());
|
|
|
|
|
- userInfo.put("age", "");
|
|
|
|
|
- userInfo.put("city", "");
|
|
|
|
|
- userInfo.put("habits", "");
|
|
|
|
|
- userInfo.put("describe", "");
|
|
|
|
|
|
|
+ List<SysDictData> portraits = SpringUtils.getBean(SysDictDataMapper.class).selectDictDataByType(AI_PORTRAIT);
|
|
|
|
|
+ List<String> dictValue = portraits.stream().map(SysDictData::getDictValue).collect(Collectors.toList());
|
|
|
|
|
+ if (crmCustomerAnalyze.getCustomerPortraitJson() != null){
|
|
|
|
|
+ Map<String, String> portraitList = JSON.parseObject(
|
|
|
|
|
+ crmCustomerAnalyze.getCustomerPortraitJson(),
|
|
|
|
|
+ new cn.hutool.core.lang.TypeReference<Map<String, String>>() {}
|
|
|
|
|
+ );
|
|
|
|
|
+ userInfo.putAll(portraitList);
|
|
|
|
|
+
|
|
|
|
|
+ }else {
|
|
|
|
|
+ dictValue.forEach(o->{
|
|
|
|
|
+ userInfo.put(o, "");
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
HashMap<String, Object> result = new HashMap<>();
|
|
HashMap<String, Object> result = new HashMap<>();
|
|
|
result.put("userInfo", userInfo);
|
|
result.put("userInfo", userInfo);
|
|
|
result.put("likeRatio", ObjectUtil.isNotEmpty(crmCustomer.getIntention()) ? crmCustomer.getIntention() : "");
|
|
result.put("likeRatio", ObjectUtil.isNotEmpty(crmCustomer.getIntention()) ? crmCustomer.getIntention() : "");
|