package net.northking.cctp.executePlan.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

@Configuration
@ConfigurationProperties("atu.plan")
public class AtuPlanConfig {
    /**
     * 任务等待超时时间 单位：小时 默认24小时
     */
    private Integer waitTimeout = 24;

    public Integer getWaitTimeout() {
        return waitTimeout;
    }

    public void setWaitTimeout(Integer waitTimeout) {
        if (waitTimeout <= 0) {
            waitTimeout = 1;
        }
        this.waitTimeout = waitTimeout;
    }

    /**
     * 是否启用执行超时，默认启用
     * atu.plan.batchExecuteTimeoutEnabled
     */
    private Boolean batchExecuteTimeoutEnabled;

    /**
     * 批次执行超时时间，默认48小时
     *  atu.plan.batchExecuteTimeout
     */
    private Integer batchExecuteTimeout;


    public boolean isBatchExecuteTimeoutEnabled() {
        return batchExecuteTimeoutEnabled == null ? true : batchExecuteTimeoutEnabled;
    }

    public void setBatchExecuteTimeoutEnabled(boolean batchExecuteTimeoutEnabled) {
        this.batchExecuteTimeoutEnabled = batchExecuteTimeoutEnabled;
    }

    public Integer getBatchExecuteTimeout() {
        if (isBatchExecuteTimeoutEnabled()) {
            // 如果是启用了批次执行超时，
            return batchExecuteTimeout == null ? 48 : batchExecuteTimeout;
        }
        return 48;
    }

    public void setBatchExecuteTimeout(Integer batchExecuteTimeout) {
        this.batchExecuteTimeout = batchExecuteTimeout;
    }
}
