package com.gyee.alarm.service;


import com.gyee.alarm.init.Cache.WindturbineCache;
import com.gyee.alarm.init.CacheContext;
import com.gyee.alarm.model.auto.ProBasicEquipment;
import com.gyee.alarm.model.auto.ProEconEarlyWarnScore;
import com.gyee.alarm.service.auto.IProEconEarlyWarnScoreService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
@Slf4j

public class EarlyWarnScoreService  {
    @Resource
    private IProEconEarlyWarnScoreService proEconEarlyWarnScoreService;



    public List<ProEconEarlyWarnScore> getListEarlyWarnScore(String windturbineid) {
        List<ProEconEarlyWarnScore> earlyWarnScores =  proEconEarlyWarnScoreService.getListEarlyWarnScore(windturbineid);
        for (int i = 0; i < earlyWarnScores.size(); i++) {

            if(CacheContext.wtmap.containsKey(earlyWarnScores.get(i).getWindturbineId()))
            {
                ProBasicEquipment windturbine= CacheContext.wtmap.get(earlyWarnScores.get(i).getWindturbineId());
                if(windturbine!=null){

                    if(CacheContext.wpmap.containsKey(windturbine.getWindpowerstationId()))
                    {
                        String stationName = CacheContext.wpmap.get(windturbine.getWindpowerstationId()).getName();
                        earlyWarnScores.get(i).setWindturbineName(windturbine.getName());
                        earlyWarnScores.get(i).setStationId(windturbine.getWindpowerstationId());
                        earlyWarnScores.get(i).setModel(windturbine.getModelId());
                        earlyWarnScores.get(i).setWindturbineCode(windturbine.getNemCode());
                        earlyWarnScores.get(i).setStationName(stationName.replace("风电场",""));
                    }

                }
            }

        }
        
        return earlyWarnScores;
    }

}
