package com.gyee.wisdom.alarm.sharding.service;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gyee.wisdom.alarm.sharding.cache.WindturbineCache;
import com.gyee.wisdom.alarm.sharding.entity.DeviceStructure;
import com.gyee.wisdom.alarm.sharding.entity.EarlyWarnScore;
import com.gyee.wisdom.alarm.sharding.entity.Windturbine;
import com.gyee.wisdom.alarm.sharding.mapper.EarlyWarnScoreMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.stereotype.Service;

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

@Service
@Slf4j
@EnableScheduling
public class EarlyWarnScoreService  {
    @Autowired
    private EarlyWarnScoreMapper earlyWarnScoreMapper;

    @Autowired
    private WindturbineCache windturbineCache;

    public List<EarlyWarnScore> getListEarlyWarnScore(String windturbineid) {
        List<EarlyWarnScore> earlyWarnScores =  earlyWarnScoreMapper.getListEarlyWarnScore(windturbineid);
        for (int i = 0; i < earlyWarnScores.size(); i++) {
            Windturbine windturbine = windturbineCache.getWindturbine(earlyWarnScores.get(i).getWindturbineid());
            if(windturbine!=null){
                earlyWarnScores.get(i).setWindturbineName(windturbine.getName());
                earlyWarnScores.get(i).setStationId(windturbine.getWindpowerstationid());
                earlyWarnScores.get(i).setModel(windturbine.getModelid());
            }

        }
        
        return earlyWarnScores;
    }

}
