package org.ts.ddcs.job;


import org.ts.ddcs.log.LogHelper;
import org.ts.ddcs.Worker.DataProcessHolder;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.util.Date;


/**
 * @author dylan
 */
@Component
public class DatagramDownloadCheckJobHandler {
    @Value("${run-config.job.jobHandler}")
    private boolean jobHandler;

    @XxlJob("CheckJobHandler")
    public void checkJobHandler() throws Exception {
        try {
            if (jobHandler) {
                LogHelper.info("*********** datagram download  task:" + new Date().toString());
                DataProcessHolder.newInstance().dataProcess.SubmitRetryCheckTask();
            }
        } catch (Exception e) {
            LogHelper.error(e);
        }
    }

    @XxlJob("ImageCompundJobHandler")
    public void imageCompundJobHandler() throws Exception {
        try {
            if (jobHandler) {
                LogHelper.info("*********** impage compund task:" + new Date().toString());
                DataProcessHolder.newInstance().dataProcess.submitImageCompundWaterLevelTask();
            }
        } catch (Exception e) {
            LogHelper.error(e);
        }
    }

}
