yudao-module-hrm/src/main/java/cn/iocoder/yudao/module/hrm/api/employee/HrmEmployeeApiImpl.java
@@ -10,6 +10,7 @@
import org.springframework.stereotype.Service;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@@ -51,7 +52,9 @@
        // 批量查部门,避免 N+1
        List<Long> deptIds = employees.stream().map(HrmEmployeeDO::getDeptId)
                .filter(Objects::nonNull).distinct().toList();
        Map<Long, DeptRespDTO> deptMap = deptIds.isEmpty() ? Map.of() : deptApi.getDeptMap(deptIds);
        // 用 new HashMap<>() 而非 Map.of():员工的 deptId 允许为空,
        // 后面 deptMap.get(e.getDeptId()) 会 get(null),Map.of() 的 get(null) 抛 NPE。
        Map<Long, DeptRespDTO> deptMap = deptIds.isEmpty() ? new HashMap<>() : deptApi.getDeptMap(deptIds);
        return employees.stream()
                .map(e -> {
                    DeptRespDTO dept = deptMap.get(e.getDeptId());