package com.gyee.wisdom.dataadapter.domain.thing;

import com.gyee.wisdom.common.data.alarm.ElectricalTestingPointAI;
import com.gyee.wisdom.common.data.alarm.ElectricalTestingPointDI;
import com.gyee.wisdom.dao.alarm.ElectricalTestingPointAIDao;
import com.gyee.wisdom.dao.alarm.ElectricalTestingPointDIDao;
import com.gyee.wisdom.dataadapter.dto.ElectricalDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

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

@Service
public class ElectricalTestingPointService {

    @Autowired
    protected ElectricalTestingPointAIDao electricalTestingPointAIDao;

    @Autowired
    protected ElectricalTestingPointDIDao electricalTestingPointDIDao;


    //uniformcode,name,windpowerstationid
    public List<ElectricalDto>  getElectricalDtoAI(String uniformcode, String name, String windpowerstationid){
        List<ElectricalDto> list = new ArrayList<>();
        List<ElectricalTestingPointAI> electricalTestingPointAIS = electricalTestingPointAIDao.findByUniformcodeNameWindpowerstationid(uniformcode,name,windpowerstationid);
        for (ElectricalTestingPointAI ElectricalTestingPointAI : electricalTestingPointAIS){
            ElectricalDto data = new ElectricalDto();
            data.setId(ElectricalTestingPointAI.getId());
            data.setName(ElectricalTestingPointAI.getName());
            data.setUniformcode(ElectricalTestingPointAI.getUniformCode());
            data.setWindpowerstationid(ElectricalTestingPointAI.getWindPowerStationId());
            list.add(data);
        }
        return list;
    }

    public List<ElectricalDto> getElectricalDtoDI(String uniformcode,String name,String windpowerstationid) {
        List<ElectricalDto> list = new ArrayList<>();
        List<ElectricalTestingPointDI> electricalTestingPointDIS = electricalTestingPointDIDao.findByUniformcodeNameWindpowerstationid(uniformcode, name, windpowerstationid);
        for (ElectricalTestingPointDI electricalTestingPointDI : electricalTestingPointDIS) {
            ElectricalDto data = new ElectricalDto();
            data.setId(electricalTestingPointDI.getId());
            data.setName(electricalTestingPointDI.getName());
            data.setUniformcode(electricalTestingPointDI.getUniformCode());
            data.setWindpowerstationid(electricalTestingPointDI.getWindPowerStationId());
            list.add(data);
        }
        return list;
    }
}
