From 9564b5da6e019b29b9779fcc13f9b82c9487befa Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期四, 28 三月 2024 15:11:25 +0800
Subject: [PATCH] Merge branch 'Four-Way-Rack' of http://47.97.1.152:5880/r/zy-asrs-master into Four-Way-Rack

---
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/action/ShuttleAction.java |   41 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 41 insertions(+), 0 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 873cb42..4a15a5d 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
@@ -1,11 +1,14 @@
 package com.zy.asrs.wcs.core.action;
 
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.zy.asrs.wcs.core.entity.BasShuttle;
 import com.zy.asrs.wcs.core.model.NavigateNode;
 import com.zy.asrs.wcs.core.model.command.ShuttleAssignCommand;
 import com.zy.asrs.wcs.core.model.command.ShuttleCommand;
 import com.zy.asrs.wcs.core.model.command.ShuttleRedisCommand;
 import com.zy.asrs.wcs.core.model.enums.ShuttleCommandModeType;
+import com.zy.asrs.wcs.core.service.BasShuttleService;
 import com.zy.asrs.wcs.core.utils.NavigateMapUtils;
 import com.zy.asrs.wcs.core.utils.RedisUtil;
 import com.zy.asrs.wcs.core.utils.Utils;
@@ -29,6 +32,8 @@
     private RedisUtil redisUtil;
     @Autowired
     private NavigateMapUtils navigateMapUtils;
+    @Autowired
+    private BasShuttleService basShuttleService;
 
     public synchronized boolean assignWork(Device device, ShuttleAssignCommand assignCommand) {
         ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, device.getId().intValue());
@@ -49,6 +54,11 @@
         redisCommand.setAssignCommand(assignCommand);//鍛戒护
         //浠诲姟鏁版嵁淇濆瓨鍒皉edis
         if (redisUtil.set(DeviceRedisConstant.SHUTTLE_WORK_FLAG + assignCommand.getTaskNo(), JSON.toJSONString(redisCommand))) {
+            //涓嬪彂琛岄┒璺緞
+            boolean result = shuttleThread.movePath(assignCommand.getNodes(), assignCommand.getTaskNo().intValue());
+            if (!result) {
+                return false;
+            }
             shuttleProtocol.setTaskNo(assignCommand.getTaskNo().intValue());
             return true;
         }
@@ -175,7 +185,38 @@
             }
         }
 
+        //鍙栧嚭鍛戒护
+        ShuttleCommand command = commands.get(commandStep);
+
+        // 涓嬪彂鍛戒护
+        if (!write(command, device)) {
+            News.error("鍥涘悜绌挎杞﹀懡浠や笅鍙戝け璐ワ紝绌挎杞﹀彿={}锛屼换鍔℃暟鎹�={}", shuttleProtocol.getShuttleNo(), JSON.toJSON(command));
+            return false;
+        }
+
         return true;
     }
 
+    private synchronized boolean write(ShuttleCommand command, Device device) {
+        if (null == command) {
+            News.error("鍥涘悜绌挎杞﹀啓鍏ュ懡浠や负绌�");
+            return false;
+        }
+        ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, device.getId().intValue());
+        boolean result = false;
+        if (command.getMode() == ShuttleCommandModeType.MOVE.id
+                || command.getMode() == ShuttleCommandModeType.IN_LIFT.id
+                || command.getMode() == ShuttleCommandModeType.OUT_LIFT.id) {//绉诲姩
+            result = shuttleThread.move(command);
+        } else if (command.getMode() == ShuttleCommandModeType.PALLET_LIFT.id
+                || command.getMode() == ShuttleCommandModeType.PALLET_DOWN.id) {//椤跺崌
+            result = shuttleThread.lift(command);
+        } else if (command.getMode() == ShuttleCommandModeType.CHARGE.id) {//鍏呯數
+            result = shuttleThread.charge(command);
+        } else if (command.getMode() == ShuttleCommandModeType.RESET.id) {//澶嶄綅
+            result = shuttleThread.reset(command);
+        }
+        return result;
+    }
+
 }

--
Gitblit v1.9.1