fix:更新指标完成状态

This commit is contained in:
2026-01-23 16:09:18 +08:00
parent 8b67dce489
commit ee5a8367bc

View File

@@ -0,0 +1,36 @@
package com.sdm.common.utils;
public class CommonUtils {
/**
* 检查字符串是否为有效的数字格式
*/
public static boolean isValidNumberFormat(String str) {
if (str == null || str.isEmpty()) {
return false;
}
// 支持:
// 1. 整数123, -123, +123
// 2. 小数123.45, .45, 123.
// 3. 科学计数法1.23e10, 1.23E-10
// 4. 排除:空字符串、纯空格、多个小数点、非法字符
// 去除首尾空格
str = str.trim();
// 检查是否为空
if (str.isEmpty()) {
return false;
}
// 检查是否只包含数字、小数点、正负号、e/E
if (!str.matches("^[+-]?[\\d.eE]+$")) {
return false;
}
// 更精确的正则表达式
return str.matches("^[+-]?(\\d+(\\.\\d*)?|\\.\\d+)([eE][+-]?\\d+)?$");
}
}