Merge branch 'dev' into test
This commit is contained in:
@@ -186,23 +186,39 @@ public class MasterDataCategorySyncServiceImpl implements MasterDataCategorySync
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String resolveParentCode(String code) {
|
private String resolveParentCode(String code) {
|
||||||
if (code == null) {
|
String normalized = normalizeCode(code);
|
||||||
|
if (normalized == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (code.length() <= 2) {
|
String numericPart = extractNumericPart(normalized);
|
||||||
|
if (StrUtil.isBlank(numericPart) || numericPart.length() <= 2) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (code.length() <= 4) {
|
String prefix = normalized.substring(0, normalized.length() - numericPart.length());
|
||||||
return code.substring(0, 2);
|
String parentNumeric = numericPart.substring(0, numericPart.length() - 2);
|
||||||
}
|
return prefix + parentNumeric;
|
||||||
return code.substring(0, 4);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private long determineLevel(String code) {
|
private long determineLevel(String code) {
|
||||||
if (code.length() <= 2) {
|
String normalized = normalizeCode(code);
|
||||||
|
if (normalized == null) {
|
||||||
return 1L;
|
return 1L;
|
||||||
}
|
}
|
||||||
if (code.length() <= 4) {
|
String numericPart = extractNumericPart(normalized);
|
||||||
|
if (StrUtil.isBlank(numericPart)) {
|
||||||
|
if (normalized.length() <= 2) {
|
||||||
|
return 1L;
|
||||||
|
}
|
||||||
|
if (normalized.length() <= 4) {
|
||||||
|
return 2L;
|
||||||
|
}
|
||||||
|
return 3L;
|
||||||
|
}
|
||||||
|
int len = numericPart.length();
|
||||||
|
if (len <= 2) {
|
||||||
|
return 1L;
|
||||||
|
}
|
||||||
|
if (len <= 4) {
|
||||||
return 2L;
|
return 2L;
|
||||||
}
|
}
|
||||||
return 3L;
|
return 3L;
|
||||||
@@ -211,4 +227,19 @@ public class MasterDataCategorySyncServiceImpl implements MasterDataCategorySync
|
|||||||
private String normalizeCode(String code) {
|
private String normalizeCode(String code) {
|
||||||
return StrUtil.isBlank(code) ? null : StrUtil.trim(code);
|
return StrUtil.isBlank(code) ? null : StrUtil.trim(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 提取编码中连续的尾部数字部分,例如 ZT0103 -> 0103,ZT010312 -> 010312
|
||||||
|
*/
|
||||||
|
private String extractNumericPart(String code) {
|
||||||
|
if (code == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
int idx = code.length();
|
||||||
|
while (idx > 0 && Character.isDigit(code.charAt(idx - 1))) {
|
||||||
|
idx--;
|
||||||
|
}
|
||||||
|
String numeric = code.substring(idx);
|
||||||
|
return StrUtil.isBlank(numeric) ? null : numeric;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user