Bläddra i källkod

客户管理详情AI分析bug优化

lk 1 vecka sedan
förälder
incheckning
1c4852abc0

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

@@ -609,7 +609,7 @@ public class CrmCustomerAnalyzeServiceImpl extends ServiceImpl<CrmCustomerAnalyz
         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().isEmpty()){
+        if (crmCustomerAnalyze.getCustomerPortraitJson()!= null && !crmCustomerAnalyze.getCustomerPortraitJson().isEmpty()){
             Map<String, String> portraitList = JSON.parseObject(
                     crmCustomerAnalyze.getCustomerPortraitJson(),
                     new TypeReference<Map<String, String>>() {}

+ 8 - 1
fs-service/src/main/java/com/fs/crm/utils/CrmCustomerAiTagUtil.java

@@ -356,7 +356,7 @@ public class CrmCustomerAiTagUtil {
         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 (!crmCustomerAnalyze.getCustomerPortraitJson().isEmpty()){
+        if (crmCustomerAnalyze.getCustomerPortraitJson()!= null && !crmCustomerAnalyze.getCustomerPortraitJson().isEmpty()){
             Map<String, String> portraitList = JSON.parseObject(
                     crmCustomerAnalyze.getCustomerPortraitJson(),
                     new cn.hutool.core.lang.TypeReference<Map<String, String>>() {}
@@ -403,6 +403,13 @@ public class CrmCustomerAiTagUtil {
         if (!maps.isEmpty()){
             CrmCustomerAnalyzeMapper bean = SpringUtils.getBean(CrmCustomerAnalyzeMapper.class);
             CrmCustomerAnalyze crmCustomerAnalyze = bean.selectLatestOne(Long.valueOf(customerId));
+            if (crmCustomerAnalyze == null){
+                CrmCustomerMapper customerMapper = SpringUtils.getBean(CrmCustomerMapper.class);
+                CrmCustomer crmCustomer = customerMapper.selectCrmCustomerById(Long.valueOf(customerId));
+                crmCustomerAnalyze = new CrmCustomerAnalyze();
+                crmCustomerAnalyze.setCustomerId(Long.valueOf(customerId));
+                crmCustomerAnalyze.setCustomerName(crmCustomer.getCustomerName());
+            }
             crmCustomerAnalyze.setAiChatRecord(JSONUtil.toJsonStr(maps));
             crmCustomerAnalyze.setCreateTime(new Date());
             bean.insertCrmCustomerAnalyze(crmCustomerAnalyze);