package org.security.trans.taskCheck;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.security.trans.taskCheck.device.DeviceCheckTask;
import org.security.trans.taskCheck.device.DeviceDeadlineCheckTask;
import org.security.trans.taskCheck.task.TaskCheckTask;
import org.security.trans.taskCheck.task.TaskDeadlineCheckTask;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.ParseException;

/**
 * @author zj 2022/4/13
 */
@Api(value = "任务-定时任务", tags = "任务-定时任务")
@AllArgsConstructor
@RequestMapping("/task")
@RestController
public class TaskCheckController {

	private final TaskCheckTask taskCheckTask;
	private final TaskDeadlineCheckTask taskDeadlineCheckTask;
	private final DeviceCheckTask deviceCheckTask;
	private final DeviceDeadlineCheckTask deviceDeadlineCheckTask;

	@ApiOperationSupport(order = 1)
	@ApiOperation(value = "生成下发任务")
	@GetMapping("/task/check/run")
	public void check() {
		taskCheckTask.check();
	}

	@ApiOperationSupport(order = 2)
	@ApiOperation(value = "检查是否超时")
	@GetMapping("/task/deadline/run")
	public void deadline() throws ParseException {
		taskDeadlineCheckTask.deadlineCeheck();
	}

	@ApiOperationSupport(order = 3)
	@ApiOperation(value = "设备检查是否超时")
	@GetMapping("/device/deadline/run")
	public void deviceDeadline() throws ParseException {
		deviceDeadlineCheckTask.deviceDeadlineCheck();
	}

	@ApiOperationSupport(order = 4)
	@ApiOperation(value = "生成设备检查任务")
	@GetMapping("/device/check/run")
	public void deviceCehck() {
		deviceCheckTask.check();
	}

	@ApiOperationSupport(order = 5)
	@ApiOperation(value = "生成设备使用状态检查任务")
	@GetMapping("/device/usageState/run")
	public void deviceUsageCheck() throws ParseException{
		deviceDeadlineCheckTask.deviceUsageStateCheck();
	}

	@ApiOperationSupport(order = 6)
	@ApiOperation(value = "生成工作提醒状态检查任务")
	@GetMapping("/noteRemind/state/run")
	public void noteRemindStateCheck() throws ParseException{
		deviceDeadlineCheckTask.deviceUsageStateCheck();
	}
}
