package com.njcn.harmonic.controller.send;

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.common.utils.LogUtil;
import com.njcn.harmonic.pojo.param.SendQueryParam;
import com.njcn.harmonic.pojo.param.UploadParam;
import com.njcn.harmonic.pojo.po.send.ConverterIndexStatisticsPO;
import com.njcn.harmonic.service.send.ConverterIndexStatisticsPOService;
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;

/**
 * Description:河北国网上送接口
 *      *2.4.1.18	接收电能质量换流站指标汇总统计数据接口
 * Date: 2023/12/13  14:52【需求编号】
 *
 * @author clam
 * @version V1.0.0
 */
@Slf4j
@RestController
@RequestMapping("/ConverterIndex")
@Api(tags = "换流站指标统计明细汇总数据")
@RequiredArgsConstructor
public class ConverterIndexStatisticsController extends BaseController {

    private final ConverterIndexStatisticsPOService converterIndexStatisticsPOService;
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/queryPage")
    @ApiOperation("数据查询")
    @ApiImplicitParam(name = "param", value = "实体参数", required = true)
    public HttpResult<Page<ConverterIndexStatisticsPO>> queryPage(@Validated @RequestBody SendQueryParam.SendPageParam param) {
        String methodDescribe = getMethodDescribe("queryPage");
        LogUtil.njcnDebug(log, "{}，实体参数：{}", methodDescribe, param);
        Page<ConverterIndexStatisticsPO> list = converterIndexStatisticsPOService.queryPage(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
    }

    @PostMapping("send")
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @ApiOperation("上报")
    @ApiImplicitParam(name = "uploadParam",value = "请求体",required = true)
    public HttpResult<String> send( @RequestBody UploadParam uploadParam){
        String methodDescribe = getMethodDescribe("send");
        String s = converterIndexStatisticsPOService.send(uploadParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
    }

}
