feat: 新增管理端工作台总览
- 新增 Dashboard 统计接口、菜单迁移与权限点 - 管理端工作台页面切换为真实概览数据和趋势图 - 默认首页切换到工作台
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
package tech.easyflow.admin.controller.dashboard;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import tech.easyflow.admin.model.dashboard.DashboardOverviewQuery;
|
||||
import tech.easyflow.admin.model.dashboard.DashboardOverviewVo;
|
||||
import tech.easyflow.admin.service.dashboard.DashboardService;
|
||||
import tech.easyflow.common.domain.Result;
|
||||
import tech.easyflow.common.satoken.util.SaTokenUtil;
|
||||
|
||||
/**
|
||||
* 管理端工作台统计接口。
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/dashboard")
|
||||
public class DashboardController {
|
||||
|
||||
private final DashboardService dashboardService;
|
||||
|
||||
public DashboardController(DashboardService dashboardService) {
|
||||
this.dashboardService = dashboardService;
|
||||
}
|
||||
|
||||
@GetMapping("/overview")
|
||||
@SaCheckPermission("/api/v1/dashboard/query")
|
||||
public Result<DashboardOverviewVo> overview(DashboardOverviewQuery query) {
|
||||
return Result.ok(dashboardService.getOverview(SaTokenUtil.getLoginAccount(), query));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package tech.easyflow.admin.model.dashboard;
|
||||
|
||||
/**
|
||||
* 工作台分布/排行项。
|
||||
*/
|
||||
public class DashboardDistributionItemVo {
|
||||
|
||||
private String key;
|
||||
|
||||
private String label;
|
||||
|
||||
private Long value;
|
||||
|
||||
private Long userTotal;
|
||||
|
||||
private Long activeUserTotal;
|
||||
|
||||
private Long botTotal;
|
||||
|
||||
private Long workflowTotal;
|
||||
|
||||
private Long knowledgeBaseTotal;
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public Long getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(Long value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public Long getUserTotal() {
|
||||
return userTotal;
|
||||
}
|
||||
|
||||
public void setUserTotal(Long userTotal) {
|
||||
this.userTotal = userTotal;
|
||||
}
|
||||
|
||||
public Long getActiveUserTotal() {
|
||||
return activeUserTotal;
|
||||
}
|
||||
|
||||
public void setActiveUserTotal(Long activeUserTotal) {
|
||||
this.activeUserTotal = activeUserTotal;
|
||||
}
|
||||
|
||||
public Long getBotTotal() {
|
||||
return botTotal;
|
||||
}
|
||||
|
||||
public void setBotTotal(Long botTotal) {
|
||||
this.botTotal = botTotal;
|
||||
}
|
||||
|
||||
public Long getWorkflowTotal() {
|
||||
return workflowTotal;
|
||||
}
|
||||
|
||||
public void setWorkflowTotal(Long workflowTotal) {
|
||||
this.workflowTotal = workflowTotal;
|
||||
}
|
||||
|
||||
public Long getKnowledgeBaseTotal() {
|
||||
return knowledgeBaseTotal;
|
||||
}
|
||||
|
||||
public void setKnowledgeBaseTotal(Long knowledgeBaseTotal) {
|
||||
this.knowledgeBaseTotal = knowledgeBaseTotal;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package tech.easyflow.admin.model.dashboard;
|
||||
|
||||
/**
|
||||
* 工作台统计查询参数。
|
||||
*/
|
||||
public class DashboardOverviewQuery {
|
||||
|
||||
private String range;
|
||||
|
||||
public String getRange() {
|
||||
return range;
|
||||
}
|
||||
|
||||
public void setRange(String range) {
|
||||
this.range = range;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package tech.easyflow.admin.model.dashboard;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 工作台总览返回对象。
|
||||
*/
|
||||
public class DashboardOverviewVo {
|
||||
|
||||
private DashboardSummaryVo summary;
|
||||
|
||||
private List<DashboardTrendItemVo> trends;
|
||||
|
||||
private List<DashboardDistributionItemVo> distribution;
|
||||
|
||||
private DashboardOverviewQuery query;
|
||||
|
||||
private Date updatedAt;
|
||||
|
||||
public DashboardSummaryVo getSummary() {
|
||||
return summary;
|
||||
}
|
||||
|
||||
public void setSummary(DashboardSummaryVo summary) {
|
||||
this.summary = summary;
|
||||
}
|
||||
|
||||
public List<DashboardTrendItemVo> getTrends() {
|
||||
return trends;
|
||||
}
|
||||
|
||||
public void setTrends(List<DashboardTrendItemVo> trends) {
|
||||
this.trends = trends;
|
||||
}
|
||||
|
||||
public List<DashboardDistributionItemVo> getDistribution() {
|
||||
return distribution;
|
||||
}
|
||||
|
||||
public void setDistribution(List<DashboardDistributionItemVo> distribution) {
|
||||
this.distribution = distribution;
|
||||
}
|
||||
|
||||
public DashboardOverviewQuery getQuery() {
|
||||
return query;
|
||||
}
|
||||
|
||||
public void setQuery(DashboardOverviewQuery query) {
|
||||
this.query = query;
|
||||
}
|
||||
|
||||
public Date getUpdatedAt() {
|
||||
return updatedAt;
|
||||
}
|
||||
|
||||
public void setUpdatedAt(Date updatedAt) {
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package tech.easyflow.admin.model.dashboard;
|
||||
|
||||
/**
|
||||
* 工作台汇总指标。
|
||||
*/
|
||||
public class DashboardSummaryVo {
|
||||
|
||||
private Long userTotal;
|
||||
|
||||
private Long activeUserTotal;
|
||||
|
||||
private Long botTotal;
|
||||
|
||||
private Long workflowTotal;
|
||||
|
||||
private Long knowledgeBaseTotal;
|
||||
|
||||
public Long getUserTotal() {
|
||||
return userTotal;
|
||||
}
|
||||
|
||||
public void setUserTotal(Long userTotal) {
|
||||
this.userTotal = userTotal;
|
||||
}
|
||||
|
||||
public Long getActiveUserTotal() {
|
||||
return activeUserTotal;
|
||||
}
|
||||
|
||||
public void setActiveUserTotal(Long activeUserTotal) {
|
||||
this.activeUserTotal = activeUserTotal;
|
||||
}
|
||||
|
||||
public Long getBotTotal() {
|
||||
return botTotal;
|
||||
}
|
||||
|
||||
public void setBotTotal(Long botTotal) {
|
||||
this.botTotal = botTotal;
|
||||
}
|
||||
|
||||
public Long getWorkflowTotal() {
|
||||
return workflowTotal;
|
||||
}
|
||||
|
||||
public void setWorkflowTotal(Long workflowTotal) {
|
||||
this.workflowTotal = workflowTotal;
|
||||
}
|
||||
|
||||
public Long getKnowledgeBaseTotal() {
|
||||
return knowledgeBaseTotal;
|
||||
}
|
||||
|
||||
public void setKnowledgeBaseTotal(Long knowledgeBaseTotal) {
|
||||
this.knowledgeBaseTotal = knowledgeBaseTotal;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package tech.easyflow.admin.model.dashboard;
|
||||
|
||||
/**
|
||||
* 工作台趋势项。
|
||||
*/
|
||||
public class DashboardTrendItemVo {
|
||||
|
||||
private String key;
|
||||
|
||||
private String label;
|
||||
|
||||
private Long activeUserTotal;
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public Long getActiveUserTotal() {
|
||||
return activeUserTotal;
|
||||
}
|
||||
|
||||
public void setActiveUserTotal(Long activeUserTotal) {
|
||||
this.activeUserTotal = activeUserTotal;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package tech.easyflow.admin.service.dashboard;
|
||||
|
||||
import tech.easyflow.admin.model.dashboard.DashboardOverviewQuery;
|
||||
import tech.easyflow.admin.model.dashboard.DashboardOverviewVo;
|
||||
import tech.easyflow.common.entity.LoginAccount;
|
||||
|
||||
/**
|
||||
* 工作台统计服务。
|
||||
*/
|
||||
public interface DashboardService {
|
||||
|
||||
DashboardOverviewVo getOverview(LoginAccount loginAccount, DashboardOverviewQuery query);
|
||||
}
|
||||
@@ -0,0 +1,307 @@
|
||||
package tech.easyflow.admin.service.dashboard.impl;
|
||||
|
||||
import com.easyagents.flow.core.chain.ChainStatus;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.core.row.Db;
|
||||
import com.mybatisflex.core.row.Row;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
import tech.easyflow.admin.model.dashboard.DashboardDistributionItemVo;
|
||||
import tech.easyflow.admin.model.dashboard.DashboardOverviewQuery;
|
||||
import tech.easyflow.admin.model.dashboard.DashboardOverviewVo;
|
||||
import tech.easyflow.admin.model.dashboard.DashboardSummaryVo;
|
||||
import tech.easyflow.admin.model.dashboard.DashboardTrendItemVo;
|
||||
import tech.easyflow.admin.service.dashboard.DashboardService;
|
||||
import tech.easyflow.common.constant.Constants;
|
||||
import tech.easyflow.common.entity.LoginAccount;
|
||||
import tech.easyflow.common.web.exceptions.BusinessException;
|
||||
import tech.easyflow.system.entity.SysAccountRole;
|
||||
import tech.easyflow.system.entity.SysRole;
|
||||
import tech.easyflow.system.service.SysAccountRoleService;
|
||||
import tech.easyflow.system.service.SysRoleService;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigInteger;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 工作台统计服务实现。
|
||||
*/
|
||||
@Service
|
||||
public class DashboardServiceImpl implements DashboardService {
|
||||
|
||||
private static final ZoneId DEFAULT_ZONE_ID = ZoneId.systemDefault();
|
||||
@Resource
|
||||
private SysAccountRoleService sysAccountRoleService;
|
||||
@Resource
|
||||
private SysRoleService sysRoleService;
|
||||
|
||||
@Override
|
||||
public DashboardOverviewVo getOverview(LoginAccount loginAccount, DashboardOverviewQuery query) {
|
||||
DashboardQueryContext context = buildContext(loginAccount, query);
|
||||
|
||||
DashboardSummaryVo summary = buildSummary(context);
|
||||
List<DashboardTrendItemVo> trends = buildTrends(context);
|
||||
List<DashboardDistributionItemVo> distribution = buildDistribution(context, summary);
|
||||
|
||||
DashboardOverviewVo result = new DashboardOverviewVo();
|
||||
result.setSummary(summary);
|
||||
result.setTrends(trends);
|
||||
result.setDistribution(distribution);
|
||||
|
||||
DashboardOverviewQuery normalizedQuery = new DashboardOverviewQuery();
|
||||
normalizedQuery.setRange(context.range);
|
||||
result.setQuery(normalizedQuery);
|
||||
result.setUpdatedAt(new Date());
|
||||
return result;
|
||||
}
|
||||
|
||||
private DashboardSummaryVo buildSummary(DashboardQueryContext context) {
|
||||
DashboardSummaryVo summary = new DashboardSummaryVo();
|
||||
summary.setUserTotal(countScopedTable("tb_sys_account", "a", true, context));
|
||||
summary.setActiveUserTotal(countActiveUsers(context));
|
||||
summary.setBotTotal(countScopedTable("tb_bot", "b", false, context));
|
||||
summary.setWorkflowTotal(countScopedTable("tb_workflow", "w", false, context));
|
||||
summary.setKnowledgeBaseTotal(countScopedTable("tb_document_collection", "d", false, context));
|
||||
return summary;
|
||||
}
|
||||
|
||||
private List<DashboardTrendItemVo> buildTrends(DashboardQueryContext context) {
|
||||
List<TimeBucket> buckets = buildBuckets(context.range);
|
||||
String bucketFormat = "today".equals(context.range) ? "%Y-%m-%d %H:00:00" : "%Y-%m-%d";
|
||||
|
||||
Map<String, Long> activeUserMap = queryActiveUserTrend(context, bucketFormat);
|
||||
|
||||
List<DashboardTrendItemVo> items = new ArrayList<>(buckets.size());
|
||||
for (TimeBucket bucket : buckets) {
|
||||
long activeUserTotal = activeUserMap.getOrDefault(bucket.key, 0L);
|
||||
|
||||
DashboardTrendItemVo item = new DashboardTrendItemVo();
|
||||
item.setKey(bucket.key);
|
||||
item.setLabel(bucket.label);
|
||||
item.setActiveUserTotal(activeUserTotal);
|
||||
items.add(item);
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
private List<DashboardDistributionItemVo> buildDistribution(DashboardQueryContext context, DashboardSummaryVo summary) {
|
||||
return buildResourceDistribution(summary);
|
||||
}
|
||||
|
||||
private List<DashboardDistributionItemVo> buildResourceDistribution(DashboardSummaryVo summary) {
|
||||
List<DashboardDistributionItemVo> items = new ArrayList<>();
|
||||
items.add(buildPlatformItem("userTotal", "用户总量", summary.getUserTotal()));
|
||||
items.add(buildPlatformItem("activeUserTotal", "活跃用户", summary.getActiveUserTotal()));
|
||||
items.add(buildPlatformItem("botTotal", "助手数量", summary.getBotTotal()));
|
||||
items.add(buildPlatformItem("workflowTotal", "工作流数量", summary.getWorkflowTotal()));
|
||||
items.add(buildPlatformItem("knowledgeBaseTotal", "知识库数量", summary.getKnowledgeBaseTotal()));
|
||||
return items;
|
||||
}
|
||||
|
||||
private DashboardDistributionItemVo buildPlatformItem(String key, String label, Long value) {
|
||||
DashboardDistributionItemVo item = new DashboardDistributionItemVo();
|
||||
item.setKey(key);
|
||||
item.setLabel(label);
|
||||
item.setValue(defaultLong(value));
|
||||
return item;
|
||||
}
|
||||
|
||||
private Map<String, Long> queryActiveUserTrend(DashboardQueryContext context, String bucketFormat) {
|
||||
StringBuilder sql = new StringBuilder();
|
||||
List<Object> params = new ArrayList<>();
|
||||
|
||||
sql.append("SELECT DATE_FORMAT(l.created, '").append(bucketFormat).append("') AS bucket_key, ")
|
||||
.append("COUNT(DISTINCT l.account_id) AS total ")
|
||||
.append("FROM tb_sys_log l ")
|
||||
.append("INNER JOIN tb_sys_account a ON a.id = l.account_id AND a.is_deleted IS NULL ")
|
||||
.append("WHERE l.created >= ? AND l.created < ? ");
|
||||
params.add(toDate(context.startTime));
|
||||
params.add(toDate(context.endTime));
|
||||
appendOptionalTenantFilter(sql, params, context.tenantFilterId, "a.tenant_id");
|
||||
appendOptionalDeptFilter(sql, params, context.deptFilterId, "a.dept_id");
|
||||
sql.append("GROUP BY bucket_key ORDER BY bucket_key ASC");
|
||||
|
||||
Map<String, Long> data = new HashMap<>();
|
||||
for (Row row : Db.selectListBySql(sql.toString(), params.toArray())) {
|
||||
data.put(asString(row.get("bucket_key")), asLong(row.get("total")));
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
private long countScopedTable(String tableName, String alias, boolean containsLogicDelete, DashboardQueryContext context) {
|
||||
StringBuilder sql = new StringBuilder();
|
||||
List<Object> params = new ArrayList<>();
|
||||
|
||||
sql.append("SELECT COUNT(*) AS total FROM ").append(tableName).append(" ").append(alias).append(" WHERE 1 = 1 ");
|
||||
if (containsLogicDelete) {
|
||||
sql.append("AND ").append(alias).append(".is_deleted IS NULL ");
|
||||
}
|
||||
appendOptionalTenantFilter(sql, params, context.tenantFilterId, alias + ".tenant_id");
|
||||
appendOptionalDeptFilter(sql, params, context.deptFilterId, alias + ".dept_id");
|
||||
return queryForLong(sql.toString(), params);
|
||||
}
|
||||
|
||||
private long countActiveUsers(DashboardQueryContext context) {
|
||||
StringBuilder sql = new StringBuilder();
|
||||
List<Object> params = new ArrayList<>();
|
||||
|
||||
sql.append("SELECT COUNT(DISTINCT l.account_id) AS total ")
|
||||
.append("FROM tb_sys_log l ")
|
||||
.append("INNER JOIN tb_sys_account a ON a.id = l.account_id AND a.is_deleted IS NULL ")
|
||||
.append("WHERE l.created >= ? AND l.created < ? ");
|
||||
params.add(toDate(context.startTime));
|
||||
params.add(toDate(context.endTime));
|
||||
appendOptionalTenantFilter(sql, params, context.tenantFilterId, "a.tenant_id");
|
||||
appendOptionalDeptFilter(sql, params, context.deptFilterId, "a.dept_id");
|
||||
return queryForLong(sql.toString(), params);
|
||||
}
|
||||
|
||||
private long queryForLong(String sql, List<Object> params) {
|
||||
Object result = Db.selectObject(sql, params.toArray());
|
||||
return asLong(result);
|
||||
}
|
||||
|
||||
private void appendOptionalTenantFilter(StringBuilder sql, List<Object> params, BigInteger tenantId, String columnName) {
|
||||
if (tenantId != null) {
|
||||
sql.append(" AND ").append(columnName).append(" = ? ");
|
||||
params.add(tenantId);
|
||||
}
|
||||
}
|
||||
|
||||
private void appendOptionalDeptFilter(StringBuilder sql, List<Object> params, BigInteger deptId, String columnName) {
|
||||
if (deptId != null) {
|
||||
sql.append(" AND ").append(columnName).append(" = ? ");
|
||||
params.add(deptId);
|
||||
}
|
||||
}
|
||||
|
||||
private DashboardQueryContext buildContext(LoginAccount loginAccount, DashboardOverviewQuery query) {
|
||||
DashboardQueryContext context = new DashboardQueryContext();
|
||||
context.range = normalizeRange(query == null ? null : query.getRange());
|
||||
context.superAdmin = isSuperAdmin(loginAccount);
|
||||
|
||||
LocalDate today = LocalDate.now(DEFAULT_ZONE_ID);
|
||||
if ("today".equals(context.range)) {
|
||||
context.startTime = LocalDateTime.of(today, LocalTime.MIN);
|
||||
context.endTime = context.startTime.plusDays(1);
|
||||
} else if ("7d".equals(context.range)) {
|
||||
context.startTime = LocalDateTime.of(today.minusDays(6), LocalTime.MIN);
|
||||
context.endTime = LocalDateTime.of(today.plusDays(1), LocalTime.MIN);
|
||||
} else {
|
||||
context.startTime = LocalDateTime.of(today.minusDays(29), LocalTime.MIN);
|
||||
context.endTime = LocalDateTime.of(today.plusDays(1), LocalTime.MIN);
|
||||
}
|
||||
|
||||
context.tenantFilterId = context.superAdmin ? null : loginAccount.getTenantId();
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
private boolean isSuperAdmin(LoginAccount loginAccount) {
|
||||
if (loginAccount == null || loginAccount.getId() == null) {
|
||||
return false;
|
||||
}
|
||||
QueryWrapper roleMappingWrapper = QueryWrapper.create();
|
||||
roleMappingWrapper.eq(SysAccountRole::getAccountId, loginAccount.getId());
|
||||
List<BigInteger> roleIds = sysAccountRoleService.list(roleMappingWrapper)
|
||||
.stream()
|
||||
.map(SysAccountRole::getRoleId)
|
||||
.collect(Collectors.toList());
|
||||
if (roleIds.isEmpty()) {
|
||||
return Constants.SUPER_ADMIN_ID.equals(loginAccount.getId());
|
||||
}
|
||||
|
||||
QueryWrapper roleWrapper = QueryWrapper.create();
|
||||
roleWrapper.in(SysRole::getId, roleIds);
|
||||
roleWrapper.eq(SysRole::getRoleKey, Constants.SUPER_ADMIN_ROLE_CODE);
|
||||
return sysRoleService.count(roleWrapper) > 0;
|
||||
}
|
||||
|
||||
private String normalizeRange(String range) {
|
||||
if (!StringUtils.hasText(range)) {
|
||||
return "7d";
|
||||
}
|
||||
if ("today".equals(range) || "7d".equals(range) || "30d".equals(range)) {
|
||||
return range;
|
||||
}
|
||||
throw new BusinessException("不支持的时间范围: " + range);
|
||||
}
|
||||
|
||||
private List<TimeBucket> buildBuckets(String range) {
|
||||
List<TimeBucket> buckets = new ArrayList<>();
|
||||
LocalDate today = LocalDate.now(DEFAULT_ZONE_ID);
|
||||
|
||||
if ("today".equals(range)) {
|
||||
DateTimeFormatter keyFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:00:00");
|
||||
DateTimeFormatter labelFormatter = DateTimeFormatter.ofPattern("HH:00");
|
||||
LocalDateTime start = LocalDateTime.of(today, LocalTime.MIN);
|
||||
for (int hour = 0; hour < 24; hour++) {
|
||||
LocalDateTime current = start.plusHours(hour);
|
||||
buckets.add(new TimeBucket(current.format(keyFormatter), current.format(labelFormatter)));
|
||||
}
|
||||
return buckets;
|
||||
}
|
||||
|
||||
int days = "7d".equals(range) ? 7 : 30;
|
||||
DateTimeFormatter keyFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
DateTimeFormatter labelFormatter = DateTimeFormatter.ofPattern("MM-dd");
|
||||
LocalDate start = today.minusDays(days - 1L);
|
||||
for (int i = 0; i < days; i++) {
|
||||
LocalDate current = start.plusDays(i);
|
||||
buckets.add(new TimeBucket(current.format(keyFormatter), current.format(labelFormatter)));
|
||||
}
|
||||
return buckets;
|
||||
}
|
||||
|
||||
private Date toDate(LocalDateTime dateTime) {
|
||||
return Date.from(dateTime.atZone(DEFAULT_ZONE_ID).toInstant());
|
||||
}
|
||||
|
||||
private long defaultLong(Long value) {
|
||||
return value == null ? 0L : value;
|
||||
}
|
||||
|
||||
private String asString(Object value) {
|
||||
return value == null ? "" : String.valueOf(value);
|
||||
}
|
||||
|
||||
private long asLong(Object value) {
|
||||
if (value == null) {
|
||||
return 0L;
|
||||
}
|
||||
if (value instanceof Number) {
|
||||
return ((Number) value).longValue();
|
||||
}
|
||||
return Long.parseLong(String.valueOf(value));
|
||||
}
|
||||
|
||||
private static class DashboardQueryContext {
|
||||
private String range;
|
||||
private BigInteger tenantFilterId;
|
||||
private BigInteger deptFilterId;
|
||||
private boolean superAdmin;
|
||||
private LocalDateTime startTime;
|
||||
private LocalDateTime endTime;
|
||||
}
|
||||
|
||||
private static class TimeBucket {
|
||||
private final String key;
|
||||
private final String label;
|
||||
|
||||
private TimeBucket(String key, String label) {
|
||||
this.key = key;
|
||||
this.label = label;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user