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

import io.swagger.annotations.ApiParam;
import lombok.Data;
import org.springframework.util.StringUtils;

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

@Data
public class SxThirdPartyPlcCollectDataModel implements Serializable {

    private static final long serialVersionUID = -1649994009292535386L;

    @ApiParam("工厂代码")
    public String organizeCode;

    @ApiParam("操作人")
    public String userInfo;

    @ApiParam("生产线代码")
    private String workCenterCode;

    @ApiParam("工位代码")
    private String workCellCode;

    @ApiParam("过程条码")
    private String serialNumber;

    @ApiParam("产品条码")
    private String productSn;

    @ApiParam("管理码")
    private String manageCode;

    @ApiParam("生产工单")
    private String workOrderNo;

    @ApiParam("物料号")
    private String partNo;

    @ApiParam("物料名称")
    private String partNameRdd;

    @ApiParam("超时时间")
    private Long timeOut = 60000L;

    @ApiParam("PLC标志位代码")
    private String plcCode2PlcFlag;

    @ApiParam("PCN标志位代码")
    private String plcCode2PcnFlag;

    @ApiParam("数据位PLC代码集合")
    private List<String> plcCode2DataList;

    public SxThirdPartyPlcCollectDataModel location(String organizeCode, String workCenterCode, String workCellCode) {
        this.organizeCode = organizeCode;
        this.workCenterCode = workCenterCode;
        this.workCellCode = workCellCode;
        return this;
    }

    public SxThirdPartyPlcCollectDataModel userInfo(String userInfo) {
        this.userInfo = userInfo;
        return this;
    }

    public SxThirdPartyPlcCollectDataModel order(String workOrderNo, String partNo, String partNameRdd) {
        this.workOrderNo = workOrderNo;
        this.partNo = partNo;
        this.partNameRdd = partNameRdd;
        return this;
    }

    public SxThirdPartyPlcCollectDataModel sn(String serialNumber, String productSn) {
        this.serialNumber = serialNumber;
        this.productSn = productSn;
        return this;
    }

    public SxThirdPartyPlcCollectDataModel manageCode(String manageCode) {
        this.manageCode = manageCode;
        return this;
    }

    public SxThirdPartyPlcCollectDataModel timeOut(Object timeOut) {
        if (!StringUtils.isEmpty(timeOut)) this.timeOut = Long.valueOf(timeOut.toString());
        return this;
    }

    public SxThirdPartyPlcCollectDataModel plcCode2Flag(String plcCode2PlcFlag, String plcCode2PcnFlag) {
        this.plcCode2PlcFlag = plcCode2PlcFlag;
        this.plcCode2PcnFlag = plcCode2PcnFlag;
        return this;
    }

    public SxThirdPartyPlcCollectDataModel plcCode2DataList(List<String> plcCode2DataList) {
        this.plcCode2DataList = plcCode2DataList;
        return this;
    }
}
