package com.base.task.model;

import com.base.task.handler.TaskHandler;
import com.base.task.model.Enums.TaskTypeEnum;
import com.base.task.model.input.Input;
import lombok.Data;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.CountDownLatch;

@Data
public class Task<T extends BaseBizInfo> {

    /**
     * 任务类型_YYYYMMDDHHMMSS_id
     */
    private String taskSerial;

    private TaskTypeEnum taskType;

    private String exeFilePath;
    private String exeFileName;

    private String inpPath;
    private String inpName;

    private String resultDataSavePath;
    private String resultDataSaveName;
    private String resultHrpreDataSaveName;
    private String satelliteCode;

    private String okFilePath;

    private String okFileName;

    private TaskHandler taskHandler;

    private Input input;

    private String satelliteName;

    private String stationCode;

    private String stationName;

    /**
     * 可执行程序
     */
    private Process process;


    /**
     * 0 进行中 1完成任务
     */
    private volatile Integer state;

    private List<String> satelliteIds;

    private List<String> satelliteCodes;

    private String startTime;

    private String endTime;

   /* private String filePathtest;*/

    private CountDownLatch countDownLatch;

    private T baseBizInfo;

    public Task(){}

    public Task(String taskSerial){
        this.taskSerial = taskSerial;
    }


    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Task task = (Task) o;
        return taskSerial.equals(task.taskSerial);
    }

    @Override
    public int hashCode() {
        return Objects.hash(taskSerial);
    }
}
