|  |  |  | 
|---|
|  |  |  | import com.zy.asrs.wcs.core.service.LocService; | 
|---|
|  |  |  | import com.zy.asrs.wcs.core.utils.RedisUtil; | 
|---|
|  |  |  | import com.zy.asrs.wcs.rcs.constant.DeviceRedisConstant; | 
|---|
|  |  |  | 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.model.enums.SlaveType; | 
|---|
|  |  |  | import com.zy.asrs.wcs.rcs.service.ShuttleDeviceStatusService; | 
|---|
|  |  |  | import lombok.Data; | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.HashMap; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 四向穿梭车 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Slf4j | 
|---|
|  |  |  | @Data | 
|---|
|  |  |  | public class ShuttleProtocol { | 
|---|
|  |  |  | public class ShuttleProtocol implements Cloneable{ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //**********************必须存在属性********************** | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | * 小车设备状态 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private Integer deviceStatus; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 小车模式,0:手动 1:自动 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private Integer mode; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 当前二维码 | 
|---|
|  |  |  | 
|---|
|  |  |  | private Long deviceDataLog = System.currentTimeMillis(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 指令下发时间 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private Long sendTime = 0L; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 最近一次在线时间 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private Long lastOnlineTime = System.currentTimeMillis(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 设备信息 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private Device device; | 
|---|
|  |  |  | 
|---|
|  |  |  | 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;//默认不空闲 | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public Integer getTaskNo() { | 
|---|
|  |  |  | RedisUtil redisUtil = SpringUtils.getBean(RedisUtil.class); | 
|---|
|  |  |  | if (null != redisUtil) { | 
|---|
|  |  |  | 
|---|
|  |  |  | return this.taskNo == null ? 0 : this.taskNo; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public void setTaskNo(Integer taskNo) { | 
|---|
|  |  |  | public synchronized void setSyncTaskNo(Integer taskNo) { | 
|---|
|  |  |  | RedisUtil redisUtil = SpringUtils.getBean(RedisUtil.class); | 
|---|
|  |  |  | if (null != redisUtil) { | 
|---|
|  |  |  | redisUtil.set(DeviceRedisConstant.SHUTTLE_FLAG + this.shuttleNo, taskNo); | 
|---|
|  |  |  | 
|---|
|  |  |  | return currentLoc.getLocNo(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public ShuttleProtocol clone() { | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | return (ShuttleProtocol) super.clone(); | 
|---|
|  |  |  | } catch (CloneNotSupportedException e) { | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|