Forráskód Böngészése

客户详情ai处理客户意向度响应调试
客户详情ai打标签响应调试

lk 2 hete
szülő
commit
a14d67689f

+ 1 - 1
fs-service/src/main/java/com/fs/crm/domain/CrmCustomerAnalyze.java

@@ -52,7 +52,7 @@ public class CrmCustomerAnalyze extends BaseEntity{
 
     /** 意向度 */
     @Excel(name = "意向度")
-    private Long intentionDegree;
+    private String intentionDegree;
 
     /** ai通话聊天记录 */
     @Excel(name = "ai通话聊天记录")

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

@@ -356,6 +356,7 @@ public class CrmCustomerAnalyzeServiceImpl extends ServiceImpl<CrmCustomerAnalyz
     }
 
     @Override
+    @Async
     public void aiIntentionDegree(Long customerId, String dataJson, Long logId) {
         Map<String, Object> stringObjectMap = buildRequestParam(customerId, dataJson);
         stringObjectMap.put("modelType","客户意向度");
@@ -368,7 +369,7 @@ public class CrmCustomerAnalyzeServiceImpl extends ServiceImpl<CrmCustomerAnalyz
 // 获取 data.responseData
         JSONArray responseData = root.getJSONObject("data").getJSONArray("responseData");
 
-        JSONArray summary = null;
+        String summary = null;
 
 // 遍历 responseData
         for (int i = 0; i < responseData.size(); i++) {
@@ -383,7 +384,7 @@ public class CrmCustomerAnalyzeServiceImpl extends ServiceImpl<CrmCustomerAnalyz
                     if ("AI".equals(historyItem.getString("obj"))) {
                         String valueStr = historyItem.getString("value");
                         JSONObject valueObj = JSON.parseObject(valueStr);
-                        summary = valueObj.getJSONArray("userContent");
+                        summary = valueObj.getString("userIntent");
                         break;
                     }
                 }
@@ -391,7 +392,10 @@ public class CrmCustomerAnalyzeServiceImpl extends ServiceImpl<CrmCustomerAnalyz
             if (summary != null) break;
         }
         if (summary != null) {
-            //todo 响应处理
+            CrmCustomerAnalyze crmCustomerAnalyze = new CrmCustomerAnalyze();
+            crmCustomerAnalyze.setCustomerId(customerId);
+            crmCustomerAnalyze.setIntentionDegree(summary);
+            baseMapper.updateCustomerPortrait(crmCustomerAnalyze);
         }
     }
 
@@ -440,7 +444,7 @@ public class CrmCustomerAnalyzeServiceImpl extends ServiceImpl<CrmCustomerAnalyz
 // 获取 data.responseData
         JSONArray responseData = root.getJSONObject("data").getJSONArray("responseData");
 
-        JSONArray summary = null;
+        String summary = null;
 
 // 遍历 responseData
         for (int i = 0; i < responseData.size(); i++) {
@@ -455,7 +459,7 @@ public class CrmCustomerAnalyzeServiceImpl extends ServiceImpl<CrmCustomerAnalyz
                     if ("AI".equals(historyItem.getString("obj"))) {
                         String valueStr = historyItem.getString("value");
                         JSONObject valueObj = JSON.parseObject(valueStr);
-                        summary = valueObj.getJSONArray("userContent");
+                        summary = valueObj.getString("userIntent");
                         break;
                     }
                 }
@@ -463,7 +467,7 @@ public class CrmCustomerAnalyzeServiceImpl extends ServiceImpl<CrmCustomerAnalyz
             if (summary != null) break;
         }
         if (summary != null) {
-            //todo 响应处理
+            return summary;
         }
         return null;
     }

+ 3 - 4
fs-service/src/main/java/com/fs/crm/utils/CrmCustomerAiTagUtil.java

@@ -48,7 +48,7 @@ public class CrmCustomerAiTagUtil {
 
     //行业字典名称
     private static final String TRADE_TYPE = "trade_type";
-    @Value("${crm.customer.ai.key:mygpt-tbQfq4ejR162mGJBCTTDUH9ecP1XCVuUfaOGTipnLjb1hP8x5prg}")
+    @Value("${crm.customer.ai.key:mygpt-xZeWD9u6tTebmfn3huS8bTQ63WL2bldp56LpXnB4FWhTnIQMqW4t}")
     private String appKey;
     private static final String CRM_AI_REDIS_KEY = "crm:AI:data:processing";
 
@@ -82,7 +82,6 @@ public class CrmCustomerAiTagUtil {
 
         // 3. 调用AI服务
         R aiResponse = callAiService(requestParam, logId);
-
         // 4. 解析响应并保存
         List<CrmCustomerAiTagVo> results = parseAiResponse(aiResponse, customerId);
 
@@ -214,7 +213,7 @@ public class CrmCustomerAiTagUtil {
             // 查找 AI 对话节点
             for (JsonNode node : responseData) {
                 String moduleName = node.path("moduleName").asText();
-                if ("AI 对话".equals(moduleName)) {
+                if ("AI 对话#7".equals(moduleName)) {
                     // 获取 historyPreview 数组
                     JsonNode historyPreview = node.path("historyPreview");
 
@@ -227,7 +226,7 @@ public class CrmCustomerAiTagUtil {
                             // 如果 value 是字符串,需要再次解析
                             if (valueNode.isTextual()) {
                                 String valueStr = valueNode.asText();
-                                JsonNode tagInfosNode = mapper.readTree(valueStr).path("tagInfos");
+                                JsonNode tagInfosNode = mapper.readTree(valueStr).path("tagsInfo");
 
                                 if (tagInfosNode.isArray()) {
                                     return mapper.convertValue(tagInfosNode,

+ 4 - 0
fs-service/src/main/resources/mapper/crm/CrmCustomerAnalyzeMapper.xml

@@ -127,6 +127,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="customerFocusJson != null and customerFocusJson != ''">
                 customer_focus_json = #{customerFocusJson},
             </if>
+            <if test="intentionDegree != null and intentionDegree != ''">
+                intention_degree = #{intentionDegree},
+            </if>
+
         </set>
         where customer_id = #{customerId}
         ORDER BY create_time DESC