package cn.estsh.i3plus.pojo.mes.model;


import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil;
import io.swagger.annotations.Api;
import lombok.Data;

import java.util.Collection;

@Data
@Api("工步返回信息")
public class StepResult<T> {

    private boolean isCompleted;

    private T data;

    private Collection<T> dataCollection;

    private String msg;

    private boolean needStop;

    private StationRequestBean stationRequestBean;

    private MesPcnEnumUtil.STEP_RESULT_CMD cmd;

    public static StepResult getNonComplete() {
        return new StepResult(false, "");
    }

    public static StepResult getNonCompleteStop() {
        StepResult result = new StepResult(false, "");
        result.setNeedStop(true);
        return result;
    }

    public static StepResult getNonComplete(StationRequestBean requestBean) {
        return new StepResult(false, "");
    }

    public static <T> StepResult getNonCompleteData(T data, String msg) {
        return new StepResult(false, data, msg);
    }

    public static <T> StepResult getNonCompleteReqBean(StationRequestBean reqBean) {
        return new StepResult(false, reqBean);
    }

    public static <T> StepResult getNonCompleteReqBeanStop(StationRequestBean reqBean) {
        StepResult stepResult = new StepResult(false, reqBean);
        stepResult.setNeedStop(true);
        return stepResult;
    }

    public static <T> StepResult getNonCompleteData(T data) {
        return new StepResult(false, data, "");
    }

    public static StepResult getNonComplete(String msg) {
        return new StepResult(false, msg);
    }

    public static StepResult getNonCompleteStop(String msg) {
        StepResult stepResult = new StepResult(false, msg);
        stepResult.setNeedStop(true);
        return stepResult;
    }

    public static StepResult getSuccessComplete(String msg) {
        return new StepResult(true, msg);
    }

    public static StepResult getSuccessComplete(MesPcnEnumUtil.STEP_RESULT_CMD cmd) {
        return new StepResult(true, cmd);
    }

    public static StepResult getSuccessComplete() {
        return new StepResult(true, "");
    }

    public static <T> StepResult getSuccessCompleteReqBean(StationRequestBean reqBean) {
        return new StepResult(true, reqBean);
    }

    public static <T> StepResult<T> getSuccessData(T data, String msg) {
        return new StepResult<>(true, data, msg);
    }

    public static <T> StepResult<T> getSuccessData(T data) {
        return new StepResult<>(true, data, "");
    }

    public static <T> StepResult<T> getSuccessData(Collection<T> data, String msg) {
        return new StepResult<T>(true, data, msg);
    }

    private StepResult() {
    }

    private StepResult(boolean isCompleted) {
        this.isCompleted = isCompleted;
    }

    private StepResult(boolean isCompleted, String msg) {
        this.isCompleted = isCompleted;
        this.msg = msg;
    }

    private StepResult(boolean isCompleted, MesPcnEnumUtil.STEP_RESULT_CMD cmd) {
        this.isCompleted = isCompleted;
        this.cmd = cmd;
    }


    public StepResult(boolean isCompleted, StationRequestBean stationRequestBean) {
        this.isCompleted = isCompleted;
        this.stationRequestBean = stationRequestBean;
    }

    public StepResult(boolean isCompleted, T data, String msg) {
        this.isCompleted = isCompleted;
        this.data = data;
        this.msg = msg;
    }

    public StepResult(boolean isCompleted, Collection<T> dataCollection, String msg) {
        this.isCompleted = isCompleted;
        this.dataCollection = dataCollection;
        this.msg = msg;
    }

    public StepResult(boolean isCompleted, T data, Collection<T> dataCollection, String msg, StationRequestBean stationRequestBean) {
        this.isCompleted = isCompleted;
        this.data = data;
        this.dataCollection = dataCollection;
        this.msg = msg;
        this.stationRequestBean = stationRequestBean;
    }
}
