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.DataIntegrityRateService;
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
 * r_mp_integrity_d
 * @date 2022/10/26
 * 数据完整率算法
 */
@Validated
@Slf4j
@RestController
@RequestMapping("/dataIntegrityRate")
@Api(tags = "数据完整率算法")
@AllArgsConstructor
public class DataIntegrityRateController extends BaseController {

    private final DataIntegrityRateService dataIntegrityRateService;

    /**
     * r_mp_integrity_d
     * @date 2023/9/21
     */
    @OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.ADD)
    @PostMapping("/lineDataIntegrityRate")
    @ApiOperation("监测点日数据完整率")
    @ApiImplicitParam(name = "lineParam", value = "算法通用查询参数", required = true)
    public HttpResult<Boolean> lineDataIntegrityRate(@RequestBody @Validated LineParam lineParam) {
        String methodDescribe = getMethodDescribe("lineDataIntegrityRate");
        boolean res = dataIntegrityRateService.lineDataIntegrityRate(lineParam);
        if(res){
            return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
        }else {
            return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
        }

    }
}
