From f11ce451cef38b58a189e92d943566282e6a316c Mon Sep 17 00:00:00 2001
From: zjj <3272660260@qq.com>
Date: 星期三, 19 六月 2024 09:48:33 +0800
Subject: [PATCH] #

---
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/model/protocol/LiftProtocol.java        |    2 
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/command/LiftCommandService.java |    4 
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/action/LiftAction.java                 |   38 ++++++++++--
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/NyLiftThread.java           |   38 +++++++++++-
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SurayLiftThread.java        |   39 +++++++++++-
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/LiftThread.java                  |    4 +
 6 files changed, 105 insertions(+), 20 deletions(-)

diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/action/LiftAction.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/action/LiftAction.java
index 49dbbc6..c8c57b0 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/action/LiftAction.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/action/LiftAction.java
@@ -8,7 +8,7 @@
 import com.zy.asrs.wcs.rcs.cache.SlaveConnection;
 import com.zy.asrs.wcs.rcs.constant.DeviceRedisConstant;
 import com.zy.asrs.wcs.rcs.entity.Device;
-import com.zy.asrs.wcs.rcs.model.enums.ShuttleProtocolStatusType;
+import com.zy.asrs.wcs.rcs.model.enums.LiftProtocolStatusType;
 import com.zy.asrs.wcs.rcs.model.enums.SlaveType;
 import com.zy.asrs.wcs.rcs.model.protocol.LiftProtocol;
 import com.zy.asrs.wcs.rcs.thread.LiftThread;
@@ -69,7 +69,7 @@
         }
 
         //鍒ゆ柇鎻愬崌鏈烘槸鍚︾┖闂�
-        if (!liftThread.isIdle()) {
+        if (!liftThread.isDeviceIdle()) {
             return false;
         }
 
@@ -83,22 +83,39 @@
 
         if (commandStep != 0) {
             LiftCommand command = commands.get(commandStep - 1);
-
-            //鐩墠娌℃湁鍒ゆ柇锛岀洿鎺ュ垽瀹氫笂涓�鏉℃寚浠ゅ畬鎴�
-            command.setComplete(true);
+            if (command.getMode() == LiftCommandModeType.MOVE.id) {
+                //鎻愬崌鏈哄崌闄�
+                if (liftProtocol.getLev() == command.getTargetLev()) {
+                    command.setComplete(true);
+                }
+            } else if (command.getMode() == LiftCommandModeType.MOVE_CAR.id) {
+                //鎻愬崌鏈哄崌闄嶅皬杞�
+                if (liftProtocol.getLev() == command.getTargetLev()) {
+                    command.setComplete(true);
+                }
+            } else if (command.getMode() == LiftCommandModeType.PALLET_INOUT.id) {
+                //鎵樼洏鍑哄叆
+                if (liftProtocol.getLev() == command.getTargetLev()) {
+                    command.setComplete(true);
+                }
+            }
 
             // 鏇存柊redis鏁版嵁
-            redisUtil.set(DeviceRedisConstant.LIFT_WORK_FLAG + redisCommand.getWrkNo(), JSON.toJSONString(redisCommand));
+            redisUtil.set(DeviceRedisConstant.LIFT_WORK_FLAG + taskNo, JSON.toJSONString(redisCommand));
 
             if (!command.getComplete()) {
                 return false;
             }
 
-
             //鍒ゆ柇鏄惁涓烘渶鍚庝竴鏉″懡浠や笖鍛戒护鎵ц瀹屾垚锛屾姏鍑虹瓑寰呯‘璁ょ姸鎬�
             LiftCommand endCommand = commands.get(commands.size() - 1);
             if (endCommand.getComplete()) {
                 News.info("鎻愬崌鏈轰换鍔℃墽琛屼笅鍙戝畬鎴愮瓑寰呮墽琛岀粨鏉燂紝鎻愬崌鏈哄彿={}锛屼换鍔℃暟鎹�={}", liftProtocol.getLiftNo(), JSON.toJSON(commands));
+
+                //瀵逛富绾跨▼鎶涘嚭绛夊緟纭鐘舵�亀aiting
+                liftThread.setProtocolStatus(LiftProtocolStatusType.WAITING);
+                liftThread.commandFinished(taskNo);//璋冪敤瀹屾垚鍚庣画鎸囦护(閮ㄥ垎鎻愬崌鏈烘湁鍚庣画鎸囦护锛屽疄闄呮儏鍐电湅鏄惁鏈夌湡姝e疄鐜版柟娉�)
+                redisUtil.del(DeviceRedisConstant.LIFT_WORK_FLAG + taskNo);
                 return false;//绂佹鍐嶄笅鍙戝懡浠�
             }
         }
@@ -114,7 +131,12 @@
             News.info("鎻愬崌鏈哄懡浠や笅鍙戞垚鍔燂紝鎻愬崌鏈哄彿={}锛屼换鍔℃暟鎹�={}", command.getLiftNo(), JSON.toJSON(command));
         }
 
