|
|
@ -1619,7 +1619,8 @@ public class SampleProofTrackingServiceImpl implements SampleProofTrackingServic |
|
|
} |
|
|
} |
|
|
List<ProofTrackingProcessCategoryData> finalRows = new ArrayList<>(); |
|
|
List<ProofTrackingProcessCategoryData> finalRows = new ArrayList<>(); |
|
|
Set<String> submitCodeKeys = new LinkedHashSet<>(); |
|
|
Set<String> submitCodeKeys = new LinkedHashSet<>(); |
|
|
int nextCategorySeq = resolveNextAutoProcessCategorySequence(existingRows); |
|
|
|
|
|
|
|
|
String categoryCodePrefix = resolveProcessCategoryCodePrefixByBuNo(buNo); |
|
|
|
|
|
int nextCategorySeq = resolveNextAutoProcessCategorySequence(existingRows, categoryCodePrefix); |
|
|
int sortNo = 10; |
|
|
int sortNo = 10; |
|
|
for (ProofTrackingProcessCategoryData row : normalizedRows) { |
|
|
for (ProofTrackingProcessCategoryData row : normalizedRows) { |
|
|
String rawCategoryCode = isBlank(row.getCategoryCode()) ? "" : row.getCategoryCode().trim(); |
|
|
String rawCategoryCode = isBlank(row.getCategoryCode()) ? "" : row.getCategoryCode().trim(); |
|
|
@ -1631,7 +1632,7 @@ public class SampleProofTrackingServiceImpl implements SampleProofTrackingServic |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
while (true) { |
|
|
while (true) { |
|
|
String candidateCode = buildAutoProcessCategoryCode(nextCategorySeq); |
|
|
|
|
|
|
|
|
String candidateCode = buildAutoProcessCategoryCode(categoryCodePrefix, nextCategorySeq); |
|
|
nextCategorySeq += 1; |
|
|
nextCategorySeq += 1; |
|
|
String candidateKey = candidateCode.toLowerCase(); |
|
|
String candidateKey = candidateCode.toLowerCase(); |
|
|
if (reservedCodeKeys.contains(candidateKey) || submitCodeKeys.contains(candidateKey)) { |
|
|
if (reservedCodeKeys.contains(candidateKey) || submitCodeKeys.contains(candidateKey)) { |
|
|
@ -1808,7 +1809,9 @@ public class SampleProofTrackingServiceImpl implements SampleProofTrackingServic |
|
|
return rows; |
|
|
return rows; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private int resolveNextAutoProcessCategorySequence(List<ProofTrackingProcessCategoryData> existingRows) { |
|
|
|
|
|
|
|
|
private int resolveNextAutoProcessCategorySequence(List<ProofTrackingProcessCategoryData> existingRows, |
|
|
|
|
|
String categoryCodePrefix) { |
|
|
|
|
|
String normalizedPrefix = isBlank(categoryCodePrefix) ? "RF" : categoryCodePrefix.trim().toUpperCase(); |
|
|
int maxSequence = 0; |
|
|
int maxSequence = 0; |
|
|
if (existingRows == null || existingRows.isEmpty()) { |
|
|
if (existingRows == null || existingRows.isEmpty()) { |
|
|
return 1; |
|
|
return 1; |
|
|
@ -1818,24 +1821,35 @@ public class SampleProofTrackingServiceImpl implements SampleProofTrackingServic |
|
|
continue; |
|
|
continue; |
|
|
} |
|
|
} |
|
|
String code = item.getCategoryCode().trim(); |
|
|
String code = item.getCategoryCode().trim(); |
|
|
if (code.length() <= 3 || !code.regionMatches(true, 0, "bu-", 0, 3)) { |
|
|
|
|
|
|
|
|
if (code.length() <= normalizedPrefix.length() |
|
|
|
|
|
|| !code.regionMatches(true, 0, normalizedPrefix, 0, normalizedPrefix.length())) { |
|
|
continue; |
|
|
continue; |
|
|
} |
|
|
} |
|
|
try { |
|
|
try { |
|
|
int parsedSeq = Integer.parseInt(code.substring(3)); |
|
|
|
|
|
|
|
|
int parsedSeq = Integer.parseInt(code.substring(normalizedPrefix.length())); |
|
|
if (parsedSeq > maxSequence) { |
|
|
if (parsedSeq > maxSequence) { |
|
|
maxSequence = parsedSeq; |
|
|
maxSequence = parsedSeq; |
|
|
} |
|
|
} |
|
|
} catch (NumberFormatException ignore) { |
|
|
} catch (NumberFormatException ignore) { |
|
|
// 非 bu-数字 格式编码不参与自动序号计算。 |
|
|
|
|
|
|
|
|
// 非“前缀+数字”格式编码不参与自动序号计算。 |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
return maxSequence + 1; |
|
|
return maxSequence + 1; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private String buildAutoProcessCategoryCode(int sequence) { |
|
|
|
|
|
|
|
|
private String buildAutoProcessCategoryCode(String categoryCodePrefix, int sequence) { |
|
|
|
|
|
String normalizedPrefix = isBlank(categoryCodePrefix) ? "RF" : categoryCodePrefix.trim().toUpperCase(); |
|
|
int safeSequence = sequence <= 0 ? 1 : sequence; |
|
|
int safeSequence = sequence <= 0 ? 1 : sequence; |
|
|
return String.format("bu-%03d", safeSequence); |
|
|
|
|
|
|
|
|
return String.format("%s%03d", normalizedPrefix, safeSequence); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private String resolveProcessCategoryCodePrefixByBuNo(String buNo) { |
|
|
|
|
|
String normalizedBuNo = isBlank(buNo) ? "" : buNo.trim().toUpperCase(); |
|
|
|
|
|
if (normalizedBuNo.contains("RFID")) { |
|
|
|
|
|
return "RFID"; |
|
|
|
|
|
} |
|
|
|
|
|
// 软标(例如 01-Label)使用 RF 前缀;其余 BU 默认也归为 RF。 |
|
|
|
|
|
return "RF"; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private String buildPlanFieldByCode(String code) { |
|
|
private String buildPlanFieldByCode(String code) { |
|
|
|