package com.gyee.frame.controller.monitor;

import com.gyee.frame.common.conf.AjaxStatus;
import com.gyee.frame.common.domain.AjaxResult;
import com.gyee.frame.model.custom.DataVo;
import com.gyee.frame.service.websocket.*;
import com.gyee.frame.util.StringUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/monitor")
@Api(value = "状态监视" ,tags =  "状态监视")
public class MonitorPushController {

    @Resource
    private WpInfoPushService wpInfoPushService;
    @Resource
    private PowerFirstPushService powerFirstPushService;
    @Resource
    private MatrixPushByWpService matrixPushByWpService;
    @Resource
    private CftInfoPushService cftInfoPushService;

    @PostMapping("/findCftInfo")
    @ResponseBody
    @ApiOperation(value = "获取测风塔信息", notes = "获取测风塔信息")
    @ApiImplicitParams({ @ApiImplicitParam(name = "wpId", value = "风场编号", required = true, dataType = "string", paramType = "query")})

    public AjaxResult findCftInfo(String wpId) throws Exception {


        Map<String, Object> map = new HashMap<String, Object>();

        if(StringUtils.notEmp(wpId))
        {
            map =cftInfoPushService.findCftInfo(wpId);
        }


        if (null!=map ){
            return AjaxResult.successData(AjaxStatus.success.code, map );
        } else {
            return AjaxResult.successData(AjaxStatus.error.code, map );
        }

    }
    @PostMapping("/monitor")
    @ResponseBody
    @ApiOperation(value = "状态监视", notes = "状态监视")
    @ApiImplicitParams({})
    public AjaxResult monitor() throws Exception {


        Map<String, Object> map=  new HashMap<>();


        map=wpInfoPushService.findWpInfo();

        if (null!=map) {
            return AjaxResult.successData(AjaxStatus.success.code, map);
        } else {
            return AjaxResult.successData(AjaxStatus.error.code, map);
        }

    }

    @PostMapping("/findWpInfoBywpId")
    @ResponseBody
    @ApiOperation(value = "场站监视", notes = "场站监视")
    @ApiImplicitParams({@ApiImplicitParam(name = "wpId", value = "风场编号", required = true, dataType = "string", paramType = "query")
    })
    public AjaxResult findWpInfoBywpId(String wpId) throws Exception {


        Map<String, Object> map=  new HashMap<>();

        if(StringUtils.notEmp(wpId))
        {
            map=wpInfoPushService.findWpInfoBy(wpId);
        }


        if (null!=map) {
            return AjaxResult.successData(AjaxStatus.success.code, map);
        } else {
            return AjaxResult.successData(AjaxStatus.error.code, map);
        }

    }

    @PostMapping("/findLossWpBar")
    @ResponseBody
    @ApiOperation(value = "场站监视损失电量图表", notes = "场站监视损失电量图表")
    @ApiImplicitParams({@ApiImplicitParam(name = "wpId", value = "风场编号", required = true, dataType = "string", paramType = "query")
    })
    public AjaxResult findLossWpBar(String wpId) throws Exception {


        List<DataVo> vos=  new ArrayList<>();

        if(StringUtils.notEmp(wpId))
        {
            vos=wpInfoPushService.findLossWpBar(wpId);
        }


        if (null!=vos) {
            return AjaxResult.successData(AjaxStatus.success.code, vos);
        } else {
            return AjaxResult.successData(AjaxStatus.error.code, vos);
        }

    }

    @PostMapping("/findPowerWpBar")
    @ResponseBody
    @ApiOperation(value = "场站监视日发电量图表", notes = "场站监视日发电量图表")
    @ApiImplicitParams({@ApiImplicitParam(name = "wpId", value = "风场编号", required = true, dataType = "string", paramType = "query")
    })
    public AjaxResult findPowerWpBar(String wpId) throws Exception {


        List<DataVo> vos=  new ArrayList<>();

        if(StringUtils.notEmp(wpId))
        {
            vos=wpInfoPushService.findPowerWpBar(wpId);
        }


        if (null!=vos) {
            return AjaxResult.successData(AjaxStatus.success.code, vos);
        } else {
            return AjaxResult.successData(AjaxStatus.error.code, vos);
        }

    }

    @PostMapping("/findMonthPowerWpBar")
    @ResponseBody
    @ApiOperation(value = "场站监视月发电量图表", notes = "场站监视月发电量图表")
    @ApiImplicitParams({@ApiImplicitParam(name = "wpId", value = "风场编号", required = true, dataType = "string", paramType = "query")
    })
    public AjaxResult findMonthPowerWpBar(String wpId) throws Exception {


        List<DataVo> vos=  new ArrayList<>();

        if(StringUtils.notEmp(wpId))
        {
            vos=wpInfoPushService.findMonthPowerWpBar(wpId);
        }


        if (null!=vos) {
            return AjaxResult.successData(AjaxStatus.success.code, vos);
        } else {
            return AjaxResult.successData(AjaxStatus.error.code, vos);
        }

    }


    @PostMapping("/findPowerFirst")
    @ResponseBody
    @ApiOperation(value = "升压站监视", notes = "升压站监视")
    @ApiImplicitParams({@ApiImplicitParam(name = "wpId", value = "风场编号", required = true, dataType = "string", paramType = "query")
    })
    public AjaxResult findPowerFirst(String wpId) throws Exception {


        Map<String, Object> map=  new HashMap<>();

        if(StringUtils.notEmp(wpId))
        {
            map=powerFirstPushService.findPowerFirst(wpId);
        }


        if (null!=map) {
            return AjaxResult.successData(AjaxStatus.success.code, map);
        } else {
            return AjaxResult.successData(AjaxStatus.error.code, map);
        }

    }

    @PostMapping("/findGeneralAppearance")
    @ResponseBody
    @ApiOperation(value = "总貌、地貌监视", notes = "总貌、地貌监视")
    @ApiImplicitParams({@ApiImplicitParam(name = "wpId", value = "风场编号", required = true, dataType = "string", paramType = "query")
    })
    public AjaxResult findGeneralAppearance(String wpId) throws Exception {


        Map<String, Object> map=  new HashMap<>();

        if(StringUtils.notEmp(wpId))
        {
            map=matrixPushByWpService.findGeneralAppearance(wpId);
        }


        if (null!=map) {
            return AjaxResult.successData(AjaxStatus.success.code, map);
        } else {
            return AjaxResult.successData(AjaxStatus.error.code, map);
        }

    }
}
