package com.njcn.harmonic.controller;

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.device.pq.pojo.param.DeviceInfoParam;
import com.njcn.harmonic.pojo.THDistortionDetailVO;
import com.njcn.harmonic.pojo.vo.RMpVThdVO;
import com.njcn.harmonic.pojo.vo.SteadyQualifyDetailVO;
import com.njcn.harmonic.pojo.vo.THDistortionCensusVO;
import com.njcn.harmonic.pojo.vo.THDistortionVO;
import com.njcn.harmonic.service.THDistortionService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
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.*;

import java.util.List;

/**
 * @author chenchao
 * @date 2022/03/10 21:39
 * @Description: <描述>
 */
@Validated
@Slf4j
@RestController
@RequestMapping("/tHDistortion")
@Api(tags = "谐波总畸变率")
@AllArgsConstructor
public class THDController extends BaseController {

    private final THDistortionService thDistortionService;

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getTHDistortionData")
    @ApiOperation("谐波总畸变率列表")
    @ApiImplicitParam(name = "thDistortionParam", value = "谐波总畸变率参数", required = true)
    public HttpResult<List<THDistortionVO>> getTHDistortionData(@RequestBody @Validated DeviceInfoParam.BusinessParam thDistortionParam){
        String methodDescribe = getMethodDescribe("getTHDistortionData");
        List<THDistortionVO> list = thDistortionService.getTHDistortionData(thDistortionParam,0);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getTHDistortionTableData")
    @ApiOperation("谐波总畸变率列表(曲靖)")
    @ApiImplicitParam(name = "steadyParam", value = "稳态列表参数", required = true)
    public HttpResult<List<THDistortionDetailVO>> getTHDistortionTableData(@RequestBody @Validated DeviceInfoParam.BusinessParam steadyParam){
        String methodDescribe = getMethodDescribe("getTHDistortionTableData");
        List<THDistortionDetailVO> list = thDistortionService.getTHDistortionTableData(steadyParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
    }



    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getNodeTHDistortionData")
    @ApiOperation("谐波总畸变率节点图")
    @ApiImplicitParam(name = "thDistortionParam", value = "谐波总畸变率参数", required = true)
    public HttpResult<List<THDistortionVO>> getNodeTHDistortionData(@RequestBody @Validated DeviceInfoParam.BusinessParam thDistortionParam){
        String methodDescribe = getMethodDescribe("getNodeTHDistortionData");
        List<THDistortionVO> list = thDistortionService.getTHDistortionData(thDistortionParam,1);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getTHDistortionCensus")
    @ApiOperation("谐波总畸变率统计")
    @ApiImplicitParam(name = "thDistortionCensusParam", value = "谐波总畸变率参数", required = true)
    public HttpResult<THDistortionCensusVO> getTHDistortionCensus(@RequestBody @Validated DeviceInfoParam.BusinessParam thDistortionCensusParam){
        String methodDescribe = getMethodDescribe("getTHDistortionCensus");
        THDistortionCensusVO censusVO = thDistortionService.getTHDistortionCensus(thDistortionCensusParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, censusVO, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getTHDTopTenData")
    @ApiOperation("谐波总畸变率topNum列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "statisticsBizBaseParam", value = "业务参数", required = true),
            @ApiImplicitParam(name = "topNum", value = "业务参数",defaultValue="10", required = true)
    }
    )
    public HttpResult<List<RMpVThdVO>> getTHDTopTenData(@RequestBody @Validated StatisticsBizBaseParam statisticsBizBaseParam, @RequestParam Integer topNum){
        String methodDescribe = getMethodDescribe("getTHDTopTenData");
        List<RMpVThdVO> list = thDistortionService.getTHDTopTenData(statisticsBizBaseParam,topNum);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
    }


}
