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

import cn.estsh.i3plus.ext.mes.pojo.util.MesExtConstWords;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiParam;
import lombok.Data;
import org.springframework.beans.BeanUtils;
import org.springframework.util.StringUtils;

import java.io.Serializable;
import java.util.Arrays;
import java.util.List;

/**
 * @PROJECT_NAME: i3plus-mes-panasonic-bu
 * @DESCRIPTION:
 * @USER: xinwang.yi
 * @DATE: 2022-11-01 15:54
 */
@Data
@ApiModel("生产数据回传软适配数据MODEL")
public class SxProdDataToSoftAdapterDataModel implements Serializable {

    private static final long serialVersionUID = -1045133621790031697L;

    @ApiParam("组织代码")
    public String organizeCode;

    @ApiParam(value = "操作人")
    private String userName;

    @ApiParam(value = "线程ID")
    private String currentThreadName;

    @ApiParam(value = "查询时间")
    private String date;

    @ApiParam("策略类")
    private String strategyClass;

    @ApiParam("执行类")
    private List<SxProdDataToSoftAdapterCfgModel> cfgModelList;

    @ApiParam("适配器代码集合")
    private List<String> suitCaseCodeList;

    @ApiParam("数据")
    private Object obj;

    @ApiParam("类名")
    private String className;

    public SxProdDataToSoftAdapterDataModel obj(Object obj) {
        this.obj = obj;
        return this;
    }

    public SxProdDataToSoftAdapterDataModel organizeCode(String organizeCode) {
        this.organizeCode = organizeCode;
        return this;
    }

    public SxProdDataToSoftAdapterDataModel date(String date) {
        this.date = date;
        return this;
    }

    public SxProdDataToSoftAdapterDataModel suitCaseCodeList(String suitCaseCode) {
        if (StringUtils.isEmpty(suitCaseCode)) return this;
        String[] suitCaseCodeArr = suitCaseCode.split(MesExtConstWords.COMMA);
        this.suitCaseCodeList = Arrays.asList(suitCaseCodeArr);
        return this;
    }

    public SxProdDataToSoftAdapterDataModel(String userName, String currentThreadName) {
        this.userName = userName;
        this.currentThreadName = currentThreadName;
    }

    public SxProdDataToSoftAdapterDataModel(SxProdDataToSoftAdapterDataModel data, String strategyClass, String className, List<SxProdDataToSoftAdapterCfgModel> cfgModelList) {
        BeanUtils.copyProperties(data, this);
        this.strategyClass = strategyClass;
        this.className = className;
        this.cfgModelList = cfgModelList;
    }
}
