package com.njcn.event.controller.majornetwork;

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.device.pq.pojo.param.DeviceInfoParam;
import com.njcn.event.pojo.vo.AreaStatisticalVO;
import com.njcn.event.service.majornetwork.AreaStatisticalService;
import com.njcn.event.pojo.vo.NodeVO;
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.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 : zhaojun
 * @version : 1.0.0
 * @date : 2022年06月24日 11:02
 */
@Slf4j
@RestController
@RequestMapping("/areaStatistics")
@Api(tags = "区域概览")
@AllArgsConstructor
public class AreaStatisticalController extends BaseController {

    private final AreaStatisticalService areaStatisticalService;

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getAreaCalculation")
    @ApiOperation("获取暂降区域电压等级月份统计")
    @ApiImplicitParam(name = "deviceInfoParam", value = "暂降事件分析参数", required = true)
    public HttpResult<AreaStatisticalVO> getAreaCalculation(@RequestBody @Validated DeviceInfoParam.BusinessParam deviceInfoParam) {
        String methodDescribe = getMethodDescribe("getAreaCalculation");
        AreaStatisticalVO res = areaStatisticalService.getAreaCalculation(deviceInfoParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, res, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getCalculation")
    @ApiOperation("获取暂降区域节点图")
    @ApiImplicitParam(name = "deviceInfoParam", value = "暂降事件分析参数", required = true)
    public HttpResult<List<NodeVO>> getCalculation(@RequestBody @Validated DeviceInfoParam.BusinessParam deviceInfoParam) {
        String methodDescribe = getMethodDescribe("getCalculation");
        List<NodeVO> calculation = areaStatisticalService.getCalculation(deviceInfoParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, calculation, methodDescribe);
    }
}
