package com.njcn.cssystem.controller.task;


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.cssystem.service.IDataTaskService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author xy
 */
@Slf4j
@RestController
@RequestMapping("/dataTask")
@Api(tags = "数据预处理")
@AllArgsConstructor
public class DataTaskController extends BaseController {

    private final IDataTaskService dataTaskService;
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/channelHarmonic")
    @ApiOperation("稳态数据")
    public HttpResult<Boolean> channelHarmonic(@RequestParam("time") String time){
        String methodDescribe = getMethodDescribe("channelHarmonic");
        dataTaskService.channelHarmonic(time);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/runAlarm")
    @ApiOperation("运行告警")
    public HttpResult<Boolean> channelRunAlarm(@RequestParam("time") String time){
        String methodDescribe = getMethodDescribe("channelRunAlarm");
        dataTaskService.channelRunAlarm(time);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/runDataAlarm")
    @ApiOperation("运行告警(完整性、在线率)")
    public HttpResult<Boolean> channelRunDataAlarm(@RequestParam("time") String time){
        String methodDescribe = getMethodDescribe("channelRunDataAlarm");
        dataTaskService.channelRunDataAlarm(time);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/pushAppMsg")
    @ApiOperation("app消息推送")
    public HttpResult<Boolean> pushAppMsg(@RequestParam("time") String time){
        String methodDescribe = getMethodDescribe("pushAppMsg");
        dataTaskService.pushAppMsg(time);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
    }

}
