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.param.StatisticsBizBaseParam;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.device.pq.pojo.dto.PollutionGridDiagramDTO;
import com.njcn.device.pq.pojo.param.DeviceInfoParam;
import com.njcn.device.pq.pojo.param.GridDiagramParam;
import com.njcn.device.pq.pojo.vo.GridDiagramVO;
import com.njcn.harmonic.pojo.param.StatSubstationBizBaseParam;
import com.njcn.harmonic.pojo.vo.RStatLimitTargetCountVO;
import com.njcn.harmonic.pojo.vo.RStatLimitTargetVO;
import com.njcn.harmonic.service.IRMpTargetWarnDService;
import com.njcn.harmonic.service.IRStatLimitTargetDService;
import com.njcn.harmonic.service.PollutionSubstationService;
import com.njcn.harmonic.service.majornetwork.RStatLimitService;
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;


@Validated
@Slf4j
@RestController
@RequestMapping("/gridDiagram")
@Api(tags = "冀北电网一张图信息展示")
@AllArgsConstructor
public class GridDiagramHarmController extends BaseController {

    private final IRMpTargetWarnDService irMpTargetWarnDService;
    private final PollutionSubstationService pollutionSubstationService;
    private final RStatLimitService rStatLimitService;
    private final IRStatLimitTargetDService targetDService;



    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getSubLineGiveAnAlarm")
    @ApiOperation("区域变电站下告警监测点数量")
    @ApiImplicitParam(name = "param", value = "变电站下监测点是否超标", required = true)
    public HttpResult<GridDiagramVO> getSubLineGiveAnAlarm(@RequestBody StatSubstationBizBaseParam param) {
        String methodDescribe = getMethodDescribe("getSubLineGiveAnAlarm");
        GridDiagramVO subLineGiveAnAlarm = irMpTargetWarnDService.getSubLineGiveAnAlarm(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, subLineGiveAnAlarm, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getAreaObjAlarm")
    @ApiOperation("区域场站监测点规模")
    @ApiImplicitParam(name = "param", value = "区域场站监测点规模参数", required = true)
    public HttpResult<GridDiagramVO> getAreaObjAlarm(@RequestBody StatSubstationBizBaseParam param) {
        String methodDescribe = getMethodDescribe("getAreaObjAlarm");
        GridDiagramVO subLineGiveAnAlarm = irMpTargetWarnDService.getAreaObjAlarm(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, subLineGiveAnAlarm, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getPollutionAlarmData")
    @ApiOperation("变电站污染告警占比")
    public HttpResult<GridDiagramVO> getPollutionAlarmData(@RequestBody StatSubstationBizBaseParam param) {
        String methodDescribe = getMethodDescribe("getSubLineGiveAnAlarm");
        GridDiagramVO subLineGiveAnAlarm = pollutionSubstationService.getNewPollutionAlarmData(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, subLineGiveAnAlarm, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getPollutionAlarmPageData")
    @ApiOperation("变电站详细列表")
    public HttpResult<Page<PollutionGridDiagramDTO>> getPollutionAlarmPageData(@RequestBody StatSubstationBizBaseParam param) {
        String methodDescribe = getMethodDescribe("getPollutionAlarmPageData");
        Page<PollutionGridDiagramDTO> subLineGiveAnAlarm = pollutionSubstationService.getPollutionAlarmPageData(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, subLineGiveAnAlarm, methodDescribe);
    }
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getPollutionAlarmList")
    @ApiOperation("变电站新详细列表")
    public HttpResult<List<List<String>>> getPollutionAlarmList(@RequestBody GridDiagramParam param) {
        String methodDescribe = getMethodDescribe("getPollutionAlarmList");
        List<List<String>> subLineGiveAnAlarm = pollutionSubstationService.getPollutionAlarmList(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, subLineGiveAnAlarm, methodDescribe);
    }
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getGridDiagramLineData")
    @ApiOperation("监测点分布统计")
    public HttpResult<List<GridDiagramVO.LineData>> getGridDiagramLineData(@RequestBody DeviceInfoParam.BusinessParam param) {
        String methodDescribe = getMethodDescribe("getGridDiagramLineData");
        List<GridDiagramVO.LineData> gridDiagramDevData = rStatLimitService.getGridDiagramLineData(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, gridDiagramDevData, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getGridDiagramAreaData")
    @ApiOperation("区域基本信息(监测点，终端，变电站等)")
    public HttpResult<List<GridDiagramVO.AreaData>> getGridDiagramAreaData(@RequestBody DeviceInfoParam.BusinessParam param) {
        String methodDescribe = getMethodDescribe("getGridDiagramAreaData");
        List<GridDiagramVO.AreaData> gridDiagramDevData = rStatLimitService.getGridDiagramAreaData(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, gridDiagramDevData, methodDescribe);
    }
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getGridDiagramRunData")
    @ApiOperation("监测运行统计")
    public HttpResult<List<GridDiagramVO.RunData>> getGridDiagramRunData(@RequestBody DeviceInfoParam.BusinessParam param) {
        String methodDescribe = getMethodDescribe("getGridDiagramRunData");
        List<GridDiagramVO.RunData> gridDiagramDevData = rStatLimitService.getGridDiagramRunData(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, gridDiagramDevData, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getGridDiagramTargetData")
    @ApiOperation("监测点告警越线天数详细信息")
    public HttpResult<RStatLimitTargetCountVO> getGridDiagramTargetData(@RequestBody StatisticsBizBaseParam param) {
        String methodDescribe = getMethodDescribe("getGridDiagramTargetData");
        RStatLimitTargetCountVO gridDiagramDevData = targetDService.getGridDiagramTargetData(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, gridDiagramDevData, methodDescribe);
    }


}
