Commit cdc6ea40 by zhouhaibao

[+]dify请求地址和appkey地址支持配置化,未设置取默认值

1 parent d37d919e
...@@ -87,8 +87,6 @@ public class AiAnalysisService { ...@@ -87,8 +87,6 @@ public class AiAnalysisService {
summary.put("总产值", totalOutput); summary.put("总产值", totalOutput);
summary.put("总人数", employees.size()); summary.put("总人数", employees.size());
summary.put("总客单价", totalUnitPrice.divide(new BigDecimal(employeeList.size()), 2, java.math.RoundingMode.HALF_UP));
summary.put("总转化率", String.format("%.2f%%", totalConversion.divide(new BigDecimal(employeeList.size()), 4, java.math.RoundingMode.HALF_UP).doubleValue() * 100));
employeeData.put("employee", employees); employeeData.put("employee", employees);
employeeData.put("summary", summary); employeeData.put("summary", summary);
...@@ -96,7 +94,7 @@ public class AiAnalysisService { ...@@ -96,7 +94,7 @@ public class AiAnalysisService {
log.info("业绩ai分析请求参数{}", JSONObject.toJSONString(employeeData)); log.info("业绩ai分析请求参数{}", JSONObject.toJSONString(employeeData));
// 调用 Dify API // 调用 Dify API
String result = callDifyApi(employeeData, PERFORMANCE_API_KEY); String result = callDifyApi(employeeData, environment.getProperty("dify.per.appkey")==null?PERFORMANCE_API_KEY:environment.getProperty("dify.per.appkey"));
log.info("业绩ai分析返回参数{}", result); log.info("业绩ai分析返回参数{}", result);
...@@ -172,14 +170,13 @@ public class AiAnalysisService { ...@@ -172,14 +170,13 @@ public class AiAnalysisService {
summary.put("总战败数", totalDefeat); summary.put("总战败数", totalDefeat);
summary.put("总录音数", totalRec); summary.put("总录音数", totalRec);
summary.put("总录音缺失", totalRec); // 这里可能需要根据实际业务逻辑调整 summary.put("总录音缺失", totalRec); // 这里可能需要根据实际业务逻辑调整
summary.put("平均录音缺失率", String.format("%.2f%%", totalMissingRate / employeeList.size()));
employeeData.put("employee", employees); employeeData.put("employee", employees);
employeeData.put("summary", summary); employeeData.put("summary", summary);
log.info("行为ai分析请求参数{}", JSONObject.toJSONString(employeeData)); log.info("行为ai分析请求参数{}", JSONObject.toJSONString(employeeData));
// 调用 Dify API // 调用 Dify API
String result = callDifyApi(employeeData, BEHAVIOR_API_KEY); String result = callDifyApi(employeeData, environment.getProperty("dify.beh.appkey")==null?BEHAVIOR_API_KEY:environment.getProperty("dify.beh.appkey"));
log.info("行为ai分析返回参数{}", result); log.info("行为ai分析返回参数{}", result);
// 存入缓存 // 存入缓存
...@@ -226,7 +223,7 @@ public class AiAnalysisService { ...@@ -226,7 +223,7 @@ public class AiAnalysisService {
// 2. 构建 Request // 2. 构建 Request
Request request = new Request.Builder() Request request = new Request.Builder()
.url(DIFY_API_URL) .url(environment.getProperty("dify.url")==null?DIFY_API_URL:environment.getProperty("dify.url"))
.post(body) .post(body)
.addHeader("Authorization", "Bearer " + apiKey) .addHeader("Authorization", "Bearer " + apiKey)
.addHeader("Content-Type", "application/json") .addHeader("Content-Type", "application/json")
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!