appendCapabilityAssessment
parent
9a6191de40
commit
8e9d91c50a
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue