fyxc
2025-05-22 09fcc4ec56a1ce6c0fcb308348d8dd5e2c08d336
src/main/java/com/zy/core/model/protocol/LiftProtocol.java
@@ -1,51 +1,59 @@
package com.zy.core.model.protocol;
import com.core.common.Cools;
import com.core.common.SpringUtils;
import com.zy.asrs.entity.BasLiftErr;
import com.zy.asrs.service.BasLiftErrService;
import com.zy.common.utils.RedisUtil;
import com.zy.core.enums.LiftProtocolStatusType;
import com.zy.core.model.command.LiftAssignCommand;
import com.zy.core.enums.RedisKeyType;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
/**
 * 提升机
 */
@Slf4j
@Data
public class LiftProtocol {
public class LiftProtocol implements Cloneable {
    //**********************必须存在属性**********************
    /**
     * 提升机号
     */
    private Short liftNo;
    private Integer liftNo;
    /**
     * 任务号
     */
    private Short taskNo = 0;
    private Integer taskNo;
    /**
     * 四向穿梭车号
     */
    private Short shuttleNo = 0;
    private Integer shuttleNo = 0;
    /**
     * 当前提升机状态(内部自我维护)
     */
    private Integer protocolStatus = 1;
    private Integer protocolStatus = -1;
    /**
     * 当前提升机状态枚举
     */
    private LiftProtocolStatusType protocolStatusType = LiftProtocolStatusType.IDLE;
    private LiftProtocolStatusType protocolStatusType = LiftProtocolStatusType.NONE;
    /**
     * 模式
     * 模式 => 自动/手动
     */
    private Boolean model;
    /**
     * 忙闲
     * 运行状态
     */
    private Boolean busy;
    private Boolean run;
    /**
     * 就绪状态
     */
    private Boolean ready;
    /**
     * 前超限
@@ -88,9 +96,14 @@
    private Boolean hasCar;
    /**
     * 设备故障
     * 故障
     */
    private Boolean deviceError;
    private Boolean error;
    /**
     * 故障码
     */
    private String errorCode;
    /**
     * 任务地址
@@ -105,22 +118,128 @@
    /**
     * 已完成的任务号
     */
    private Short completeTaskNo;
    private String completeTaskNo;
    /**
     * 层
     */
    private Short lev;
    private Integer lev;
    /**
     * 作业标记
     */
    private Boolean pakMk = false;
    private Boolean pakMk = true;
    /**
     * 任务命令
     * 指令下发时间
     */
    private LiftAssignCommand assignCommand;
    private Long sendTime = 0L;
    /**
     * 日志采集时间
     */
    private Long deviceDataLog = System.currentTimeMillis();
    /**
     * 扩展字段
     */
    private Object extend;
    public String getRun$() {
        if (this.run == null) {
            return "未知";
        }
        return this.run ? "运行中" : "空闲";
    }
    public String getReady$() {
        if (this.ready == null) {
            return "未知";
        }
        return this.ready ? "就绪" : "未就绪";
    }
    public String getModel$() {
        if (this.model == null) {
            return "未知";
        }
        return this.model ? "自动" : "手动";
    }
    public String getHasTray$() {
        if (this.hasTray == null) {
            return "未知";
        }
        return this.hasTray ? "Y" : "N";
    }
    public String getHasCar$() {
        if (this.hasCar == null) {
            return "未知";
        }
        return this.hasCar ? "Y" : "N";
    }
    public String getFrontOverrun$() {
        if (this.frontOverrun == null) {
            return "未知";
        }
        return this.frontOverrun ? "Y" : "N";
    }
    public String getBackOverrun$() {
        if (this.backOverrun == null) {
            return "未知";
        }
        return this.backOverrun ? "Y" : "N";
    }
    public String getLeftOverrun$() {
        if (this.leftOverrun == null) {
            return "未知";
        }
        return this.leftOverrun ? "Y" : "N";
    }
    public String getRightOverrun$() {
        if (this.rightOverrun == null) {
            return "未知";
        }
        return this.rightOverrun ? "Y" : "N";
    }
    public String getOverHeight$() {
        if (this.overHeight == null) {
            return "未知";
        }
        return this.overHeight ? "Y" : "N";
    }
    public String getOverWeight$() {
        if (this.overWeight == null) {
            return "未知";
        }
        return this.overWeight ? "Y" : "N";
    }
    public String getProtocolStatus$() {
        if (this.protocolStatusType == null) {
            return "未知";
        }
        return this.protocolStatusType.desc;
    }
    /**
     * 设置提升机状态
@@ -138,64 +257,48 @@
        this.protocolStatusType = status;
    }
    // 是否处于空闲待命状态
    public Boolean isIdle(Short taskNo) {
        if(this.taskNo == null
                || this.busy == null
                || this.model == null
                || this.deviceError == null
                || this.pakMk == null
        ){
            return false;
    public synchronized void setTaskNo(Integer taskNo) {
        RedisUtil redisUtil = SpringUtils.getBean(RedisUtil.class);
        if (null != redisUtil) {
            redisUtil.set(RedisKeyType.LIFT_FLAG.key + this.liftNo, taskNo);
            this.taskNo = taskNo;
        }
        boolean res = (this.taskNo == 0 || this.taskNo.intValue() == taskNo.intValue())
                && !this.busy
                && this.model
                && !this.pakMk
                && !this.deviceError
                ;
        return res;
    }
    // 是否处于空闲待命状态
    public Boolean isIdle() {
        if(this.taskNo == null
                || this.busy == null
                || this.model == null
                || this.deviceError == null
                || this.pakMk == null
        ){
            return false;
    public Integer getTaskNo() {
        RedisUtil redisUtil = SpringUtils.getBean(RedisUtil.class);
        if (null != redisUtil) {
            Object o = redisUtil.get(RedisKeyType.LIFT_FLAG.key + this.liftNo);
            if (!Cools.isEmpty(o)) {
                this.taskNo = Integer.valueOf(String.valueOf(o));
            }
        }
        boolean res = this.taskNo == 0
                && !this.busy
                && this.model
                && !this.pakMk
                && !this.deviceError
                ;
        return res;
        return this.taskNo == null ? 0 : this.taskNo;
    }
    // 是否处于空闲待命状态,不判断任务号
    public Boolean isIdleNoTask() {
        if(this.taskNo == null
                || this.busy == null
                || this.model == null
                || this.deviceError == null
                || this.pakMk == null
        ){
            return false;
    /**
     * 错误码
     */
    public String getErrCode$() {
        if (this.errorCode == null) {
            return "";
        }
        boolean res = !this.busy
                && this.model
                && !this.pakMk
                && !this.deviceError
                ;
        return res;
        BasLiftErrService basLiftErrService = SpringUtils.getBean(BasLiftErrService.class);
        BasLiftErr basLiftErr = basLiftErrService.selectById(this.errorCode);
        if (basLiftErr == null) {
            return String.valueOf(this.errorCode);
        }
        return basLiftErr.getErrName();
    }
    @Override
    public LiftProtocol clone() {
        try {
            return (LiftProtocol) super.clone();
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
        return null;
    }
}