yudao-module-hrm/src/main/java/cn/iocoder/yudao/module/hrm/service/employee/HrmEmployeeServiceImpl.java
@@ -48,6 +48,7 @@
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
@@ -370,18 +371,67 @@
                .filter(Objects::nonNull)
                .collect(Collectors.toSet());
        Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(deptIds);
        // 解析岗位ID(post_ids 存的是 JSON 数组字符串,如 [38]),并批量加载岗位名称
        Map<Long, List<Long>> empPostIdsMap = new LinkedHashMap<>();
        Set<Long> allPostIds = new LinkedHashSet<>();
        for (HrmEmployeeDO emp : list) {
            List<Long> postIdList = parseEmployeePostIds(emp.getPostIds());
            empPostIdsMap.put(emp.getId(), postIdList);
            allPostIds.addAll(postIdList);
        }
        Map<Long, PostRespDTO> postMap = CollUtil.isEmpty(allPostIds)
                ? Collections.emptyMap() : postApi.getPostMap(allPostIds);
        return list.stream().map(emp -> {
            HrmEmployeeSimpleRespVO vo = new HrmEmployeeSimpleRespVO();
            vo.setId(emp.getId());
            vo.setEmployeeNo(emp.getEmployeeNo());
            vo.setName(emp.getName());
            vo.setEmployeeStatus(emp.getEmployeeStatus());
            vo.setDeptId(emp.getDeptId());
            if (emp.getDeptId() != null && deptMap.containsKey(emp.getDeptId())) {
                vo.setDeptName(deptMap.get(emp.getDeptId()).getName());
            }
            // 岗位信息(用于调岗等场景自动带出原岗位)
            List<Long> postIdList = empPostIdsMap.getOrDefault(emp.getId(), Collections.emptyList());
            vo.setPostIds(postIdList);
            if (CollUtil.isNotEmpty(postIdList)) {
                vo.setPostName(postIdList.stream()
                        .map(postMap::get)
                        .filter(Objects::nonNull)
                        .map(PostRespDTO::getName)
                        .collect(Collectors.joining(",")));
            }
            return vo;
        }).collect(Collectors.toList());
    }
    /**
     * 解析员工的岗位ID字符串(JSON 数组格式,如 [38] 或 [1,2])
     */
    /**
     * 解析员工岗位ID字符串(post_ids 存 JSON 数组,如 [38] 或 [1,2])
     */
    private java.util.List<Long> parseEmployeePostIds(String postIds) {
        if (StrUtil.isBlank(postIds)) {
            return Collections.emptyList();
        }
        // post_ids 形如 "[38]" 或 "[1,2]":去掉中括号后按逗号解析
        return Arrays.stream(postIds.replace("[", "").replace("]", "").split(","))
                .map(String::trim)
                .filter(StrUtil::isNotBlank)
                .map(s -> {
                    try {
                        return Long.valueOf(s);
                    } catch (NumberFormatException ex) {
                        return null;
                    }
                })
                .filter(Objects::nonNull)
                .collect(Collectors.toList());
    }
    @Override
    public HrmEmployeeDO getEmployeeByUserId(Long userId) {
@@ -459,8 +509,9 @@
        if (StrUtil.isBlank(importEmployee.getPhone())) {
            throw exception(EMPLOYEE_IMPORT_FIELD_REQUIRED, "手机号");
        }
        if (importEmployee.getHireDate() == null) {
            throw exception(EMPLOYEE_IMPORT_FIELD_REQUIRED, "入职日期");
        LocalDate hireDate = parseImportDate(importEmployee.getHireDate());
        if (hireDate == null) {
            throw exception(EMPLOYEE_IMPORT_FIELD_REQUIRED, "入职日期(格式:2015 或 2015-01-01)");
        }
        HrmEmployeeSaveReqVO reqVO = new HrmEmployeeSaveReqVO();
        reqVO.setName(importEmployee.getName());
@@ -469,11 +520,11 @@
        reqVO.setDeptId(deptId);
        reqVO.setPostIds(CollUtil.isEmpty(postIds) ? null : new ArrayList<>(postIds));
        reqVO.setRoleIds(CollUtil.isEmpty(roleIds) ? null : new ArrayList<>(roleIds));
        reqVO.setHireDate(importEmployee.getHireDate());
        reqVO.setHireDate(hireDate);
        reqVO.setEmployeeStatus(importEmployee.getEmployeeStatus() != null
                ? importEmployee.getEmployeeStatus() : 1); // 默认在职
        reqVO.setEmail(importEmployee.getEmail());
        reqVO.setBirthday(importEmployee.getBirthday());
        reqVO.setBirthday(parseImportDate(importEmployee.getBirthday()));
        reqVO.setIdCard(importEmployee.getIdCard());
        reqVO.setNation(importEmployee.getNation());
        reqVO.setMarriageStatus(importEmployee.getMarriageStatus());
@@ -541,6 +592,57 @@
        return roleIds;
    }
    /**
     * 容错解析导入日期文本,支持:2015 / 2015年 / 2015-01 / 2015-01-02 / 2015/1/2 / 2015.1.2 /
     * 2015-01-02 00:00:00 / 20150102,以及 Excel 日期序列号;解析不出返回 null。
     */
    private static LocalDate parseImportDate(String raw) {
        if (StrUtil.isBlank(raw)) {
            return null;
        }
        String s = raw.trim();
        // 去掉时间部分
        int sp = s.indexOf(' ');
        if (sp > 0) {
            s = s.substring(0, sp);
        }
        // 中文年月日 / 斜杠 / 点 / 下划线 统一成 - 分隔
        s = s.replace("年", "-").replace("月", "-").replace("日", "")
                .replace("/", "-").replace(".", "-").replace("_", "-").trim();
        s = s.replaceAll("^-+|-+$", "");
        if (StrUtil.isBlank(s)) {
            return null;
        }
        try {
            if (s.matches("\\d+")) {
                int len = s.length();
                if (len == 4) { // 2015
                    return LocalDate.of(Integer.parseInt(s), 1, 1);
                }
                if (len == 5) { // Excel 日期序列号(1900 日期系统,基准 1899-12-30)
                    return LocalDate.of(1899, 12, 30).plusDays(Long.parseLong(s));
                }
                if (len == 6) { // 201506
                    return LocalDate.of(Integer.parseInt(s.substring(0, 4)), Integer.parseInt(s.substring(4, 6)), 1);
                }
                if (len == 8) { // 20150601
                    return LocalDate.of(Integer.parseInt(s.substring(0, 4)), Integer.parseInt(s.substring(4, 6)), Integer.parseInt(s.substring(6, 8)));
                }
                return null;
            }
            String[] parts = s.split("-");
            if (parts.length == 2) { // 2015-06
                return LocalDate.of(Integer.parseInt(parts[0]), Integer.parseInt(parts[1]), 1);
            }
            if (parts.length >= 3) { // 2015-06-01
                return LocalDate.of(Integer.parseInt(parts[0]), Integer.parseInt(parts[1]), Integer.parseInt(parts[2]));
            }
        } catch (Exception e) {
            return null;
        }
        return null;
    }
    // ========== 转正 ==========
    @Override