package com.njcn.advance.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.netflix.ribbon.proxy.annotation.Http;
import com.njcn.advance.pojo.dto.BalanceInfo;
import com.njcn.advance.pojo.param.AdvanceBaseParam;
import com.njcn.advance.service.EventRelevantAnalysisService;
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.PubUtils;
import com.njcn.event.pojo.vo.AdvanceEventDetailVO;
import com.njcn.web.controller.BaseController;
import com.njcn.web.pojo.annotation.DateTimeStrValid;
import com.njcn.web.pojo.param.BaseParam;
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.*;

import javax.servlet.http.HttpServletRequest;
import java.io.DataInputStream;
import java.net.URLDecoder;
import java.time.LocalDateTime;
import java.util.List;

/**
 * pqs
 * 事件关联分析
 *
 * @author cdf
 * @date 2023/6/30
 */
@RestController
@RequestMapping("process")
@Api(tags = "暂降事件关联分析")
@RequiredArgsConstructor
@Slf4j
public class EventRelevantAnalysisController extends BaseController {

    private final EventRelevantAnalysisService eventRelevantAnalysisService;

    @GetMapping("processEvents")
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @ApiOperation("启动关联分析")
    public HttpResult<Object> processEvents(@RequestParam("startTime") String startTime, @RequestParam("endTime")String endTime) {
        String methodDescribe = getMethodDescribe("processEvents");
        List<LocalDateTime> timeVal = PubUtils.checkLocalDateTime(startTime,endTime);
        eventRelevantAnalysisService.processEvents(timeVal.get(0),timeVal.get(1));
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
    }



    /**
     * 高级算法-暂降事件关联分析主列表
     * @author cdf
     * @date 2023/7/20
     */
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/querySagEventsPage")
    @ApiOperation("高级算法-暂降事件关联分析主列表")
    public HttpResult<Page<AdvanceEventDetailVO>> querySagEventsPage(BaseParam baseParam){
        String methodDescribe = getMethodDescribe("querySagEventsPage");
        Page<AdvanceEventDetailVO> list = eventRelevantAnalysisService.querySagEventsPage(baseParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
    }

}
