项目初始化

This commit is contained in:
2026-03-26 16:43:44 +08:00
parent 1dff06a35a
commit b6f0a4e37f
2 changed files with 16 additions and 6 deletions

View File

@@ -4,6 +4,7 @@ import cn.hutool.core.date.DateUtil;
import cn.hutool.system.oshi.CpuInfo;
import cn.hutool.system.oshi.OshiUtil;
import com.jeesite.modules.apps.Module.ChartInfo;
import com.jeesite.modules.utils.KeyUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@@ -23,17 +24,17 @@ public class SysAnalysisController {
long uptimeMs = OshiUtil.getOs().getSystemUptime();
String runTime = DateUtil.formatBetween(uptimeMs);
// 系统使用率(红色)
chartInfoList.add(new ChartInfo("sys", "系统使用率", cpuInfo.getSys(), "#F43F5E", runTime));
chartInfoList.add(new ChartInfo("sys", "系统使用率", cpuInfo.getSys(), KeyUtil.getColor(), runTime));
// 用户使用率(蓝色)
chartInfoList.add(new ChartInfo("user", "用户使用率", cpuInfo.getUser(), "#3B82F6", runTime));
chartInfoList.add(new ChartInfo("user", "用户使用率", cpuInfo.getUser(), KeyUtil.getColor(), runTime));
// CPU等待率橙色
chartInfoList.add(new ChartInfo("wait", "CPU等待率", cpuInfo.getWait(), "#F97316", runTime));
chartInfoList.add(new ChartInfo("wait", "CPU等待率", cpuInfo.getWait(), KeyUtil.getColor(), runTime));
// CPU空闲率绿色
chartInfoList.add(new ChartInfo("free", "CPU空闲率", cpuInfo.getFree(), "#10B981", runTime));
chartInfoList.add(new ChartInfo("free", "CPU空闲率", cpuInfo.getFree(), KeyUtil.getColor(), runTime));
// CPU总使用率粉色
chartInfoList.add(new ChartInfo("used", "CPU总使用率", cpuInfo.getUsed(), "#EC4899", runTime));
chartInfoList.add(new ChartInfo("used", "CPU总使用率", cpuInfo.getUsed(), KeyUtil.getColor(), runTime));
// 系统运行时间(紫色)
chartInfoList.add(new ChartInfo("time", "系统运行时间", 0, "#8B5CF6", runTime));
chartInfoList.add(new ChartInfo("time", "系统运行时间", 0, KeyUtil.getColor(), runTime));
return chartInfoList;
}
}

View File

@@ -1,5 +1,6 @@
package com.jeesite.modules.utils;
import java.awt.*;
import java.util.Random;
public class KeyUtil {
@@ -45,4 +46,12 @@ public class KeyUtil {
return key.toString();
}
}
public static String getColor() {
int r = 100 + (int) (Math.random() * 140);
int g = 100 + (int) (Math.random() * 140);
int b = 100 + (int) (Math.random() * 140);
Color color = new Color(r, g, b);
return "#" + Integer.toHexString(color.getRGB()).substring(2).toUpperCase();
}
}