From 0f5a5a759221bde50ace126eae797326837f5f72 Mon Sep 17 00:00:00 2001 From: Junjie <xjj@123> Date: 星期三, 16 十月 2024 16:15:12 +0800 Subject: [PATCH] # --- zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/action/ShuttleAction.java | 65 ++++++++++++++++++++++---------- 1 files changed, 45 insertions(+), 20 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 1be358f..61cd617 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 @@ -36,6 +36,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Objects; +import java.util.Optional; @Component public class ShuttleAction { @@ -132,13 +133,36 @@ ShuttleAssignCommand assignCommand = redisCommand.getAssignCommand(); int commandStep = redisCommand.getCommandStep(); + Integer mode = -1; + if(commandStep < commands.size()) { + //鍙栧嚭鍛戒护 + ShuttleCommand currentCommand = commands.get(commandStep); + mode = currentCommand.getMode(); + } + + //鍒ゆ柇璁惧鏄惁绌洪棽 + Integer finalMode = mode; + if (!shuttleThread.isDeviceIdle(new ExecuteSupport() { + @Override + public Boolean judgement() { + if (ShuttleCommandModeType.CHARGE_CLOSE.id.equals(finalMode)) {//鍏抽棴鍏呯數motion + return false;//涓嶉渶瑕佸垽鏂姸鎬� + } + return true;//闇�瑕佸垽鏂姸鎬� + } + })) { + return false; + } + // 瀹岀粨涓婁竴鏉″懡浠� + 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 +190,7 @@ //鍒ゆ柇鏄惁椤跺崌鍒颁綅 if (shuttleProtocol.getHasLift()) { command.setComplete(true); + updateCommand = true; // //鍒ゆ柇鏄惁鏈夌墿 // if (shuttleProtocol.getHasPallet()) { // command.setComplete(true); @@ -176,19 +201,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; @@ -228,20 +258,6 @@ //鍙栧嚭鍛戒护 ShuttleCommand command = commands.get(commandStep); - - Integer mode = command.getMode(); - //鍒ゆ柇璁惧鏄惁绌洪棽 - if (!shuttleThread.isDeviceIdle(new ExecuteSupport() { - @Override - public Boolean judgement() { - if (ShuttleCommandModeType.CHARGE_CLOSE.id.equals(mode)) {//鍏抽棴鍏呯數motion - return false;//涓嶉渶瑕佸垽鏂姸鎬� - } - return true;//闇�瑕佸垽鏂姸鎬� - } - })) { - return false; - } // 涓嬪彂鍛戒护 if (!write(command, device)) { @@ -323,8 +339,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 +380,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 +506,7 @@ return; } } + return; } //璋冨害鍘诲簱浣� @@ -641,7 +662,11 @@ result = shuttleThread.charge(command); } else if (command.getMode() == ShuttleCommandModeType.RESET.id) {//澶嶄綅 result = shuttleThread.reset(command); + } 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