appendCapabilityAssessment

dev-tmp1
luotaiqian 2026-08-18 21:25:52 +08:00
parent b8fce630ed
commit afd36ea349
3 changed files with 81 additions and 32 deletions

View File

@ -15,11 +15,7 @@ import org.qinan.safetyeval.client.co.OrgPersonnelImportResultCO;
import org.qinan.safetyeval.domain.constant.basic.IndustryEnum; import org.qinan.safetyeval.domain.constant.basic.IndustryEnum;
import org.qinan.safetyeval.domain.constant.basic.ProfessionalCapabilityEnum; import org.qinan.safetyeval.domain.constant.basic.ProfessionalCapabilityEnum;
import org.qinan.safetyeval.domain.constant.basic.ProfessionalCapabilitySourceEnum; import org.qinan.safetyeval.domain.constant.basic.ProfessionalCapabilitySourceEnum;
import org.qinan.safetyeval.domain.entity.CapabilityAssessmentDTO; import org.qinan.safetyeval.domain.entity.*;
import org.qinan.safetyeval.domain.entity.OrgDepartmentEntity;
import org.qinan.safetyeval.domain.entity.OrgPersonnelCertEntity;
import org.qinan.safetyeval.domain.entity.OrgPersonnelEntity;
import org.qinan.safetyeval.domain.entity.OrgPositionEntity;
import org.qinan.safetyeval.domain.exception.BizException; import org.qinan.safetyeval.domain.exception.BizException;
import org.qinan.safetyeval.domain.exception.ErrorCode; import org.qinan.safetyeval.domain.exception.ErrorCode;
import org.qinan.safetyeval.domain.gateway.OrgDepartmentGateway; import org.qinan.safetyeval.domain.gateway.OrgDepartmentGateway;
@ -262,7 +258,6 @@ public class OrgPersonnelExcelImporter {
basic.setRowIndex(i + 2); basic.setRowIndex(i + 2);
row.setBasic(basic); row.setBasic(basic);
Pair<Boolean, OrgPersonnelImportRow.CapabilityRow> capabilityRow = matchCapability(basic, capabilityMap, errors); Pair<Boolean, OrgPersonnelImportRow.CapabilityRow> capabilityRow = matchCapability(basic, capabilityMap, errors);
row.setCapability(capabilityRow.getValue());
// 能力信息未匹配或存在多条,已记录异常,剔除该行 // 能力信息未匹配或存在多条,已记录异常,剔除该行
if (!capabilityRow.getKey()) { if (!capabilityRow.getKey()) {
continue; continue;
@ -322,6 +317,7 @@ public class OrgPersonnelExcelImporter {
if (CollectionUtils.isEmpty(capabilityList)) { if (CollectionUtils.isEmpty(capabilityList)) {
return Pair.of(true, null); return Pair.of(true, null);
} }
if (capabilityList.size() > 1) { if (capabilityList.size() > 1) {
errors.add(new OrgPersonnelImportErrorCO(basic.getRowIndex(), trim(basic.getAccount()), trim(basic.getUserName()), errors.add(new OrgPersonnelImportErrorCO(basic.getRowIndex(), trim(basic.getAccount()), trim(basic.getUserName()),
"专职人员能力信息中查询到多条数据")); "专职人员能力信息中查询到多条数据"));
@ -329,11 +325,32 @@ public class OrgPersonnelExcelImporter {
} }
OrgPersonnelImportRow.CapabilityRow capabilityRow = capabilityList.get(0); OrgPersonnelImportRow.CapabilityRow capabilityRow = capabilityList.get(0);
// 校验基础信息
// 2. sheet2 能力信息校验(未匹配到能力信息时跳过),行号取 sheet2 行号,消息加前缀便于区分来源
Set<ConstraintViolation<OrgPersonnelImportRow.CapabilityRow>> capabilityViolations =
validator.validate(capabilityRow);
if (!capabilityViolations.isEmpty()) {
capabilityViolations.stream()
.collect(Collectors.toMap(
v -> v.getPropertyPath().toString(),
v -> v,
(a, b) -> a))
.values()
.forEach(v -> errors.add(new OrgPersonnelImportErrorCO(capabilityRow.getRowIndex(),
capabilityRow.getUserName(), capabilityRow.getIdCardNo(), "能力信息:" + v.getMessage())));
return Pair.of(false, null);
}
// 能力认证一/二:认证行业、专业能力、来源 有值时校验枚举并回填,不通过记录异常 // 能力认证一/二:认证行业、专业能力、来源 有值时校验枚举并回填,不通过记录异常
if (!validateAndFillCertEnums(basic, capabilityRow, errors)) { if (!validateAndFillCertEnums(basic, capabilityRow, errors)) {
return Pair.of(false, null); return Pair.of(false, null);
} }
basic.setEducationType(capabilityRow.getEducationType());
basic.setGraduateSchool(capabilityRow.getGraduateSchool());
basic.setEducationLevel(capabilityRow.getEducationLevel());
basic.setMajor(capabilityRow.getMajor());
return Pair.of(true, capabilityRow); return Pair.of(true, capabilityRow);
} }
@ -356,6 +373,12 @@ public class OrgPersonnelExcelImporter {
String userName = trim(basic.getUserName()); String userName = trim(basic.getUserName());
Integer rowIndex = capability.getRowIndex(); Integer rowIndex = capability.getRowIndex();
// 学历类型、毕业院校、学历层次、所学专业 回填到基础信息行(@ExcelIgnore 字段Excel原始值忽略
basic.setEducationType(trim(capability.getEducationType()));
basic.setGraduateSchool(trim(capability.getGraduateSchool()));
basic.setEducationLevel(trim(capability.getEducationLevel()));
basic.setMajor(trim(capability.getMajor()));
// 能力认证一(必填):认证行业、专业能力、来源,查询不到枚举即记录异常并返回 // 能力认证一(必填):认证行业、专业能力、来源,查询不到枚举即记录异常并返回
String cert1Industry = trim(capability.getCert1Industry()); String cert1Industry = trim(capability.getCert1Industry());
IndustryEnum cert1IndustryEnum = IndustryEnum.ofName(cert1Industry); IndustryEnum cert1IndustryEnum = IndustryEnum.ofName(cert1Industry);
@ -423,7 +446,6 @@ public class OrgPersonnelExcelImporter {
} }
return true; return true;
} }
@ -480,31 +502,6 @@ public class OrgPersonnelExcelImporter {
return false; return false;
} }
// 2. sheet2 能力信息校验(未匹配到能力信息时跳过),行号取 sheet2 行号,消息加前缀便于区分来源
OrgPersonnelImportRow.CapabilityRow capability = row.getCapability();
if (capability != null) {
Set<ConstraintViolation<OrgPersonnelImportRow.CapabilityRow>> capabilityViolations =
validator.validate(capability);
if (!capabilityViolations.isEmpty()) {
capabilityViolations.stream()
.collect(Collectors.toMap(
v -> v.getPropertyPath().toString(),
v -> v,
(a, b) -> a))
.values()
.forEach(v -> errors.add(new OrgPersonnelImportErrorCO(capability.getRowIndex(),
account, userName, "能力信息:" + v.getMessage())));
return false;
}
// sheet2 身份证号格式校验DB: id_card_no varchar(18)
String capabilityIdCardNo = trim(capability.getIdCardNo());
if (StringUtils.hasText(capabilityIdCardNo) && !IdcardUtil.isValidCard(capabilityIdCardNo)) {
errors.add(new OrgPersonnelImportErrorCO(capability.getRowIndex(), account, userName,
"能力信息身份证号格式不正确应为15或18位有效身份证号"));
return false;
}
}
// 3. 身份证号格式校验DB: id_card_no varchar(18) // 3. 身份证号格式校验DB: id_card_no varchar(18)
String idCardNo = trim(row.getBasic().getIdCardNo()); String idCardNo = trim(row.getBasic().getIdCardNo());

