package com.njcn.harmonic.controller.hebeinorth;

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.harmonic.pojo.param.hebeinorth.AssessParam;
import com.njcn.harmonic.pojo.vo.hebeinorth.AssessDetailVo;
import com.njcn.harmonic.pojo.vo.hebeinorth.AssessVo;
import com.njcn.harmonic.pojo.vo.hebeinorth.EvaluationLevelVo;
import com.njcn.harmonic.pojo.vo.hebeinorth.EvaluationVo;
import com.njcn.harmonic.service.hebeinorth.IGridService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.*;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 类的介绍：
 *
 * @author xuyang
 * @version 1.0.0
 * @createTime 2024/4/24 17:19
 */
@Validated
@Slf4j
@RestController
@RequestMapping("/grid")
@Api(tags = "冀北全景一张图")
@AllArgsConstructor
public class GridController extends BaseController {

    private final IGridService gridService;

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getAssessOverview")
    @ApiOperation("综合评估概览数据")
    @ApiImplicitParam(name = "param", value = "参数", required = true)
    public HttpResult<AssessVo.AssessOverview> getAssessOverview(@RequestBody @Validated AssessParam param){
        String methodDescribe = getMethodDescribe("getAssessOverview");
        AssessVo.AssessOverview result = gridService.getAssessOverview(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getAssessDetail")
    @ApiOperation("综合评估详细数据")
    @ApiImplicitParam(name = "param", value = "参数", required = true)
    public HttpResult<List<AssessDetailVo>> getAssessDetail(@RequestBody @Validated AssessParam param){
        String methodDescribe = getMethodDescribe("getAssessDetail");
        List<AssessDetailVo> result = gridService.getData(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getAssessTrend")
    @ApiOperation("综合评估趋势对比")
    @ApiImplicitParam(name = "param", value = "参数", required = true)
    public HttpResult<List<AssessVo.AssessTrendVo>> getAssessTrend(@RequestBody @Validated AssessParam param){
        String methodDescribe = getMethodDescribe("getAssessTrend");
        List<AssessVo.AssessTrendVo> result = gridService.getAssessTrend(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getLineAssess")
    @ApiOperation("监测点评估")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "lineId", value = "监测点id"),
        @ApiImplicitParam(name = "startTime", value = "开始时间"),
        @ApiImplicitParam(name = "endTime", value = "结束时间")
    })
    public HttpResult<AssessDetailVo> getLineAssess(@RequestParam(value = "lineId") String lineId, @RequestParam(value = "startTime") String startTime, @RequestParam(value = "endTime") String endTime){
        String methodDescribe = getMethodDescribe("getLineAssess");
        AssessDetailVo vo = gridService.getLineAssess(lineId,startTime,endTime);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, vo, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getEvaluationOverview")
    @ApiOperation("稳态电能质量水平评价概览数据")
    @ApiImplicitParam(name = "param", value = "参数", required = true)
    public HttpResult<EvaluationVo> getEvaluationOverview(@RequestBody @Validated AssessParam param){
        String methodDescribe = getMethodDescribe("getEvaluationOverview");
        EvaluationVo result = gridService.getEvaluationOverview(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getEvaluationData")
    @ApiOperation("稳态电能质量水平平均值、标准差")
    @ApiImplicitParam(name = "param", value = "参数", required = true)
    public HttpResult<List<EvaluationLevelVo>> getEvaluationData(@RequestBody @Validated AssessParam param){
        String methodDescribe = getMethodDescribe("getEvaluationData");
        List<EvaluationLevelVo> result = gridService.getEvaluationData(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/evaluationRatio")
    @ApiOperation("各稳态指标的环比")
    @ApiImplicitParam(name = "param", value = "参数", required = true)
    public HttpResult<List<EvaluationLevelVo.EvaluationRatio>> evaluationRatio(@RequestBody @Validated AssessParam param){
        String methodDescribe = getMethodDescribe("evaluationRatio");
        List<EvaluationLevelVo.EvaluationRatio> result = gridService.evaluationRatio(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/evaluationDetail")
    @ApiOperation("稳态指标超标详情")
    @ApiImplicitParam(name = "param", value = "参数", required = true)
    public HttpResult<List<EvaluationLevelVo.EvaluationDetail>> evaluationDetail(@RequestBody @Validated AssessParam param){
        String methodDescribe = getMethodDescribe("evaluationDetail");
        List<EvaluationLevelVo.EvaluationDetail> result = gridService.getEvaluationDetail(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/qualifiedDetail")
    @ApiOperation("稳态指标合格率详情")
    @ApiImplicitParam(name = "param", value = "参数", required = true)
    public HttpResult<List<EvaluationLevelVo.QualifiedDetail>> getQualifiedDetail(@RequestBody @Validated AssessParam param){
        String methodDescribe = getMethodDescribe("getQualifiedDetail");
        List<EvaluationLevelVo.QualifiedDetail> result = gridService.getQualifiedDetail(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/lineQualifiedDetail")
    @ApiOperation("监测点稳态指标合格率详情")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "lineId", value = "监测点id"),
            @ApiImplicitParam(name = "startTime", value = "开始时间"),
            @ApiImplicitParam(name = "endTime", value = "结束时间")
    })
    public HttpResult<EvaluationLevelVo.QualifiedDetail> getLineQualifiedDetail(@RequestParam(value = "lineId") String lineId, @RequestParam(value = "startTime") String startTime, @RequestParam(value = "endTime") String endTime){
        String methodDescribe = getMethodDescribe("getLineQualifiedDetail");
        EvaluationLevelVo.QualifiedDetail result = gridService.getLineQualifiedDetail(lineId,startTime,endTime);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }
}
