package com.njcn.event.controller.majornetwork;

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.event.pojo.param.*;
import com.njcn.event.pojo.vo.*;
import com.njcn.event.common.service.EventAnalysisService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.*;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.text.ParseException;
import java.util.List;

/**
 * pqs-event
 * 暂降 监测点
 * @author cdf
 * @date 2022/6/23
 */

@Slf4j
@RestController
@RequestMapping("/monitor")
@Api(tags = "监测点")
@RequiredArgsConstructor
public class MonitorPointController extends BaseController {

    private final EventAnalysisService eventAnalysisService;



    /**
     * 获取监测点暂降事件分析
     * @author cdf
     * @date 2022/6/23
     */
 /*   @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getEventAnalyse")
    @ApiOperation("获取监测点暂降事件分析")
    @ApiImplicitParam(name = "eventBaseParam", value = "暂降事件分析参数", required = true)
    public HttpResult<Page<EventDetail>> getEventAnalyse(@RequestBody @Validated EventBaseParam eventBaseParam){
        String methodDescribe = getMethodDescribe("getEventAnalyse");
        Page<EventDetail> page = eventAnalysisService.getEventAnalyse(eventBaseParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, page, methodDescribe);
    }*/

    /**
     * 获取电压暂态表及密度图
     * @author xxy
     * @param statisticsParam
     * @return
     */
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getCoords")
    @ApiOperation("获取电压暂态表及密度坐标图")
    @ApiImplicitParam(name = "statisticsParam", value = "电压暂态表及密度图坐标参数", required = true)
    public HttpResult<List<CoordsVO>> getCoords(@RequestBody @Validated StatisticsParam statisticsParam){
        String methodDescribe = getMethodDescribe("getCoords");
        List<CoordsVO> list = eventAnalysisService.getCoords(statisticsParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,list,methodDescribe);
    }

    /**
     * 获取Disdip表格
     * @param statisticsParam
     * @return
     */
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/eventDisdip")
    @ApiOperation("获取Disdip表格")
    @ApiImplicitParam(name = "statisticsParam", value = "Disdip表格参数", required = true)
    public HttpResult<List<DISDIPVO>> eventDisdip(@RequestBody @Validated StatisticsParam statisticsParam){
        String methodDescribe = getMethodDescribe("eventDisdip");
        List<DISDIPVO> list = eventAnalysisService.eventDisdip(statisticsParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,list,methodDescribe);
    }

    /**
     * 获取IEC411数据
     * @param statisticsParam
     * @return
     */
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/IEC411")
    @ApiOperation("获取IEC411数据")
    @ApiImplicitParam(name = "statisticsParam", value = "IEC411参数", required = true)
    public HttpResult<List<IEC411VO>> IEC411(@RequestBody @Validated StatisticsParam statisticsParam){
        String methodDescribe = getMethodDescribe("IEC411");
        List<IEC411VO> list = eventAnalysisService.IEC411(statisticsParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,list,methodDescribe);
    }

    /**
     * 获取IEC28数据
     * @param statisticsParam
     * @return
     */
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/IEC28")
    @ApiOperation("获取IEC28数据")
    @ApiImplicitParam(name = "statisticsParam", value = "IEC28参数", required = true)
    public HttpResult<List<IEC28VO>> IEC28(@RequestBody @Validated StatisticsParam statisticsParam){
        String methodDescribe = getMethodDescribe("IEC28");
        List<IEC28VO> list = eventAnalysisService.IEC28(statisticsParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,list,methodDescribe);
    }

    /**
     * 暂降原因类型和时间
     * @author xxy
     * @param statisticsParam
     * @return
     */
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getReasonTypeTime")
    @ApiOperation("暂降原因类型和时间")
    @ApiImplicitParam(name = "statisticsParam", value = "暂降原因类型和时间参数", required = true)
    public HttpResult<List<TimeVO>> getReasonTypeTime(@RequestBody @Validated StatisticsParam statisticsParam) throws ParseException {
        String methodDescribe = getMethodDescribe("getReasonTypeTime");
        List<TimeVO> page = eventAnalysisService.getReasonTypeTime(statisticsParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,page,methodDescribe);
    }

    /**
     * 暂降原因类型和时间分布统计
     * @author xxy
     * @param statisticsParam
     * @return
     */
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getStatistic")
    @ApiOperation("暂降原因类型和时间分布统计")
    @ApiImplicitParam(name = "statisticsParam", value = "暂降原因类型和时间分布统计参数", required = true)
    public HttpResult<StatisticVO> getStatistic(@RequestBody @Validated StatisticsParam statisticsParam){
        String methodDescribe = getMethodDescribe("getStatistic");
        StatisticVO page = eventAnalysisService.getStatistic(statisticsParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,page,methodDescribe);
    }

    /**
     * 暂降幅值的概率分布函数
     * @author xxy
     * @param statisticsParam
     * @return
     */
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getProbabilityDistribution")
    @ApiOperation("暂降幅值的概率分布函数")
    @ApiImplicitParam(name = "statisticsParam", value = "暂降幅值的概率分布函数参数", required = true)
    public HttpResult<ProbabilityVO> getProbabilityDistribution(@RequestBody @Validated StatisticsParam statisticsParam){
        String methodDescribe = getMethodDescribe("getProbabilityDistribution");
        ProbabilityVO page = eventAnalysisService.getProbabilityDistribution(statisticsParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,page,methodDescribe);
    }

    /**
     * 暂降事件点图
     * @author xxy
     * @param statisticsParam
     * @return
     */
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getPlot")
    @ApiOperation("暂降事件点图")
    @ApiImplicitParam(name = "statisticsParam", value = "暂降事件点图参数", required = true)
    public HttpResult<VoltageToleranceCurveVO> getPlot(@RequestBody @Validated StatisticsParam statisticsParam){
        String methodDescribe = getMethodDescribe("getPlot");
        VoltageToleranceCurveVO page = eventAnalysisService.getPlot(statisticsParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,page,methodDescribe);
    }





    /**
     *监测点暂降事件分析查询
     * @author zbj
     * @date 2022/7/25
     */
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getMonitorEventAnalyseQuery")
    @ApiOperation("监测点暂降事件分析查询")
    @ApiImplicitParam(name = "eventBaseParam", value = "暂降事件分析参数", required = true)
    public HttpResult<Page<WaveTypeVO>> getMonitorEventAnalyseQuery (@RequestBody @Validated EventBaseParam eventBaseParam){
        String methodDescribe = getMethodDescribe("getMonitorEventAnalyseQuery");
        Page<WaveTypeVO> result = eventAnalysisService.getMonitorEventAnalyseQuery(eventBaseParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }



    /**
     *监测点事件波形下载
     * @author zbj
     * @date 2022/7/28
     */
    /*@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DOWNLOAD)
    @PostMapping("/downloadMonitorEventWaveFile")
    @ApiOperation("监测点事件波形下载")
    @ApiImplicitParam(name = "waveFileParam", value = "波形下载参数", required = true)
    public HttpResult downloadMonitorEventWaveFile(@RequestBody @Validated WaveFileParam waveFileParam, HttpServletResponse response) throws Exception {
        String methodDescribe = getMethodDescribe("downloadMonitorEventWaveFile");
        HttpServletResponse resp = eventAnalysisService.downloadMonitorEventWaveFile(waveFileParam, response);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, resp, methodDescribe);
    }*/

}
