From dad3cd8ed8afa86b651bb1a053421e7aa2b8c7ac Mon Sep 17 00:00:00 2001
From: Junjie <540245094@qq.com>
Date: 星期日, 05 五月 2024 16:31:09 +0800
Subject: [PATCH] #

---
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/model/protocol/ShuttleProtocol.java |   96 +++++++++++++++++++++++++++++++++++-------------
 1 files changed, 70 insertions(+), 26 deletions(-)

diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/model/protocol/ShuttleProtocol.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/model/protocol/ShuttleProtocol.java
index b0ff291..619c409 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/model/protocol/ShuttleProtocol.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/model/protocol/ShuttleProtocol.java
@@ -3,9 +3,10 @@
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.zy.asrs.framework.common.Cools;
 import com.zy.asrs.framework.common.SpringUtils;
+import com.zy.asrs.wcs.core.entity.Loc;
+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;
@@ -18,13 +19,13 @@
  */
 @Slf4j
 @Data
-public class ShuttleProtocol {
+public class ShuttleProtocol implements Cloneable{
 
     //**********************蹇呴』瀛樺湪灞炴��**********************
     /**
      * 鍥涘悜绌挎杞﹀彿
      */
-    private String shuttleNo;
+    private Integer shuttleNo;
 
     /**
      * 浠诲姟鍙�
@@ -57,6 +58,11 @@
     private Integer deviceStatus;
 
     /**
+     * 灏忚溅妯″紡锛�0锛氭墜鍔� 1锛氳嚜鍔�
+     */
+    private Integer mode;
+
+    /**
      * 褰撳墠浜岀淮鐮�
      * 0涓虹┖
      */
@@ -84,6 +90,11 @@
      * 鏄惁椤跺崌
      */
     private Boolean hasLift;
+
+    /**
+     * 鏄惁鏈夋墭鐩�
+     */
+    private Boolean hasPallet;
 
     /**
      * 琛岄┒鏂瑰悜
@@ -153,9 +164,24 @@
     private Long deviceDataLog = System.currentTimeMillis();
 
     /**
+     * 鎸囦护涓嬪彂鏃堕棿
+     */
+    private Long sendTime = 0L;
+
+    /**
+     * 鏈�杩戜竴娆″湪绾挎椂闂�
+     */
+    private Long lastOnlineTime = System.currentTimeMillis();
+
+    /**
      * 璁惧淇℃伅
      */
     private Device device;
+
+    /**
+     * 鎵╁睍瀛楁
+     */
+    private Object extend;
 
     /**
      * 璁剧疆灏忚溅鐘舵��
@@ -192,32 +218,10 @@
         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) {
-            Object o = redisUtil.get(DeviceRedisConstant.SHUTTLE_FLAG + this.taskNo);
+            Object o = redisUtil.get(DeviceRedisConstant.SHUTTLE_FLAG + this.shuttleNo);
             if (!Cools.isEmpty(o)) {
                 this.taskNo = Integer.parseInt(String.valueOf(o));
             }
@@ -225,4 +229,44 @@
         return this.taskNo == null ? 0 : this.taskNo;
     }
 
+    public synchronized void setSyncTaskNo(Integer taskNo) {
+        RedisUtil redisUtil = SpringUtils.getBean(RedisUtil.class);
+        if (null != redisUtil) {
+            redisUtil.set(DeviceRedisConstant.SHUTTLE_FLAG + this.shuttleNo, taskNo);
+            this.taskNo = taskNo;
+        }
+    }
+
+    //閫氳繃褰撳墠浜岀淮鐮佽幏鍙栧綋鍓嶅簱浣嶅彿
+    public String getCurrentLocNo() {
+        LocService locService = SpringUtils.getBean(LocService.class);
+        if (locService == null) {
+            return null;
+        }
+        if (this.currentCode == null) {
+            return null;
+        }
+
+        //婧愬簱浣�(灏忚溅褰撳墠浣嶇疆)
+        LambdaQueryWrapper<Loc> wrapper = new LambdaQueryWrapper<Loc>()
+                .eq(Loc::getCode, this.currentCode)
+                .eq(Loc::getHostId, this.device.getHostId());
+        Loc currentLoc = locService.getOne(wrapper);
+        if (currentLoc == null) {
+            return null;
+        }
+
+        return currentLoc.getLocNo();
+    }
+
+    @Override
+    public ShuttleProtocol clone() {
+        try {
+            return (ShuttleProtocol) super.clone();
+        } catch (CloneNotSupportedException e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
 }

--
Gitblit v1.9.1