调整实体库管理数据来源维护规则
This commit is contained in:
@@ -89,7 +89,6 @@ public class CcdiEnterpriseBaseInfoAddDTO implements Serializable {
|
||||
private String shareholder5;
|
||||
|
||||
@Schema(description = "经营状态")
|
||||
@NotBlank(message = "经营状态不能为空")
|
||||
@Size(max = 50, message = "经营状态长度不能超过50个字符")
|
||||
private String status;
|
||||
|
||||
@@ -102,6 +101,5 @@ public class CcdiEnterpriseBaseInfoAddDTO implements Serializable {
|
||||
private String entSource;
|
||||
|
||||
@Schema(description = "数据来源")
|
||||
@NotBlank(message = "数据来源不能为空")
|
||||
private String dataSource;
|
||||
}
|
||||
|
||||
@@ -89,7 +89,6 @@ public class CcdiEnterpriseBaseInfoEditDTO implements Serializable {
|
||||
private String shareholder5;
|
||||
|
||||
@Schema(description = "经营状态")
|
||||
@NotBlank(message = "经营状态不能为空")
|
||||
@Size(max = 50, message = "经营状态长度不能超过50个字符")
|
||||
private String status;
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ public class CcdiEnterpriseBaseInfoExcel implements Serializable {
|
||||
@ColumnWidth(18)
|
||||
private String shareholder5;
|
||||
|
||||
@ExcelProperty(value = "经营状态*", index = 16)
|
||||
@ExcelProperty(value = "经营状态", index = 16)
|
||||
@ColumnWidth(16)
|
||||
private String status;
|
||||
|
||||
@@ -99,8 +99,4 @@ public class CcdiEnterpriseBaseInfoExcel implements Serializable {
|
||||
@ExcelProperty(value = "企业来源*", index = 18)
|
||||
@ColumnWidth(18)
|
||||
private String entSource;
|
||||
|
||||
@ExcelProperty(value = "数据来源*", index = 19)
|
||||
@ColumnWidth(18)
|
||||
private String dataSource;
|
||||
}
|
||||
|
||||
@@ -131,10 +131,6 @@ public class CcdiEnterpriseBaseInfoImportServiceImpl implements ICcdiEnterpriseB
|
||||
if (!excel.getSocialCreditCode().matches("^[0-9A-HJ-NPQRTUWXY]{2}\\d{6}[0-9A-HJ-NPQRTUWXY]{10}$")) {
|
||||
throw new RuntimeException("统一社会信用代码格式不正确");
|
||||
}
|
||||
if (StringUtils.isEmpty(excel.getStatus())) {
|
||||
throw new RuntimeException("经营状态不能为空");
|
||||
}
|
||||
|
||||
String riskLevel = EnterpriseRiskLevel.resolveCode(StringUtils.trim(excel.getRiskLevel()));
|
||||
if (riskLevel == null) {
|
||||
throw new RuntimeException("风险等级不在允许范围内");
|
||||
@@ -143,10 +139,6 @@ public class CcdiEnterpriseBaseInfoImportServiceImpl implements ICcdiEnterpriseB
|
||||
if (entSource == null) {
|
||||
throw new RuntimeException("企业来源不在允许范围内");
|
||||
}
|
||||
String dataSource = resolveDataSourceCode(StringUtils.trim(excel.getDataSource()));
|
||||
if (dataSource == null) {
|
||||
throw new RuntimeException("数据来源不在允许范围内");
|
||||
}
|
||||
|
||||
if (existingCreditCodes.contains(excel.getSocialCreditCode())) {
|
||||
throw new RuntimeException(String.format("统一社会信用代码[%s]已存在,请勿重复导入", excel.getSocialCreditCode()));
|
||||
@@ -159,8 +151,8 @@ public class CcdiEnterpriseBaseInfoImportServiceImpl implements ICcdiEnterpriseB
|
||||
BeanUtils.copyProperties(excel, entity);
|
||||
entity.setRiskLevel(riskLevel);
|
||||
entity.setEntSource(entSource);
|
||||
entity.setDataSource(dataSource);
|
||||
entity.setStatus(StringUtils.trim(excel.getStatus()));
|
||||
entity.setDataSource(DataSource.IMPORT.getCode());
|
||||
entity.setStatus(trimToNull(excel.getStatus()));
|
||||
entity.setCreatedBy(userName);
|
||||
entity.setUpdatedBy(userName);
|
||||
return entity;
|
||||
@@ -206,15 +198,6 @@ public class CcdiEnterpriseBaseInfoImportServiceImpl implements ICcdiEnterpriseB
|
||||
redisTemplate.opsForHash().putAll(buildStatusKey(taskId), statusData);
|
||||
}
|
||||
|
||||
private String resolveDataSourceCode(String value) {
|
||||
for (DataSource source : DataSource.values()) {
|
||||
if (source.getCode().equals(value) || source.getDesc().equals(value)) {
|
||||
return source.getCode();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String buildStatusKey(String taskId) {
|
||||
return "import:enterpriseBaseInfo:" + taskId;
|
||||
}
|
||||
@@ -222,4 +205,11 @@ public class CcdiEnterpriseBaseInfoImportServiceImpl implements ICcdiEnterpriseB
|
||||
private String buildFailuresKey(String taskId) {
|
||||
return "import:enterpriseBaseInfo:" + taskId + ":failures";
|
||||
}
|
||||
|
||||
private String trimToNull(String value) {
|
||||
if (StringUtils.isEmpty(value)) {
|
||||
return null;
|
||||
}
|
||||
return value.trim();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,10 +85,12 @@ public class CcdiEnterpriseBaseInfoServiceImpl implements ICcdiEnterpriseBaseInf
|
||||
if (enterpriseBaseInfoMapper.selectById(addDTO.getSocialCreditCode()) != null) {
|
||||
throw new RuntimeException("该统一社会信用代码已存在");
|
||||
}
|
||||
validateEnumFields(addDTO.getStatus(), addDTO.getRiskLevel(), addDTO.getEntSource(), addDTO.getDataSource());
|
||||
validateRiskLevelAndEnterpriseSource(addDTO.getRiskLevel(), addDTO.getEntSource());
|
||||
|
||||
CcdiEnterpriseBaseInfo entity = new CcdiEnterpriseBaseInfo();
|
||||
BeanUtils.copyProperties(addDTO, entity);
|
||||
entity.setStatus(trimToNull(addDTO.getStatus()));
|
||||
entity.setDataSource(DataSource.MANUAL.getCode());
|
||||
return enterpriseBaseInfoMapper.insert(entity);
|
||||
}
|
||||
|
||||
@@ -103,6 +105,8 @@ public class CcdiEnterpriseBaseInfoServiceImpl implements ICcdiEnterpriseBaseInf
|
||||
|
||||
CcdiEnterpriseBaseInfo entity = new CcdiEnterpriseBaseInfo();
|
||||
BeanUtils.copyProperties(editDTO, entity);
|
||||
entity.setStatus(trimToNull(editDTO.getStatus()));
|
||||
entity.setDataSource(existing.getDataSource());
|
||||
return enterpriseBaseInfoMapper.updateById(entity);
|
||||
}
|
||||
|
||||
@@ -176,18 +180,22 @@ public class CcdiEnterpriseBaseInfoServiceImpl implements ICcdiEnterpriseBaseInf
|
||||
}
|
||||
|
||||
private void validateEnumFields(String status, String riskLevel, String entSource, String dataSource) {
|
||||
if (StringUtils.isEmpty(status)) {
|
||||
throw new RuntimeException("经营状态不能为空");
|
||||
validateRiskLevelAndEnterpriseSource(riskLevel, entSource);
|
||||
if (StringUtils.isNotEmpty(status) && StringUtils.trim(status).length() > 50) {
|
||||
throw new RuntimeException("经营状态长度不能超过50个字符");
|
||||
}
|
||||
if (!containsDataSource(dataSource)) {
|
||||
throw new RuntimeException("数据来源不在允许范围内");
|
||||
}
|
||||
}
|
||||
|
||||
private void validateRiskLevelAndEnterpriseSource(String riskLevel, String entSource) {
|
||||
if (!EnterpriseRiskLevel.contains(riskLevel)) {
|
||||
throw new RuntimeException("风险等级不在允许范围内");
|
||||
}
|
||||
if (!EnterpriseSource.contains(entSource)) {
|
||||
throw new RuntimeException("企业来源不在允许范围内");
|
||||
}
|
||||
if (!containsDataSource(dataSource)) {
|
||||
throw new RuntimeException("数据来源不在允许范围内");
|
||||
}
|
||||
}
|
||||
|
||||
private boolean containsDataSource(String code) {
|
||||
@@ -199,6 +207,13 @@ public class CcdiEnterpriseBaseInfoServiceImpl implements ICcdiEnterpriseBaseInf
|
||||
return false;
|
||||
}
|
||||
|
||||
private String trimToNull(String value) {
|
||||
if (StringUtils.isEmpty(value)) {
|
||||
return null;
|
||||
}
|
||||
return value.trim();
|
||||
}
|
||||
|
||||
private void validateDeleteRelations(String socialCreditCode) {
|
||||
StringJoiner relationTypes = new StringJoiner("、");
|
||||
if (staffEnterpriseRelationMapper.selectCount(new LambdaQueryWrapper<CcdiStaffEnterpriseRelation>()
|
||||
|
||||
Reference in New Issue
Block a user