xiaoyi
5 天以前 05ab6e3f69a5e73624b2573db043f5923e8f7d8b
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/safety/SafetyRefResolver.java
@@ -9,6 +9,7 @@
import org.springframework.stereotype.Component;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@@ -65,12 +66,15 @@
     * 批量取员工,返回 id -> 员工 的 Map
     */
    public Map<Long, HrmEmployeeSimpleDTO> employeeMap(Collection<Long> employeeIds) {
        // 注意:这里必须返回可接受 null key 的空 Map。
        // 调用方会直接 map.get(记录里的 xxxId),而 xxxId 允许为 null(例如组织未设负责人、
        // 证件未关联持证人),Map.of() 的 get(null) 会抛 NPE,导致列表接口 500。
        if (CollUtil.isEmpty(employeeIds)) {
            return Map.of();
            return new HashMap<>();
        }
        List<Long> ids = employeeIds.stream().filter(Objects::nonNull).distinct().toList();
        if (ids.isEmpty()) {
            return Map.of();
            return new HashMap<>();
        }
        return hrmEmployeeApi.getEmployeeList(ids).stream()
                .collect(Collectors.toMap(HrmEmployeeSimpleDTO::getId, e -> e, (a, b) -> a));
@@ -103,12 +107,13 @@
     * 批量取车间,返回 id -> 车间 的 Map
     */
    public Map<Long, MesMdWorkshopDO> workshopMap(Collection<Long> workshopIds) {
        // 同上:车间编号允许为 null,空集合必须返回可接受 null key 的 Map
        if (CollUtil.isEmpty(workshopIds)) {
            return Map.of();
            return new HashMap<>();
        }
        List<Long> ids = workshopIds.stream().filter(Objects::nonNull).distinct().toList();
        if (ids.isEmpty()) {
            return Map.of();
            return new HashMap<>();
        }
        return workshopMapper.selectBatchIds(ids).stream()
                .collect(Collectors.toMap(MesMdWorkshopDO::getId, w -> w, (a, b) -> a));