diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/util/VersionUtil.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/util/VersionUtil.java index 2426a153..7ecdb7ec 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/util/VersionUtil.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/util/VersionUtil.java @@ -122,4 +122,42 @@ public class VersionUtil { return Integer.compare(split1.length, split2.length); } + + /** + * 获取PBOM 升级版本号(PBOM升级版本号规则) + * @param version + * @return + */ + public static String getPBomUpgradNextVersion(String version) { + if (version == null || version.isEmpty()) { + throw new IllegalArgumentException("输入版本号不能为空"); + } + char lastChar = version.charAt(version.length() - 1); + boolean isLetter = Character.isLetter(lastChar); + if (!isLetter) { + return version + "a"; + } else { + int lastCharIndex = version.length() - 1; + char newLastChar = (char) (lastChar + 1); + + if (newLastChar > 'z') { + // Handle case where the last character is 'z' + StringBuilder sb = new StringBuilder(version.substring(0, lastCharIndex)); + sb.append("a").append('a'); + return sb.toString(); + } else { + return version.substring(0, lastCharIndex) + newLastChar; + } + } + } + + private static String getNextLetter(char currentLetter) { + char nextLetter = (char) (currentLetter + 1); + if (nextLetter > 'z') { + return "a" + getNextLetter('a'); + } else { + return "" + nextLetter; + } + } + }