appendCapabilityAssessment

dev-tmp1
luotaiqian 2026-08-19 08:08:20 +08:00
parent 9a6191de40
commit 8e9d91c50a
2 changed files with 126 additions and 26 deletions

View File

@ -354,6 +354,17 @@ public class OrgPersonnelExcelImporter {
return Pair.of(false, null);
}
// 是否评价师:为[是]时 评价师等级/证书编号 必填并校验枚举,通过后写入证书实体
if (!validateAndFillEvaluatorCert(basic, capabilityRow, errors)) {
return Pair.of(false, null);
}
// 职称:有值时校验枚举并回填,查询不到记录异常
if (!validateAndFillTitle(basic, capabilityRow, errors)) {
return Pair.of(false, null);
}
basic.setEducationType(capabilityRow.getEducationType());
basic.setGraduateSchool(capabilityRow.getGraduateSchool());
basic.setEducationLevel(capabilityRow.getEducationLevel());
@ -552,6 +563,99 @@ public class OrgPersonnelExcelImporter {
return cert;
}
/**
*
* <ul>
* <li> []</li>
* <li>[] </li>
* <li> -> {@link QualificationLevelEnum#ofNameLevelContain}</li>
* </ul>
* {@link OrgPersonnelCertEntity}
* {@link OrgPersonnelImportRow.BasicRow#getPersonnelCertEntities()} sheet2
*
* @return true false
*/
private boolean validateAndFillEvaluatorCert(OrgPersonnelImportRow.BasicRow basic
, OrgPersonnelImportRow.CapabilityRow capability, List<OrgPersonnelImportErrorCO> errors) {
String evaluator = trim(capability.getEvaluator());
if (!YES.equals(evaluator)) {
return true;
}
Integer rowIndex = capability.getRowIndex();
String account = trim(basic.getAccount());
String userName = trim(basic.getUserName());
// 是否评价师为[是]:评价师等级、证书编号 必填
String level = trim(capability.getEvaluatorLevel());
String certNo = trim(capability.getEvaluatorCertNo());
if (!StringUtils.hasText(level) || !StringUtils.hasText(certNo)) {
errors.add(new OrgPersonnelImportErrorCO(rowIndex, account, userName,
"是否评价师为[是]时,评价师等级、证书编号必须全部填写"));
return false;
}
// 评价师等级:枚举查询不到即记录异常并返回
QualificationLevelEnum levelEnum = QualificationLevelEnum.ofNameLevelContain(level);
if (levelEnum == null) {
errors.add(new OrgPersonnelImportErrorCO(rowIndex, account, userName,
"评价师等级[" + level + "]无法识别"));
return false;
}
// 校验通过 -> 组装评价师证书实体写入基础信息行
basic.getPersonnelCertEntities().add(buildEvaluatorCert(levelEnum, certNo));
return true;
}
/**
*
*
*/
private OrgPersonnelCertEntity buildEvaluatorCert(QualificationLevelEnum levelEnum, String certNo) {
OrgPersonnelCertEntity cert = new OrgPersonnelCertEntity();
cert.setCertName("安全评价师");
// 评价师等级编码同证书等级SENIOR/MIDDLE/JUNIOR
cert.setCertLevel(levelEnum.getCode());
cert.setCertNo(certNo);
return cert;
}
/**
*
* <ul>
* <li> </li>
* <li> {@link QualificationLevelEnum#ofNameContain}
* </li>
* <li> {@link TitleCodeCo}
* {@link OrgPersonnelImportRow.BasicRow#getTitleCodeArr()} sheet2 </li>
* </ul>
*
* @return true false
*/
private boolean validateAndFillTitle(OrgPersonnelImportRow.BasicRow basic
, OrgPersonnelImportRow.CapabilityRow capability, List<OrgPersonnelImportErrorCO> errors) {
String title = trim(capability.getSeniorEngineer());
if (!StringUtils.hasText(title)) {
return true;
}
// 职称:枚举查询不到即记录异常并返回
QualificationLevelEnum levelEnum = QualificationLevelEnum.ofNameContain(title);
if (levelEnum == null) {
errors.add(new OrgPersonnelImportErrorCO(capability.getRowIndex(), trim(basic.getAccount()),
trim(basic.getUserName()), "职称[" + title + "]无法识别"));
return false;
}
// 校验通过 -> 组装职称写入基础信息行
TitleCodeCo titleCode = new TitleCodeCo();
titleCode.setTitleCode(levelEnum.getCode());
titleCode.setIndustryName(capability.getSeriesMajor());
basic.getTitleCodeArr().add(titleCode);
return true;
}
/**
*
* <ol>

View File

@ -2,10 +2,12 @@ package org.qinan.safetyeval.app.support;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Range;
import org.qinan.safetyeval.domain.entity.CapabilityAssessmentDTO;
import org.qinan.safetyeval.domain.entity.OrgPersonnelCertEntity;
import org.qinan.safetyeval.domain.entity.TitleCodeCo;
import org.springframework.util.StringUtils;
import javax.validation.constraints.NotBlank;
@ -167,46 +169,39 @@ public class OrgPersonnelImportRow {
@Size(max = 1000, message = "自我申报的专业能力信息长度不能超过1000个字符")
private String abilityDeclaration;
/**
* sheet1 1
*/
@ExcelIgnore
@ApiModelProperty(value = " sheet1 的物理行号从1开始含表头由导入器填充用于错误提示。")
private Integer rowIndex;
/**
*
*/
@ExcelIgnore
@ApiModelProperty(value = "学历类型")
private String educationType;
/**
*
*/
@ExcelIgnore
@ApiModelProperty(value = "毕业院校")
private String graduateSchool;
/**
*
*/
@ApiModelProperty(value = "学历层次")
@ExcelIgnore
private String educationLevel;
/**
*
*/
@ApiModelProperty(value = "所学专业")
@ExcelIgnore
private String major;
/**
*
*/
@ApiModelProperty(value = "能力")
@ExcelIgnore
private List<CapabilityAssessmentDTO> capabilityAssessment = new ArrayList<>(2);
/**
*
*/
@ApiModelProperty(value = "证书")
@ExcelIgnore
private List<OrgPersonnelCertEntity> personnelCertEntities = new ArrayList<>(2);
@ApiModelProperty(value = "职称(多个逗号分隔)")
@ExcelIgnore
private List<TitleCodeCo> titleCodeArr = new ArrayList<>(2);
}
/**
@ -306,15 +301,16 @@ public class OrgPersonnelImportRow {
private String evaluatorLevel;
@ExcelProperty(value = "评价师证书编号", index = 19)
@Size(max = 64, message = "评价师证书编号长度不能超过100个字符")
@Size(max = 64, message = "评价师证书编号长度不能超过64个字符")
private String evaluatorCertNo;
@ExcelProperty(value = "是否高级工程师", index = 20)
@Pattern(regexp = "^([是否])?$", message = "是否高级工程师仅允许:是、否")
@ExcelProperty(value = "职称", index = 20)
@Size(max = 64, message = "评价师证书编号长度不能超过64个字符")
private String seniorEngineer;
@ExcelProperty(value = "高级工程师系列/专业", index = 21)
private String seniorEngineerSeries;
@ExcelProperty(value = "系列/专业", index = 21)
@Size(max = 64, message = "评价师证书编号长度不能超过64个字符")
private String seriesMajor;
@ExcelIgnore
private Integer rowIndex;