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.*; import lombok.Data; import lombok.extern.slf4j.Slf4j; /** * 提升机 */ @Slf4j @Data public class LiftProtocol implements Cloneable { /** * 提升机号 */ private Integer liftNo; /** * 模式0手动 1单机 2联机 */ private Integer model; /** * 任务号 */ private Integer taskNo = 0; /** * PLC任务号 */ private Integer plcTaskNo; /** * 任务状态 */ private Integer protocolStatus = LiftProtocolStatusType.IDLE.id; /** * 任务状态枚举 */ private LiftProtocolStatusType protocolStatusType = LiftProtocolStatusType.IDLE; /** * 设备状态 */ private Integer deviceStatus = LiftDeviceStatusType.NONE.id; /** * 设备状态枚举 */ private LiftDeviceStatusType deviceStatusType = LiftDeviceStatusType.NONE; /** * 任务模式 */ private Integer taskMode = LiftTaskModeType.NONE.id; /** * 任务模式枚举 */ private LiftTaskModeType modeType = LiftTaskModeType.NONE; /** * 取货数据 */ private Integer pick; /** * 放货数据 */ private Integer put; /** * 有托盘 */ private Boolean hasTray; /** * 有小车 */ private Boolean hasCar; /** * 出入库模式 */ private Integer iOMode = LiftIoModeType.NONE.id; /** * 出入库模式枚举 */ private LiftIoModeType iOModeType = LiftIoModeType.NONE; /** * 故障码 */ private Integer errorCode; /** * 当前层 */ private Integer lev; /** * 作业标记 */ private Boolean pakMk = false; /** * 指令下发时间 */ private Long sendTime = 0L; /** * 日志采集时间 */ private Long deviceDataLog = System.currentTimeMillis(); /** * 扩展字段 */ private Object extend; /** * 设置任务状态 */ public void setProtocolStatus(Integer status) { this.protocolStatus = status; this.protocolStatusType = LiftProtocolStatusType.get(status); } /** * 设置任务状态 */ public void setProtocolStatus(LiftProtocolStatusType status) { this.protocolStatus = status.id; this.protocolStatusType = status; } /** * 设置任务模式 */ public void setTaskMode(Integer taskMode) { this.taskMode = taskMode; this.modeType = LiftTaskModeType.get(taskMode); } /** * 设置任务模式 */ public void setMode(LiftTaskModeType taskMode) { this.taskMode = taskMode.id; this.modeType = taskMode; } /** * 设置出入库模式 */ 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 ""; } 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; } }