package cn.cecep.talroad.task;

import cn.cecep.talroad.common.core.web.domain.AjaxResults;
import cn.cecep.talroad.data.analyse.task.missing.impl.MAmProblemFiRatioService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 预警比例
 */
@Slf4j
@Api(tags = "预警比例")
@RestController
@RequestMapping("/problem/ratio")
public class ProblemRatioController {

    @Resource
    public MAmProblemFiRatioService mAmProblemFiRatioService;

    @ApiOperation(value = "预警比例调整")
    @PostMapping(value = "/theAdjustment")
    public AjaxResults<Void> theAdjustment() {
        log.info("执行任务 start：预警比例调整开始");
        boolean result = mAmProblemFiRatioService.mainProcess();
        if (!result){
            log.error("执行数据逻辑分析任务失败！: 预警比例调整");
            return AjaxResults.error();
        }
        log.info("执行任务 end：预警比例调整结束");
        return AjaxResults.success();
    }


    @ApiOperation(value = "预警比例调整测试")
    @PostMapping(value = "/test")
    public AjaxResults<Void> test() {

        boolean result = mAmProblemFiRatioService.mainProcessByTest();
        if (!result){
            return AjaxResults.error();
        }
        return AjaxResults.success();
    }


}
