From 8e9d91c50a6ca567a03951b8b3b5f94f0c29c065 Mon Sep 17 00:00:00 2001 From: luotaiqian <1147642922@qq.com> Date: Wed, 19 Aug 2026 08:08:20 +0800 Subject: [PATCH] appendCapabilityAssessment --- .../support/OrgPersonnelExcelImporter.java | 104 ++++++++++++++++++ .../app/support/OrgPersonnelImportRow.java | 48 ++++---- 2 files changed, 126 insertions(+), 26 deletions(-) diff --git a/safety-eval-app/src/main/java/org/qinan/safetyeval/app/support/OrgPersonnelExcelImporter.java b/safety-eval-app/src/main/java/org/qinan/safetyeval/app/support/OrgPersonnelExcelImporter.java index 4fa83348..e0997155 100644 --- a/safety-eval-app/src/main/java/org/qinan/safetyeval/app/support/OrgPersonnelExcelImporter.java +++ b/safety-eval-app/src/main/java/org/qinan/safetyeval/app/support/OrgPersonnelExcelImporter.java @@ -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; } + /** + * 是否评价师证书校验并回填: + * + * 全部通过后组装 {@link OrgPersonnelCertEntity} + * 写入 {@link OrgPersonnelImportRow.BasicRow#getPersonnelCertEntities()},行号取 sheet2 行号。 + * + * @return true 通过(或无需校验),false 存在不通过项(已记录异常) + */ + private boolean validateAndFillEvaluatorCert(OrgPersonnelImportRow.BasicRow basic + , OrgPersonnelImportRow.CapabilityRow capability, List 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; + } + + /** + * 职称校验并回填: + * + * + * @return true 通过(或无需校验),false 存在不通过项(已记录异常) + */ + private boolean validateAndFillTitle(OrgPersonnelImportRow.BasicRow basic + , OrgPersonnelImportRow.CapabilityRow capability, List 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; + } + /** * 字段级校验: *
    diff --git a/safety-eval-app/src/main/java/org/qinan/safetyeval/app/support/OrgPersonnelImportRow.java b/safety-eval-app/src/main/java/org/qinan/safetyeval/app/support/OrgPersonnelImportRow.java index 8bd4a66f..61101e78 100644 --- a/safety-eval-app/src/main/java/org/qinan/safetyeval/app/support/OrgPersonnelImportRow.java +++ b/safety-eval-app/src/main/java/org/qinan/safetyeval/app/support/OrgPersonnelImportRow.java @@ -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 capabilityAssessment = new ArrayList<>(2); - /** - * 证书 - */ + + @ApiModelProperty(value = "证书") @ExcelIgnore private List personnelCertEntities = new ArrayList<>(2); + + @ApiModelProperty(value = "职称(多个逗号分隔)") + @ExcelIgnore + private List 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;