package com.zy.asrs.wcs.rcs.model.protocol;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.zy.asrs.framework.common.SpringUtils;
|
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.service.ShuttleDeviceStatusService;
|
import lombok.Data;
|
import lombok.extern.slf4j.Slf4j;
|
|
/**
|
* 四向穿梭车
|
*/
|
@Slf4j
|
@Data
|
public class ShuttleProtocol {
|
|
//**********************必须存在属性**********************
|
/**
|
* 四向穿梭车号
|
*/
|
private String shuttleNo;
|
|
/**
|
* 任务号
|
*/
|
private String taskNo;
|
|
/**
|
* 当前小车状态(内部自我维护)
|
*/
|
private Integer protocolStatus;
|
|
/**
|
* 当前小车作业状态枚举
|
*/
|
private ShuttleProtocolStatusType protocolStatusType;
|
|
/**
|
* 源库位
|
*/
|
private String sourceLocNo;
|
|
/**
|
* 目标库位
|
*/
|
private String locNo;
|
|
/**
|
* 小车设备状态
|
*/
|
private Integer deviceStatus;
|
|
/**
|
* 当前二维码
|
* 0为空
|
*/
|
private String currentCode;
|
|
/**
|
* 电池电量
|
*/
|
private String batteryPower;
|
|
/**
|
* 错误编号
|
*/
|
private String errorCode;
|
|
|
//**********************非必须属性,实际使用中可能存在空值**********************
|
|
/**
|
* 电池温度
|
*/
|
private String batteryTemp;
|
|
/**
|
* 是否顶升
|
*/
|
private Boolean hasLift;
|
|
/**
|
* 行驶方向
|
*/
|
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 Device device;
|
|
/**
|
* 设置小车状态
|
*/
|
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 String getDeviceStatus$() {
|
if (this.deviceStatus == null) {
|
return "";
|
}
|
ShuttleDeviceStatusService shuttleDeviceStatusService = SpringUtils.getBean(ShuttleDeviceStatusService.class);
|
ShuttleDeviceStatus status = shuttleDeviceStatusService.getOne(new LambdaQueryWrapper<ShuttleDeviceStatus>()
|
.eq(ShuttleDeviceStatus::getHostId, this.device.getHostId())
|
.eq(ShuttleDeviceStatus::getDevicePlc, this.device.getDevicePlc())
|
.eq(ShuttleDeviceStatus::getStatus, 1)
|
.eq(ShuttleDeviceStatus::getDeviceStatus, this.deviceStatus));
|
if (status != null) {
|
return status.getName();
|
}
|
return "";
|
}
|
|
/**
|
* 获取小车空闲状态
|
*/
|
public Boolean getIdle() {
|
if (this.deviceStatus == null) {
|
return false;
|
}
|
|
ShuttleDeviceStatusService shuttleDeviceStatusService = SpringUtils.getBean(ShuttleDeviceStatusService.class);
|
ShuttleDeviceStatus status = shuttleDeviceStatusService.getOne(new LambdaQueryWrapper<ShuttleDeviceStatus>()
|
.eq(ShuttleDeviceStatus::getHostId, this.device.getHostId())
|
.eq(ShuttleDeviceStatus::getDevicePlc, this.device.getDevicePlc())
|
.eq(ShuttleDeviceStatus::getStatus, 1)
|
.eq(ShuttleDeviceStatus::getDeviceStatus, this.deviceStatus));
|
if (status != null) {
|
if (status.getFlag() != null && status.getFlag().equals(String.valueOf(ShuttleDeviceStatusType.IDLE))) {
|
return true;//空闲中
|
}
|
}
|
return false;//默认不空闲
|
}
|
|
}
|