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.common.utils.LogUtil;
import com.njcn.device.pq.pojo.param.DeviceInfoParam;
import com.njcn.event.pojo.vo.AreaLineVO;
import com.njcn.event.pojo.vo.EventHeatMapVO;
import com.njcn.event.pojo.vo.EventSeverityVO;
import com.njcn.event.pojo.vo.TerminalRunningStatisticsVO;
import com.njcn.event.service.majornetwork.AreaLineService;
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;

/**
 * @author denghuajun
 * @version 1.0.0
 * @date 2022年04月07日 09:33
 */
@Slf4j
@RestController
@RequestMapping("/area")
@Api(tags = "区域暂降相关")
@AllArgsConstructor
public class AreaController extends BaseController {
    
    private final AreaLineService areaLineService;
    
    /**
     * 获取监测网分布
     *
     * @param deviceInfoParam 参数
     * @return 结果
     */
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getAreaLineDetail")
    @ApiOperation("获取监测网分布")
    @ApiImplicitParam(name = "deviceInfoParam", value = "监测网分布参数", required = true)
    public HttpResult<AreaLineVO> getAreaLineDetail(@RequestBody @Validated DeviceInfoParam deviceInfoParam) {
        String methodDescribe = getMethodDescribe("getAreaLineDetail");
        LogUtil.njcnDebug(log, "{}，参数为：{}", methodDescribe, deviceInfoParam);
        AreaLineVO result = areaLineService.getAreaLineVO(deviceInfoParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }
    
    /**
     * 获取暂降热力图
     *
     * @param deviceInfoParam 参数
     * @return 结果
     */
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getEventHeatMap")
    @ApiOperation("获取暂降热力图")
    @ApiImplicitParam(name = "deviceInfoParam", value = "监测网分布参数", required = true)
    public HttpResult<EventHeatMapVO> getEventHeatMap(@RequestBody @Validated DeviceInfoParam.BusinessParam deviceInfoParam) {
        String methodDescribe = getMethodDescribe("getEventHeatMap");
        LogUtil.njcnDebug(log, "{}，参数为：{}", methodDescribe, deviceInfoParam);
        EventHeatMapVO result = areaLineService.getEventHeatMap(deviceInfoParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }
    
    /**
     * 获取暂降严重度
     *
     * @param deviceInfoParam 参数
     * @return 结果
     */
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getEventSeverity")
    @ApiOperation("获取暂降严重度")
    @ApiImplicitParam(name = "deviceInfoParam", value = "监测网分布参数", required = true)
    public HttpResult<EventSeverityVO> getEventSeverity(@RequestBody @Validated DeviceInfoParam.BusinessParam deviceInfoParam) {
        String methodDescribe = getMethodDescribe("getEventSeverity");
        LogUtil.njcnDebug(log, "{}，参数为：{}", methodDescribe, deviceInfoParam);
        EventSeverityVO result = areaLineService.getEventSeverity(deviceInfoParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }
    
    
    /**
     * 获取终端运行统计
     *
     * @param deviceInfoParam 参数
     * @return 结果
     */
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getTerminalRunningStatistics")
    @ApiOperation("获取终端运行统计")
    @ApiImplicitParam(name = "deviceInfoParam", value = "监测网分布参数", required = true)
    public HttpResult<TerminalRunningStatisticsVO> getTerminalRunningStatistics(@RequestBody @Validated DeviceInfoParam.BusinessParam deviceInfoParam) {
        String methodDescribe = getMethodDescribe("getTerminalRunningStatistics");
        LogUtil.njcnDebug(log, "{}，参数为：{}", methodDescribe, deviceInfoParam);
        TerminalRunningStatisticsVO result = areaLineService.getTerminalRunningStatistics(deviceInfoParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }
    
}
