From 7c0df4fd0871cf89517a7dbed46dbb2cccd4caff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E5=BF=A0=E6=9E=97?= <170083662@qq.com> Date: Sat, 31 Jan 2026 01:13:16 +0800 Subject: [PATCH] =?UTF-8?q?feat(batch-import):=20=E6=89=A9=E5=B1=95?= =?UTF-8?q?=E6=89=B9=E9=87=8F=E5=AF=BC=E5=85=A5=E6=94=AF=E6=8C=81=E5=A4=9A?= =?UTF-8?q?=E5=88=97=E4=BC=81=E4=B8=9A=E5=90=8D=E7=A7=B0=E5=8C=B9=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 PARTY_SPLIT_PATTERN 正则表达式用于分割当事人名称 - 实现 refreshCompanyIdByCompanyNames 方法支持多列名称匹配 - 添加 splitPartyNames 工具方法处理当事人名称分割 - 优化公司ID刷新逻辑支持原告/被告等多个当事人字段 - 更新信用公示登记控制器使用多列名称 --- .../credit/controller/BatchImportSupport.java | 153 ++++++++++++++++-- .../controller/CreditGqdjController.java | 12 +- .../controller/CreditXgxfController.java | 19 ++- .../param/CreditBreachOfTrustImportParam.java | 3 + .../credit/param/CreditXgxfImportParam.java | 21 +++ 5 files changed, 184 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/gxwebsoft/credit/controller/BatchImportSupport.java b/src/main/java/com/gxwebsoft/credit/controller/BatchImportSupport.java index ea2d2ec..ca07a1d 100644 --- a/src/main/java/com/gxwebsoft/credit/controller/BatchImportSupport.java +++ b/src/main/java/com/gxwebsoft/credit/controller/BatchImportSupport.java @@ -22,6 +22,7 @@ import java.util.function.BiFunction; import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Supplier; +import java.util.regex.Pattern; /** * credit 模块 Excel 导入批处理支持: @@ -32,6 +33,7 @@ import java.util.function.Supplier; public class BatchImportSupport { private final TransactionTemplate requiresNewTx; + private static final Pattern PARTY_SPLIT_PATTERN = Pattern.compile("[,,;;、\\n\\r\\t/|]+"); public BatchImportSupport(PlatformTransactionManager transactionManager) { TransactionTemplate template = new TransactionTemplate(transactionManager); @@ -71,7 +73,7 @@ public class BatchImportSupport { /** * 按企业名称匹配 CreditCompany(name / matchName) 并回填 companyId。 * - *
默认仅更新 companyId=0 的记录(onlyNull=true);onlyNull=false 时会覆盖更新(仅当 companyId 不同)。
+ *默认仅更新 companyId 为空/0 的记录(onlyNull=true);onlyNull=false 时会覆盖更新(仅当 companyId 不同)。
* *注意:为避免跨租户误更新,当 currentTenantId 为空时会按记录自身 tenantId 维度匹配, * tenantId 为空的记录将被跳过并计入 notFound。
@@ -90,15 +92,80 @@ public class BatchImportSupport { BiConsumer按传入列顺序优先匹配:原告/上诉人 > 被告/被上诉人 > 其他当事人/第三人等。
+ * + *同一列若匹配到多个不同企业则视为歧义;若最终无法得到唯一 companyId,则跳过并计入 ambiguous/notFound。
+ */ + @SafeVarargs + public final默认仅更新 companyId=0 的记录;如需覆盖更新,传 onlyNull=false。
+ *默认仅更新 companyId 为空/0 的记录;如需覆盖更新,传 onlyNull=false。
*/ @PreAuthorize("hasAuthority('credit:creditGqdj:update')") @OperationLog @@ -160,7 +160,8 @@ public class CreditGqdjController extends BaseController { User loginUser = getLoginUser(); Integer currentTenantId = loginUser != null ? loginUser.getTenantId() : null; - BatchImportSupport.CompanyIdRefreshStats stats = batchImportSupport.refreshCompanyIdByCompanyName( + // Match companyId by any party/company-name column (e.g. plaintiff/appellant, defendant/appellee). + BatchImportSupport.CompanyIdRefreshStats stats = batchImportSupport.refreshCompanyIdByCompanyNames( creditGqdjService, creditCompanyService, currentTenantId, @@ -168,13 +169,14 @@ public class CreditGqdjController extends BaseController { limit, CreditGqdj::getId, CreditGqdj::setId, - CreditGqdj::getAppellee, CreditGqdj::getCompanyId, CreditGqdj::setCompanyId, CreditGqdj::getHasData, CreditGqdj::setHasData, CreditGqdj::getTenantId, - CreditGqdj::new + CreditGqdj::new, + CreditGqdj::getPlaintiffAppellant, + CreditGqdj::getAppellee ); if (!stats.anyDataRead) { diff --git a/src/main/java/com/gxwebsoft/credit/controller/CreditXgxfController.java b/src/main/java/com/gxwebsoft/credit/controller/CreditXgxfController.java index e949e6a..2e95ef2 100644 --- a/src/main/java/com/gxwebsoft/credit/controller/CreditXgxfController.java +++ b/src/main/java/com/gxwebsoft/credit/controller/CreditXgxfController.java @@ -603,11 +603,24 @@ public class CreditXgxfController extends BaseController { entity.setCaseNumber(param.getCaseNumber()); entity.setType(param.getType()); entity.setDataType(param.getDataType()); + entity.setPlaintiffUser(param.getPlaintiffUser()); + entity.setDefendantUser(param.getDefendantUser()); + entity.setOtherPartiesThirdParty(param.getOtherPartiesThirdParty()); entity.setPlaintiffAppellant(param.getPlaintiffAppellant()); + entity.setDataStatus(param.getDataStatus()); entity.setAppellee(param.getAppellee()); - entity.setInvolvedAmount(param.getInvolvedAmount()); - entity.setOccurrenceTime(param.getOccurrenceTime()); - entity.setCourtName(param.getCourtName()); + + // 兼容不同模板字段:如果 *2 有值则以 *2 为准写入主字段 + entity.setInvolvedAmount(!ImportHelper.isBlank(param.getInvolvedAmount2()) + ? param.getInvolvedAmount2() + : param.getInvolvedAmount()); + entity.setOccurrenceTime(!ImportHelper.isBlank(param.getOccurrenceTime2()) + ? param.getOccurrenceTime2() + : param.getOccurrenceTime()); + entity.setCourtName(!ImportHelper.isBlank(param.getCourtName2()) + ? param.getCourtName2() + : param.getCourtName()); + entity.setReleaseDate(param.getReleaseDate()); entity.setComments(param.getComments()); diff --git a/src/main/java/com/gxwebsoft/credit/param/CreditBreachOfTrustImportParam.java b/src/main/java/com/gxwebsoft/credit/param/CreditBreachOfTrustImportParam.java index 1dc9c0a..0be1895 100644 --- a/src/main/java/com/gxwebsoft/credit/param/CreditBreachOfTrustImportParam.java +++ b/src/main/java/com/gxwebsoft/credit/param/CreditBreachOfTrustImportParam.java @@ -39,4 +39,7 @@ public class CreditBreachOfTrustImportParam implements Serializable { @Excel(name = "备注") private String comments; +// @Excel(name = "原告/上诉人") +// private String plaintiffAppellant2; + } diff --git a/src/main/java/com/gxwebsoft/credit/param/CreditXgxfImportParam.java b/src/main/java/com/gxwebsoft/credit/param/CreditXgxfImportParam.java index 6a57235..d0eb97d 100644 --- a/src/main/java/com/gxwebsoft/credit/param/CreditXgxfImportParam.java +++ b/src/main/java/com/gxwebsoft/credit/param/CreditXgxfImportParam.java @@ -31,9 +31,15 @@ public class CreditXgxfImportParam implements Serializable { @Excel(name = "涉案金额(元)") private String involvedAmount; + @Excel(name = "涉案金额") + private String involvedAmount2; + @Excel(name = "立案日期") private String occurrenceTime; + @Excel(name = "发生时间") + private String occurrenceTime2; + @Excel(name = "执行法院") private String courtName; @@ -43,4 +49,19 @@ public class CreditXgxfImportParam implements Serializable { @Excel(name = "备注") private String comments; + @Excel(name = "原告/上诉人") + private String plaintiffUser; + + @Excel(name = "被告/被上诉人") + private String defendantUser; + + @Excel(name = "其他当事人/第三人") + private String otherPartiesThirdParty; + + @Excel(name = "数据状态") + private String dataStatus; + + @Excel(name = "法院") + private String courtName2; + }