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 443cfb5..3c5410a 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 @@ -9,6 +9,7 @@ import org.qinan.safetyeval.domain.entity.OrgPositionEntity; import org.qinan.safetyeval.domain.entity.TitleCodeCo; import org.qinan.safetyeval.domain.exception.BizException; import org.qinan.safetyeval.domain.exception.ErrorCode; +import org.qinan.safetyeval.domain.constant.QualificationLevelEnum; import org.qinan.safetyeval.domain.gateway.OrgDepartmentGateway; import org.qinan.safetyeval.domain.gateway.OrgPersonnelGateway; import org.qinan.safetyeval.domain.gateway.OrgPositionGateway; @@ -402,7 +403,7 @@ public class OrgPersonnelExcelImporter { } // 职称:无字典,按分隔符拆分后原样存入(保留信息,待后续字典完善) -// entity.setTitleCodeArr(parseTitles(trim(row.getTitle()))); + entity.setTitleCodeArr(parseTitles(trim(row.getTitle()))); return entity; } @@ -415,13 +416,26 @@ public class OrgPersonnelExcelImporter { .filter(StringUtils::hasText) .map(t -> { TitleCodeCo co = new TitleCodeCo(); - co.setTitleCode(t); + co.setTitleCode(convertTitleToCode(t)); return co; }) .collect(Collectors.toList()); return list.isEmpty() ? null : list; } + /** + * 职称文本转 code:按 QualificationLevelEnum 名称包含匹配(如"高级工程师"→SENIOR、"中级工程师"→MIDDLE、"初级"→JUNIOR), + * 匹配不到则原样返回。 + */ + private String convertTitleToCode(String titleText) { + for (QualificationLevelEnum level : QualificationLevelEnum.values()) { + if (titleText.contains(level.getName())) { + return level.getCode(); + } + } + return titleText; + } + /** * 解析日期:兼容 yyyy-MM-dd 与 yyyy/M/d(如 1988-05-12、1988/5/12)等常见 Excel 格式。 */