package com.njcn.harmonic.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
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.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.common.utils.LogUtil;
import com.njcn.device.pq.pojo.param.DeviceInfoParam;
import com.njcn.harmonic.pojo.param.HistoryParam;
import com.njcn.harmonic.pojo.photoVO.WarningAreaVO;
import com.njcn.harmonic.pojo.photoVO.WarningMonitorVO;
import com.njcn.harmonic.pojo.vo.*;
import com.njcn.harmonic.service.HistoryResultService;
import com.njcn.harmonic.service.IAnalyzeService;
import com.njcn.harmonic.service.PhotovoltaicService;
import com.njcn.harmonic.service.SteadyQualifyService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
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 xuyang
 * @version 1.0.0
 * @createTime 2022/7/5 10:37
 */
@Validated
@Slf4j
@RestController
@RequestMapping("/photovoltaicHarmonic")
@Api(tags = "分布式光伏-稳态")
@AllArgsConstructor
public class PhotovoltaicController extends BaseController {

    private final IAnalyzeService IAnalyzeService;

    private final SteadyQualifyService steadyQualifyService;

    private final HistoryResultService historyResultService;

    private final PhotovoltaicService photovoltaicService;

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/overAreaStatistics")
    @ApiOperation("稳态指标超标统计")
    @ApiImplicitParam(name = "param", value = "实体参数", required = true)
    public HttpResult<Page<OverAreaLimitVO>> overAreaStatistics(@Validated @RequestBody OverAreaVO param) {
        String methodDescribe = getMethodDescribe("overAreaStatistics");
        LogUtil.njcnDebug(log, "{}，实体参数：{}", methodDescribe, param);
        Page<OverAreaLimitVO> list = IAnalyzeService.getAreaData(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/test")
    @ApiOperation("有问题-稳态指标超标分类统计")
    @ApiImplicitParam(name = "param", value = "实体参数", required = true)
    public HttpResult<Page<OverAreaLimitVO>> test(@Validated @RequestBody OverAreaVO param) {
        String methodDescribe = getMethodDescribe("overAreaStatistics");
        LogUtil.njcnDebug(log, "{}，实体参数：{}", methodDescribe, param);
        Page<OverAreaLimitVO> list = IAnalyzeService.getAreaData(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/lineOverLimit")
    @ApiOperation("稳态指标超标明细")
    @ApiImplicitParam(name = "param", value = "实体参数", required = true)
    public HttpResult<Page<MonitorOverLimitVO>> lineOverLimit(@Validated @RequestBody OverAreaVO param) {
        String methodDescribe = getMethodDescribe("lineOverLimit");
        LogUtil.njcnDebug(log, "{}，实体参数：{}", methodDescribe, param);
        Page<MonitorOverLimitVO> list = IAnalyzeService.monitorOverLimitVO(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getSteadyQualifyData")
    @ApiOperation("稳态合格率统计")
    @ApiImplicitParam(name = "steadyParam", value = "稳态列表参数", required = true)
    public HttpResult<List<SteadyQualifyVO>> getSteadyQualifyData(@RequestBody @Validated DeviceInfoParam.BusinessParam steadyParam){
        String methodDescribe = getMethodDescribe("getSteadyQualifyData");
        List<SteadyQualifyVO> list = steadyQualifyService.getSteadyQualifyData(steadyParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getHistoryResult")
    @ApiOperation("稳态指标历史趋势")
    @ApiImplicitParam(name = "historyParam", value = "稳态数据分析参数", required = true)
    public HttpResult<List<HistoryDataResultVO>> getHistoryResult(@RequestBody @Validated HistoryParam historyParam) {
        String methodDescribe = getMethodDescribe("getHistoryResult");
        List<HistoryDataResultVO> list = historyResultService.getHistoryResult(historyParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/wholeEvaluation")
    @ApiOperation("有问题-全网水平评价")
    @ApiImplicitParam(name = "param", value = "实体参数", required = true)
    public HttpResult<List<HistoryDataResultVO>> wholeEvaluation(@Validated @RequestBody OverAreaVO param) {
        String methodDescribe = getMethodDescribe("wholeEvaluation");
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
    }


    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/areaWithEvaluation")
    @ApiOperation("有问题-台区水平评价")
    @ApiImplicitParam(name = "param", value = "实体参数", required = true)
    public HttpResult<List<HistoryDataResultVO>> areaWithEvaluation(@Validated @RequestBody OverAreaVO param) {
        String methodDescribe = getMethodDescribe("areaWithEvaluation");
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/areaWarningManage")
    @ApiOperation("区域告警管理")
    @ApiImplicitParam(name = "param", value = "实体参数", required = true)
    public HttpResult<Page<WarningAreaVO>> areaWarningManage(@Validated @RequestBody OverAreaVO param) {
        String methodDescribe = getMethodDescribe("areaWarningManage");
        Page<WarningAreaVO> page = photovoltaicService.areaWarningManage(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, page, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/monitorWarningManage")
    @ApiOperation("监测点告警管理")
    @ApiImplicitParam(name = "param", value = "实体参数", required = true)
    public HttpResult<Page<WarningMonitorVO>> monitorWarningManage(@Validated @RequestBody OverAreaVO param) {
        String methodDescribe = getMethodDescribe("monitorWarningManage");
        Page<WarningMonitorVO> page = photovoltaicService.monitorWarningManage(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, page, methodDescribe);
    }



}