View File

@ -5,6 +5,7 @@ import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data; import lombok.Data;
import org.hibernate.validator.constraints.Range; import org.hibernate.validator.constraints.Range;
import org.qinan.safetyeval.domain.entity.CapabilityAssessmentDTO; import org.qinan.safetyeval.domain.entity.CapabilityAssessmentDTO;
import org.qinan.safetyeval.domain.entity.OrgPersonnelCertEntity;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
@ -171,11 +172,41 @@ public class OrgPersonnelImportRow {
*/ */
@ExcelIgnore @ExcelIgnore
private Integer rowIndex; private Integer rowIndex;
/**
*
*/
@ExcelIgnore
private String educationType;
/**
*
*/
@ExcelIgnore
private String graduateSchool;
/**
*
*/
@ExcelIgnore
private String educationLevel;
/**
*
*/
@ExcelIgnore
private String major;
/** /**
* *
*/ */
@ExcelIgnore @ExcelIgnore
private List<CapabilityAssessmentDTO> capabilityAssessment = new ArrayList<>(2); private List<CapabilityAssessmentDTO> capabilityAssessment = new ArrayList<>(2);
/**
*
*/
@ExcelIgnore
private List<OrgPersonnelCertEntity> personnelCertEntities = new ArrayList<>(2);
} }
/** /**

View File

@ -29,4 +29,25 @@ public enum SafetyCategoryEnum {
"CONSTRUCTION=>建筑施工安全 ;" + "CONSTRUCTION=>建筑施工安全 ;" +
"ROAD_TRANSPORT=>道路运输安全;" + "ROAD_TRANSPORT=>道路运输安全;" +
"OTHER=>其他安全"; "OTHER=>其他安全";
public static IndustryEnum getIndustry(SafetyCategoryEnum safetyCategoryEnum) {
switch (safetyCategoryEnum) {
case COAL_MINE:
return IndustryEnum.COAL_MINING;
case METAL_NONMETAL_MINE:
return IndustryEnum.METAL_NONMETAL_MINING;
case CHEMICAL:
return IndustryEnum.PETROCHEMICAL_CHEMICAL_PHARMACEUTICAL;
case METAL_SMELTING:
return IndustryEnum.METAL_SMELTING;
case CONSTRUCTION:
return IndustryEnum.METAL_NONMETAL_MINING;
case ROAD_TRANSPORT:
return IndustryEnum.METAL_NONMETAL_MINING;
case OTHER:
return IndustryEnum.METAL_NONMETAL_MINING;
default:
return null ;
}
}
} }