package com.cpp.web.service.station.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cpp.web.domain.station.ElectricField;
import com.cpp.web.mapper.station.ElectricFieldMapper;
import com.cpp.web.service.station.ElectricFieldService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

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

/**
 * cpp_electric_field
 *
 * @author tl
 * @date 2024-09-23 15:28:33
 */
@Service
@RequiredArgsConstructor
public class ElectricFieldServiceImpl extends ServiceImpl<ElectricFieldMapper, ElectricField> implements ElectricFieldService {

    @Override
    public ElectricField findByStationCode(String stationCode) {
        QueryWrapper<ElectricField> wrapper = new QueryWrapper<>();
        if (stationCode != null && !stationCode.equals("")) {
            wrapper.eq("station_code", stationCode);
        }
        return baseMapper.selectOne(wrapper);
    }

    public List<ElectricField> syncStation() {
        ElectricField electricField;
        List<ElectricField> electricFieldList = new ArrayList<>();
//        List<Unit> unitList = remoteUnitService.getByApplyCodeAndUnitType("ipp", "3").getData();
//        List<ElectricField> e = this.list();
//        for (int i = 0; i < unitList.size(); i++) {
//            for (int j = 0; j < e.size(); j++) {
//                if (unitList.size() != 0 && unitList.get(i).getUnitName().equals(e.get(j).getName())) {
//                    unitList.remove(unitList.get(i));
//                }
//            }
//        }
//        for (Unit u : unitList) {
//            electricField = new ElectricField();
//            //场站地址
//            electricField.setLocation(u.getAddress());
//            //场站名称
//            electricField.setName(u.getUnitName());
//            //纬度
//            electricField.setLatitude(new BigDecimal(u.getLatitude()));
//            //经度
//            electricField.setLongitude(new BigDecimal(u.getLongitude()));
//            //场站标识
//            electricField.setSign(u.getUnitCode());
//            electricFieldList.add(electricField);
//        }
        return electricFieldList;
    }
}
