package com.zy.core.model.protocol;
|
|
import com.core.common.Cools;
|
import com.core.common.SpringUtils;
|
import com.zy.asrs.entity.BasShuttleErr;
|
import com.zy.asrs.entity.LocMast;
|
import com.zy.asrs.service.BasShuttleErrService;
|
import com.zy.asrs.service.LocMastService;
|
import com.zy.common.utils.RedisUtil;
|
import com.zy.core.enums.RedisKeyType;
|
import com.zy.core.enums.ShuttleProtocolStatusType;
|
import lombok.Data;
|
import lombok.extern.slf4j.Slf4j;
|
|
/**
|
* 四向穿梭车
|
*/
|
@Slf4j
|
@Data
|
public class ShuttleProtocol implements Cloneable {
|
|
//**********************必须存在属性**********************
|
/**
|
* 四向穿梭车号
|
*/
|
private Integer shuttleNo;
|
|
/**
|
* 任务号
|
*/
|
private Integer taskNo;
|
|
/**
|
* 当前小车状态(内部自我维护)
|
*/
|
private Integer protocolStatus;
|
|
/**
|
* 当前小车作业状态枚举
|
*/
|
private ShuttleProtocolStatusType protocolStatusType;
|
|
/**
|
* 源库位
|
*/
|
private String sourceLocNo;
|
|
/**
|
* 目标库位
|
*/
|
private String locNo;
|
|
/**
|
* 小车设备状态
|
*/
|
private Integer deviceStatus;
|
|
/**
|
* 小车模式,0:手动 1:自动
|
*/
|
private Integer mode;
|
|
/**
|
* 当前二维码
|
* 0为空
|
*/
|
private String currentCode;
|
|
/**
|
* 电池电量
|
*/
|
private String batteryPower;
|
|
/**
|
* 错误编号
|
*/
|
private String errorCode;
|
|
|
//**********************非必须属性,实际使用中可能存在空值**********************
|
|
/**
|
* 电池温度
|
*/
|
private String batteryTemp;
|
|
/**
|
* 是否顶升
|
*/
|
private Boolean hasLift;
|
|
/**
|
* 是否有托盘
|
*/
|
private Boolean hasPallet;
|
|
/**
|
* 行驶方向
|
*/
|
private String runDirection;
|
|
/**
|
* 是否为充电状态
|
*/
|
private Boolean hasCharge;
|
|
/**
|
* 电池电压
|
*/
|
private Integer batteryVoltage;
|
|
|
//**********************系统自身所需属性**********************
|
/**
|
* 作业标记 false表示正在作业
|
*/
|
private Boolean pakMk = true;
|
|
/**
|
* 跑库状态
|
*/
|
private Boolean moveLoc = false;
|
|
/**
|
* 跑库类型,0:跑轨道,1:跑库位
|
*/
|
private Integer moveType = 0;
|
|
/**
|
* 跑库X起点
|
*/
|
private Integer xStart = 0;
|
|
/**
|
* 跑库X终点
|
*/
|
private Integer xTarget = 0;
|
|
/**
|
* 跑库X当前点位
|
*/
|
private Integer xCurrent = 0;
|
|
/**
|
* 跑库Y起点
|
*/
|
private Integer yStart = 0;
|
|
/**
|
* 跑库Y终点
|
*/
|
private Integer yTarget = 0;
|
|
/**
|
* 跑库Y当前点位
|
*/
|
private Integer yCurrent = 0;
|
|
/**
|
* 日志采集时间
|
*/
|
private Long deviceDataLog = System.currentTimeMillis();
|
|
/**
|
* 指令下发时间
|
*/
|
private Long sendTime = 0L;
|
|
/**
|
* 最近一次在线时间
|
*/
|
private Long lastOnlineTime = System.currentTimeMillis();
|
|
/**
|
* 扩展字段
|
*/
|
private Object extend;
|
|
/**
|
* 设置小车状态
|
*/
|
public void setProtocolStatus(Integer status) {
|
this.protocolStatus = status;
|
this.protocolStatusType = ShuttleProtocolStatusType.get(status);
|
}
|
|
/**
|
* 设置小车状态
|
*/
|
public void setProtocolStatus(ShuttleProtocolStatusType status) {
|
this.protocolStatus = status.id;
|
this.protocolStatusType = status;
|
}
|
|
public Integer getTaskNo() {
|
RedisUtil redisUtil = SpringUtils.getBean(RedisUtil.class);
|
if (null != redisUtil) {
|
Object o = redisUtil.get(RedisKeyType.SHUTTLE_FLAG.key + this.shuttleNo);
|
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.SHUTTLE_FLAG.key + this.shuttleNo, taskNo);
|
this.taskNo = taskNo;
|
}
|
}
|
|
@Override
|
public ShuttleProtocol clone() {
|
try {
|
return (ShuttleProtocol) super.clone();
|
} catch (CloneNotSupportedException e) {
|
e.printStackTrace();
|
}
|
return null;
|
}
|
|
//通过当前二维码获取当前库位号
|
public String getCurrentLocNo() {
|
LocMastService locMastService = SpringUtils.getBean(LocMastService.class);
|
if (locMastService == null) {
|
return null;
|
}
|
//源库位(小车当前位置)
|
LocMast currentLocMast = locMastService.queryByQrCode(this.currentCode);
|
if (currentLocMast == null) {
|
return null;
|
}
|
return currentLocMast.getLocNo();
|
}
|
|
public String getStatusErrorCode$() {
|
BasShuttleErrService basShuttleErrService = SpringUtils.getBean(BasShuttleErrService.class);
|
if (this.errorCode == null) {
|
return "";
|
}
|
BasShuttleErr basShuttleErr = basShuttleErrService.queryByCode(Integer.valueOf(this.errorCode));
|
if (basShuttleErr == null) {
|
return this.errorCode;
|
}
|
return basShuttleErr.getErrName();
|
}
|
|
}
|