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.ConverterDetailStatisticsPO;
import com.njcn.harmonic.service.send.ConverterDetailStatisticsPOService;
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;

/**
 *需求：
 *  * FWJK-PMS3.0-TC0013-电能质量管理两级贯通接口V1.10
 *  * 2.4.1.19	接收电能质量换流站指标统计明细数据接口
 *
 * @author clam
 * @version V1.0.0
 */


@Slf4j
@RestController
@RequestMapping("/ConverterDetail")
@Api(tags = "换流站指标统计明细数据")
@RequiredArgsConstructor
public class ConverterDetailStatisticsController extends BaseController {


    private final ConverterDetailStatisticsPOService converterDetailStatisticsPOService;

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/queryPage")
    @ApiOperation("数据查询")
    @ApiImplicitParam(name = "param", value = "实体参数", required = true)
    public HttpResult<Page<ConverterDetailStatisticsPO>> queryPage(@Validated @RequestBody SendQueryParam.SendPageParam param) {
        String methodDescribe = getMethodDescribe("queryPage");
        LogUtil.njcnDebug(log, "{}，实体参数：{}", methodDescribe, param);
        Page<ConverterDetailStatisticsPO> list = converterDetailStatisticsPOService.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 = converterDetailStatisticsPOService.send(uploadParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
    }

}
