AsyncRepositionDto.java

package com.mycim.valueobject.wip.dto;

import com.mycim.framework.utils.lang.StringUtils;
import com.mycim.valueobject.SystemConstant;
import com.mycim.valueobject.wip.Lot;

import java.sql.Timestamp;

/**
 * @Author: yibing.liu
 * @Date: 2022/2/21 15:00
 */
public class AsyncRepositionDto {

    private long      queueSeq;
    private String    typeFlag;
    private long      facilityRrn;
    private long      lotRrn;
    private String    lotId;
    private String    flowSeq;
    private long      stepSequence;
    private String    processStepVersion;
    private String    processStepIdVersion;
    private long      samplingGroupRrn;
    private String    samplingGroupId;
    private long      samplingGroupSubRrn;
    private String    skipFlag;
    private String    createUserId;
    private long      createUserRrn;
    private Timestamp createTimeSamp;
    private String    failReason;

    public long getQueueSeq() {
        return queueSeq;
    }

    public void setQueueSeq(long queueSeq) {
        this.queueSeq = queueSeq;
    }

    public String getTypeFlag() {
        return typeFlag;
    }

    public void setTypeFlag(String typeFlag) {
        this.typeFlag = typeFlag;
    }

    public long getFacilityRrn() {
        return facilityRrn;
    }

    public void setFacilityRrn(long facilityRrn) {
        this.facilityRrn = facilityRrn;
    }

    public long getLotRrn() {
        return lotRrn;
    }

    public void setLotRrn(long lotRrn) {
        this.lotRrn = lotRrn;
    }

    public String getLotId() {
        return lotId;
    }

    public void setLotId(String lotId) {
        this.lotId = lotId;
    }

    public String getFlowSeq() {
        return flowSeq;
    }

    public void setFlowSeq(String flowSeq) {
        this.flowSeq = flowSeq;
    }

    public long getStepSequence() {
        return stepSequence;
    }

    public void setStepSequence(long stepSequence) {
        this.stepSequence = stepSequence;
    }

    public String getProcessStepVersion() {
        return processStepVersion;
    }

    public void setProcessStepVersion(String processStepVersion) {
        this.processStepVersion = processStepVersion;
    }

    public String getProcessStepIdVersion() {
        return processStepIdVersion;
    }

    public void setProcessStepIdVersion(String processStepIdVersion) {
        this.processStepIdVersion = processStepIdVersion;
    }

    public long getSamplingGroupRrn() {
        return samplingGroupRrn;
    }

    public void setSamplingGroupRrn(long samplingGroupRrn) {
        this.samplingGroupRrn = samplingGroupRrn;
    }

    public String getSamplingGroupId() {
        return samplingGroupId;
    }

    public void setSamplingGroupId(String samplingGroupId) {
        this.samplingGroupId = samplingGroupId;
    }

    public long getSamplingGroupSubRrn() {
        return samplingGroupSubRrn;
    }

    public void setSamplingGroupSubRrn(long samplingGroupSubRrn) {
        this.samplingGroupSubRrn = samplingGroupSubRrn;
    }

    public String getSkipFlag() {
        return skipFlag;
    }

    public void setSkipFlag(String skipFlag) {
        this.skipFlag = skipFlag;
    }

    public String getCreateUserId() {
        return createUserId;
    }

    public void setCreateUserId(String createUserId) {
        this.createUserId = createUserId;
    }

    public long getCreateUserRrn() {
        return createUserRrn;
    }

    public void setCreateUserRrn(long createUserRrn) {
        this.createUserRrn = createUserRrn;
    }

    public Timestamp getCreateTimeSamp() {
        return createTimeSamp;
    }

    public void setCreateTimeSamp(Timestamp createTimeSamp) {
        this.createTimeSamp = createTimeSamp;
    }

    public String getFailReason() {
        return failReason;
    }

