package org.security.trans.taskCheck.task.impl;

import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.security.common.eum.FrequencyEnum;
import org.security.trans.task.entity.Task;
import org.security.trans.taskCheck.task.ITaskCheck;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * @author zj 2022/4/11
 * 按季
 */
@Slf4j
@AllArgsConstructor
@Service
public class ByQuarterTaskCheck implements ITaskCheck {
	private final BaseTaskCheck baseTaskCheck;

	@Override
	public void handle(Task task) {
		log.info("=============任务类型[按季]开始处理==============");
		DateTime date = DateUtil.date();
		Date begin = DateUtil.beginOfQuarter(date);
		Date end = DateUtil.endOfQuarter(date);
		baseTaskCheck.handle(task, begin, end);
		log.info("=============任务类型[按季]处理结束==============");
	}

	@Override
	public boolean support(FrequencyEnum frequencyEnum) {
		return FrequencyEnum.BY_QUARTER.equals(frequencyEnum);
	}
}
