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.device.biz.enums.DeviceResponseEnum;
import com.njcn.prepare.harmonic.pojo.param.LineParam;
import com.njcn.prepare.harmonic.service.mysql.line.DataExceptionService;
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/10/26
 * 数据是否异常
 */
@Validated
@Slf4j
@RestController
@RequestMapping("/dataException")
@Api(tags = "数据是否异常")
@AllArgsConstructor
public class DataExceptionController extends BaseController {

    private final DataExceptionService dataExceptionService;

    @OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.ADD)
    @PostMapping("/lineDataException")
    @ApiOperation("监测点数据是否异常")
    @ApiImplicitParam(name = "lineParam", value = "算法通用查询参数", required = true)
    public HttpResult<String> lineDataException(@RequestBody @Validated LineParam lineParam) {
        String methodDescribe = getMethodDescribe("lineDataException");
        DeviceResponseEnum deviceResponseEnum = dataExceptionService.lineDataException(lineParam);
        if(deviceResponseEnum != null){
            return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, deviceResponseEnum.getMessage(), methodDescribe);
        }else {
            return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, "不存在数据异常！", methodDescribe);
        }

    }
}
