RobotDomain.java 2.24 KB
package com.huaheng.api.acs.domain;

import com.huaheng.common.exception.service.ServiceException;
import com.huaheng.common.utils.StringUtils;
import lombok.Data;

import java.math.BigDecimal;

/***
 * 商片二楼机械人码垛入参
 *
 */
@Data
public class RobotDomain {
    /**
     * 容器
     */
    private String containerCode;
    /**
     * 位置
     */
    private Integer position;
    /**
     * 垛型
     */
    // 
    private Integer stackType;
    /**
     * 子托盘高度
     */
    private Integer height;
    /**
     * 结束标志
     */
    private Integer finish;
    /**
     * 条码
     */
    private String allCode;

    public Integer getBoxType(){
        return stackType == null ? null :stackType / 100;
    }

    /***
     * 垛型数量
     * @return
     */
    public Integer getStackTypeTotal(){
        return stackType == null ? null :stackType % 100;
    }

    public String getMaterialCode(){
        String materialCode = null;
        if(StringUtils.isNotEmpty(allCode) && !allCode.contains("NoRead")){
            String[] materialInfo = allCode.split(" ");
            if(materialInfo.length < 3){
                throw new ServiceException("条码格式不对:"+allCode);
            }
            materialCode = materialInfo[0];
        }else{
            throw new ServiceException("条码为空或未读取到数据:"+allCode);
        }
        return materialCode;
    }

    public BigDecimal getQty(){
        BigDecimal qty = BigDecimal.ZERO;
        if(StringUtils.isNotEmpty(allCode) && !allCode.contains("NoRead")){
            String[] materialInfo = allCode.split(" ");
            if(materialInfo.length < 3){
                throw new ServiceException("条码格式不对:"+allCode);
            }
            qty.add(BigDecimal.valueOf(Integer.valueOf(materialInfo[1])));
        }
        return qty;
    }

    public String getLot(){
        String lot = null;
        if(StringUtils.isNotEmpty(allCode) && !allCode.contains("NoRead")){
            String[] materialInfo = allCode.split(" ");
            if(materialInfo.length < 3){
                throw new ServiceException("条码格式不对:"+allCode);
            }
            lot = materialInfo[2];
        }
        return lot;
    }
    
}