package com.njcn.harmonic.controller.majornetwork;


import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.constant.BizParamConstant;
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.RStatOrgParam;
import com.njcn.harmonic.pojo.param.StatSubstationBizBaseParam;
import com.njcn.harmonic.pojo.vo.*;
import com.njcn.harmonic.service.majornetwork.*;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;


import java.util.List;


/**
 * <p>
 * 区域分类统计月表 前端控制器
 * </p>
 *
 * @author rui.wu
 * @since 2022-10-17
 */
@RestController
@RequiredArgsConstructor
@Api(tags = "主网指标-稳态指标")
@RequestMapping("/harmonic/rStatOrg")
public class RStatOrgController extends BaseController {

    private final RStatOrgYService rStatOrgYService;
    private final RStatOrgQService rStatOrgQService;
    private final RStatOrgMService rStatOrgMService;
    private final RStatOrgBusbarVoltageService rStatOrgBusbarVoltageService;
    private final RStatLoadTypeService rStatLoadTypeService;
    private final RMpPartHarmonicDetailMService rMpPartHarmonicDetailMService;
    private final RMpPartHarmonicDetailDService rMpPartHarmonicDetailDService;
    private final RMpPassRateService rMpPassRateService;


    /**
     * 查询区域超标统计
     */
    @PostMapping("/getAllRStatHarmonicOrg")
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @ApiOperation("区域超标统计")
    public HttpResult<List<RStatOrgVO>> getAllRStatHarmonicOrg(@RequestBody RStatOrgParam.Info param) {
        String methodDescribe = getMethodDescribe("getAllRStatHarmonicOrg");
        List<RStatOrgVO> rStatHarmonicOrgMAll = null;
        String string = param.getType().toString();
        switch (string) {
            //查询区域超标统计-年数据
            case BizParamConstant.STAT_BIZ_YEAR:
                rStatHarmonicOrgMAll = rStatOrgYService.getRStatHarmonicYAll(param);
                break;
            //查询区域超标统计-季数据
            case BizParamConstant.STAT_BIZ_QUARTER:
                rStatHarmonicOrgMAll = rStatOrgQService.getRStatHarmonicQAll(param);
                break;
            //查询各区域超标统计-月数据
            case BizParamConstant.STAT_BIZ_MONTH:
                rStatHarmonicOrgMAll = rStatOrgMService.getRStatHarmonicMAll(param);
                break;
            default:
                break;
        }
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, rStatHarmonicOrgMAll, methodDescribe);
    }


    /**
     * 区域稳态指标超标分类统计表
     */
    @PostMapping("/getRStatSubstation")
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @ApiOperation("区域稳态指标超标分类统计表")
    public HttpResult<List<RStatSubstationOrg2VO.MonitorType>> getRStatSubstation(@RequestBody StatSubstationBizBaseParam param) {
        String methodDescribe = getMethodDescribe("getRStatSubstation");
        List<RStatSubstationOrg2VO.MonitorType> statSubstationIcon = rStatOrgYService.getRStatSubstationOrg(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, statSubstationIcon, methodDescribe);
    }

    /**
     * 区域稳态指标超标分类统计表
     */
    @PostMapping("/getRStatOrgBusbarVoltage")
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @ApiOperation("区域电站母线电压类指标超标计")
    public HttpResult<List<RStatOrgBusbarVoltageVO>> getRStatOrgBusbarVoltage(@RequestBody StatSubstationBizBaseParam param) {
        String methodDescribe = getMethodDescribe("getRStatOrgBusbarVoltage");
        List<RStatOrgBusbarVoltageVO> statSubstationIcon = rStatOrgBusbarVoltageService.getRStatOrgBusbarVoltage(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, statSubstationIcon, methodDescribe);
    }

    /**
     * 区域干扰源电流类指标超标统计
     *
     */
    @GetMapping("/getRStatLoadType")
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @ApiOperation("区域干扰源电流类指标超标统计")
    public HttpResult<List<RArrayVO>> getRStatLoadType(StatisticsBizBaseParam param) {
        String methodDescribe = getMethodDescribe("getRStatLoadType");
        List<RArrayVO> rStatLoadType = rStatLoadTypeService.getRStatLoadType(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, rStatLoadType, methodDescribe);
    }

    /**
     * 变电站（换流站）稳态指标超标分类统计表
     *
     */
    @PostMapping("/getRStatSubstationOrg")
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @ApiOperation("变电站（换流站）稳态指标超标分类统计表")
    public HttpResult<List<RSubstationIcon2VO.RSubstationInfoVO>> getRStatSubstationOrg(@RequestBody StatSubstationBizBaseParam param
    ) {
        String methodDescribe = getMethodDescribe("getRStatSubstationOrg");
        List<RSubstationIcon2VO.RSubstationInfoVO> rStatOrg = rStatOrgYService.getRStatSubstation(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, rStatOrg, methodDescribe);
    }

    /**
     * 稳态指标超标明细表
     *
     */
    @PostMapping("/getRMpPartHarmonicDetail")
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @ApiOperation("稳态指标超标明细表")
    public HttpResult<List<RMpPartHarmonicDetailVO>> getRMpPartHarmonicDetail(@RequestBody RStatOrgParam param) {
        String methodDescribe = getMethodDescribe("getRMpPartHarmonicDetail");
        List<RMpPartHarmonicDetailVO> rMpPartHarmonicDetail = rMpPartHarmonicDetailMService.getRMpPartHarmonicDetail(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, rMpPartHarmonicDetail, methodDescribe);
    }

    /**
     * 稳态指标超标明细表-指标趋势图
     *
     */
    @GetMapping("/getRMpPartHarmonicDetailIcon")
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @ApiOperation("稳态指标超标明细表-指标趋势图")
    public HttpResult<List<RMpPartHarmonicDetailIconVO>> getRMpPartHarmonicDetailIcon(StatisticsBizBaseParam param) {
        String methodDescribe = getMethodDescribe("getRMpPartHarmonicDetailIcon");
        List<RMpPartHarmonicDetailIconVO> rMpPartHarmonicDetail = rMpPartHarmonicDetailDService.getRMpPartHarmonicDetailIcon(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, rMpPartHarmonicDetail, methodDescribe);
    }

    /**
     * 区域稳态指标合格率统计表-主网（稳态指标合格率统计）
     *
     */
    @GetMapping("/getRStatOrgIndex")
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @ApiOperation("区域稳态指标合格率统计表")
    public HttpResult<List<RStatOrgIndexVO.RStatOrgIndexInfoVO>> getRStatOrgIndex(StatisticsBizBaseParam param) {
        String methodDescribe = getMethodDescribe("getRStatOrgIndex");
        List<RStatOrgIndexVO.RStatOrgIndexInfoVO> rStatOrg = rStatOrgYService.getRStatOrgIndex(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, rStatOrg, methodDescribe);
    }

    /**
     * 区域稳态指标合格率统计表-主网（稳态指标合格率统计）
     *
     */
    @PostMapping("/getRMpPassRateInfo")
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @ApiOperation("稳态指标合格率明细表")
    public HttpResult<List<RStatOrgIndexVO>> getRMpPassRateInfo(@RequestBody RStatOrgParam param) {
        String methodDescribe = getMethodDescribe("getRMpPassRateInfo");
        List<RStatOrgIndexVO> rStatOrg = rMpPassRateService.getRMpPassRateInfo(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, rStatOrg, methodDescribe);
    }

}

