package com.njcn.event.controller.majornetwork;

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.device.pq.pojo.param.DeviceInfoParam;
import com.njcn.event.pojo.vo.AreaAnalysisVO;
import com.njcn.event.pojo.vo.VoltageToleranceCurveVO;
import com.njcn.event.service.majornetwork.AreaAnalysisService;
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.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;

/**
 * pqs-event
 * 区域分析
 *
 * @author cdf
 * @date 2022/6/24
 */

@Slf4j
@RestController
@RequestMapping("/areaAnalysis")
@Api(tags = "区域统计")
@RequiredArgsConstructor
public class AreaAnalysisController extends BaseController {

    private final AreaAnalysisService areaAnalysisService;

    /**
     * 区域暂降原因,类型
     *
     * @author cdf
     * @date 2022/6/24
     */
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getEventReason")
    @ApiOperation("获取监测点暂降事件分析")
    @ApiImplicitParam(name = "deviceInfoParam", value = "暂降事件分析参数", required = true)
    public HttpResult<AreaAnalysisVO> getEventReason(@RequestBody @Validated DeviceInfoParam.BusinessParam deviceInfoParam) {
        String methodDescribe = getMethodDescribe("getEventReason");
        AreaAnalysisVO res = areaAnalysisService.getEventReason(deviceInfoParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, res, methodDescribe);
    }


    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getVoltageToleranceCurve")
    @ApiOperation("获取电压容忍度曲线兼容性统计")
    @ApiImplicitParam(name = "deviceInfoParam", value = "暂降事件分析参数", required = true)
    public HttpResult<VoltageToleranceCurveVO> getVoltageToleranceCurve(@RequestBody @Validated DeviceInfoParam.BusinessParam deviceInfoParam) {
        String methodDescribe = getMethodDescribe("getVoltageToleranceCurve");
        VoltageToleranceCurveVO res = areaAnalysisService.getVoltageToleranceCurve(deviceInfoParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, res, methodDescribe);
    }
}
