告警管理,告警日志接口。更改计算95值定时任务时间
This commit is contained in:
@@ -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