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:
@@ -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<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 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);
|
||||
|
||||
Reference in New Issue
Block a user