清洗流水本方证件号格式

This commit is contained in:
wjj
2026-06-30 13:40:24 +08:00
parent 5e4bfca05b
commit 066d850389
3 changed files with 63 additions and 0 deletions

View File

@@ -207,6 +207,7 @@ public class CcdiBankStatement implements Serializable {
entity.setBatchSequence(item.getUploadSequnceNumber());
entity.setCustomerCertNo(item.getCustomerCertNo());
entity.setCustomerSocialCreditCode(item.getCustomerSocialCreditCode());
entity.setCretNo(normalizeCertNo(item.getCretNo()));
// 5. 特殊字段处理
entity.setMetaJson(null); // 根据文档要求强制设为 null
@@ -219,4 +220,19 @@ public class CcdiBankStatement implements Serializable {
throw new RuntimeException("流水数据转换失败", e);
}
}
private static String normalizeCertNo(String value) {
if (value == null || value.isBlank()) {
return null;
}
String normalized = value.trim()
.replace('', '-')
.replace('—', '-')
.replace('', '-');
int separatorIndex = normalized.indexOf('-');
if (separatorIndex >= 0) {
normalized = normalized.substring(0, separatorIndex).trim();
}
return normalized.isEmpty() ? null : normalized;
}
}

View File

@@ -104,4 +104,26 @@ class CcdiBankStatementTest {
assertEquals("330101199001011234", entity.getCustomerCertNo());
assertEquals("91330100123456789X", entity.getCustomerSocialCreditCode());
}
@Test
void testFromResponse_ShouldNormalizeCretNoBeforeDash() {
BankStatementItem item = new BankStatementItem();
item.setCretNo(" 330100198801010033 - 测试人员 ");
CcdiBankStatement entity = CcdiBankStatement.fromResponse(item);
assertNotNull(entity);
assertEquals("330100198801010033", entity.getCretNo());
}
@Test
void testFromResponse_ShouldNormalizeCretNoWithChineseDash() {
BankStatementItem item = new BankStatementItem();
item.setCretNo("330100198801010033测试人员");
CcdiBankStatement entity = CcdiBankStatement.fromResponse(item);
assertNotNull(entity);
assertEquals("330100198801010033", entity.getCretNo());
}
}