appendCapabilityAssessment
parent
afd36ea349
commit
9a6191de40
|
|
@ -12,9 +12,11 @@ import com.zcloud.gbscommon.utils.MD5;
|
|||
import com.zcloud.gbscommon.utils.Sm2Util;
|
||||
import org.qinan.safetyeval.client.co.OrgPersonnelImportErrorCO;
|
||||
import org.qinan.safetyeval.client.co.OrgPersonnelImportResultCO;
|
||||
import org.qinan.safetyeval.domain.constant.QualificationLevelEnum;
|
||||
import org.qinan.safetyeval.domain.constant.basic.IndustryEnum;
|
||||
import org.qinan.safetyeval.domain.constant.basic.ProfessionalCapabilityEnum;
|
||||
import org.qinan.safetyeval.domain.constant.basic.ProfessionalCapabilitySourceEnum;
|
||||
import org.qinan.safetyeval.domain.constant.basic.SafetyCategoryEnum;
|
||||
import org.qinan.safetyeval.domain.entity.*;
|
||||
import org.qinan.safetyeval.domain.exception.BizException;
|
||||
import org.qinan.safetyeval.domain.exception.ErrorCode;
|
||||
|
|
@ -347,6 +349,11 @@ public class OrgPersonnelExcelImporter {
|
|||
return Pair.of(false, null);
|
||||
}
|
||||
|
||||
// 是否注册安全工程师:为[是]时 注安专业类别/注安等级/证书编号/执业证书编号 必填并校验枚举,通过后写入证书实体
|
||||
if (!validateAndFillRegisterEngineerCert(basic, capabilityRow, errors)) {
|
||||
return Pair.of(false, null);
|
||||
}
|
||||
|
||||
basic.setEducationType(capabilityRow.getEducationType());
|
||||
basic.setGraduateSchool(capabilityRow.getGraduateSchool());
|
||||
basic.setEducationLevel(capabilityRow.getEducationLevel());
|
||||
|
|
@ -469,6 +476,82 @@ public class OrgPersonnelExcelImporter {
|
|||
basic.getCapabilityAssessment().add(assessment);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否注册安全工程师证书校验并回填:
|
||||
* <ul>
|
||||
* <li>是否注册安全工程师 非[是]时不校验直接通过;</li>
|
||||
* <li>为[是]时 注安专业类别、注安等级、证书编号、执业证书编号 必填,任一未填写记录异常并返回;</li>
|
||||
* <li>注安专业类别 -> {@link SafetyCategoryEnum#ofName},查询不到记录异常并返回;</li>
|
||||
* <li>注安等级 -> {@link QualificationLevelEnum#ofNameContain},查询不到记录异常并返回。</li>
|
||||
* </ul>
|
||||
* 全部通过后组装 {@link OrgPersonnelCertEntity}
|
||||
* 写入 {@link OrgPersonnelImportRow.BasicRow#getPersonnelCertEntities()},行号取 sheet2 行号。
|
||||
*
|
||||
* @return true 通过(或无需校验),false 存在不通过项(已记录异常)
|
||||
*/
|
||||
private boolean validateAndFillRegisterEngineerCert(OrgPersonnelImportRow.BasicRow basic
|
||||
, OrgPersonnelImportRow.CapabilityRow capability, List<OrgPersonnelImportErrorCO> errors) {
|
||||
String registerEngineer = trim(capability.getRegisterEngineer());
|
||||
if (!YES.equals(registerEngineer)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Integer rowIndex = capability.getRowIndex();
|
||||
String account = trim(basic.getAccount());
|
||||
String userName = trim(basic.getUserName());
|
||||
|
||||
// 是否注册安全工程师为[是]:注安专业类别、注安等级、证书编号、执业证书编号 必填
|
||||
String category = trim(capability.getRegisterEngineerCategory());
|
||||
String level = trim(capability.getRegisterEngineerLevel());
|
||||
String certNo = trim(capability.getRegisterEngineerCertNo());
|
||||
String practiceCertNo = trim(capability.getPracticeCertNo());
|
||||
if (!StringUtils.hasText(category) || !StringUtils.hasText(level)
|
||||
|| !StringUtils.hasText(certNo) || !StringUtils.hasText(practiceCertNo)) {
|
||||
errors.add(new OrgPersonnelImportErrorCO(rowIndex, account, userName,
|
||||
"是否注册安全工程师为[是]时,注安专业类别、注安等级、证书编号、执业证书编号必须全部填写"));
|
||||
return false;
|
||||
}
|
||||
|
||||
// 注安专业类别:枚举查询不到即记录异常并返回
|
||||
SafetyCategoryEnum categoryEnum = SafetyCategoryEnum.ofName(category);
|
||||
if (categoryEnum == null) {
|
||||
errors.add(new OrgPersonnelImportErrorCO(rowIndex, account, userName,
|
||||
"注安专业类别[" + category + "]无法识别"));
|
||||
return false;
|
||||
}
|
||||
|
||||
// 注安等级:枚举查询不到即记录异常并返回
|
||||
QualificationLevelEnum levelEnum = QualificationLevelEnum.ofNameContain(level);
|
||||
if (levelEnum == null) {
|
||||
errors.add(new OrgPersonnelImportErrorCO(rowIndex, account, userName,
|
||||
"注安等级[" + level + "]无法识别"));
|
||||
return false;
|
||||
}
|
||||
|
||||
// 校验通过 -> 组装注安证书实体写入基础信息行
|
||||
basic.getPersonnelCertEntities().add(
|
||||
buildRegisterEngineerCert(categoryEnum, levelEnum, certNo, practiceCertNo));
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 组装注册安全工程师证书实体(证书数据处理公共方法):
|
||||
* 注安专业类别/注安等级 枚举均已校验通过,直接取编码与名称回填。
|
||||
*/
|
||||
private OrgPersonnelCertEntity buildRegisterEngineerCert(SafetyCategoryEnum categoryEnum
|
||||
, QualificationLevelEnum levelEnum, String certNo, String practiceCertNo) {
|
||||
OrgPersonnelCertEntity cert = new OrgPersonnelCertEntity();
|
||||
cert.setCertName("注册安全工程师");
|
||||
// 注安专业类别
|
||||
cert.setCertCategoryCode(categoryEnum.getValue());
|
||||
cert.setCertCategoryName(categoryEnum.getLabel());
|
||||
// 注安等级(编码同证书等级:SENIOR/MIDDLE/JUNIOR)
|
||||
cert.setCertLevel(levelEnum.getCode());
|
||||
cert.setCertNo(certNo);
|
||||
cert.setPractisingCertCode(practiceCertNo);
|
||||
return cert;
|
||||
}
|
||||
|
||||
/**
|
||||
* 字段级校验:
|
||||
* <ol>
|
||||
|
|
|
|||
|
|
@ -12,6 +12,10 @@ public enum QualificationLevelEnum {
|
|||
JUNIOR("JUNIOR", "初级"),
|
||||
;
|
||||
|
||||
public static final String SENIOR_ONE = "一级";
|
||||
public static final String MIDDLE_TWO = "二级";
|
||||
public static final String JUNIOR_THREE = "三级";
|
||||
|
||||
private final String code;
|
||||
private final String name;
|
||||
|
||||
|
|
@ -20,6 +24,28 @@ public enum QualificationLevelEnum {
|
|||
this.name = name;
|
||||
}
|
||||
|
||||
public static QualificationLevelEnum ofNameContain(String name) {
|
||||
for (QualificationLevelEnum value : QualificationLevelEnum.values()) {
|
||||
if (name.contains(value.getName())) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static QualificationLevelEnum ofNameLevelContain(String name) {
|
||||
if (name.contains(SENIOR_ONE)) {
|
||||
return SENIOR;
|
||||
}
|
||||
if (name.contains(MIDDLE_TWO)) {
|
||||
return MIDDLE;
|
||||
}
|
||||
if (name.contains(JUNIOR_THREE)) {
|
||||
return JUNIOR;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,18 @@ public enum SafetyCategoryEnum {
|
|||
"ROAD_TRANSPORT=>道路运输安全;" +
|
||||
"OTHER=>其他安全";
|
||||
|
||||
public static SafetyCategoryEnum ofName(String name) {
|
||||
if (name == null) {
|
||||
return null;
|
||||
}
|
||||
for (SafetyCategoryEnum item : values()) {
|
||||
if (item.getValue().equals(name)) {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static IndustryEnum getIndustry(SafetyCategoryEnum safetyCategoryEnum) {
|
||||
switch (safetyCategoryEnum) {
|
||||
case COAL_MINE:
|
||||
|
|
|
|||
Loading…
Reference in New Issue