package com.ruoyi.system.service.impl;

import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.enums.DataSourceType;
import com.ruoyi.system.domain.DeviceBo;
import com.ruoyi.system.mapper.AisDatabaseMapper;
import com.ruoyi.system.service.IAisDatabase;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

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

/**
 * @Description: TODO
 * @Author: huangcheng
 * @Date: 2021/8/31
 * @Version V1.0
 */
@Service
@DataSource(DataSourceType.SLAVE_AIS)
public class AisDatabaseImpl implements IAisDatabase {

    @Autowired
    private AisDatabaseMapper aisDatabaseMapper;

    @Override
    public List<Map<String, Object>> queryDeviceStatic() {
        return aisDatabaseMapper.queryDeviceStatic();
    }

    @Override
    public int queryDeviceCount() {
        return aisDatabaseMapper.queryDeviceCount();
    }

    @Override
    public List<DeviceBo> queryDeviceList(String monitor) {
        return aisDatabaseMapper.queryDeviceList(monitor);
    }

    @Override
    public Map<String, Object> queryById(String id) {
        return aisDatabaseMapper.queryById(id);
    }

    @Override
    public Map<String, String> queryDeviceMap() {
        List<DeviceBo> deviceBos = this.queryDeviceList("");
        return deviceBos.stream().collect(Collectors.toMap(DeviceBo::getDeviceId, DeviceBo::getName));
    }
}
