#
luxiaotao1123
2024-04-07 bda52da89628d1587ab804510f9995c671a318ca
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/model/protocol/ShuttleProtocol.java
@@ -1,14 +1,22 @@
package com.zy.asrs.wcs.rcs.model.protocol;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zy.asrs.framework.common.Cools;
import com.zy.asrs.framework.common.SpringUtils;
import com.zy.asrs.wcs.core.entity.Loc;
import com.zy.asrs.wcs.core.service.LocService;
import com.zy.asrs.wcs.core.utils.RedisUtil;
import com.zy.asrs.wcs.rcs.constant.DeviceRedisConstant;
import com.zy.asrs.wcs.rcs.model.enums.ShuttleDeviceStatusType;
import com.zy.asrs.wcs.rcs.model.enums.ShuttleProtocolStatusType;
import com.zy.asrs.wcs.rcs.entity.Device;
import com.zy.asrs.wcs.rcs.entity.ShuttleDeviceStatus;
import com.zy.asrs.wcs.rcs.model.enums.SlaveType;
import com.zy.asrs.wcs.rcs.service.ShuttleDeviceStatusService;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import java.util.HashMap;
/**
 * 四向穿梭车
@@ -21,12 +29,12 @@
    /**
     * 四向穿梭车号
     */
    private String shuttleNo;
    private Integer shuttleNo;
    /**
     * 任务号
     */
    private String taskNo;
    private Integer taskNo;
    /**
     * 当前小车状态(内部自我维护)
@@ -81,6 +89,11 @@
     * 是否顶升
     */
    private Boolean hasLift;
    /**
     * 是否有托盘
     */
    private Boolean hasPallet;
    /**
     * 行驶方向
@@ -155,6 +168,11 @@
    private Device device;
    /**
     * 扩展字段
     */
    private Object extend;
    /**
     * 设置小车状态
     */
    public void setProtocolStatus(Integer status) {
@@ -211,4 +229,45 @@
        return false;//默认不空闲
    }
    public Integer getTaskNo() {
        RedisUtil redisUtil = SpringUtils.getBean(RedisUtil.class);
        if (null != redisUtil) {
            Object o = redisUtil.get(DeviceRedisConstant.SHUTTLE_FLAG + this.shuttleNo);
            if (!Cools.isEmpty(o)) {
                this.taskNo = Integer.parseInt(String.valueOf(o));
            }
        }
        return this.taskNo == null ? 0 : this.taskNo;
    }
    public void setTaskNo(Integer taskNo) {
        RedisUtil redisUtil = SpringUtils.getBean(RedisUtil.class);
        if (null != redisUtil) {
            redisUtil.set(DeviceRedisConstant.SHUTTLE_FLAG + this.shuttleNo, taskNo);
            this.taskNo = taskNo;
        }
    }
    //通过当前二维码获取当前库位号
    public String getCurrentLocNo() {
        LocService locService = SpringUtils.getBean(LocService.class);
        if (locService == null) {
            return null;
        }
        if (this.currentCode == null) {
            return null;
        }
        //源库位(小车当前位置)
        LambdaQueryWrapper<Loc> wrapper = new LambdaQueryWrapper<Loc>()
                .eq(Loc::getCode, this.currentCode)
                .eq(Loc::getHostId, this.device.getHostId());
        Loc currentLoc = locService.getOne(wrapper);
        if (currentLoc == null) {
            return null;
        }
        return currentLoc.getLocNo();
    }
}