Commit 0442af88 by Jony.L

平台总体态势 真实数据; 后台添加算力资源spu中的算力来源:合作、自有、社会

parent ac09ad9f
package com.luhu.computility.module.biz.controller.admin.home.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.util.List;
import java.util.Map;
/**
* @Author: jony
* @Date : 2026/02/04
* @VERSION v1.0
* @Description: 首页大屏数据响应VO
*/
@Schema(description = "管理后台 - 首页大屏数据 RespVO")
@Data
public class HomeDashboardRespVO {
@Schema(description = "平台总体态势")
private OverallSituationVO overallSituation;
@Schema(description = "算力资源结构分布")
private ComputeDistributionVO computeDistribution;
@Schema(description = "API调用趋势数据(key: d/m/y, value: 对应维度的数据列表)")
private Map<String, List<ApiCallsVO>> apiCalls;
@Schema(description = "轮播数据列表(中间区域月度数据)")
private List<CarouselItemVO> carouselItems;
@Schema(description = "订单管理数据(key: d/m/y, value: 对应维度的数据列表)")
private Map<String, List<OrderStatisticsVO>> orders;
@Schema(description = "服务能力数据")
private ServiceCapabilityVO serviceCapability;
@Schema(description = "用户管理数据(key: d/m/y, value: 对应维度的数据列表)")
private Map<String, List<UserStatisticsVO>> users;
/**
* 平台总体态势
*/
@Schema(description = "平台总体态势")
@Data
public static class OverallSituationVO {
@Schema(description = "算力总规模(PTOPS)")
private String allCompute;
@Schema(description = "已租赁算力(PTOPS)")
private String leaseCompute;
@Schema(description = "算力利用率(%)")
private String computeUtilizationRate;
@Schema(description = "运行中任务数")
private Integer runningTaskCount;
@Schema(description = "GPU总卡数")
private Long gpuCount;
@Schema(description = "CPU总核数")
private Long coreCount;
@Schema(description = "内存总量(GB)")
private Long memoryCapacity;
}
/**
* 算力资源结构分布
*/
@Schema(description = "算力资源结构分布")
@Data
public static class ComputeDistributionVO {
@Schema(description = "GPU型号分布")
private List<DistributionItem> gpu;
@Schema(description = "算力来源分布")
private List<DistributionItem> source;
@Schema(description = "计算资源分布")
private List<DistributionItem> resource;
}
/**
* 分布项(用于饼图)
*/
@Schema(description = "分布项")
@Data
public static class DistributionItem {
@Schema(description = "名称")
private String name;
@Schema(description = "数值")
private Double value;
}
/**
* API调用记录
*/
@Schema(description = "API调用记录")
@Data
public static class ApiCallsVO {
@Schema(description = "统计日期(格式: yyyy-MM-dd 或 yyyy-MM)")
private String countDate;
@Schema(description = "调用次数")
private Integer callsCount;
}
/**
* 轮播项(中间区域月度数据)
*/
@Schema(description = "轮播项")
@Data
public static class CarouselItemVO {
@Schema(description = "年月(格式: yyyy-MM)")
private String yearMonth;
@Schema(description = "上线应用数")
private Integer appOnlineCount;
@Schema(description = "可用API数量")
private Integer apiOnline;
@Schema(description = "模型服务在线率(%)")
private String modelOnlineRate;
@Schema(description = "API调用总次数")
private Integer apiCallTotal;
}
/**
* 订单统计
*/
@Schema(description = "订单统计")
@Data
public static class OrderStatisticsVO {
@Schema(description = "统计日期")
private String countDate;
@Schema(description = "算力订单数量")
private Integer computeOrdersCount;
@Schema(description = "API订单数量")
private Integer apiOrdersCount;
@Schema(description = "算力订单金额(分)")
private Integer computeOrdersAmount;
@Schema(description = "API订单金额(分)")
private Integer apiOrdersAmount;
@Schema(description = "总订单数量")
private Integer totalOrdersCount;
@Schema(description = "总订单金额(分)")
private Integer totalOrdersAmount;
}
/**
* 服务能力数据
*/
@Schema(description = "服务能力数据")
@Data
public static class ServiceCapabilityVO {
@Schema(description = "年份列表")
private List<String> years;
@Schema(description = "上线应用数列表")
private List<Double> appOnline;
@Schema(description = "上线API数量列表")
private List<Double> apiOnline;
}
/**
* 用户统计
*/
@Schema(description = "用户统计")
@Data
public static class UserStatisticsVO {
@Schema(description = "统计日期")
private String countDate;
@Schema(description = "累计用户数")
private Integer usersCount;
@Schema(description = "增长用户数")
private Integer growthUsersCount;
@Schema(description = "活跃用户数")
private Integer activeUsersCount;
}
}
......@@ -14,24 +14,15 @@ import java.math.BigDecimal;
@Data
public class HomeIndexOverallSituationRespVO {
@Schema(description = "算力总规模")
@Schema(description = "算力总规模(PTOPS)")
private BigDecimal allCompute;
@Schema(description = "可租赁算力")
@Schema(description = "已租赁算力(PTOPS)")
private BigDecimal leaseCompute;
@Schema(description = "已使用算力")
private BigDecimal usedCompute;
@Schema(description = "算力利用率")
@Schema(description = "算力利用率(%)")
private BigDecimal computeUtilizationRate;
@Schema(description = "GPU总卡数")
private Long gpuCount;
@Schema(description = "Cpu总核数")
private Long coreCount;
@Schema(description = "内存总量")
private Long memoryCapacity;
@Schema(description = "运行中任务数")
private Integer runningTaskCount;
}
......@@ -286,20 +286,36 @@ public class HomeIndexServiceImpl implements HomeIndexService {
@Override
public HomeIndexOverallSituationRespVO getOverallSituation() {
// 1. 获取总算力(从 compute_resource_spu 表统计所有 compute 字段之和)
ResourceSpuStatisticDTO resourceSpuStatisticDTO = computeStatisticsApi.getAllCompute();
// 2. 获取已租赁算力(从 compute_resource_order_snapshot 表统计在租赁时间内的 compute 之和)
ResourceOrderSnapshotStatisticDTO resourceOrderSnapshotStatisticDTO =
computeStatisticsApi.queryResourceOrderSnapshotStatistic();
HomeIndexOverallSituationRespVO homeIndexOverallSituation = new HomeIndexOverallSituationRespVO();
homeIndexOverallSituation.setAllCompute(BigDecimal.valueOf(resourceSpuStatisticDTO.getTotalCompute()).setScale(2) );
homeIndexOverallSituation.setCoreCount(resourceSpuStatisticDTO.getTotalCoreCount());
homeIndexOverallSituation.setGpuCount(resourceSpuStatisticDTO.getTotalGpuCount());
homeIndexOverallSituation.setMemoryCapacity(resourceSpuStatisticDTO.getTotalMemoryCapacity());
homeIndexOverallSituation.setUsedCompute(BigDecimal.valueOf(resourceOrderSnapshotStatisticDTO.getTotalCompute()).setScale(2));
homeIndexOverallSituation.setLeaseCompute(BigDecimal.valueOf(resourceSpuStatisticDTO.getTotalCompute()- resourceOrderSnapshotStatisticDTO.getTotalCompute()).setScale(2));
//百分比 不带% 前端展示+%即可
homeIndexOverallSituation.setComputeUtilizationRate(BigDecimal.valueOf(resourceOrderSnapshotStatisticDTO.getTotalCompute()/resourceSpuStatisticDTO.getTotalCompute()).multiply(BigDecimal.valueOf(100))
.setScale(2, RoundingMode.HALF_UP));
return homeIndexOverallSituation;
HomeIndexOverallSituationRespVO result = new HomeIndexOverallSituationRespVO();
// 3. 算力总规模(保留2位小数)
result.setAllCompute(BigDecimal.valueOf(resourceSpuStatisticDTO.getTotalCompute()).setScale(2, RoundingMode.HALF_UP));
// 4. 已租赁算力 = 当前在租赁期内的订单算力总和(保留2位小数)
result.setLeaseCompute(BigDecimal.valueOf(resourceOrderSnapshotStatisticDTO.getTotalCompute()).setScale(2, RoundingMode.HALF_UP));
// 5. 算力利用率 = 已租赁算力 / 总算力 * 100(保留2位小数)
if (resourceSpuStatisticDTO.getTotalCompute() > 0) {
BigDecimal utilizationRate = BigDecimal.valueOf(resourceOrderSnapshotStatisticDTO.getTotalCompute())
.divide(BigDecimal.valueOf(resourceSpuStatisticDTO.getTotalCompute()), 4, RoundingMode.HALF_UP)
.multiply(BigDecimal.valueOf(100))
.setScale(2, RoundingMode.HALF_UP);
result.setComputeUtilizationRate(utilizationRate);
} else {
result.setComputeUtilizationRate(BigDecimal.ZERO);
}
// 6. 运行中任务数(暂时写死为 40)
result.setRunningTaskCount(40);
return result;
}
@Override
......
......@@ -76,6 +76,10 @@ public class ResourceSpuRespVO {
@ExcelProperty("算力资源分类编号")
private Long categoryId;
@Schema(description = "算力来源:own-自有, cooperative-合作, social-社会", example = "own")
@ExcelProperty("算力来源")
private String source;
@Schema(description = "算力资源分类名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "高性能计算服务资源")
@ExcelProperty("算力资源分类名称")
private String categoryName;
......
......@@ -70,6 +70,9 @@ public class ResourceSpuSaveReqVO {
@NotNull(message = "算力资源分类编号不能为空")
private Long categoryId;
@Schema(description = "算力来源", example = "own")
private String source;
@Schema(description = "商品封面图", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn")
@NotEmpty(message = "商品封面图不能为空")
private String picUrl;
......
......@@ -92,6 +92,10 @@ public class ResourceSpuDO extends BaseDO {
*/
private Long categoryId;
/**
* 算力来源:own-自有, cooperative-合作, social-社会
*/
private String source;
/**
* 商品封面图
*/
private String picUrl;
......
......@@ -75,10 +75,11 @@ public interface ResourceOrderSnapshotMapper extends BaseMapperX<ResourceOrderSn
default ResourceOrderSnapshotStatisticDTO queryResourceOrderSnapshotStatistic() {
ResourceOrderSnapshotStatisticDTO resp = new ResourceOrderSnapshotStatisticDTO();
// SQL sum 查询
// SQL sum 查询 - 统计当前在租赁期内的订单(租赁开始时间 <= 当前时间 AND 租赁结束时间 >= 当前时间)
List<Map<String, Object>> result = selectMaps(new QueryWrapper<ResourceOrderSnapshotDO>()
.select("IFNULL(SUM(compute), 0) as totalCompute, IFNULL(SUM(gpu_count), 0) as totalGpuCount, " +
"IFNULL(SUM(core_count), 0) as totalCoreCount, IFNULL(SUM(memory_capacity), 0) as totalMemoryCapacity"));
"IFNULL(SUM(core_count), 0) as totalCoreCount, IFNULL(SUM(memory_capacity), 0) as totalMemoryCapacity")
.apply("rent_start_time <= NOW() AND rent_end_time >= NOW()"));
if (!result.isEmpty()) {
......
......@@ -43,12 +43,12 @@ spring:
datasource:
master:
# 重点加了 catalog=new_computility,强制绑定数据库目录
url: jdbc:mysql://8.136.9.68:3306/new_computility?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&catalog=new_computility
# url: jdbc:mysql://8.136.9.68:3306/new_computility?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&catalog=new_computility
# username: root
# password: Luchuan@123
url: jdbc:mysql://43.139.100.220:13306/new_computility?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
username: root
password: Luchuan@123
#url: jdbc:mysql://43.139.100.220:13306/new_computility?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
#username: root
#password: D7kaJdNdLsjzXGhD
password: D7kaJdNdLsjzXGhD
# Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优
redis:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment