package com.njcn.harmonic.controller.distribution;

import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.param.StatisticsBizBaseParam;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.harmonic.pojo.param.OverviewParam;
import com.njcn.harmonic.pojo.vo.OverviewVO;
import com.njcn.harmonic.service.majornetwork.RStatHarmonicOrgMService;
import com.njcn.harmonic.service.majornetwork.RStatOrgMService;
import com.njcn.harmonic.service.specialanalysis.RStatOrgPvPowerQualityService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <分布式光伏概览>
 *
 * @author wr
 */
@RestController
@RequestMapping("/pwOverview")
@Slf4j
@Api(tags = "分布式光伏概览")
@RequiredArgsConstructor
public class PwOverviewController extends BaseController {

    private final RStatHarmonicOrgMService rStatHarmonicOrgMService;
    private final RStatOrgPvPowerQualityService rStatOrgPvPowerQualityService;
    private final RStatOrgMService rStatOrgMService;


    @PostMapping("/getExcessiveProportion")
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @ApiOperation("稳态指标超标占比")
    @ApiImplicitParam(name = "param", value = "条件参数", required = true)
    public HttpResult<List<OverviewVO.ExcessiveVO>> getExcessiveProportion(@RequestBody OverviewParam param) {
        String methodDescribe = getMethodDescribe("getExcessiveProportion");
        List<OverviewVO.ExcessiveVO> monitorYoY = rStatHarmonicOrgMService.getExcessiveProportion(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, monitorYoY, methodDescribe);
    }

    @PostMapping("/getVoltage")
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @ApiOperation("电压问题")
    @ApiImplicitParam(name = "param", value = "条件参数", required = true)
    public HttpResult<List<OverviewVO.IcoVO>> getVoltage(@RequestBody OverviewParam.OverviewVoltageParam param) {
        String methodDescribe = getMethodDescribe("getVoltage");
        List<OverviewVO.IcoVO> groupVOS = rStatOrgPvPowerQualityService.getVoltage(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, groupVOS, methodDescribe);
    }

    @PostMapping("/getPowerFactor")
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @ApiOperation("功率因数问题")
    @ApiImplicitParam(name = "param", value = "条件参数", required = true)
    public HttpResult<List<OverviewVO.NumVO> > getPowerFactor(@RequestBody OverviewParam param) {
        String methodDescribe = getMethodDescribe("getPowerFactor");
        List<OverviewVO.NumVO> groupVOS = rStatOrgPvPowerQualityService.getPowerFactor(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, groupVOS, methodDescribe);
    }

    @PostMapping("/getBackTheTide")
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @ApiOperation("潮流倒送与重过载问题")
    @ApiImplicitParam(name = "param", value = "条件参数", required = true)
    public HttpResult<List<OverviewVO.IcoVO> > getBackTheTide(@RequestBody OverviewParam param) {
        String methodDescribe = getMethodDescribe("getBackTheTide");
        List<OverviewVO.IcoVO> groupVOS = rStatOrgPvPowerQualityService.getBackTheTide(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, groupVOS, methodDescribe);
    }

    @PostMapping("/getExceedMonitor")
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @ApiOperation("超标监测点数量")
    @ApiImplicitParam(name = "param", value = "条件参数", required = true)
    public HttpResult<List<OverviewVO.GroupVO>> getExceedMonitor(@RequestBody OverviewParam.OverviewDateParam param) {
        String methodDescribe = getMethodDescribe("getExceedMonitor");
        List<OverviewVO.GroupVO> groupVOS = rStatOrgMService.getExceedMonitor(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, groupVOS, methodDescribe);
    }

    @PostMapping("/getPVVoltage")
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @ApiOperation("高低电压问题(冀北)")
    @ApiImplicitParam(name = "param", value = "条件参数", required = true)
    public HttpResult<List<List<Object>>> getPVVoltage(@RequestBody StatisticsBizBaseParam param) {
        String methodDescribe = getMethodDescribe("getPVVoltage");
        List<List<Object>> pvVoltage = rStatOrgPvPowerQualityService.getPVVoltage(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, pvVoltage, methodDescribe);
    }
}
