fix(import): 修复Excel导入时企业名称字段处理问题

- 移除CreditCompetitor、CreditCustomer、CreditExternal、CreditRiskRelation、CreditSupplier和CreditUser实体中companyName字段的@TableField(exist = false)注解
- 在各控制器的convertImportParamToEntity方法中添加CreditCompany::setCompanyName方法引用
- 从companyId获取对应的企业名称并设置到fixedCompanyName变量中
- 更新导入逻辑中的注释说明,明确name和companyName字段的不同用途
- 在导入过程中当companyName为空且存在固定公司名称时进行赋值处理
This commit is contained in:
2026-03-15 11:55:24 +08:00
parent 7c1af7c207
commit 50f6b49da9
12 changed files with 61 additions and 7 deletions

View File

@@ -6,6 +6,7 @@ import com.gxwebsoft.common.core.web.BaseController;
import com.gxwebsoft.common.core.web.BatchParam; import com.gxwebsoft.common.core.web.BatchParam;
import com.gxwebsoft.common.core.web.PageResult; import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.common.system.entity.User; import com.gxwebsoft.common.system.entity.User;
import com.gxwebsoft.credit.entity.CreditCompany;
import com.gxwebsoft.credit.entity.CreditCompetitor; import com.gxwebsoft.credit.entity.CreditCompetitor;
import com.gxwebsoft.credit.param.CreditCompetitorImportParam; import com.gxwebsoft.credit.param.CreditCompetitorImportParam;
import com.gxwebsoft.credit.param.CreditCompetitorParam; import com.gxwebsoft.credit.param.CreditCompetitorParam;
@@ -170,6 +171,7 @@ public class CreditCompetitorController extends BaseController {
CreditCompetitor::getName, CreditCompetitor::getName,
CreditCompetitor::getCompanyId, CreditCompetitor::getCompanyId,
CreditCompetitor::setCompanyId, CreditCompetitor::setCompanyId,
CreditCompetitor::setCompanyName,
CreditCompetitor::getHasData, CreditCompetitor::getHasData,
CreditCompetitor::setHasData, CreditCompetitor::setHasData,
CreditCompetitor::getTenantId, CreditCompetitor::getTenantId,
@@ -212,6 +214,11 @@ public class CreditCompetitorController extends BaseController {
Integer currentTenantId = loginUser != null ? loginUser.getTenantId() : null; Integer currentTenantId = loginUser != null ? loginUser.getTenantId() : null;
Map<String, String> urlByName = ExcelImportSupport.readUrlByKey( Map<String, String> urlByName = ExcelImportSupport.readUrlByKey(
file, usedSheetIndex, usedTitleRows, usedHeadRows, "企业名称"); 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 chunkSize = 500;
final int mpBatchSize = 500; final int mpBatchSize = 500;
@@ -222,7 +229,7 @@ public class CreditCompetitorController extends BaseController {
CreditCompetitorImportParam param = list.get(i); CreditCompetitorImportParam param = list.get(i);
try { try {
CreditCompetitor item = convertImportParamToEntity(param); CreditCompetitor item = convertImportParamToEntity(param);
// name 才是持久化字段companyName 为关联查询的临时字段exist=false导入时不应使用 // name 为竞争对手企业名称companyName 为主体企业名称
if (!ImportHelper.isBlank(item.getName())) { if (!ImportHelper.isBlank(item.getName())) {
String link = urlByName.get(item.getName().trim()); String link = urlByName.get(item.getName().trim());
if (!ImportHelper.isBlank(link)) { if (!ImportHelper.isBlank(link)) {
@@ -232,6 +239,9 @@ public class CreditCompetitorController extends BaseController {
if (item.getCompanyId() == null && companyId != null) { if (item.getCompanyId() == null && companyId != null) {
item.setCompanyId(companyId); item.setCompanyId(companyId);
if (ImportHelper.isBlank(item.getCompanyName()) && !ImportHelper.isBlank(fixedCompanyName)) {
item.setCompanyName(fixedCompanyName);
}
} }
if (item.getUserId() == null && currentUserId != null) { if (item.getUserId() == null && currentUserId != null) {
item.setUserId(currentUserId); item.setUserId(currentUserId);

View File

@@ -6,6 +6,7 @@ import com.gxwebsoft.common.core.web.BaseController;
import com.gxwebsoft.common.core.web.BatchParam; import com.gxwebsoft.common.core.web.BatchParam;
import com.gxwebsoft.common.core.web.PageResult; import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.common.system.entity.User; import com.gxwebsoft.common.system.entity.User;
import com.gxwebsoft.credit.entity.CreditCompany;
import com.gxwebsoft.credit.entity.CreditCustomer; import com.gxwebsoft.credit.entity.CreditCustomer;
import com.gxwebsoft.credit.param.CreditCustomerImportParam; import com.gxwebsoft.credit.param.CreditCustomerImportParam;
import com.gxwebsoft.credit.param.CreditCustomerParam; import com.gxwebsoft.credit.param.CreditCustomerParam;
@@ -167,6 +168,7 @@ public class CreditCustomerController extends BaseController {
CreditCustomer::getName, CreditCustomer::getName,
CreditCustomer::getCompanyId, CreditCustomer::getCompanyId,
CreditCustomer::setCompanyId, CreditCustomer::setCompanyId,
CreditCustomer::setCompanyName,
CreditCustomer::getHasData, CreditCustomer::getHasData,
CreditCustomer::setHasData, CreditCustomer::setHasData,
CreditCustomer::getTenantId, CreditCustomer::getTenantId,
@@ -208,6 +210,11 @@ public class CreditCustomerController extends BaseController {
Integer currentUserId = loginUser != null ? loginUser.getUserId() : null; Integer currentUserId = loginUser != null ? loginUser.getUserId() : null;
Integer currentTenantId = loginUser != null ? loginUser.getTenantId() : null; Integer currentTenantId = loginUser != null ? loginUser.getTenantId() : null;
Map<String, String> urlByName = ExcelImportSupport.readUrlByKey(file, usedSheetIndex, usedTitleRows, usedHeadRows, "客户"); Map<String, String> 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 chunkSize = 500;
final int mpBatchSize = 500; final int mpBatchSize = 500;
@@ -229,6 +236,9 @@ public class CreditCustomerController extends BaseController {
if (item.getCompanyId() == null && companyId != null) { if (item.getCompanyId() == null && companyId != null) {
item.setCompanyId(companyId); item.setCompanyId(companyId);
if (ImportHelper.isBlank(item.getCompanyName()) && !ImportHelper.isBlank(fixedCompanyName)) {
item.setCompanyName(fixedCompanyName);
}
} }
if (item.getUserId() == null && currentUserId != null) { if (item.getUserId() == null && currentUserId != null) {
item.setUserId(currentUserId); item.setUserId(currentUserId);

View File

@@ -6,6 +6,7 @@ import com.gxwebsoft.common.core.web.BaseController;
import com.gxwebsoft.common.core.web.BatchParam; import com.gxwebsoft.common.core.web.BatchParam;
import com.gxwebsoft.common.core.web.PageResult; import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.common.system.entity.User; import com.gxwebsoft.common.system.entity.User;
import com.gxwebsoft.credit.entity.CreditCompany;
import com.gxwebsoft.credit.entity.CreditExternal; import com.gxwebsoft.credit.entity.CreditExternal;
import com.gxwebsoft.credit.param.CreditExternalImportParam; import com.gxwebsoft.credit.param.CreditExternalImportParam;
import com.gxwebsoft.credit.param.CreditExternalParam; import com.gxwebsoft.credit.param.CreditExternalParam;
@@ -170,6 +171,7 @@ public class CreditExternalController extends BaseController {
CreditExternal::getName, CreditExternal::getName,
CreditExternal::getCompanyId, CreditExternal::getCompanyId,
CreditExternal::setCompanyId, CreditExternal::setCompanyId,
CreditExternal::setCompanyName,
CreditExternal::getHasData, CreditExternal::getHasData,
CreditExternal::setHasData, CreditExternal::setHasData,
CreditExternal::getTenantId, CreditExternal::getTenantId,
@@ -211,6 +213,11 @@ public class CreditExternalController extends BaseController {
Integer currentUserId = loginUser != null ? loginUser.getUserId() : null; Integer currentUserId = loginUser != null ? loginUser.getUserId() : null;
Integer currentTenantId = loginUser != null ? loginUser.getTenantId() : null; Integer currentTenantId = loginUser != null ? loginUser.getTenantId() : null;
Map<String, String> urlByName = ExcelImportSupport.readUrlByKey(file, usedSheetIndex, usedTitleRows, usedHeadRows, "被投资企业名称"); Map<String, String> 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 chunkSize = 500;
final int mpBatchSize = 500; final int mpBatchSize = 500;
@@ -230,6 +237,9 @@ public class CreditExternalController extends BaseController {
if (item.getCompanyId() == null && companyId != null) { if (item.getCompanyId() == null && companyId != null) {
item.setCompanyId(companyId); item.setCompanyId(companyId);
if (ImportHelper.isBlank(item.getCompanyName()) && !ImportHelper.isBlank(fixedCompanyName)) {
item.setCompanyName(fixedCompanyName);
}
} }
if (item.getUserId() == null && currentUserId != null) { if (item.getUserId() == null && currentUserId != null) {
item.setUserId(currentUserId); item.setUserId(currentUserId);

View File

@@ -6,6 +6,7 @@ import com.gxwebsoft.common.core.web.BaseController;
import com.gxwebsoft.common.core.web.BatchParam; import com.gxwebsoft.common.core.web.BatchParam;
import com.gxwebsoft.common.core.web.PageResult; import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.common.system.entity.User; import com.gxwebsoft.common.system.entity.User;
import com.gxwebsoft.credit.entity.CreditCompany;
import com.gxwebsoft.credit.entity.CreditRiskRelation; import com.gxwebsoft.credit.entity.CreditRiskRelation;
import com.gxwebsoft.credit.param.CreditRiskRelationImportParam; import com.gxwebsoft.credit.param.CreditRiskRelationImportParam;
import com.gxwebsoft.credit.param.CreditRiskRelationParam; import com.gxwebsoft.credit.param.CreditRiskRelationParam;
@@ -170,6 +171,7 @@ public class CreditRiskRelationController extends BaseController {
CreditRiskRelation::getMainBodyName, CreditRiskRelation::getMainBodyName,
CreditRiskRelation::getCompanyId, CreditRiskRelation::getCompanyId,
CreditRiskRelation::setCompanyId, CreditRiskRelation::setCompanyId,
CreditRiskRelation::setCompanyName,
CreditRiskRelation::getHasData, CreditRiskRelation::getHasData,
CreditRiskRelation::setHasData, CreditRiskRelation::setHasData,
CreditRiskRelation::getTenantId, CreditRiskRelation::getTenantId,
@@ -209,6 +211,11 @@ public class CreditRiskRelationController extends BaseController {
User loginUser = getLoginUser(); User loginUser = getLoginUser();
Integer currentUserId = loginUser != null ? loginUser.getUserId() : null; Integer currentUserId = loginUser != null ? loginUser.getUserId() : null;
Integer currentTenantId = loginUser != null ? loginUser.getTenantId() : 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 chunkSize = 500;
final int mpBatchSize = 500; final int mpBatchSize = 500;
@@ -222,6 +229,9 @@ public class CreditRiskRelationController extends BaseController {
if (item.getCompanyId() == null && companyId != null) { if (item.getCompanyId() == null && companyId != null) {
item.setCompanyId(companyId); item.setCompanyId(companyId);
if (ImportHelper.isBlank(item.getCompanyName()) && !ImportHelper.isBlank(fixedCompanyName)) {
item.setCompanyName(fixedCompanyName);
}
} }
if (item.getUserId() == null && currentUserId != null) { if (item.getUserId() == null && currentUserId != null) {
item.setUserId(currentUserId); item.setUserId(currentUserId);

View File

@@ -6,6 +6,7 @@ import com.gxwebsoft.common.core.web.BaseController;
import com.gxwebsoft.common.core.web.BatchParam; import com.gxwebsoft.common.core.web.BatchParam;
import com.gxwebsoft.common.core.web.PageResult; import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.common.system.entity.User; import com.gxwebsoft.common.system.entity.User;
import com.gxwebsoft.credit.entity.CreditCompany;
import com.gxwebsoft.credit.entity.CreditSupplier; import com.gxwebsoft.credit.entity.CreditSupplier;
import com.gxwebsoft.credit.param.CreditSupplierImportParam; import com.gxwebsoft.credit.param.CreditSupplierImportParam;
import com.gxwebsoft.credit.param.CreditSupplierParam; import com.gxwebsoft.credit.param.CreditSupplierParam;
@@ -170,6 +171,7 @@ public class CreditSupplierController extends BaseController {
CreditSupplier::getSupplier, CreditSupplier::getSupplier,
CreditSupplier::getCompanyId, CreditSupplier::getCompanyId,
CreditSupplier::setCompanyId, CreditSupplier::setCompanyId,
CreditSupplier::setCompanyName,
CreditSupplier::getHasData, CreditSupplier::getHasData,
CreditSupplier::setHasData, CreditSupplier::setHasData,
CreditSupplier::getTenantId, CreditSupplier::getTenantId,
@@ -211,6 +213,11 @@ public class CreditSupplierController extends BaseController {
Integer currentUserId = loginUser != null ? loginUser.getUserId() : null; Integer currentUserId = loginUser != null ? loginUser.getUserId() : null;
Integer currentTenantId = loginUser != null ? loginUser.getTenantId() : null; Integer currentTenantId = loginUser != null ? loginUser.getTenantId() : null;
Map<String, String> urlBySupplier = ExcelImportSupport.readUrlByKey(file, usedSheetIndex, usedTitleRows, usedHeadRows, "供应商"); Map<String, String> 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 chunkSize = 500;
final int mpBatchSize = 500; final int mpBatchSize = 500;
@@ -230,6 +237,9 @@ public class CreditSupplierController extends BaseController {
if (item.getCompanyId() == null && companyId != null) { if (item.getCompanyId() == null && companyId != null) {
item.setCompanyId(companyId); item.setCompanyId(companyId);
if (ImportHelper.isBlank(item.getCompanyName()) && !ImportHelper.isBlank(fixedCompanyName)) {
item.setCompanyName(fixedCompanyName);
}
} }
if (item.getUserId() == null && currentUserId != null) { if (item.getUserId() == null && currentUserId != null) {
item.setUserId(currentUserId); item.setUserId(currentUserId);

View File

@@ -8,6 +8,7 @@ import com.gxwebsoft.common.core.web.BaseController;
import com.gxwebsoft.common.core.web.BatchParam; import com.gxwebsoft.common.core.web.BatchParam;
import com.gxwebsoft.common.core.web.PageResult; import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.common.system.entity.User; import com.gxwebsoft.common.system.entity.User;
import com.gxwebsoft.credit.entity.CreditCompany;
import com.gxwebsoft.credit.entity.CreditUser; import com.gxwebsoft.credit.entity.CreditUser;
import com.gxwebsoft.credit.param.CreditUserImportParam; import com.gxwebsoft.credit.param.CreditUserImportParam;
import com.gxwebsoft.credit.param.CreditUserParam; import com.gxwebsoft.credit.param.CreditUserParam;
@@ -176,6 +177,7 @@ public class CreditUserController extends BaseController {
CreditUser::getWinningName, CreditUser::getWinningName,
CreditUser::getCompanyId, CreditUser::getCompanyId,
CreditUser::setCompanyId, CreditUser::setCompanyId,
CreditUser::setCompanyName,
CreditUser::getHasData, CreditUser::getHasData,
CreditUser::setHasData, CreditUser::setHasData,
CreditUser::getTenantId, CreditUser::getTenantId,
@@ -216,6 +218,11 @@ public class CreditUserController extends BaseController {
Integer currentUserId = loginUser != null ? loginUser.getUserId() : null; Integer currentUserId = loginUser != null ? loginUser.getUserId() : null;
Integer currentTenantId = loginUser != null ? loginUser.getTenantId() : null; Integer currentTenantId = loginUser != null ? loginUser.getTenantId() : null;
Map<Integer, String> urlMap = readNameHyperlinks(file, sheetIndex, usedTitleRows, usedHeadRows); Map<Integer, String> 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 chunkSize = 500;
final int mpBatchSize = 500; final int mpBatchSize = 500;
@@ -233,6 +240,9 @@ public class CreditUserController extends BaseController {
} }
if (item.getCompanyId() == null && companyId != null) { if (item.getCompanyId() == null && companyId != null) {
item.setCompanyId(companyId); item.setCompanyId(companyId);
if (ImportHelper.isBlank(item.getCompanyName()) && !ImportHelper.isBlank(fixedCompanyName)) {
item.setCompanyName(fixedCompanyName);
}
} }
if (item.getCompanyId() != null && item.getCompanyId() > 0) { if (item.getCompanyId() != null && item.getCompanyId() > 0) {
touchedCompanyIds.add(item.getCompanyId()); touchedCompanyIds.add(item.getCompanyId());

View File

@@ -58,7 +58,6 @@ public class CreditCompetitor implements Serializable {
private Integer companyId; private Integer companyId;
@Schema(description = "企业名称") @Schema(description = "企业名称")
@TableField(exist = false)
private String companyName; private String companyName;
@Schema(description = "所属企业名称") @Schema(description = "所属企业名称")

View File

@@ -52,7 +52,6 @@ public class CreditCustomer implements Serializable {
private Integer companyId; private Integer companyId;
@Schema(description = "企业名称") @Schema(description = "企业名称")
@TableField(exist = false)
private String companyName; private String companyName;
@Schema(description = "是否有数据") @Schema(description = "是否有数据")

View File

@@ -79,7 +79,6 @@ public class CreditExternal implements Serializable {
private Integer companyId; private Integer companyId;
@Schema(description = "企业名称") @Schema(description = "企业名称")
@TableField(exist = false)
private String companyName; private String companyName;
@Schema(description = "是否有数据") @Schema(description = "是否有数据")

View File

@@ -51,7 +51,6 @@ public class CreditRiskRelation implements Serializable {
private Integer companyId; private Integer companyId;
@Schema(description = "企业名称") @Schema(description = "企业名称")
@TableField(exist = false)
private String companyName; private String companyName;
@Schema(description = "是否有数据") @Schema(description = "是否有数据")

View File

@@ -52,7 +52,6 @@ public class CreditSupplier implements Serializable {
private Integer companyId; private Integer companyId;
@Schema(description = "企业名称") @Schema(description = "企业名称")
@TableField(exist = false)
private String companyName; private String companyName;
@Schema(description = "是否有数据") @Schema(description = "是否有数据")

View File

@@ -82,7 +82,6 @@ public class CreditUser implements Serializable {
private Integer companyId; private Integer companyId;
@Schema(description = "企业名称") @Schema(description = "企业名称")
@TableField(exist = false)
private String companyName; private String companyName;
@Schema(description = "是否有数据") @Schema(description = "是否有数据")