package com.njcn.csharmonic.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.csharmonic.pojo.param.StatisticsDataParam;
import com.njcn.csharmonic.pojo.vo.DataVo;
import com.njcn.csharmonic.pojo.vo.HalfMonthReportVO;
import com.njcn.csharmonic.service.IStatisticsDataDataService;
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.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 xy
 */
@Slf4j
@RestController
@RequestMapping("/statisticsData")
@Api(tags = "统计数据")
@AllArgsConstructor
public class StatisticsDataDataController extends BaseController {

    private final IStatisticsDataDataService statisticsDataDataService;

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/lineIntegrity")
    @ApiOperation("监测点数据完整性")
    @ApiImplicitParam(name = "param", value = "参数", required = true)
    public HttpResult<List<DataVo>> getLineIntegrity(@RequestBody StatisticsDataParam param) {
        String methodDescribe = getMethodDescribe("getLineIntegrity");
        List<DataVo> list = statisticsDataDataService.getLineIntegrity(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/devOnlineRate")
    @ApiOperation("装置在线率")
    @ApiImplicitParam(name = "param", value = "参数", required = true)
    public HttpResult<List<DataVo>> getDevOnlineRate(@RequestBody StatisticsDataParam param) {
        String methodDescribe = getMethodDescribe("getDevOnlineRate");
        List<DataVo> list = statisticsDataDataService.getDevOnlineRate(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/halfMonthReport")
    @ApiOperation("半月报功能")
    @ApiImplicitParam(name = "param", value = "参数", required = true)
    public HttpResult<List<HalfMonthReportVO>> getHalfMonthReport(@RequestBody StatisticsDataParam param) {
        String methodDescribe = getMethodDescribe("getHalfMonthReport");
        List<HalfMonthReportVO> result =  statisticsDataDataService.getHalfMonthReport(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }
}
