| | |
| | | package com.zy.core.model.protocol; |
| | | |
| | | import com.zy.core.enums.LiftProtocolStatusType; |
| | | import com.zy.core.model.command.LiftAssignCommand; |
| | | 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.*; |
| | | import lombok.Data; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | |
| | | */ |
| | | @Slf4j |
| | | @Data |
| | | public class LiftProtocol { |
| | | public class LiftProtocol implements Cloneable { |
| | | |
| | | /** |
| | | * 提升机号 |
| | | */ |
| | | private Short liftNo; |
| | | private Integer liftNo; |
| | | |
| | | /** |
| | | * 模式0手动 1单机 2联机 |
| | | */ |
| | | private Integer model; |
| | | |
| | | /** |
| | | * 任务号 |
| | | */ |
| | | private Short taskNo = 0; |
| | | private Integer taskNo = 0; |
| | | |
| | | /** |
| | | * 四向穿梭车号 |
| | | * PLC任务号 |
| | | */ |
| | | private Short shuttleNo = 0; |
| | | private Integer plcTaskNo; |
| | | |
| | | /** |
| | | * 当前提升机状态(内部自我维护) |
| | | * 任务状态 |
| | | */ |
| | | private Integer protocolStatus = 1; |
| | | private Integer protocolStatus = LiftProtocolStatusType.IDLE.id; |
| | | |
| | | /** |
| | | * 当前提升机状态枚举 |
| | | * 任务状态枚举 |
| | | */ |
| | | private LiftProtocolStatusType protocolStatusType = LiftProtocolStatusType.IDLE; |
| | | |
| | | /** |
| | | * 模式 |
| | | * 设备状态 |
| | | */ |
| | | private Boolean model; |
| | | private Integer deviceStatus = LiftDeviceStatusType.NONE.id; |
| | | |
| | | /** |
| | | * 忙闲 |
| | | * 设备状态枚举 |
| | | */ |
| | | private Boolean busy; |
| | | private LiftDeviceStatusType deviceStatusType = LiftDeviceStatusType.NONE; |
| | | |
| | | /** |
| | | * 前超限 |
| | | * 任务模式 |
| | | */ |
| | | private Boolean frontOverrun; |
| | | private Integer taskMode = LiftTaskModeType.NONE.id; |
| | | |
| | | /** |
| | | * 后超限 |
| | | * 任务模式枚举 |
| | | */ |
| | | private Boolean backOverrun; |
| | | private LiftTaskModeType modeType = LiftTaskModeType.NONE; |
| | | |
| | | /** |
| | | * 左超限 |
| | | * 取货数据 |
| | | */ |
| | | private Boolean leftOverrun; |
| | | private Integer pick; |
| | | |
| | | /** |
| | | * 右超限 |
| | | * 放货数据 |
| | | */ |
| | | private Boolean rightOverrun; |
| | | |
| | | /** |
| | | * 超高 |
| | | */ |
| | | private Boolean overHeight; |
| | | |
| | | /** |
| | | * 超重 |
| | | */ |
| | | private Boolean overWeight; |
| | | private Integer put; |
| | | |
| | | /** |
| | | * 有托盘 |
| | |
| | | private Boolean hasCar; |
| | | |
| | | /** |
| | | * 设备故障 |
| | | * 出入库模式 |
| | | */ |
| | | private Boolean deviceError; |
| | | private Integer iOMode = LiftIoModeType.NONE.id; |
| | | |
| | | /** |
| | | * 任务地址 |
| | | * 出入库模式枚举 |
| | | */ |
| | | private Short taskAddress; |
| | | private LiftIoModeType iOModeType = LiftIoModeType.NONE; |
| | | |
| | | /** |
| | | * 目的地址 |
| | | * 故障码 |
| | | */ |
| | | private Short distAddress; |
| | | private Integer errorCode; |
| | | |
| | | /** |
| | | * 已完成的任务号 |
| | | * 当前层 |
| | | */ |
| | | private Short completeTaskNo; |
| | | |
| | | /** |
| | | * 层 |
| | | */ |
| | | private Short lev; |
| | | private Integer lev; |
| | | |
| | | /** |
| | | * 作业标记 |
| | | */ |
| | | private Boolean pakMk = true; |
| | | private Boolean pakMk = false; |
| | | |
| | | /** |
| | | * 任务命令 |
| | | * 指令下发时间 |
| | | */ |
| | | private LiftAssignCommand assignCommand; |
| | | private Long sendTime = 0L; |
| | | |
| | | /** |
| | | * 设置提升机状态 |
| | | * 日志采集时间 |
| | | */ |
| | | private Long deviceDataLog = System.currentTimeMillis(); |
| | | |
| | | /** |
| | | * 扩展字段 |
| | | */ |
| | | private Object extend; |
| | | |
| | | /** |
| | | * 设置任务状态 |
| | | */ |
| | | public void setProtocolStatus(Integer status) { |
| | | this.protocolStatus = status; |
| | |
| | | } |
| | | |
| | | /** |
| | | * 设置提升机状态 |
| | | * 设置任务状态 |
| | | */ |
| | | public void setProtocolStatus(LiftProtocolStatusType status) { |
| | | this.protocolStatus = status.id; |
| | | 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; |
| | | } |
| | | |
| | | boolean res = (this.taskNo == 0 || this.taskNo.intValue() == taskNo.intValue()) |
| | | && !this.busy |
| | | && this.model |
| | | && this.pakMk.equals(true) |
| | | && !this.deviceError |
| | | ; |
| | | return res; |
| | | /** |
| | | * 设置任务模式 |
| | | */ |
| | | public void setTaskMode(Integer taskMode) { |
| | | this.taskMode = taskMode; |
| | | this.modeType = LiftTaskModeType.get(taskMode); |
| | | } |
| | | |
| | | // 是否处于空闲待命状态 |
| | | public Boolean isIdle() { |
| | | if(this.taskNo == null |
| | | || this.busy == null |
| | | || this.model == null |
| | | || this.deviceError == null |
| | | || this.pakMk == null |
| | | ){ |
| | | return false; |
| | | } |
| | | |
| | | boolean res = this.taskNo == 0 |
| | | && !this.busy |
| | | && this.model |
| | | && this.pakMk.equals(true) |
| | | && !this.deviceError |
| | | ; |
| | | return res; |
| | | /** |
| | | * 设置任务模式 |
| | | */ |
| | | public void setMode(LiftTaskModeType taskMode) { |
| | | this.taskMode = taskMode.id; |
| | | this.modeType = taskMode; |
| | | } |
| | | |
| | | // 是否处于空闲待命状态,不判断任务号 |
| | | public Boolean isIdleNoTask() { |
| | | if(this.taskNo == null |
| | | || this.busy == null |
| | | || this.model == null |
| | | || this.deviceError == null |
| | | || this.pakMk == null |
| | | ){ |
| | | return false; |
| | | /** |
| | | * 设置出入库模式 |
| | | */ |
| | | public void setIOMode(Integer ioMode) { |
| | | this.iOMode = ioMode; |
| | | this.iOModeType = LiftIoModeType.get(ioMode); |
| | | } |
| | | |
| | | /** |
| | | * 设置出入库模式 |
| | | */ |
| | | public void setIOMode(LiftIoModeType ioMode) { |
| | | this.iOMode = ioMode.id; |
| | | this.iOModeType = ioMode; |
| | | } |
| | | |
| | | /** |
| | | * 错误码 |
| | | */ |
| | | public String getErrCode$() { |
| | | if (this.errorCode == null) { |
| | | return ""; |
| | | } |
| | | BasLiftErrService basLiftErrService = SpringUtils.getBean(BasLiftErrService.class); |
| | | BasLiftErr basLiftErr = basLiftErrService.selectById(this.errorCode); |
| | | if (basLiftErr == null) { |
| | | return String.valueOf(this.errorCode); |
| | | } |
| | | return basLiftErr.getErrName(); |
| | | } |
| | | |
| | | 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.parseInt(String.valueOf(o)); |
| | | } |
| | | } |
| | | return this.taskNo == null ? 0 : this.taskNo; |
| | | } |
| | | |
| | | public synchronized void setSyncTaskNo(Integer taskNo) { |
| | | RedisUtil redisUtil = SpringUtils.getBean(RedisUtil.class); |
| | | if (null != redisUtil) { |
| | | redisUtil.set(RedisKeyType.LIFT_FLAG.key + this.liftNo, taskNo); |
| | | this.taskNo = taskNo; |
| | | } |
| | | } |
| | | |
| | | public String getModel$() { |
| | | if (this.model == null) { |
| | | return ""; |
| | | } |
| | | |
| | | boolean res = !this.busy |
| | | && this.model |
| | | && this.pakMk.equals(true) |
| | | && !this.deviceError |
| | | ; |
| | | return res; |
| | | String name = ""; |
| | | if (this.model == 0) { |
| | | name = "手动"; |
| | | } else if (this.model == 1) { |
| | | name = "单机"; |
| | | }else if (this.model == 2) { |
| | | name = "联机"; |
| | | } |
| | | return name; |
| | | } |
| | | |
| | | public String getProtocolStatus$() { |
| | | if (this.protocolStatus == null) { |
| | | return ""; |
| | | } |
| | | |
| | | return LiftProtocolStatusType.get(this.protocolStatus).desc; |
| | | } |
| | | |
| | | public String getDeviceStatus$() { |
| | | if (this.deviceStatus == null) { |
| | | return ""; |
| | | } |
| | | |
| | | return LiftDeviceStatusType.get(this.deviceStatus).desc; |
| | | } |
| | | |
| | | public String getTaskMode$() { |
| | | if (this.taskMode == null) { |
| | | return ""; |
| | | } |
| | | |
| | | return LiftTaskModeType.get(this.taskMode).desc; |
| | | } |
| | | |
| | | public String getIOMode$() { |
| | | if (this.iOMode == null) { |
| | | return ""; |
| | | } |
| | | |
| | | return LiftIoModeType.get(this.iOMode).desc; |
| | | } |
| | | |
| | | @Override |
| | | public LiftProtocol clone() { |
| | | try { |
| | | return (LiftProtocol) super.clone(); |
| | | } catch (CloneNotSupportedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |