package com.jiayue.ipp.idp.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.jiayue.ipp.common.data.entity.ElectricField;
import com.jiayue.ipp.idp.mapper.ElectricFieldMapper;
import com.jiayue.ipp.idp.service.ElectricFieldService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

/**
 * idp_electric_field
 *
 * @author whc
 * @date 2022-03-18 15:48:48
 */
@Service
public class ElectricFieldServiceImpl extends ServiceImpl<ElectricFieldMapper, ElectricField> implements ElectricFieldService {
//    @Autowired
//    RemoteUnitService remoteUnitService;

    @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;
    }
}
