自动化立体仓库 - WCS系统
Junjie
2023-04-14 95acbc65a8f55ac54a631a149f50192b085d5ad9
src/main/java/com/zy/core/model/protocol/ShuttleProtocol.java
@@ -1,7 +1,11 @@
package com.zy.core.model.protocol;
import com.core.common.SpringUtils;
import com.zy.asrs.entity.BasDevp;
import com.zy.asrs.entity.BasShuttleErr;
import com.zy.asrs.entity.LocMast;
import com.zy.asrs.service.BasDevpService;
import com.zy.asrs.service.BasShuttleErrService;
import com.zy.asrs.service.BasShuttleService;
import com.zy.asrs.service.LocMastService;
import com.zy.core.News;
@@ -96,6 +100,26 @@
     * Plc输出状态IO
     */
    private Short plcOutputStatusIO;
    /**
     * Plc输出状态IO-顶升位
     */
    private Boolean plcOutputLift;
    /**
     * Plc输出状态IO-换向位
     */
    private Boolean plcOutputTransfer;
    /**
     * Plc输出状态IO-抱闸位
     */
    private Boolean plcOutputBrake;
    /**
     * Plc输出状态IO-充电位
     */
    private Boolean plcOutputCharge;
    /**
     * 错误信息码
@@ -230,6 +254,48 @@
        }
    }
    // 是否处于空闲待命状态,传入的taskNo和当前taskNo相同时允许放行
    public Boolean isIdle(Short taskNo) {
        boolean res = this.busyStatusType.equals(ShuttleStatusType.IDLE)
                && this.pakMk.equals(true)
                && this.errorCodeType.equals(ShuttleErrorCodeType.NORMAL)
                && (this.taskNo == 0 || this.taskNo == taskNo)
                ;
        if (!res) {
            return res;
        } else {
            // 电量
            try {
                Integer chargeLine = SpringUtils.getBean(BasShuttleService.class).selectById(this.shuttleNo).getChargeLine();
                return this.getBatteryPower$() > chargeLine;
            } catch (Exception e) {
                News.error("fail", e);
                return false;
            }
        }
    }
    // 是否满足充电状态
    public Boolean isRequireCharge() {
        boolean res = this.busyStatusType.equals(ShuttleStatusType.IDLE)
                && this.pakMk.equals(true)
                && this.errorCodeType.equals(ShuttleErrorCodeType.NORMAL)
                && this.taskNo == 0
                ;
        if (!res) {
            return res;
        } else {
            // 电量小于阈值或电压小于48V,需要进行充电
            try {
                Integer chargeLine = SpringUtils.getBean(BasShuttleService.class).selectById(this.shuttleNo).getChargeLine();
                return this.getBatteryPower$() < chargeLine || this.currentVoltage < 480;
            } catch (Exception e) {
                News.error("fail", e);
                return false;
            }
        }
    }
    //通过当前二维码获取当前库位号
    public String getCurrentLocNo() {
        LocMastService locMastService = SpringUtils.getBean(LocMastService.class);
@@ -244,4 +310,33 @@
        return currentLocMast.getLocNo();
    }
    public String getStatusErrorCode$() {
        BasShuttleErrService basShuttleErrService = SpringUtils.getBean(BasShuttleErrService.class);
        BasShuttleErr basShuttleErr = basShuttleErrService.queryByCode(this.statusErrorCode.intValue());
        if (basShuttleErr == null) {
            return null;
        }
        return basShuttleErr.getErrName();
    }
    public void setCurrentCode(Short currentCode) {
        this.currentCode = currentCode;
        LocMastService locMastService = SpringUtils.getBean(LocMastService.class);
        if (locMastService != null) {
            LocMast locMast = locMastService.queryByQrCode(currentCode.toString());
            if (locMast == null) {
                //查不到库位号,查询是否为站点
                BasDevpService basDevpService = SpringUtils.getBean(BasDevpService.class);
                if (basDevpService != null) {
                    BasDevp basDevp = basDevpService.queryByLocNo(currentCode.toString());
                    if (basDevp != null) {
                        this.locNo = basDevp.getLocNo();
                    }
                }
            }else{
                this.locNo = locMast.getLocNo();
            }
        }
    }
}