-        redisUtil.del(DeviceRedisConstant.LIFT_WORK_FLAG + command.getTaskNo());
+        liftThread.setProtocolStatus(LiftProtocolStatusType.WORKING);
+        commandStep++;
+        //鏇存柊redis鏁版嵁
+        redisCommand.setCommandStep(commandStep);
+        // 鏇存柊redis鏁版嵁
+        redisUtil.set(DeviceRedisConstant.LIFT_WORK_FLAG + taskNo, JSON.toJSONString(redisCommand));
         return true;
     }
 
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/command/LiftCommandService.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/command/LiftCommandService.java
index c1cb3e6..0f6e51c 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/command/LiftCommandService.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/command/LiftCommandService.java
@@ -12,6 +12,7 @@
 import com.zy.asrs.wcs.core.service.MotionService;
 import com.zy.asrs.wcs.core.service.TaskService;
 import com.zy.asrs.wcs.rcs.cache.SlaveConnection;
+import com.zy.asrs.wcs.rcs.model.enums.LiftProtocolStatusType;
 import com.zy.asrs.wcs.rcs.model.enums.SlaveType;
 import com.zy.asrs.wcs.rcs.model.protocol.LiftProtocol;
 import com.zy.asrs.wcs.rcs.thread.LiftThread;
@@ -194,9 +195,8 @@
         }
 
         liftThread.setSyncTaskNo(0);//娓呴浂宸ヤ綔鍙�
-        liftThread.commandFinished(motion.getTaskNo());//璋冪敤瀹屾垚鍚庣画鎸囦护(閮ㄥ垎鎻愬崌鏈烘湁鍚庣画鎸囦护锛屽疄闄呮儏鍐电湅鏄惁鏈夌湡姝e疄鐜版柟娉�)
+        liftThread.setProtocolStatus(LiftProtocolStatusType.IDLE);
         return true;
     }
-
 
 }
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/model/protocol/LiftProtocol.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/model/protocol/LiftProtocol.java
index 7989217..3288912 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/model/protocol/LiftProtocol.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/model/protocol/LiftProtocol.java
@@ -125,7 +125,7 @@
     /**
      * 浣滀笟鏍囪
      */
