From f43b508dda7334487a1640b0bbd908d7b3aa3cb6 Mon Sep 17 00:00:00 2001
From: Junjie <xjj@123>
Date: 星期二, 15 十月 2024 13:14:28 +0800
Subject: [PATCH] #

---
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/action/ShuttleAction.java |   27 +++++++++++++++++++++------
 1 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/action/ShuttleAction.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/action/ShuttleAction.java
index 8e0c161..730dcd8 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/action/ShuttleAction.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/action/ShuttleAction.java
@@ -133,12 +133,14 @@
         int commandStep = redisCommand.getCommandStep();
 
         // 瀹岀粨涓婁竴鏉″懡浠�
+        boolean updateCommand = false;
         if (commandStep != 0) {
             ShuttleCommand command = commands.get(commandStep - 1);
             if (command.getMode() == ShuttleCommandModeType.MOVE.id) {
                 // 姝e父绉诲姩
                 if (command.getTargetLocNo().equals(shuttleProtocol.getCurrentLocNo())) {
                     command.setComplete(true);
+                    updateCommand = true;
                     //瑙i攣閿佸畾璺緞锛屼笂涓�鏉¤矾寰�
                     List<NavigateNode> nodes = null;
                     try {
@@ -166,6 +168,7 @@
                 //鍒ゆ柇鏄惁椤跺崌鍒颁綅
                 if (shuttleProtocol.getHasLift()) {
                     command.setComplete(true);
+                    updateCommand = true;
 //                    //鍒ゆ柇鏄惁鏈夌墿
 //                    if (shuttleProtocol.getHasPallet()) {
 //                        command.setComplete(true);
@@ -176,19 +179,24 @@
                 // 鍒ゆ柇鏄惁涓嬮檷鍒颁綅
                 if (!shuttleProtocol.getHasLift()) {
                     command.setComplete(true);
+                    updateCommand = true;
                 }
             } else if (command.getMode() == ShuttleCommandModeType.CHARGE_OPEN.id) {
                 // 鍏呯數寮�
                 //鍒ゆ柇灏忚溅鍏呯數鐘舵��
                 if (shuttleProtocol.getHasCharge()) {
                     command.setComplete(true);
+                    updateCommand = true;
                 }
             }else {
                 command.setComplete(true);//鍏朵粬鍛戒护榛樿璁や负瀹屾垚
+                updateCommand = true;
             }
 
-            // 鏇存柊redis鏁版嵁
-            redisUtil.set(DeviceRedisConstant.SHUTTLE_WORK_FLAG + redisCommand.getTaskNo(), JSON.toJSONString(redisCommand, SerializerFeature.DisableCircularReferenceDetect));
+            if(updateCommand) {
+                // 鏇存柊redis鏁版嵁
+                redisUtil.set(DeviceRedisConstant.SHUTTLE_WORK_FLAG + redisCommand.getTaskNo(), JSON.toJSONString(redisCommand, SerializerFeature.DisableCircularReferenceDetect));
+            }
 
             if (!command.getComplete()) {
                 return false;
@@ -323,8 +331,10 @@
                     shuttleDispatcher.generateMoveTask(device, start.getLocNo());
                 }else {
                     //鍦ㄨ捣鐐逛綅缃紝璋冨害鍘荤洰鏍囦綅缃�
-                    shuttleDispatcher.generateMoveTask(device, target.getLocNo());
-                    shuttleProtocol.setYCurrent(shuttleProtocol.getYCurrent() + 1);//鍒囨崲y杞�
+                    Task task = shuttleDispatcher.generateMoveTask(device, target.getLocNo());
+                    if (task != null) {
+                        shuttleProtocol.setYCurrent(shuttleProtocol.getYCurrent() + 1);//鍒囨崲y杞�
+                    }
 
                     if(shuttleProtocol.getYCurrent() > shuttleProtocol.getYTarget()) {
                         //y杞翠篃璺戝畬浜嗭紝缁撴潫璺戝簱
@@ -362,8 +372,10 @@
                     shuttleDispatcher.generateMoveTask(device, start.getLocNo());
                 }else {
                     //鍦ㄨ捣鐐逛綅缃紝璋冨害鍘荤洰鏍囦綅缃�
-                    shuttleDispatcher.generateMoveTask(device, target.getLocNo());
-                    shuttleProtocol.setXCurrent(shuttleProtocol.getXCurrent() + 1);//鍒囨崲x杞�
+                    Task task = shuttleDispatcher.generateMoveTask(device, target.getLocNo());
+                    if (task != null) {
+                        shuttleProtocol.setXCurrent(shuttleProtocol.getXCurrent() + 1);//鍒囨崲x杞�
+                    }
 
                     if(shuttleProtocol.getXCurrent() > shuttleProtocol.getXTarget()) {
                         //y杞翠篃璺戝畬浜嗭紝缁撴潫璺戝簱
@@ -486,6 +498,7 @@
                             return;
                         }
                     }
+                    return;
                 }
 
                 //璋冨害鍘诲簱浣�
@@ -644,6 +657,8 @@
         } else if (command.getMode() == ShuttleCommandModeType.UPDATE_LOCATION.id) {//鏇存柊鍧愭爣
             result = shuttleThread.updateLocation(command);
         }
+
+        News.info("鍥涘悜绌挎杞﹀懡浠や笅鍙戯紝绌挎杞﹀彿={}锛屼换鍔℃暟鎹�={}", device.getDeviceNo(), JSON.toJSON(command));
         return result;
     }
 

--
Gitblit v1.9.1