package com.njcn.harmonic.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
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.harmonic.pojo.param.OnlineParam;
import com.njcn.harmonic.pojo.vo.LineLimitDetailVo;
import com.njcn.harmonic.pojo.vo.PmsOnlineVo;
import com.njcn.harmonic.service.IPmsLineWarningService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
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 java.util.List;

/**
 * <p>
 * 监测点每日稳态指标超标天数统计表 前端控制器
 * </p>
 *
 * @author xy
 * @since 2024-06-17
 */
@Slf4j
@RestController
@RequestMapping("/onlineMonitor")
@Api(tags = "在线监测")
@AllArgsConstructor
public class PmsLineWarningController extends BaseController {

    private final IPmsLineWarningService iPmsLineWarningService;

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/heBeiNorthAdd")
    @ApiOperation("新增在线监测数据(按月统计累计超标天数)")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "startTime", value = "开始时间"),
        @ApiImplicitParam(name = "endTime", value = "结束时间")
    })
    public HttpResult<String> heBeiNorthAdd(@RequestParam(value = "startTime",required = false) String startTime, @RequestParam(value = "endTime",required = false) String endTime) {
        String methodDescribe = getMethodDescribe("heBeiNorthAdd");
        iPmsLineWarningService.addHeBeiNorthLineWarning(startTime,endTime);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/list")
    @ApiOperation("分页查询在线监测数据")
    @ApiImplicitParam(name = "param", value = "参数", required = true)
    public HttpResult<Page<PmsOnlineVo>> lineWarningList(@RequestBody @Validated OnlineParam param) {
        String methodDescribe = getMethodDescribe("lineWarningList");
        Page<PmsOnlineVo> list = iPmsLineWarningService.getLineWarningList(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/overLimitDetail")
    @ApiOperation("查看越限详情")
    @ApiImplicitParam(name = "param", value = "参数", required = true)
    public HttpResult<List<LineLimitDetailVo>> getOverLimitDetail(@RequestBody @Validated OnlineParam.DetailParam param) {
        String methodDescribe = getMethodDescribe("getOverLimitDetail");
        List<LineLimitDetailVo> result = iPmsLineWarningService.getOverLimitDetail(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }

}