    public void setFailReason(String failReason) {
        if (StringUtils.isNotBlank(failReason)){
            this.failReason = SystemConstant.Str.SubString(failReason, 0, 1024);
        } else {
            this.failReason = failReason;
        }
    }

    public AsyncRepositionDto(){}

    /**
     * Returns a normal LotSamplingQueueDto object by default.
     * @param lot
     * @param createUserId
     */
    public AsyncRepositionDto(Lot lot, String createUserId){
        this.facilityRrn = lot.getFacilityRrn();
        this.lotRrn = lot.getLotRrn();
        this.lotId = lot.getLotId();
        this.flowSeq = lot.getFlowSeq();
        this.stepSequence = lot.getStepSequence();
        this.processStepVersion = lot.getProcessStepVersion();
        this.processStepIdVersion = lot.getProcessStepIdVersion();
        this.createUserId = createUserId;
    }

    public AsyncRepositionDto(Lot lot, String createUserId, long createUserRrn, String skipType){
        this.facilityRrn = lot.getFacilityRrn();
        this.lotRrn = lot.getLotRrn();
        this.lotId = lot.getLotId();
        this.flowSeq = lot.getFlowSeq();
        this.stepSequence = lot.getStepSequence();
        this.processStepVersion = lot.getProcessStepVersion();
        this.processStepIdVersion = lot.getProcessStepIdVersion();
        this.createUserId = createUserId;
        this.createUserRrn = createUserRrn;
        this.typeFlag = skipType;
    }

    public static AsyncRepositionDto buildSpecialQueueInfo(Lot lot, String userId, long samplingGroupRrn, String samplingGroupId, long samplingGroupSubRrn) {
        AsyncRepositionDto lsq = new AsyncRepositionDto(lot, userId);
        lsq.setTypeFlag(SystemConstant.AsyncReposition.SPECIAL);
        lsq.setSamplingGroupRrn(samplingGroupRrn);
        lsq.setSamplingGroupId(samplingGroupId);
        lsq.setSamplingGroupSubRrn(samplingGroupSubRrn);
        return lsq;
    }

    // public static LotSamplingQueueDto buildSpecialQueueInfo(LotSamplingGroupDTO group, LotSamplingGroupDetailDTO detail, Long facilityRrn, String userId) {
    //     LotSamplingQueueDto ssq = new LotSamplingQueueDto();
    //     ssq.setTypeFlag(SystemConstant.LotSampling.SPECIAL);
    //     ssq.setCreateUserId(userId);
    //     ssq.setFacilityRrn(facilityRrn);
    //     ssq.setLotRrn(detail.getLotRrn());
    //     ssq.setLotId(detail.getLotId());
    //     ssq.setFlowSeq(group.getMeasurementStepFlowSeq());
    //     ssq.setProcessStepVersion(detail.getMeasurementStepVersion());
    //     ssq.setProcessStepIdVersion(detail.getMeasurementStepIdVersion());
    //     ssq.setSamplingGroupRrn(group.getSamplingGroupRrn());
    //     ssq.setSamplingGroupId(group.getSamplingGroupId());
    //     ssq.setSamplingGroupSubRrn(detail.getSamplingGroupSubRrn());
    //     return ssq;
    // }


    @Override
    public String toString() {
        return "LotSamplingQueueDto{" + "queueSeq=" + queueSeq + ", typeFlag='" + typeFlag + '\'' + ", lotRrn=" +
                lotRrn + ", lotId='" + lotId + '\'' + ", flowSeq='" + flowSeq + '\'' + ", processStepVersion='" +
                processStepVersion + '\'' + ", processStepIdVersion='" + processStepIdVersion + '\'' +
                ", samplingGroupRrn=" + samplingGroupRrn + ", samplingGroupId='" + samplingGroupId + '\'' +
                ", samplingGroupSubRrn=" + samplingGroupSubRrn + ", skipFlag='" + skipFlag + '\'' + ", createUserId='" +
                createUserId + '\'' + ", createTimeSamp=" + createTimeSamp + '}';
    }

}