From 50f6b49da91143d50b0d1c4b5e1c4306b10a41ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E5=BF=A0=E6=9E=97?= <170083662@qq.com> Date: Sun, 15 Mar 2026 11:55:24 +0800 Subject: [PATCH] =?UTF-8?q?fix(import):=20=E4=BF=AE=E5=A4=8DExcel=E5=AF=BC?= =?UTF-8?q?=E5=85=A5=E6=97=B6=E4=BC=81=E4=B8=9A=E5=90=8D=E7=A7=B0=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E5=A4=84=E7=90=86=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除CreditCompetitor、CreditCustomer、CreditExternal、CreditRiskRelation、CreditSupplier和CreditUser实体中companyName字段的@TableField(exist = false)注解 - 在各控制器的convertImportParamToEntity方法中添加CreditCompany::setCompanyName方法引用 - 从companyId获取对应的企业名称并设置到fixedCompanyName变量中 - 更新导入逻辑中的注释说明,明确name和companyName字段的不同用途 - 在导入过程中当companyName为空且存在固定公司名称时进行赋值处理 --- .../controller/CreditCompetitorController.java | 12 +++++++++++- .../credit/controller/CreditCustomerController.java | 10 ++++++++++ .../credit/controller/CreditExternalController.java | 10 ++++++++++ .../controller/CreditRiskRelationController.java | 10 ++++++++++ .../credit/controller/CreditSupplierController.java | 10 ++++++++++ .../credit/controller/CreditUserController.java | 10 ++++++++++ .../gxwebsoft/credit/entity/CreditCompetitor.java | 1 - .../com/gxwebsoft/credit/entity/CreditCustomer.java | 1 - .../com/gxwebsoft/credit/entity/CreditExternal.java | 1 - .../gxwebsoft/credit/entity/CreditRiskRelation.java | 1 - .../com/gxwebsoft/credit/entity/CreditSupplier.java | 1 - .../java/com/gxwebsoft/credit/entity/CreditUser.java | 1 - 12 files changed, 61 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/gxwebsoft/credit/controller/CreditCompetitorController.java b/src/main/java/com/gxwebsoft/credit/controller/CreditCompetitorController.java index d45e03f..2a73a74 100644 --- a/src/main/java/com/gxwebsoft/credit/controller/CreditCompetitorController.java +++ b/src/main/java/com/gxwebsoft/credit/controller/CreditCompetitorController.java @@ -6,6 +6,7 @@ import com.gxwebsoft.common.core.web.BaseController; import com.gxwebsoft.common.core.web.BatchParam; import com.gxwebsoft.common.core.web.PageResult; import com.gxwebsoft.common.system.entity.User; +import com.gxwebsoft.credit.entity.CreditCompany; import com.gxwebsoft.credit.entity.CreditCompetitor; import com.gxwebsoft.credit.param.CreditCompetitorImportParam; import com.gxwebsoft.credit.param.CreditCompetitorParam; @@ -170,6 +171,7 @@ public class CreditCompetitorController extends BaseController { CreditCompetitor::getName, CreditCompetitor::getCompanyId, CreditCompetitor::setCompanyId, + CreditCompetitor::setCompanyName, CreditCompetitor::getHasData, CreditCompetitor::setHasData, CreditCompetitor::getTenantId, @@ -212,6 +214,11 @@ public class CreditCompetitorController extends BaseController { Integer currentTenantId = loginUser != null ? loginUser.getTenantId() : null; Map urlByName = ExcelImportSupport.readUrlByKey( file, usedSheetIndex, usedTitleRows, usedHeadRows, "企业名称"); + String fixedCompanyName = null; + if (companyId != null && companyId > 0) { + CreditCompany fixedCompany = creditCompanyService.getById(companyId); + fixedCompanyName = fixedCompany != null ? fixedCompany.getName() : null; + } final int chunkSize = 500; final int mpBatchSize = 500; @@ -222,7 +229,7 @@ public class CreditCompetitorController extends BaseController { CreditCompetitorImportParam param = list.get(i); try { CreditCompetitor item = convertImportParamToEntity(param); - // name 才是持久化字段;companyName 为关联查询的临时字段(exist=false),导入时不应使用。 + // name 为竞争对手企业名称;companyName 为主体企业名称。 if (!ImportHelper.isBlank(item.getName())) { String link = urlByName.get(item.getName().trim()); if (!ImportHelper.isBlank(link)) { @@ -232,6 +239,9 @@ public class CreditCompetitorController extends BaseController { if (item.getCompanyId() == null && companyId != null) { item.setCompanyId(companyId); + if (ImportHelper.isBlank(item.getCompanyName()) && !ImportHelper.isBlank(fixedCompanyName)) { + item.setCompanyName(fixedCompanyName); + } } if (item.getUserId() == null && currentUserId != null) { item.setUserId(currentUserId); diff --git a/src/main/java/com/gxwebsoft/credit/controller/CreditCustomerController.java b/src/main/java/com/gxwebsoft/credit/controller/CreditCustomerController.java index a6df9d3..e16c950 100644 --- a/src/main/java/com/gxwebsoft/credit/controller/CreditCustomerController.java +++ b/src/main/java/com/gxwebsoft/credit/controller/CreditCustomerController.java @@ -6,6 +6,7 @@ import com.gxwebsoft.common.core.web.BaseController; import com.gxwebsoft.common.core.web.BatchParam; import com.gxwebsoft.common.core.web.PageResult; import com.gxwebsoft.common.system.entity.User; +import com.gxwebsoft.credit.entity.CreditCompany; import com.gxwebsoft.credit.entity.CreditCustomer; import com.gxwebsoft.credit.param.CreditCustomerImportParam; import com.gxwebsoft.credit.param.CreditCustomerParam; @@ -167,6 +168,7 @@ public class CreditCustomerController extends BaseController { CreditCustomer::getName, CreditCustomer::getCompanyId, CreditCustomer::setCompanyId, + CreditCustomer::setCompanyName, CreditCustomer::getHasData, CreditCustomer::setHasData, CreditCustomer::getTenantId, @@ -208,6 +210,11 @@ public class CreditCustomerController extends BaseController { Integer currentUserId = loginUser != null ? loginUser.getUserId() : null; Integer currentTenantId = loginUser != null ? loginUser.getTenantId() : null; Map urlByName = ExcelImportSupport.readUrlByKey(file, usedSheetIndex, usedTitleRows, usedHeadRows, "客户"); + String fixedCompanyName = null; + if (companyId != null && companyId > 0) { + CreditCompany fixedCompany = creditCompanyService.getById(companyId); + fixedCompanyName = fixedCompany != null ? fixedCompany.getName() : null; + } final int chunkSize = 500; final int mpBatchSize = 500; @@ -229,6 +236,9 @@ public class CreditCustomerController extends BaseController { if (item.getCompanyId() == null && companyId != null) { item.setCompanyId(companyId); + if (ImportHelper.isBlank(item.getCompanyName()) && !ImportHelper.isBlank(fixedCompanyName)) { + item.setCompanyName(fixedCompanyName); + } } if (item.getUserId() == null && currentUserId != null) { item.setUserId(currentUserId); diff --git a/src/main/java/com/gxwebsoft/credit/controller/CreditExternalController.java b/src/main/java/com/gxwebsoft/credit/controller/CreditExternalController.java index 9bdbf95..85e1bd6 100644 --- a/src/main/java/com/gxwebsoft/credit/controller/CreditExternalController.java +++ b/src/main/java/com/gxwebsoft/credit/controller/CreditExternalController.java @@ -6,6 +6,7 @@ import com.gxwebsoft.common.core.web.BaseController; import com.gxwebsoft.common.core.web.BatchParam; import com.gxwebsoft.common.core.web.PageResult; import com.gxwebsoft.common.system.entity.User; +import com.gxwebsoft.credit.entity.CreditCompany; import com.gxwebsoft.credit.entity.CreditExternal; import com.gxwebsoft.credit.param.CreditExternalImportParam; import com.gxwebsoft.credit.param.CreditExternalParam; @@ -170,6 +171,7 @@ public class CreditExternalController extends BaseController { CreditExternal::getName, CreditExternal::getCompanyId, CreditExternal::setCompanyId, + CreditExternal::setCompanyName, CreditExternal::getHasData, CreditExternal::setHasData, CreditExternal::getTenantId, @@ -211,6 +213,11 @@ public class CreditExternalController extends BaseController { Integer currentUserId = loginUser != null ? loginUser.getUserId() : null; Integer currentTenantId = loginUser != null ? loginUser.getTenantId() : null; Map urlByName = ExcelImportSupport.readUrlByKey(file, usedSheetIndex, usedTitleRows, usedHeadRows, "被投资企业名称"); + String fixedCompanyName = null; + if (companyId != null && companyId > 0) { + CreditCompany fixedCompany = creditCompanyService.getById(companyId); + fixedCompanyName = fixedCompany != null ? fixedCompany.getName() : null; + } final int chunkSize = 500; final int mpBatchSize = 500; @@ -230,6 +237,9 @@ public class CreditExternalController extends BaseController { if (item.getCompanyId() == null && companyId != null) { item.setCompanyId(companyId); + if (ImportHelper.isBlank(item.getCompanyName()) && !ImportHelper.isBlank(fixedCompanyName)) { + item.setCompanyName(fixedCompanyName); + } } if (item.getUserId() == null && currentUserId != null) { item.setUserId(currentUserId); diff --git a/src/main/java/com/gxwebsoft/credit/controller/CreditRiskRelationController.java b/src/main/java/com/gxwebsoft/credit/controller/CreditRiskRelationController.java index 80a497f..ae6cfcf 100644 --- a/src/main/java/com/gxwebsoft/credit/controller/CreditRiskRelationController.java +++ b/src/main/java/com/gxwebsoft/credit/controller/CreditRiskRelationController.java @@ -6,6 +6,7 @@ import com.gxwebsoft.common.core.web.BaseController; import com.gxwebsoft.common.core.web.BatchParam; import com.gxwebsoft.common.core.web.PageResult; import com.gxwebsoft.common.system.entity.User; +import com.gxwebsoft.credit.entity.CreditCompany; import com.gxwebsoft.credit.entity.CreditRiskRelation; import com.gxwebsoft.credit.param.CreditRiskRelationImportParam; import com.gxwebsoft.credit.param.CreditRiskRelationParam; @@ -170,6 +171,7 @@ public class CreditRiskRelationController extends BaseController { CreditRiskRelation::getMainBodyName, CreditRiskRelation::getCompanyId, CreditRiskRelation::setCompanyId, + CreditRiskRelation::setCompanyName, CreditRiskRelation::getHasData, CreditRiskRelation::setHasData, CreditRiskRelation::getTenantId, @@ -209,6 +211,11 @@ public class CreditRiskRelationController extends BaseController { User loginUser = getLoginUser(); Integer currentUserId = loginUser != null ? loginUser.getUserId() : null; Integer currentTenantId = loginUser != null ? loginUser.getTenantId() : null; + String fixedCompanyName = null; + if (companyId != null && companyId > 0) { + CreditCompany fixedCompany = creditCompanyService.getById(companyId); + fixedCompanyName = fixedCompany != null ? fixedCompany.getName() : null; + } final int chunkSize = 500; final int mpBatchSize = 500; @@ -222,6 +229,9 @@ public class CreditRiskRelationController extends BaseController { if (item.getCompanyId() == null && companyId != null) { item.setCompanyId(companyId); + if (ImportHelper.isBlank(item.getCompanyName()) && !ImportHelper.isBlank(fixedCompanyName)) { + item.setCompanyName(fixedCompanyName); + } } if (item.getUserId() == null && currentUserId != null) { item.setUserId(currentUserId); diff --git a/src/main/java/com/gxwebsoft/credit/controller/CreditSupplierController.java b/src/main/java/com/gxwebsoft/credit/controller/CreditSupplierController.java index 7a41953..30073af 100644 --- a/src/main/java/com/gxwebsoft/credit/controller/CreditSupplierController.java +++ b/src/main/java/com/gxwebsoft/credit/controller/CreditSupplierController.java @@ -6,6 +6,7 @@ import com.gxwebsoft.common.core.web.BaseController; import com.gxwebsoft.common.core.web.BatchParam; import com.gxwebsoft.common.core.web.PageResult; import com.gxwebsoft.common.system.entity.User; +import com.gxwebsoft.credit.entity.CreditCompany; import com.gxwebsoft.credit.entity.CreditSupplier; import com.gxwebsoft.credit.param.CreditSupplierImportParam; import com.gxwebsoft.credit.param.CreditSupplierParam; @@ -170,6 +171,7 @@ public class CreditSupplierController extends BaseController { CreditSupplier::getSupplier, CreditSupplier::getCompanyId, CreditSupplier::setCompanyId, + CreditSupplier::setCompanyName, CreditSupplier::getHasData, CreditSupplier::setHasData, CreditSupplier::getTenantId, @@ -211,6 +213,11 @@ public class CreditSupplierController extends BaseController { Integer currentUserId = loginUser != null ? loginUser.getUserId() : null; Integer currentTenantId = loginUser != null ? loginUser.getTenantId() : null; Map urlBySupplier = ExcelImportSupport.readUrlByKey(file, usedSheetIndex, usedTitleRows, usedHeadRows, "供应商"); + String fixedCompanyName = null; + if (companyId != null && companyId > 0) { + CreditCompany fixedCompany = creditCompanyService.getById(companyId); + fixedCompanyName = fixedCompany != null ? fixedCompany.getName() : null; + } final int chunkSize = 500; final int mpBatchSize = 500; @@ -230,6 +237,9 @@ public class CreditSupplierController extends BaseController { if (item.getCompanyId() == null && companyId != null) { item.setCompanyId(companyId); + if (ImportHelper.isBlank(item.getCompanyName()) && !ImportHelper.isBlank(fixedCompanyName)) { + item.setCompanyName(fixedCompanyName); + } } if (item.getUserId() == null && currentUserId != null) { item.setUserId(currentUserId); diff --git a/src/main/java/com/gxwebsoft/credit/controller/CreditUserController.java b/src/main/java/com/gxwebsoft/credit/controller/CreditUserController.java index fef2a57..cef616e 100644 --- a/src/main/java/com/gxwebsoft/credit/controller/CreditUserController.java +++ b/src/main/java/com/gxwebsoft/credit/controller/CreditUserController.java @@ -8,6 +8,7 @@ import com.gxwebsoft.common.core.web.BaseController; import com.gxwebsoft.common.core.web.BatchParam; import com.gxwebsoft.common.core.web.PageResult; import com.gxwebsoft.common.system.entity.User; +import com.gxwebsoft.credit.entity.CreditCompany; import com.gxwebsoft.credit.entity.CreditUser; import com.gxwebsoft.credit.param.CreditUserImportParam; import com.gxwebsoft.credit.param.CreditUserParam; @@ -176,6 +177,7 @@ public class CreditUserController extends BaseController { CreditUser::getWinningName, CreditUser::getCompanyId, CreditUser::setCompanyId, + CreditUser::setCompanyName, CreditUser::getHasData, CreditUser::setHasData, CreditUser::getTenantId, @@ -216,6 +218,11 @@ public class CreditUserController extends BaseController { Integer currentUserId = loginUser != null ? loginUser.getUserId() : null; Integer currentTenantId = loginUser != null ? loginUser.getTenantId() : null; Map urlMap = readNameHyperlinks(file, sheetIndex, usedTitleRows, usedHeadRows); + String fixedCompanyName = null; + if (companyId != null && companyId > 0) { + CreditCompany fixedCompany = creditCompanyService.getById(companyId); + fixedCompanyName = fixedCompany != null ? fixedCompany.getName() : null; + } final int chunkSize = 500; final int mpBatchSize = 500; @@ -233,6 +240,9 @@ public class CreditUserController extends BaseController { } if (item.getCompanyId() == null && companyId != null) { item.setCompanyId(companyId); + if (ImportHelper.isBlank(item.getCompanyName()) && !ImportHelper.isBlank(fixedCompanyName)) { + item.setCompanyName(fixedCompanyName); + } } if (item.getCompanyId() != null && item.getCompanyId() > 0) { touchedCompanyIds.add(item.getCompanyId()); diff --git a/src/main/java/com/gxwebsoft/credit/entity/CreditCompetitor.java b/src/main/java/com/gxwebsoft/credit/entity/CreditCompetitor.java index c7a580c..68ae7ba 100644 --- a/src/main/java/com/gxwebsoft/credit/entity/CreditCompetitor.java +++ b/src/main/java/com/gxwebsoft/credit/entity/CreditCompetitor.java @@ -58,7 +58,6 @@ public class CreditCompetitor implements Serializable { private Integer companyId; @Schema(description = "企业名称") - @TableField(exist = false) private String companyName; @Schema(description = "所属企业名称") diff --git a/src/main/java/com/gxwebsoft/credit/entity/CreditCustomer.java b/src/main/java/com/gxwebsoft/credit/entity/CreditCustomer.java index 522faa5..06777d5 100644 --- a/src/main/java/com/gxwebsoft/credit/entity/CreditCustomer.java +++ b/src/main/java/com/gxwebsoft/credit/entity/CreditCustomer.java @@ -52,7 +52,6 @@ public class CreditCustomer implements Serializable { private Integer companyId; @Schema(description = "企业名称") - @TableField(exist = false) private String companyName; @Schema(description = "是否有数据") diff --git a/src/main/java/com/gxwebsoft/credit/entity/CreditExternal.java b/src/main/java/com/gxwebsoft/credit/entity/CreditExternal.java index e95a42f..abea802 100644 --- a/src/main/java/com/gxwebsoft/credit/entity/CreditExternal.java +++ b/src/main/java/com/gxwebsoft/credit/entity/CreditExternal.java @@ -79,7 +79,6 @@ public class CreditExternal implements Serializable { private Integer companyId; @Schema(description = "企业名称") - @TableField(exist = false) private String companyName; @Schema(description = "是否有数据") diff --git a/src/main/java/com/gxwebsoft/credit/entity/CreditRiskRelation.java b/src/main/java/com/gxwebsoft/credit/entity/CreditRiskRelation.java index 1d75ff2..b71cc6b 100644 --- a/src/main/java/com/gxwebsoft/credit/entity/CreditRiskRelation.java +++ b/src/main/java/com/gxwebsoft/credit/entity/CreditRiskRelation.java @@ -51,7 +51,6 @@ public class CreditRiskRelation implements Serializable { private Integer companyId; @Schema(description = "企业名称") - @TableField(exist = false) private String companyName; @Schema(description = "是否有数据") diff --git a/src/main/java/com/gxwebsoft/credit/entity/CreditSupplier.java b/src/main/java/com/gxwebsoft/credit/entity/CreditSupplier.java index ceb4ff0..698e75b 100644 --- a/src/main/java/com/gxwebsoft/credit/entity/CreditSupplier.java +++ b/src/main/java/com/gxwebsoft/credit/entity/CreditSupplier.java @@ -52,7 +52,6 @@ public class CreditSupplier implements Serializable { private Integer companyId; @Schema(description = "企业名称") - @TableField(exist = false) private String companyName; @Schema(description = "是否有数据") diff --git a/src/main/java/com/gxwebsoft/credit/entity/CreditUser.java b/src/main/java/com/gxwebsoft/credit/entity/CreditUser.java index f29220a..7de34a0 100644 --- a/src/main/java/com/gxwebsoft/credit/entity/CreditUser.java +++ b/src/main/java/com/gxwebsoft/credit/entity/CreditUser.java @@ -82,7 +82,6 @@ public class CreditUser implements Serializable { private Integer companyId; @Schema(description = "企业名称") - @TableField(exist = false) private String companyName; @Schema(description = "是否有数据")