-    private Boolean pakMk = false;
+    private Boolean pakMk = true;
 
     /**
      * 鎸囦护涓嬪彂鏃堕棿
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/LiftThread.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/LiftThread.java
index 8cc8100..775572c 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/LiftThread.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/LiftThread.java
@@ -28,6 +28,10 @@
 
     boolean isIdle(ExecuteSupport support);//鏄惁绌洪棽
 
+    boolean isDeviceIdle();//璁惧鏄惁绌洪棽
+
+    boolean isDeviceIdle(ExecuteSupport support);//璁惧鏄惁绌洪棽
+
     boolean setProtocolStatus(LiftProtocolStatusType status);//璁剧疆宸ヤ綔鐘舵��
 
     boolean setSyncTaskNo(Integer taskNo);//璁剧疆宸ヤ綔鍙�
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/NyLiftThread.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/NyLiftThread.java
index 43e1abd..7b75405 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/NyLiftThread.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/NyLiftThread.java
@@ -81,9 +81,9 @@
         try {
             readStatus();
 
-            //鎻愬崌鏈哄浜庤繍琛岀姸鎬侊紝灏嗘爣璁扮疆涓篺alse
+            //鎻愬崌鏈哄浜庤繍琛岀姸鎬侊紝灏嗘爣璁扮疆涓簍rue
             if (liftProtocol.getRun()) {
-                liftProtocol.setPakMk(false);
+                liftProtocol.setPakMk(true);
             }
         } catch (Exception e) {
             OutputQueue.LIFT.offer(MessageFormat.format("銆恵0}銆戣鍙栨彁鍗囨満鐘舵�佷俊鎭け璐� ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), device.getId(), device.getIp(), device.getPort()));
@@ -308,17 +308,45 @@
     @Override
     public boolean isIdle(ExecuteSupport support) {
         if (null != support) {
-            if (!support.judgement()) {
-                return false;
+            Boolean judgement = support.judgement();
+            if (judgement != null && !judgement) {
+                return true;
             }
         }
+
         // 鍒ゆ柇鎻愬崌鏈烘槸鍚﹁嚜鍔ㄣ�佸氨缁�佺┖闂�
         if (this.liftProtocol.getModel()
                 && !this.liftProtocol.getRun()
                 && this.liftProtocol.getReady()
                 && this.liftProtocol.getPakMk()
                 && this.liftProtocol.getErrorCode().equals("0")
-                && this.liftProtocol.getProtocolStatus().equals(LiftProtocolStatusType.IDLE)
+                && (this.liftProtocol.getProtocolStatusType().equals(LiftProtocolStatusType.IDLE)
+                || this.liftProtocol.getProtocolStatusType().equals(LiftProtocolStatusType.WAITING))
+        ) {
+            return true;
+        }
+        return false;
+    }
+
+    @Override
+    public boolean isDeviceIdle() {
+        return isDeviceIdle(null);
+    }
+
+    @Override
+    public boolean isDeviceIdle(ExecuteSupport support) {
+        if (null != support) {
+            Boolean judgement = support.judgement();
+            if (judgement != null && !judgement) {
+                return true;
+            }
+        }
+
+        // 鍒ゆ柇鎻愬崌鏈烘槸鍚﹁嚜鍔ㄣ�佸氨缁�佺┖闂�
+        if (this.liftProtocol.getModel()
+                && !this.liftProtocol.getRun()
+                && this.liftProtocol.getReady()
+                && this.liftProtocol.getErrorCode().equals("0")
         ) {
             return true;
         }
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SurayLiftThread.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SurayLiftThread.java
index 69172ff..1766542 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SurayLiftThread.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SurayLiftThread.java
@@ -63,9 +63,9 @@
         try {
             readStatus();
 
-            //鎻愬崌鏈哄浜庤繍琛岀姸鎬侊紝灏嗘爣璁扮疆涓篺alse
+            //鎻愬崌鏈哄浜庤繍琛岀姸鎬侊紝灏嗘爣璁扮疆涓簍rue
             if (liftProtocol.getRun()) {
-                liftProtocol.setPakMk(false);
+                liftProtocol.setPakMk(true);
             }
         } catch (Exception e) {
             OutputQueue.LIFT.offer(MessageFormat.format("銆恵0}銆戣鍙栨彁鍗囨満鐘舵�佷俊鎭け璐� ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), device.getId(), device.getIp(), device.getPort()));
@@ -345,10 +345,11 @@
         // 鍒ゆ柇鎻愬崌鏈烘槸鍚﹁嚜鍔ㄣ�佸氨缁�佺┖闂层�佹湭閿佸畾
         if (this.liftProtocol.getModel()
                 && !this.liftProtocol.getRun()
+                && this.liftProtocol.getPakMk()
                 && this.liftProtocol.getReady()
-//                && this.liftProtocol.getPakMk()
                 && this.liftProtocol.getErrorCode().equals("0")
-                && this.liftProtocol.getProtocolStatusType().equals(LiftProtocolStatusType.IDLE)
+                && (this.liftProtocol.getProtocolStatusType().equals(LiftProtocolStatusType.IDLE)
+                || this.liftProtocol.getProtocolStatusType().equals(LiftProtocolStatusType.WAITING))
                 && !extend.getLock()
         ) {
             return true;
@@ -357,6 +358,36 @@
     }
 
     @Override
+    public boolean isDeviceIdle() {
+        return isDeviceIdle(null);
+    }
+
+    @Override
+    public boolean isDeviceIdle(ExecuteSupport support) {
+        if (null != support) {
+            Boolean judgement = support.judgement();
+            if (judgement != null && !judgement) {
+                return true;
+            }
+        }
+
+        // 鍒ゆ柇鎻愬崌鏈烘槸鍚﹁嚜鍔ㄣ�佸氨缁�佺┖闂�
+        if (this.liftProtocol.getModel()
+                && !this.liftProtocol.getRun()
+                && this.liftProtocol.getErrorCode().equals("0")
+        ) {
+            if (this.liftProtocol.getTaskNo() == 0) {
+                //鏃犱换鍔℃儏鍐典笅妫�娴嬫槸鍚﹀氨缁�
+                if (!this.liftProtocol.getReady()) {
+                    return false;
+                }
+            }
+            return true;
+        }
+        return false;
+    }
+
+    @Override
     public boolean setProtocolStatus(LiftProtocolStatusType status) {
         this.liftProtocol.setProtocolStatus(status);
         return true;

--
Gitblit v1.9.1