buhuazhen
2026-04-24 e8d0bdce89ae0937763736f75868a43bd8690985
src/main/java/com/ruoyi/common/utils/StringUtils.java
@@ -6,6 +6,9 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.pinyin.PinyinUtil;
import org.springframework.util.AntPathMatcher;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.text.StrFormatter;
@@ -386,6 +389,18 @@
     * 
     * @param str 字符串
     * @param sep 分隔符
     * @return list集合
     */
    public static final List<String> str2List(String str, String sep)
    {
        return str2List(str, sep, true, false);
    }
    /**
     * 字符串转list
     *
     * @param str 字符串
     * @param sep 分隔符
     * @param filterBlank 过滤纯空白
     * @param trim 去掉首尾空白
     * @return list集合
@@ -707,4 +722,43 @@
        }
        return sb.toString();
    }
    public static String padRight(String str, int length) {
        if (str == null) str = "";
        if (str.length() >= length) return str;
        // 用空格补齐
        return String.format("%-" + length + "s", str);
    }
    public static boolean containsChinese(String str) {
        if (str == null) return false;
        for (char c : str.toCharArray()) {
            if (Character.UnicodeScript.of(c) == Character.UnicodeScript.HAN) {
                return true;
            }
        }
        return false;
    }
    public static String getProcessNo(String processName) {
        if (StrUtil.isBlank(processName)) {
            return "";
        }
        // 判断是否包含中文
        if (StringUtils.containsChinese(processName)) {
            // 中文:拼音首字母
            return StrUtil.toUpperCase(PinyinUtil.getFirstLetter(processName, ""));
        } else {
            // 英文:取大写字母 目前工序名称没有英文的形式 只能处理ExxxBxxx
            StringBuilder sb = new StringBuilder();
            for (char c : processName.toCharArray()) {
                if (Character.isUpperCase(c)) {
                    sb.append(c);
                }
            }
            return sb.toString();
        }
    }
}