package org.jeecg.modules.yjComprehensiveLog.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.yjComprehensiveLog.entity.YjComprehensiveRealLog;
import org.jeecg.modules.yjComprehensiveLog.model.YjComprehensiveRealLogModel;
import org.jeecg.modules.yjComprehensiveLog.model.YjComprehensiveSumModel;
import org.jeecg.modules.yjComprehensiveLog.service.YjComprehensiveRealLogService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * <p>
 * 配置 前端控制器
 * <p>
 *
 * @Author:
 */
@RestController
@RequestMapping("/warning/comprehensiveRealLog")
@Slf4j
public class YjComprehensiveRealLogController {

    @Resource
    private YjComprehensiveRealLogService comprehensiveRealLogService;

    /**
     * 分页查询列表
     *
     * @param param
     * @param pageNo
     * @param pageSize
     * @param req
     * @return
     */
    @GetMapping("/queryPage")
    public Result<IPage<YjComprehensiveRealLog>> queryPage(YjComprehensiveRealLog param, @RequestParam(name="pageNo", defaultValue="1")Integer pageNo,
                                                           @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, HttpServletRequest req){
        IPage<YjComprehensiveRealLog> res = comprehensiveRealLogService.queryPage(param, pageNo, pageSize, req);
        return Result.OK(res);
    }

    /**
     * 获取当前最新的风险数据
     *
     * @return
     */
    @GetMapping("/queryRealList")
    public Result<?> queryRealList(){
        List<YjComprehensiveRealLogModel> res = comprehensiveRealLogService.queryRealList();
        return Result.OK(res);
    }


    /**
     * 获取各类风险统计数量
     *
     * @return
     */
    @GetMapping("/getRiskCount")
    public Result<?> getRiskCount(){
        List<YjComprehensiveSumModel> res = comprehensiveRealLogService.getRiskCount();
        return Result.OK(res);
    }

    /**
     * 根据井号获取当前井最新工况及风险
     * @param jh
     * @return
     */
    @GetMapping("/getRealDataByJh")
    public Result<?> getRealDataByJh(@RequestParam("jh") String jh){
        List<YjComprehensiveRealLog> res = comprehensiveRealLogService.getRealTimeLogByJh(jh);
        return Result.OK(res);
    }

}
