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

import cn.estsh.i3plus.ext.mes.pcn.pojo.bean.MesManageCode;
import cn.estsh.i3plus.ext.mes.pcn.pojo.bean.MesProduceSnExt;
import cn.estsh.i3plus.ext.mes.pcn.pojo.bean.MesProduceSnMcRecord;
import cn.estsh.i3plus.ext.mes.pcn.pojo.bean.MesWorkCenterExt;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.WorkOrderExtModel;
import cn.estsh.i3plus.pojo.mes.bean.MesPart;
import lombok.Data;
import org.springframework.util.StringUtils;

import java.io.Serializable;

/**
 * @Author: wangjie
 * @CreateDate: 2021/01/18 11:41 上午
 * @Description: 产品条码业务策略实现参数构建器
 **/
@Data
public class JxProdBusiStrategyParamsBuilder implements Serializable {

    private static final long serialVersionUID = 2545853707952640078L;

    private String organizeCode;

    private String scanInfo;

    private String scanName;

    private String manageCode;

    private String serialNumber;

    private String productSn;

    private String userInfo;

    private String workCenterCode;

    private String workCellCode;

    private MesManageCode manageCodeDb;

    private MesProduceSnMcRecord produceSnMcRecordDb;

    private MesWorkCenterExt workCenterExtDb;

    private WorkOrderExtModel orderModel;

    private MesProduceSnExt produceSnExtDb;

    private MesPart partDb;

    private Object strategyService;

    private String routeCode;

    private String processCode;

    private String lockContent;

    private Object obj;

    public static class builder {

        JxProdBusiStrategyParamsBuilder params = new JxProdBusiStrategyParamsBuilder();

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

        public builder scanInfo(String scanInfo) {
            params.scanInfo = scanInfo;
            return this;
        }

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

        public builder serialNumber(String serialNumber) {
            params.serialNumber = serialNumber;
            return this;
        }

        public builder productSn(String productSn) {
            params.productSn = productSn;
            return this;
        }

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

        public builder location(String workCenterCode, String workCellCode) {
            params.workCenterCode = workCenterCode;
            params.workCellCode = workCellCode;
            return this;
        }

        public builder orderModel(WorkOrderExtModel orderModel) {
            params.orderModel = orderModel;
            return this;
        }

        public builder workCenterExtDb(MesWorkCenterExt workCenterExtDb) {
            params.workCenterExtDb = workCenterExtDb;
            return this;
        }

        public builder partDb(MesPart partDb) {
            params.partDb = partDb;
            return this;
        }

        public builder strategyService(Object strategyService) {
            params.strategyService = strategyService;
            return this;
        }

        public builder routeProcess(String routeCode, String processCode) {
            params.routeCode = routeCode;
            params.processCode = processCode;
            return this;
        }

        public builder lockContent(String lockContent) {
            params.lockContent = lockContent;
            return this;
        }

        public builder produceSnExtDb(MesProduceSnExt produceSnExtDb) {
            params.produceSnExtDb = produceSnExtDb;
            return this;
        }

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

        public JxProdBusiStrategyParamsBuilder build() {
            return params;
        }

    }

    public JxProdBusiStrategyParamsBuilder manageCodeDb(MesManageCode manageCodeDb) {
        this.manageCodeDb = manageCodeDb;
        return this;
    }

    public JxProdBusiStrategyParamsBuilder produceSnMcRecordDb(MesProduceSnMcRecord produceSnMcRecordDb) {
        this.produceSnMcRecordDb = produceSnMcRecordDb;
        return this;
    }

    public JxProdBusiStrategyParamsBuilder produceSnExtDb(MesProduceSnExt produceSnExtDb) {
        this.produceSnExtDb = produceSnExtDb;
        return this;
    }

    public JxProdBusiStrategyParamsBuilder workCenterExtDb(MesWorkCenterExt workCenterExtDb) {
        this.workCenterExtDb = workCenterExtDb;
        return this;
    }

    public JxProdBusiStrategyParamsBuilder manageCode() {
        this.manageCode = null;
        return this;
    }

    public JxProdBusiStrategyParamsBuilder manageCode(String manageCode) {
        if (!StringUtils.isEmpty(manageCode)) this.manageCode = manageCode;
        return this;
    }

    public JxProdBusiStrategyParamsBuilder sn() {
        this.serialNumber = null;
        this.productSn = null;
        return this;
    }

    public JxProdBusiStrategyParamsBuilder sn(String serialNumber, String productSn) {
        if (!StringUtils.isEmpty(serialNumber)) this.serialNumber = serialNumber;
        if (!StringUtils.isEmpty(productSn)) this.productSn = productSn;
        return this;
    }

    public JxProdBusiStrategyParamsBuilder serialNumber(String serialNumber) {
        if (!StringUtils.isEmpty(serialNumber)) this.serialNumber = serialNumber;
        return this;
    }

    public JxProdBusiStrategyParamsBuilder productSn(String productSn) {
        if (!StringUtils.isEmpty(productSn)) this.productSn = productSn;
        return this;
    }

    public JxProdBusiStrategyParamsBuilder scanName() {
        if (!StringUtils.isEmpty(manageCode) && this.scanInfo.equals(manageCode)) this.scanName = "管理编码";
        else if (!StringUtils.isEmpty(productSn) && this.scanInfo.equals(productSn)) this.scanName = "产品条码";
        else this.scanName = "扫描信息";
        return this;
    }

}