告警管理,告警日志接口。更改计算95值定时任务时间
This commit is contained in:
@@ -2,6 +2,7 @@ package com.ruoyi.rocketmq.utils;
|
||||
|
||||
import com.ruoyi.common.core.constant.SecurityConstants;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.utils.StringUtils;
|
||||
import com.ruoyi.rocketmq.domain.RmTemplateLinux;
|
||||
import com.ruoyi.rocketmq.domain.RmTemplateSwitch;
|
||||
import com.ruoyi.rocketmq.mapper.RmMonitorTemplateMapper;
|
||||
@@ -9,10 +10,12 @@ import com.ruoyi.rocketmq.mapper.RmTemplateLinuxMapper;
|
||||
import com.ruoyi.rocketmq.mapper.RmTemplateSwitchMapper;
|
||||
import com.ruoyi.system.api.RemoteRevenueConfigService;
|
||||
import com.ruoyi.system.api.domain.RmResourceGroupRemote;
|
||||
import com.ruoyi.system.api.domain.RmResourceRegistrationRemote;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -44,6 +47,22 @@ public class DataProcessUtil {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* 资源组信息
|
||||
*/
|
||||
public static RmResourceGroupRemote getResourceMsgById(Long resourceGroupId) {
|
||||
try {
|
||||
R<RmResourceGroupRemote> resourceGroupResponse = remoteRevenueConfigService
|
||||
.getResourceGroupMsgById(resourceGroupId, SecurityConstants.INNER);
|
||||
|
||||
if (resourceGroupResponse != null && resourceGroupResponse.getData() != null) {
|
||||
return resourceGroupResponse.getData();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("获取资源信息失败,resourceGroupId: {}", resourceGroupId, e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* 处理Linux模板数据
|
||||
*/
|
||||
@@ -56,7 +75,7 @@ public class DataProcessUtil {
|
||||
Map<String, List<RmTemplateLinux>> linuxData = new HashMap<>();
|
||||
linuxData.put("cpu", filterItemsByDataType(linuxItems, "CPU"));
|
||||
linuxData.put("other", filterItemsByDataType(linuxItems, "OTHER"));
|
||||
linuxData.put("point", filterItemsByDataType(linuxItems, "POINT"));
|
||||
linuxData.put("vfs", filterItemsByDataType(linuxItems, "POINT"));
|
||||
linuxData.put("net", filterItemsByDataType(linuxItems, "NET"));
|
||||
linuxData.put("disk", filterItemsByDataType(linuxItems, "DISK"));
|
||||
linuxData.put("docker", filterItemsByDataType(linuxItems, "DOCKER"));
|
||||
@@ -75,12 +94,12 @@ public class DataProcessUtil {
|
||||
|
||||
if (!switchItems.isEmpty()) {
|
||||
Map<String, List<RmTemplateSwitch>> switchData = new HashMap<>();
|
||||
switchData.put("system", filterItemsByDataType(switchItems, "SYSTEM"));
|
||||
switchData.put("mpu", filterItemsByDataType(switchItems, "MPU"));
|
||||
switchData.put("power", filterItemsByDataType(switchItems, "POWERSOURCE"));
|
||||
switchData.put("netport", filterItemsByDataType(switchItems, "NETPORT"));
|
||||
switchData.put("lightmodule", filterItemsByDataType(switchItems, "LIGHTMODULE"));
|
||||
switchData.put("fan", filterItemsByDataType(switchItems, "FAN"));
|
||||
switchData.put("switchOther", filterItemsByDataType(switchItems, "SYSTEM"));
|
||||
switchData.put("switchMpu", filterItemsByDataType(switchItems, "MPU"));
|
||||
switchData.put("switchPwr", filterItemsByDataType(switchItems, "POWERSOURCE"));
|
||||
switchData.put("switchNet", filterItemsByDataType(switchItems, "NETPORT"));
|
||||
switchData.put("switchModule", filterItemsByDataType(switchItems, "LIGHTMODULE"));
|
||||
switchData.put("switchFan", filterItemsByDataType(switchItems, "FAN"));
|
||||
|
||||
result.put("switch", switchData);
|
||||
}
|
||||
@@ -101,4 +120,23 @@ public class DataProcessUtil {
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
/**
|
||||
* 获取资源设备列表
|
||||
*/
|
||||
public static List<RmResourceRegistrationRemote> getResourceDevices(Long resourceGroupId) {
|
||||
R<RmResourceGroupRemote> groupResponse = remoteRevenueConfigService
|
||||
.getResourceGroupMsgById(resourceGroupId, SecurityConstants.INNER);
|
||||
|
||||
if (groupResponse == null || groupResponse.getData() == null
|
||||
|| StringUtils.isEmpty(groupResponse.getData().getIncludedDevicesId())) {
|
||||
log.error("资源组信息不完整,resourceGroupId: {}", resourceGroupId);
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
String[] deviceIds = groupResponse.getData().getIncludedDevicesId().split(",");
|
||||
R<List<RmResourceRegistrationRemote>> devicesResponse = remoteRevenueConfigService
|
||||
.getRegistrationByIds(deviceIds, SecurityConstants.INNER);
|
||||
|
||||
return devicesResponse != null ? devicesResponse.getData() : Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
package com.ruoyi.rocketmq.utils;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
* 数据库字段名转换工具类
|
||||
*/
|
||||
public class FieldNameConverterUtil {
|
||||
|
||||
/**
|
||||
* 将数据库字段名转换为Java属性名(带Collect后缀)
|
||||
* 示例:system.swap.size.free -> systemSwapSizeFreeCollect
|
||||
*
|
||||
* @param dbFieldName 数据库字段名
|
||||
* @return Java属性名
|
||||
*/
|
||||
public static String convertToJavaProperty(String dbFieldName) {
|
||||
return convertToJavaProperty(dbFieldName, "Collect");
|
||||
}
|
||||
|
||||
/**
|
||||
* 将数据库字段名转换为Java属性名(自定义后缀)
|
||||
* 示例:system.swap.size.free + "Config" -> systemSwapSizeFreeConfig
|
||||
*
|
||||
* @param dbFieldName 数据库字段名
|
||||
* @param suffix 自定义后缀
|
||||
* @return Java属性名
|
||||
*/
|
||||
public static String convertToJavaProperty(String dbFieldName, String suffix) {
|
||||
if (StringUtils.isBlank(dbFieldName)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
// 分割字段名
|
||||
String[] parts = dbFieldName.split("\\.");
|
||||
|
||||
// 处理每个部分
|
||||
StringBuilder result = new StringBuilder(parts[0]);
|
||||
for (int i = 1; i < parts.length; i++) {
|
||||
result.append(StringUtils.capitalize(parts[i]));
|
||||
}
|
||||
|
||||
// 添加后缀
|
||||
if (StringUtils.isNotBlank(suffix)) {
|
||||
result.append(suffix);
|
||||
}
|
||||
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 将Java属性名转换回数据库字段名
|
||||
* 示例:systemSwapSizeFreeCollect -> system.swap.size.free
|
||||
*
|
||||
* @param javaProperty Java属性名
|
||||
* @param suffix 需要去除的后缀
|
||||
* @return 数据库字段名
|
||||
*/
|
||||
public static String convertToDbField(String javaProperty, String suffix) {
|
||||
if (StringUtils.isBlank(javaProperty)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
// 去除后缀
|
||||
String withoutSuffix = StringUtils.isNotBlank(suffix)
|
||||
? StringUtils.removeEnd(javaProperty, suffix)
|
||||
: javaProperty;
|
||||
|
||||
// 使用正则表达式在大小写字母之间插入点号
|
||||
return withoutSuffix.replaceAll("(?<=[a-z])(?=[A-Z])", ".")
|
||||
.toLowerCase();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user