package com.njcn.product.advance.responsility.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.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.influx.pojo.dto.HarmHistoryDataDTO;
import com.njcn.product.advance.harmonicUp.pojo.param.HistoryParam;
import com.njcn.product.advance.harmonicUp.pojo.vo.HistoryDataResultVO;
import com.njcn.product.advance.harmonicUp.service.HistoryResultService;
import com.njcn.product.advance.responsility.pojo.param.HistoryHarmParam;
import com.njcn.product.advance.eventSource.service.HistoryHarmonicService;
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;

import java.util.List;

/**
 * @Author: cdf
 * @CreateTime: 2025-09-08
 * @Description:
 */
@Validated
@Slf4j
@RestController
@RequestMapping("/harmonic")
@Api(tags = "稳态数据分析")
@RequiredArgsConstructor
public class HistoryHarmonicController extends BaseController {

    private final HistoryHarmonicService historyHarmonicService;

    private final HistoryResultService historyResultService;


    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getHistoryHarmData")
    @ApiOperation("获取谐波历史数据")
    @ApiImplicitParam(name = "historyHarmParam", value = "谐波历史数据请求参数", required = true)
    public HttpResult<HarmHistoryDataDTO> getHistoryHarmData(@RequestBody @Validated HistoryHarmParam historyHarmParam) {
        String methodDescribe = getMethodDescribe("getHistoryHarmData");
        HarmHistoryDataDTO harmHistoryDataDTO = historyHarmonicService.getHistoryHarmData(historyHarmParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, harmHistoryDataDTO, methodDescribe);
    }


    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getHistoryResult")
    @ApiOperation("稳态数据分析")
    @ApiImplicitParam(name = "historyParam", value = "稳态数据分析参数", required = true)
    public HttpResult<List<HistoryDataResultVO>> getHistoryResult(@RequestBody @Validated HistoryParam historyParam) {
        String methodDescribe = getMethodDescribe("getHistoryResult");
        List<HistoryDataResultVO> list = historyResultService.getHistoryResult(historyParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
    }


}
