package com.njcn.product.diagram.LedgerScale.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.response.HttpResult;
import com.njcn.product.advance.responsility.pojo.dto.CustomerResponsibility;
import com.njcn.product.diagram.LedgerScale.pojo.dto.EventSourceDTO;
import com.njcn.product.diagram.LedgerScale.pojo.dto.LedgerScaleDTO;
import com.njcn.product.diagram.LedgerScale.pojo.vo.EventDetailVO;
import com.njcn.product.diagram.LedgerScale.pojo.vo.EventLedgerVO;
import com.njcn.product.terminal.mysqlTerminal.pojo.po.PqStation;
import com.njcn.product.terminal.mysqlTerminal.pojo.vo.TerminalShowVO;
import com.njcn.product.diagram.LedgerScale.service.LedgerScaleService;
import com.njcn.product.terminal.mysqlTerminal.pojo.param.LargeScreenCountParam;
import com.njcn.web.controller.BaseController;
import com.njcn.web.utils.HttpResultUtil;
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.web.bind.annotation.*;

import java.util.List;

/**
 * @Author: cdf
 * @CreateTime: 2025-09-01
 * @Description: 台账规模
 */
@Slf4j
@RestController
@Api(tags = "大屏")
@RequestMapping("/scale")
@RequiredArgsConstructor
public class LedgerScaleController extends BaseController {

    private final LedgerScaleService ledgerScaleService;


    @OperateInfo(info = LogEnum.SYSTEM_COMMON)
    @PostMapping("/ledgerScale")
    @ApiOperation("台账规模")
    @ApiImplicitParam(name = "param", value = "查询参数", required = true)
    public HttpResult<LedgerScaleDTO> ledgerScale(@RequestBody LargeScreenCountParam param) {
        String methodDescribe = getMethodDescribe("ledgerScale");
        LedgerScaleDTO ledgerScaleDTO = ledgerScaleService.ledgerScaleStatistic(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, ledgerScaleDTO, methodDescribe);
    }


    @OperateInfo(info = LogEnum.SYSTEM_COMMON)
    @PostMapping("/eventSource")
    @ApiOperation("暂降溯源统计")
    @ApiImplicitParam(name = "param", value = "查询参数", required = true)
    public HttpResult<EventSourceDTO> eventSource(@RequestBody LargeScreenCountParam param) {
        String methodDescribe = getMethodDescribe("eventSource");
        EventSourceDTO eventSourceDTO = ledgerScaleService.eventSource(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, eventSourceDTO, methodDescribe);
    }


    @OperateInfo(info = LogEnum.SYSTEM_COMMON)
    @PostMapping("/eventAggregation")
    @ApiOperation("暂降聚合分析")
    @ApiImplicitParam(name = "param", value = "查询参数", required = true)
    public HttpResult<EventSourceDTO> eventAggregation(@RequestBody LargeScreenCountParam param) {
        String methodDescribe = getMethodDescribe("eventAggregation");
        EventSourceDTO eventSourceDTO = ledgerScaleService.eventAggregation(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, eventSourceDTO, methodDescribe);
    }

