package com.dcs.hnyz.utils;

import com.dcs.hnyz.domain.vo.EquipmentParamFormVO;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * EquipmentParamUtils
 *
 * @author: hmy
 * @date: 2025/5/30 14:53
 */
public class EquipmentParamUtils {

    /**
     * 将 paramList 转换为 Map<寄存器code, EquipmentParamFormVo>
     */
    public static Map<String, EquipmentParamFormVO> paramListToMap(List<EquipmentParamFormVO> paramList) {
        return paramList.stream()
                .filter(p -> p.getCode() != null && p.getValue() != null)
                .collect(Collectors.toMap(
                        EquipmentParamFormVO::getCode,
                        p -> p,
                        (existing, replacement) -> replacement // 重复时覆盖
                ));
    }
}
