package com.ruoyi.bst.device.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ruoyi.bst.device.domain.DeviceVO;
import com.ruoyi.bst.device.service.DeviceAssembler;
import com.ruoyi.bst.device.service.DeviceIotService;
import com.ruoyi.bst.device.utils.DeviceUtil;
import com.ruoyi.common.utils.collection.CollectionUtils;

@Service
public class DeviceAssemblerImpl implements DeviceAssembler {

    @Autowired
    private DeviceIotService deviceIotService;

    @Override
    public void assembleIot(List<DeviceVO> list) {
        if (CollectionUtils.isEmptyElement(list)) {
            return;
        }
        for (DeviceVO device : list) {
            if (device == null) {
                continue;
            }
            Map<String, Object> info = deviceIotService.getIotInfo(device.getMac());
            DeviceUtil.setIotInfo(device, info);
        }
    }
}