    @OperateInfo(info = LogEnum.SYSTEM_COMMON)
    @PostMapping("/hasEventList")
    @ApiOperation("一次接线图发生暂降事件的监测点闪烁")
    @ApiImplicitParam(name = "param", value = "查询参数", required = true)
    public HttpResult<List<EventLedgerVO>> hasEventList(@RequestBody LargeScreenCountParam param) {
        String methodDescribe = getMethodDescribe("hasEventList");
        List<EventLedgerVO> result = ledgerScaleService.hasEventList(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }

    @OperateInfo(info = LogEnum.SYSTEM_COMMON)
    @PostMapping("/hasUpEventList")
    @ApiOperation("一次接线图发生谐波放大的监测点闪烁")
    @ApiImplicitParam(name = "param", value = "查询参数", required = true)
    public HttpResult<List<EventLedgerVO>> hasUpEventList(@RequestBody LargeScreenCountParam param) {
        String methodDescribe = getMethodDescribe("hasUpEventList");
        List<EventLedgerVO> result = ledgerScaleService.hasUpEventList(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }


    @OperateInfo(info = LogEnum.SYSTEM_COMMON)
    @PostMapping("/clickImage")
    @ApiOperation("一次接线图点击事件")
    @ApiImplicitParam(name = "lineId", value = "查询参数", required = true)
    public HttpResult<EventLedgerVO> clickImage(@RequestBody LargeScreenCountParam param) {
        String methodDescribe = getMethodDescribe("clickImage");
        EventLedgerVO result = ledgerScaleService.clickImage(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }



    @OperateInfo(info = LogEnum.SYSTEM_COMMON)
    @PostMapping("/eventList")
    @ApiOperation("暂降实时数据")
    @ApiImplicitParam(name = "param", value = "查询参数", required = true)
    public HttpResult<Page<EventDetailVO>> eventList(@RequestBody LargeScreenCountParam param) {
        String methodDescribe = getMethodDescribe("eventList");
        Page<EventDetailVO> result = ledgerScaleService.eventList(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }

    @OperateInfo(info = LogEnum.SYSTEM_COMMON)
    @PostMapping("/eventListByLineId")
    @ApiOperation("暂降实时数据")
    @ApiImplicitParam(name = "param", value = "查询参数", required = true)
    public HttpResult<Page<EventDetailVO>> eventListByLineId(@RequestBody LargeScreenCountParam param) {
        String methodDescribe = getMethodDescribe("eventListByLineId");
        Page<EventDetailVO> result = ledgerScaleService.eventListByLineId(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }


    @OperateInfo(info = LogEnum.SYSTEM_COMMON)
    @PostMapping("/stationPage")
    @ApiOperation("电站详情")
    @ApiImplicitParam(name = "param", value = "查询参数", required = true)
    public HttpResult<Page<TerminalShowVO>> stationPage(@RequestBody LargeScreenCountParam param) {
        String methodDescribe = getMethodDescribe("stationPage");
        Page<TerminalShowVO> result = ledgerScaleService.stationPage(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }

    @OperateInfo(info = LogEnum.SYSTEM_COMMON)
    @PostMapping("/devPage")
    @ApiOperation("终端详情")
    @ApiImplicitParam(name = "param", value = "查询参数", required = true)
    public HttpResult<Page<TerminalShowVO>> devPage(@RequestBody LargeScreenCountParam param) {
        String methodDescribe = getMethodDescribe("devPage");
        Page<TerminalShowVO> result = ledgerScaleService.devPage(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }

    @OperateInfo(info = LogEnum.SYSTEM_COMMON)
    @PostMapping("/linePage")
    @ApiOperation("监测点详情")
    @ApiImplicitParam(name = "param", value = "查询参数", required = true)
    public HttpResult<Page<TerminalShowVO>> linePage(@RequestBody LargeScreenCountParam param) {
        String methodDescribe = getMethodDescribe("linePage");
        Page<TerminalShowVO> result = ledgerScaleService.linePage(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }


    @OperateInfo(info = LogEnum.SYSTEM_COMMON)
    @GetMapping("/harmOneImage")
    @ApiOperation("谐波溯源事件点击关联一次接线图")
    @ApiImplicitParam(name = "param", value = "查询参数", required = true)
    public HttpResult<List<CustomerResponsibility>> harmOneImage(@RequestParam("id")String id, @RequestParam("time")Integer time) {
        String methodDescribe = getMethodDescribe("harmOneImage");
        List<CustomerResponsibility> result = ledgerScaleService.harmOneImage(id,time);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }


    @OperateInfo(info = LogEnum.SYSTEM_COMMON)
    @PostMapping("/stationMap")
    @ApiOperation("获取变电站详情")
    @ApiImplicitParam(name = "param", value = "查询参数", required = true)
    public HttpResult<List<PqStation>> stationMap(@RequestBody LargeScreenCountParam param) {
        String methodDescribe = getMethodDescribe("stationMap");
        List<PqStation> result = ledgerScaleService.stationMap(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }



}
