package com.njcn.event.controller.majornetwork.area;

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.po.EventDetailNew;
import com.njcn.event.pojo.vo.AreaSubLineVO;
import com.njcn.event.service.majornetwork.AreaInfoService;
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.*;

import javax.validation.constraints.NotBlank;
import java.util.List;

/**
 * pqs-event
 * 区域信息
 * @author cdf
 * @date 2022/6/29
 */
@Slf4j
@RestController
@RequestMapping("/areaInfo")
@Api(tags = "区域地理信息")
@AllArgsConstructor
public class AreaInfoController extends BaseController {

    private final AreaInfoService areaInfoService;



    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getAreaLineInfo")
    @ApiOperation("获取监测点区域信息")
    @ApiImplicitParam(name = "deviceInfoParam", value = "参数体", required = true)
    public HttpResult<List<AreaSubLineVO>> getAreaLineInfo(@RequestBody @Validated DeviceInfoParam.GridDiagram deviceInfoParam) {
        String methodDescribe = getMethodDescribe("getAreaLineInfo");
        List<AreaSubLineVO> res = areaInfoService.getAreaLineInfo(deviceInfoParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, res, methodDescribe);
    }



    /**
     * 未处理暂降事件列表
     * @author cdf
     * @date 2022/6/30
     */
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getNoDealEvents")
    @ApiOperation("获取区域未处理暂态事件")
    @ApiImplicitParam(name = "deviceInfoParam", value = "参数体", required = true)
    public HttpResult<List<EventDetailNew>> getNoDealEvents(@RequestBody @Validated DeviceInfoParam.BusinessParam deviceInfoParam) {
        String methodDescribe = getMethodDescribe("getNoDealEvents");
        List<EventDetailNew> res = areaInfoService.getNoDealEvents(deviceInfoParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, res, methodDescribe);
    }


    /**
     * 获取监测点下未处理的暂降事件
     * @author cdf
     * @date 2022/8/23
     */
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @GetMapping("/getNoDealEventsByLineId")
    @ApiOperation("获取监测点下未处理的暂降事件")
    @ApiImplicitParam(name = "id", value = "监测点id", required = true)
    public HttpResult<List<EventDetailNew>> getNoDealEventsByLineId(@RequestParam("id") @NotBlank(message = "监测点id不可为空") String id,
                                                                    @RequestParam("searchBeginTime") @NotBlank(message = "开始时间不可为空") String searchBeginTime,
                                                                    @RequestParam("searchEndTime") @NotBlank(message = "结束时间不可为空") String searchEndTime
                                                                    ) {
        String methodDescribe = getMethodDescribe("getNoDealEventsByLineId");
        List<EventDetailNew> res = areaInfoService.getNoDealEventsByLineId(id,searchBeginTime,searchEndTime);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, res, methodDescribe);
    }

}
