Преглед изворни кода

客户详情ai意向度显示优化
对话图录入ai打标签优化

lk пре 2 недеља
родитељ
комит
e432595561

+ 6 - 6
fs-company/src/main/java/com/fs/company/controller/crm/CrmCustomerController.java

@@ -191,12 +191,12 @@ public class CrmCustomerController extends BaseController
 //            param.setCompanyId(0L);
 //        }
         //默认值处理
-        if(param.getIntentionDegreeGt() != null && param.getIntentionDegreeGt() == 0){
-            param.setIntentionDegreeGt(null);
-        }
-        if(param.getIntentionDegreelt() != null && param.getIntentionDegreelt() == 0){
-            param.setIntentionDegreelt(null);
-        }
+//        if(param.getIntentionDegreeGt() != null && param.getIntentionDegreeGt() == 0){
+//            param.setIntentionDegreeGt(null);
+//        }
+//        if(param.getIntentionDegreelt() != null && param.getIntentionDegreelt() == 0){
+//            param.setIntentionDegreelt(null);
+//        }
         if (param.getIsReceive() != null && param.getIsReceive() == 0){
             CrmLineCustomerListQueryParam param1 = new CrmLineCustomerListQueryParam();
             BeanUtils.copyProperties(param,param1);

+ 3 - 0
fs-service/src/main/java/com/fs/crm/mapper/CrmCustomerMapper.java

@@ -509,6 +509,9 @@ public interface CrmCustomerMapper extends BaseMapper<CrmCustomer> {
             "<if test = 'maps.intentionDegreelt != null'> " +
             "and ca.intention_degree &lt;= #{maps.intentionDegreelt} " +
             "</if>" +
+            "<if test = 'maps.intentionDegree != null and maps.intentionDegree != \"\" ' > " +
+            "and ca.intention_degree = #{maps.intentionDegree} " +
+            "</if>" +
             " order by c.customer_id desc "+
             "</script>"})
     List<CrmLineCustomerListQueryVO> selectCrmLineCustomerListQuery(@Param("maps") CrmLineCustomerListQueryParam param);

+ 2 - 1
fs-service/src/main/java/com/fs/crm/param/CrmCustomerListQueryParam.java

@@ -109,6 +109,7 @@ public class CrmCustomerListQueryParam extends BaseQueryParam
     private Long intentionDegreeGt;
     /** 意向度<= */
     private Long intentionDegreelt;
-
+    /** 意向度 */
+    private String intentionDegree;
 
 }

+ 2 - 0
fs-service/src/main/java/com/fs/crm/param/CrmLineCustomerListQueryParam.java

@@ -92,4 +92,6 @@ public class CrmLineCustomerListQueryParam extends BaseQueryParam
     /** 意向度<= */
     private Long intentionDegreelt;
 
+    /** 意向度 */
+    private String intentionDegree;
 }

+ 1 - 1
fs-service/src/main/java/com/fs/crm/service/impl/CrmCustomerAnalyzeServiceImpl.java

@@ -114,7 +114,7 @@ public class CrmCustomerAnalyzeServiceImpl extends ServiceImpl<CrmCustomerAnalyz
     }
     private static final String AI_PORTRAIT = "crm_ai_portrait";
     private static final ObjectMapper mapper = new ObjectMapper();
-    @Value("${crm.customer.ai.Key:mygpt-qZllJOSsaKw51T8D1Ug20aGJWcEPlC9OoR5kOKLQ8G9dsCeW3xa2m}")
+    @Value("${crm.customer.ai.Key:mygpt-oPG2ifhnq0ODGioOBMUvMfOZGrtCykqw3oMeYLchdUDK5He6iNiactrhFWA0sID}")
     private String OTHER_KEY;
     //ai获取客户画像
     @Override

+ 22 - 12
fs-service/src/main/java/com/fs/crm/utils/CrmCustomerAiTagUtil.java

@@ -1,10 +1,9 @@
 package com.fs.crm.utils;
 
-import cn.hutool.core.collection.ListUtil;
 import cn.hutool.core.util.ObjectUtil;
 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.QueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.fasterxml.jackson.core.JsonProcessingException;
 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.fs.common.core.domain.R;
 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.date.DateUtil;
 import com.fs.common.utils.spring.SpringUtils;
 import com.fs.config.ai.AiHostProper;
 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.service.ChatService;
 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.Qualifier;
 import org.springframework.beans.factory.annotation.Value;
@@ -48,9 +45,10 @@ public class CrmCustomerAiTagUtil {
 
     //行业字典名称
     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 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();
 
@@ -342,6 +340,8 @@ public class CrmCustomerAiTagUtil {
 
     private static Map<String, Object> getUserInfo(Long customerId) {
         CrmCustomerMapper customerMapper = SpringUtils.getBean(CrmCustomerMapper.class);
+        CrmCustomerAnalyzeMapper CrmCustomerAnalyzeMapper = SpringUtils.getBean(CrmCustomerAnalyzeMapper.class);
+
         CrmCustomer crmCustomer = customerMapper.selectCrmCustomerById(customerId);
         if (ObjectUtil.isEmpty(crmCustomer)) throw new RuntimeException("客户不存在");
         CrmCustomerInfo crmCustomerInfo = customerMapper.selectCrmCustomerInfoById(customerId);
@@ -351,13 +351,23 @@ public class CrmCustomerAiTagUtil {
                     .setTalk("首次交流");
             customerMapper.insertCrmCustomerInfo(crmCustomerInfo);
         }
+        CrmCustomerAnalyze crmCustomerAnalyze = CrmCustomerAnalyzeMapper.selectLatestOne(customerId);
+        if (ObjectUtil.isEmpty(crmCustomerAnalyze))throw new RuntimeException("客户信息不存在");
         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<>();
         result.put("userInfo", userInfo);
         result.put("likeRatio", ObjectUtil.isNotEmpty(crmCustomer.getIntention()) ? crmCustomer.getIntention() : "");

+ 1 - 1
fs-service/src/main/java/com/fs/crm/vo/CrmLineCustomerListQueryVO.java

@@ -111,7 +111,7 @@ public class CrmLineCustomerListQueryVO implements Serializable
     private Long attritionLevel;
     /** 意向度 */
     @Excel(name = "意向度")
-    private Long intentionDegree;
+    private String intentionDegree;
 
 
 }