package com.gyee.runeconomy.controller.base;

import com.alibaba.fastjson.JSONObject;
import com.gyee.runeconomy.dto.result.JsonResult;
import com.gyee.runeconomy.dto.result.ResultCode;
import com.gyee.runeconomy.model.auto.ProBasicEquipment;
import com.gyee.runeconomy.model.auto.ProBasicPowerstation;
import com.gyee.runeconomy.service.TokenService;
import com.gyee.runeconomy.service.base.WindInfoService;
import com.gyee.runeconomy.service.fiveloss.FiveLossService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
import java.util.stream.Collectors;

/**
 * 场站风机等基础数据
 */
@RestController
@CrossOrigin
@RequestMapping("/base")
public class WindInfoController {


    @Resource
    private WindInfoService windInfoService;


//    @GetMapping("station")
//    public JSONObject getStation() {
//        List<ProBasicPowerstation> list = InitialRunner.wpNewList;
////        List<ProBasicPowerstation> list = tokenService.getWpls(request);
////        list = list.stream().filter(f -> f.getId().contains("FDC")).collect(Collectors.toList());
//        return JsonResult.successData(ResultCode.SUCCESS, list);
//    }

    @GetMapping("windturbine")
    public JSONObject getWindTurbine(@RequestParam(value = "wpids", required = true) String wpids) {

        Map<String, Object> map = windInfoService.windsPosition(wpids);
        if (map.size() > 0)
            return JsonResult.successData(ResultCode.SUCCESS, map);

        return JsonResult.error(ResultCode.ERROR_MODEL);
    }

//    @GetMapping("/gfstation")
//    public JSONObject getGFStation() {
//
//        List<ProBasicPowerstation> list = tokenService.getWpls(request);
//        list = list.stream().filter(f -> f.getId().contains("GDC")).collect(Collectors.toList());
////        List<ProBasicPowerstation> list = InitialRunner.gfwpNewList;
//        return JsonResult.successData(ResultCode.SUCCESS, list);
//    }

//    @GetMapping("/inverter")
//    public JSONObject getInverter(String stationId) {
//        List<ProBasicEquipment> list = InitialRunner.gfwpNewMap.get(stationId);
//        return JsonResult.successData(ResultCode.SUCCESS, list);
//    }



    /**
     * 获取风机经纬度信息
     * @param ids
     * @return
     */
//    @GetMapping("location")
//    public JSONObject dataLocation(String ids){
//        List<ProBasicEquipment> result = new ArrayList<>();
//        List<ProEconPowerFittingAnalySis> list = powerService.listByIds(Arrays.asList(ids.split(",")));
//        for (ProEconPowerFittingAnalySis obj : list){
//            String[] pids = obj.getProcessid().split(",");
//            for (String id : pids){
//                ProEconPowerFittingAnalySis item = powerService.getById(id);
//                ProBasicEquipment wt = InitialRunner.wtNewMap.get(item.getWindturbineId());
//                wt.setProcessId(id);
//                wt.setFittingId(obj.getId());
//                result.add(wt);
//            }
//        }
//        return JsonResult.successData(ResultCode.SUCCESS, result);
//    }

}
