feat: 增强工作台趋势概览与聊天排行

- 支持用户活跃与智能体活跃趋势统计及自定义时间范围

- 增加用户活跃榜与智能体趋势数据结构及查询实现

- 同步补齐工作台页面展示与定向测试
This commit is contained in:
2026-05-06 19:22:09 +08:00
parent 5827ecde42
commit 31b0e21d3d
20 changed files with 2087 additions and 146 deletions

View File

@@ -1,5 +1,7 @@
package tech.easyflow.chatlog.service;
import tech.easyflow.chatlog.domain.dto.ChatActiveUserRank;
import tech.easyflow.chatlog.domain.dto.ChatAssistantSessionTrend;
import tech.easyflow.chatlog.domain.dto.ChatAssistantUsageRank;
import tech.easyflow.chatlog.domain.dto.ChatDashboardSummary;
import tech.easyflow.chatlog.domain.dto.ChatDashboardTrend;
@@ -58,6 +60,48 @@ public interface ChatDashboardQueryService {
BigInteger tenantId,
int limit);
/**
* 查询智能体日趋势。
*
* @param startDate 开始日期,包含当天
* @param endDate 结束日期,不包含当天
* @param tenantId 租户 ID空表示全局
* @param assistantIds 智能体 ID 列表
* @return 智能体日趋势
*/
List<ChatAssistantSessionTrend> queryAssistantTrends(LocalDate startDate,
LocalDate endDate,
BigInteger tenantId,
List<BigInteger> assistantIds);
/**
* 查询智能体小时趋势。
*
* @param startTime 开始时间,包含
* @param endTime 结束时间,不包含
* @param tenantId 租户 ID空表示全局
* @param assistantIds 智能体 ID 列表
* @return 智能体小时趋势
*/
List<ChatAssistantSessionTrend> queryAssistantHourlyTrends(LocalDateTime startTime,
LocalDateTime endTime,
BigInteger tenantId,
List<BigInteger> assistantIds);
/**
* 查询活跃用户排行。
*
* @param startDate 开始日期,包含当天
* @param endDate 结束日期,不包含当天
* @param tenantId 租户 ID空表示全局
* @param limit 返回条数
* @return 活跃用户排行
*/
List<ChatActiveUserRank> queryActiveUserRanks(LocalDate startDate,
LocalDate endDate,
BigInteger tenantId,
int limit);
/**
* 当前分析库是否可用。
*

View File

@@ -1,6 +1,8 @@
package tech.easyflow.chatlog.service.impl;
import org.springframework.stereotype.Service;
import tech.easyflow.chatlog.domain.dto.ChatActiveUserRank;
import tech.easyflow.chatlog.domain.dto.ChatAssistantSessionTrend;
import tech.easyflow.chatlog.domain.dto.ChatAssistantUsageRank;
import tech.easyflow.chatlog.domain.dto.ChatDashboardSummary;
import tech.easyflow.chatlog.domain.dto.ChatDashboardTrend;
@@ -93,6 +95,66 @@ public class ChatDashboardQueryServiceImpl implements ChatDashboardQueryService
return analyticalDBRepository.queryAssistantUsageRanks(startDate, endDate, tenantId, limit);
}
/**
* 查询智能体日趋势。
*
* @param startDate 开始日期,包含当天
* @param endDate 结束日期,不包含当天
* @param tenantId 租户 ID空表示全局
* @param assistantIds 智能体 ID 列表
* @return 智能体日趋势
*/
@Override
public List<ChatAssistantSessionTrend> queryAssistantTrends(LocalDate startDate,
LocalDate endDate,
BigInteger tenantId,
List<BigInteger> assistantIds) {
if (!available() || assistantIds == null || assistantIds.isEmpty()) {
return Collections.emptyList();
}
return analyticalDBRepository.queryAssistantSessionTrends(startDate, endDate, tenantId, assistantIds);
}
/**
* 查询智能体小时趋势。
*
* @param startTime 开始时间,包含
* @param endTime 结束时间,不包含
* @param tenantId 租户 ID空表示全局
* @param assistantIds 智能体 ID 列表
* @return 智能体小时趋势
*/
@Override
public List<ChatAssistantSessionTrend> queryAssistantHourlyTrends(LocalDateTime startTime,
LocalDateTime endTime,
BigInteger tenantId,
List<BigInteger> assistantIds) {
if (!available() || assistantIds == null || assistantIds.isEmpty()) {
return Collections.emptyList();
}
return analyticalDBRepository.queryAssistantSessionHourlyTrends(startTime, endTime, tenantId, assistantIds);
}
/**
* 查询活跃用户排行。
*
* @param startDate 开始日期,包含当天
* @param endDate 结束日期,不包含当天
* @param tenantId 租户 ID空表示全局
* @param limit 返回条数
* @return 活跃用户排行
*/
@Override
public List<ChatActiveUserRank> queryActiveUserRanks(LocalDate startDate,
LocalDate endDate,
BigInteger tenantId,
int limit) {
if (!available()) {
return Collections.emptyList();
}
return analyticalDBRepository.queryActiveUserRanks(startDate, endDate, tenantId, limit);
}
/**
* 当前分析库是否可用。
*