|
|
@@ -797,54 +797,51 @@ public class CompanyVoiceRoboticServiceImpl extends ServiceImpl<CompanyVoiceRobo
|
|
|
);
|
|
|
// 切换 Redis 租户上下文
|
|
|
RedisTenantContext.setTenantId(TenantHelper.getTenantId());
|
|
|
- isSwitched = true;
|
|
|
} catch (Exception e) {
|
|
|
log.error("callerResult4EasyCall 切换租户数据源失败: tenantId={}", TenantHelper.getTenantId(), e);
|
|
|
}
|
|
|
-// // intent(意向度)由对方异步评估写入,回调时可能尚未赋值,进入延迟重试队列等待
|
|
|
-// if (StringUtils.isBlank(callPhoneRes.getIntent())) {
|
|
|
-// String retryKey = EASYCALL_INTENT_RETRY_KEY + result.getUuid();
|
|
|
-// Integer retryCount = redisCache2.getCacheObject(retryKey);
|
|
|
-// if (retryCount == null) {
|
|
|
-// retryCount = 0;
|
|
|
-// }
|
|
|
-// if (retryCount < EASYCALL_INTENT_MAX_RETRY) {
|
|
|
-// redisCache2.setCacheObject(retryKey, retryCount + 1, 10, java.util.concurrent.TimeUnit.MINUTES);
|
|
|
-// log.info("easyCall外呼回调intent意向度暂未评估完成,uuid={},第{}次放入延迟重试队列", result.getUuid(), retryCount + 1);
|
|
|
-// doRetryCallerResult4EasyCall(result, retryCount + 1);
|
|
|
-// } else {
|
|
|
-// // 超过最大重试次数,以 intent 为空(意向未知)兜底继续处理
|
|
|
-// log.warn("easyCall外呼回调intent意向度在{}次重试后仍为空,uuid={},以意向未知兜底处理", EASYCALL_INTENT_MAX_RETRY, result.getUuid());
|
|
|
-// redisCache2.deleteObject(retryKey);
|
|
|
-// doHandleEasyCallResult(callPhoneRes);
|
|
|
-// }
|
|
|
-// return;
|
|
|
-// }
|
|
|
-// // intent 已有值,直接正常处理
|
|
|
-// redisCache2.deleteObject(EASYCALL_INTENT_RETRY_KEY + result.getUuid());
|
|
|
-// doHandleEasyCallResult(callPhoneRes);
|
|
|
- // dialogue(对话内容)由对方异步写入,回调时可能尚未赋值,进入延迟重试队列等待
|
|
|
- if (isDialogueEmpty(callPhoneRes.getDialogue()) && !"未接通".equals(callPhoneRes.getIntent())) {
|
|
|
- String retryKey = EASYCALL_DIALOGUE_RETRY_KEY + result.getUuid();
|
|
|
+ // 【当前启用】cc_call_phone.intent 由 EasyCall 异步评估写入,回调时可能尚未赋值,进入延迟重试队列等待
|
|
|
+ if (StringUtils.isBlank(resolveCcCallPhoneIntent(callPhoneRes))) {
|
|
|
+ String retryKey = EASYCALL_INTENT_RETRY_KEY + result.getUuid();
|
|
|
Integer retryCount = redisCache2.getCacheObject(retryKey);
|
|
|
if (retryCount == null) {
|
|
|
retryCount = 0;
|
|
|
}
|
|
|
- if (retryCount < EASYCALL_DIALOGUE_MAX_RETRY) {
|
|
|
+ if (retryCount < EASYCALL_INTENT_MAX_RETRY) {
|
|
|
redisCache2.setCacheObject(retryKey, retryCount + 1, 10, java.util.concurrent.TimeUnit.MINUTES);
|
|
|
- log.info("easyCall外呼回调dialogue对话内容暂未写入,uuid={},第{}次放入延迟重试队列", result.getUuid(), retryCount + 1);
|
|
|
- doRetryDialogue4EasyCall(result, retryCount + 1);
|
|
|
+ log.info("easyCall外呼回调intent意向度暂未评估完成,uuid={},第{}次放入延迟重试队列", result.getUuid(), retryCount + 1);
|
|
|
+ doRetryCallerResult4EasyCall(result, retryCount + 1);
|
|
|
} else {
|
|
|
- // 超过最大重试次数,以 dialogue 为空兜底继续处理
|
|
|
- log.warn("easyCall外呼回调dialogue对话内容在{}次重试后仍为空,uuid={},以对话为空兜底处理", EASYCALL_DIALOGUE_MAX_RETRY, result.getUuid());
|
|
|
+ log.warn("easyCall外呼回调intent意向度在{}次重试后仍为空,uuid={},以意向未知兜底处理", EASYCALL_INTENT_MAX_RETRY, result.getUuid());
|
|
|
redisCache2.deleteObject(retryKey);
|
|
|
doHandleEasyCallResult(callPhoneRes);
|
|
|
}
|
|
|
return;
|
|
|
}
|
|
|
- // dialogue 已有值,直接正常处理
|
|
|
- redisCache2.deleteObject(EASYCALL_DIALOGUE_RETRY_KEY + result.getUuid());
|
|
|
+ redisCache2.deleteObject(EASYCALL_INTENT_RETRY_KEY + result.getUuid());
|
|
|
doHandleEasyCallResult(callPhoneRes);
|
|
|
+
|
|
|
+ // ========== 【历史保留-自家AI】根据 dialogue 等待后走 AI 意向度,回滚时注释上方 intent 重试并取消下方注释 ==========
|
|
|
+// // 当前:根据对话内容同步调用自家 AI 计算意向度,不依赖第三方 intent
|
|
|
+// if (isDialogueEmpty(callPhoneRes.getDialogue()) && !"未接通".equals(callPhoneRes.getIntent())) {
|
|
|
+// String retryKey = EASYCALL_DIALOGUE_RETRY_KEY + result.getUuid();
|
|
|
+// Integer retryCount = redisCache2.getCacheObject(retryKey);
|
|
|
+// if (retryCount == null) {
|
|
|
+// retryCount = 0;
|
|
|
+// }
|
|
|
+// if (retryCount < EASYCALL_DIALOGUE_MAX_RETRY) {
|
|
|
+// redisCache2.setCacheObject(retryKey, retryCount + 1, 10, java.util.concurrent.TimeUnit.MINUTES);
|
|
|
+// log.info("easyCall外呼回调dialogue对话内容暂未写入,uuid={},第{}次放入延迟重试队列", result.getUuid(), retryCount + 1);
|
|
|
+// doRetryDialogue4EasyCall(result, retryCount + 1);
|
|
|
+// } else {
|
|
|
+// log.warn("easyCall外呼回调dialogue对话内容在{}次重试后仍为空,uuid={},以对话为空兜底处理", EASYCALL_DIALOGUE_MAX_RETRY, result.getUuid());
|
|
|
+// redisCache2.deleteObject(retryKey);
|
|
|
+// doHandleEasyCallResult(callPhoneRes);
|
|
|
+// }
|
|
|
+// return;
|
|
|
+// }
|
|
|
+// redisCache2.deleteObject(EASYCALL_DIALOGUE_RETRY_KEY + result.getUuid());
|
|
|
+// doHandleEasyCallResult(callPhoneRes);
|
|
|
} catch (Exception e) {
|
|
|
throw new RuntimeException(e);
|
|
|
} finally {
|
|
|
@@ -1054,27 +1051,37 @@ public class CompanyVoiceRoboticServiceImpl extends ServiceImpl<CompanyVoiceRobo
|
|
|
// log.error("pushDialogContent4EasyCall 切换租户数据源失败: tenantId={}", TenantHelper.getTenantId(), e);
|
|
|
// }
|
|
|
// }
|
|
|
- String intention = null;
|
|
|
- String intentionDegree = null;
|
|
|
- if (StringUtils.isNotBlank(callPhoneRes.getDialogue())) {
|
|
|
- log.info("【验证】意向度来源=自家AI, uuid={}, dialogueLength={}", callPhoneRes.getUuid(),
|
|
|
- StringUtils.isBlank(callPhoneRes.getDialogue()) ? 0 : callPhoneRes.getDialogue().length());
|
|
|
- try {
|
|
|
- intentionDegree = crmCustomerAnalyzeService.aiIntentionDegree(
|
|
|
- callPhoneRes.getDialogue(),
|
|
|
- now().getLong(ChronoField.MILLI_OF_SECOND)
|
|
|
- );
|
|
|
- log.info("【验证】意向度结果={}, uuid={}", intentionDegree, callPhoneRes.getUuid());
|
|
|
- intention = getIntention(intentionDegree);
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("easyCall意向度AI解析失败,uuid={},将使用意向未知兜底", callPhoneRes.getUuid(), e);
|
|
|
- }
|
|
|
- }
|
|
|
- // 2) 最终兜底:意向未知
|
|
|
-// String intention = getIntention(callPhoneRes.getIntent());
|
|
|
+ // 【当前启用】读取 cc_call_phone.intent,再转换为系统字典 intention 数值
|
|
|
+ String intentRaw = resolveCcCallPhoneIntent(callPhoneRes);
|
|
|
+ String intention = convertEasyCallIntent(intentRaw);
|
|
|
+ log.info("easyCall意向度来源=EasyCall平台, uuid={}, intent(raw)={}, intention(converted)={}",
|
|
|
+ callPhoneRes.getUuid(), intentRaw, intention);
|
|
|
if (StringUtils.isEmpty(intention)) {
|
|
|
intention = "0";
|
|
|
}
|
|
|
+
|
|
|
+ // ========== 【历史保留-自家AI】回滚时注释上方 EasyCall 逻辑并取消下方注释 ==========
|
|
|
+// String intention = null;
|
|
|
+// String intentionDegree = null;
|
|
|
+// if (StringUtils.isNotBlank(callPhoneRes.getDialogue())) {
|
|
|
+// log.info("【验证】意向度来源=自家AI, uuid={}, dialogueLength={}", callPhoneRes.getUuid(),
|
|
|
+// StringUtils.isBlank(callPhoneRes.getDialogue()) ? 0 : callPhoneRes.getDialogue().length());
|
|
|
+// try {
|
|
|
+// intentionDegree = crmCustomerAnalyzeService.aiIntentionDegree(
|
|
|
+// callPhoneRes.getDialogue(),
|
|
|
+// java.time.LocalTime.now().getLong(java.time.temporal.ChronoField.MILLI_OF_SECOND)
|
|
|
+// );
|
|
|
+// log.info("【验证】意向度结果={}, uuid={}", intentionDegree, callPhoneRes.getUuid());
|
|
|
+// intention = getIntention(intentionDegree);
|
|
|
+// } catch (Exception e) {
|
|
|
+// log.error("easyCall意向度AI解析失败,uuid={},将使用意向未知兜底", callPhoneRes.getUuid(), e);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// if (StringUtils.isEmpty(intention)) {
|
|
|
+// intention = "0";
|
|
|
+// }
|
|
|
+// // 历史第三方值(仅 intent 字段,未走 AI 时的写法)
|
|
|
+// // String intention = getIntention(callPhoneRes.getIntent());
|
|
|
CompanyVoiceRoboticCallees callee = companyVoiceRoboticCalleesMapper.selectCompanyVoiceRoboticCalleesById(cacheInfo.getLong("calleeId"));
|
|
|
callee.setUuid(callPhoneRes.getUuid());
|
|
|
callee.setIntention(intention);
|
|
|
@@ -2325,4 +2332,29 @@ public class CompanyVoiceRoboticServiceImpl extends ServiceImpl<CompanyVoiceRobo
|
|
|
new LambdaQueryWrapper<CompanyVoiceRobotic>().eq(CompanyVoiceRobotic::getTaskId, Long.valueOf(taskId)));
|
|
|
return robotic != null ? robotic.getCompanyId() : null;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 读取 EasyCall cc_call_phone 表原始字段 intent(非本系统 intention 字典值)
|
|
|
+ */
|
|
|
+ private String resolveCcCallPhoneIntent(EasyCallCallPhoneVO callPhoneRes) {
|
|
|
+ if (callPhoneRes == null || StringUtils.isBlank(callPhoneRes.getIntent())) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return callPhoneRes.getIntent().trim();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 将 cc_call_phone.intent 原始值转为系统字典数值 intention(customer_intention_level.dict_value)
|
|
|
+ */
|
|
|
+ private String convertEasyCallIntent(String intentRaw) {
|
|
|
+ if (StringUtils.isBlank(intentRaw)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ String t = intentRaw.trim();
|
|
|
+ if (t.matches("^\\d+$")) {
|
|
|
+ return t;
|
|
|
+ }
|
|
|
+ return getIntention(t);
|
|
|
+ }
|
|
|
+
|
|
|
}
|