package com.njcn.prepare.harmonic.controller.line;

import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.constant.OperateType;
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.prepare.harmonic.pojo.param.LineParam;
import com.njcn.prepare.harmonic.service.mysql.line.SteadyIndexExceedService;
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 qijian
 * @date 2022/12/02
 * 监测点稳态指标超标明细
 */
@Validated
@Slf4j
@RestController
@RequestMapping("/steadyIndexExceed")
@Api(tags = "监测点稳态指标超标明细")
@AllArgsConstructor
public class SteadyIndexExceedController extends BaseController {

    private final SteadyIndexExceedService steadyIndexExceedService;

    @Deprecated
    @OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.ADD)
    @PostMapping("/isValueExceedID")
    @ApiOperation("日统计I、II、III类监测点是否超标限值")
    @ApiImplicitParam(name = "lineParam", value = "算法通用查询参数", required = true)
    public HttpResult<Boolean> isValueExceedID(@RequestBody @Validated LineParam lineParam) {
        String methodDescribe = getMethodDescribe("isValueExceedID");
        boolean res = steadyIndexExceedService.isValueExceedID(lineParam);
        if(res){
            return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
        }else {
            return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
        }

    }

    @Deprecated
    @OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.ADD)
    @PostMapping("/isValueExceedIID")
    @ApiOperation("日统计I、II类监测点是否超标限值")
    @ApiImplicitParam(name = "lineParam", value = "算法通用查询参数", required = true)
    public HttpResult<Boolean> isValueExceedIID(@RequestBody @Validated LineParam lineParam) {
        String methodDescribe = getMethodDescribe("isValueExceedIID");
        boolean res = steadyIndexExceedService.isValueExceedIID(lineParam);
        if(res){
            return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
        }else {
            return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
        }

    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.ADD)
    @PostMapping("/isValueExceedIM")
    @ApiOperation("月统计I、II、III类监测点是否超标限值")
    @ApiImplicitParam(name = "lineParam", value = "算法通用查询参数", required = true)
    public HttpResult<Boolean> isValueExceedIM(@RequestBody @Validated LineParam lineParam) {
        String methodDescribe = getMethodDescribe("isValueExceedIM");
        boolean res = steadyIndexExceedService.isValueExceedIM(lineParam);
        if(res){
            return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
        }else {
            return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
        }
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.ADD)
    @PostMapping("/isValueExceedIIM")
    @ApiOperation("月统计I、II类监测点是否超标限值")
    @ApiImplicitParam(name = "lineParam", value = "算法通用查询参数", required = true)
    public HttpResult<Boolean> isValueExceedIIM(@RequestBody @Validated LineParam lineParam) {
        String methodDescribe = getMethodDescribe("isValueExceedIIM");
        boolean res = steadyIndexExceedService.isValueExceedIIM(lineParam);
        if(res){
            return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
        }else {
            return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
        }

    }
}
