From a4996f162b0ca63113f573e315e3ce4f5dce7ad3 Mon Sep 17 00:00:00 2001
From: Junjie <540245094@qq.com>
Date: 星期三, 05 六月 2024 15:39:37 +0800
Subject: [PATCH] #算法优化

---
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SurayShuttleThread.java |   45 +++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 41 insertions(+), 4 deletions(-)

diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SurayShuttleThread.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SurayShuttleThread.java
index 32d18d7..bcd4c5a 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SurayShuttleThread.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SurayShuttleThread.java
@@ -10,6 +10,7 @@
 import com.zy.asrs.framework.common.SpringUtils;
 import com.zy.asrs.framework.exception.CoolException;
 import com.zy.asrs.wcs.common.ExecuteSupport;
+import com.zy.asrs.wcs.core.domain.param.ShuttleMoveLocParam;
 import com.zy.asrs.wcs.core.entity.BasShuttle;
 import com.zy.asrs.wcs.core.entity.Loc;
 import com.zy.asrs.wcs.core.model.NavigateNode;
@@ -184,6 +185,7 @@
                     basShuttle.setStatus(1);
                     basShuttle.setDeleted(0);
                     basShuttle.setHostId(device.getHostId());
+                    basShuttle.setDeviceId(device.getId().intValue());
                     shuttleService.save(basShuttle);
                 }
                 //浠诲姟鍙�
@@ -217,10 +219,15 @@
 
     @Override
     public ShuttleProtocol getStatus() {
+        return getStatus(true);
+    }
+
+    @Override
+    public ShuttleProtocol getStatus(boolean clone) {
         if (this.shuttleProtocol == null) {
             return null;
         }
-        return this.shuttleProtocol.clone();
+        return clone ? this.shuttleProtocol.clone() : this.shuttleProtocol;
     }
 
     @Override
@@ -257,11 +264,11 @@
                 NavigateNode targetPath = sectionNodes.get(sectionNodes.size() - 1);
                 if (ShuttleRunDirection.get(startPath.getDirection()) == ShuttleRunDirection.LEFT
                         || ShuttleRunDirection.get(startPath.getDirection()) == ShuttleRunDirection.RIGHT) {
-                    //姣嶈建鏂瑰悜
-                    oper = 5;
-                } else {
                     //瀛愯建鏂瑰悜
                     oper = 6;
+                } else {
+                    //姣嶈建鏂瑰悜
+                    oper = 5;
                 }
 
                 for (int i = 0; i < sectionNodes.size(); i++) {
@@ -299,7 +306,11 @@
                     .doPost();
             JSONObject jsonObject = JSON.parseObject(response);
             Integer code = jsonObject.getInteger("code");
+            System.out.println("璺緞涓嬪彂" + taskNo);
+            System.out.println(JSON.toJSONString(jsonObject));
+            System.out.println(JSON.toJSONString(param));
             if (code.equals(200)) {
+                System.out.println("璺緞涓嬪彂" + taskNo);
                 return true;
             }
         } catch (Exception e) {
@@ -329,6 +340,7 @@
                     .doPost();
             JSONObject jsonObject = JSON.parseObject(response);
             Integer code = jsonObject.getInteger("code");
+            System.out.println(JSON.toJSONString(command.getBody()));
             if (code.equals(200)) {
                 this.shuttleProtocol.setSendTime(System.currentTimeMillis());//鎸囦护涓嬪彂鏃堕棿
                 return true;
@@ -405,6 +417,7 @@
     public synchronized boolean reset(ShuttleCommand command) {
         setSyncTaskNo(0);
         setProtocolStatus(ShuttleProtocolStatusType.IDLE);
+        enableMoveLoc(null, false);
         return true;
     }
 
@@ -608,6 +621,30 @@
     }
 
     @Override
+    public boolean enableMoveLoc(ShuttleMoveLocParam param, boolean enable) {
+        if (enable) {
+            shuttleProtocol.setMoveLoc(true);//寮�鍚窇搴�
+            shuttleProtocol.setMoveType(param.getMoveType());
+            shuttleProtocol.setXStart(param.getStartX());
+            shuttleProtocol.setXTarget(param.getTargetX());
+            shuttleProtocol.setXCurrent(param.getStartX());
+            shuttleProtocol.setYStart(param.getStartY());
+            shuttleProtocol.setYTarget(param.getTargetY());
+            shuttleProtocol.setYCurrent(param.getStartY());
+        }else {
+            shuttleProtocol.setMoveLoc(false);
+            shuttleProtocol.setMoveType(0);
+            shuttleProtocol.setXStart(0);
+            shuttleProtocol.setXTarget(0);
+            shuttleProtocol.setXCurrent(0);
+            shuttleProtocol.setYStart(0);
+            shuttleProtocol.setYTarget(0);
+            shuttleProtocol.setYCurrent(0);
+        }
+        return true;
+    }
+
+    @Override
     public ShuttleCommand getMoveCommand(Integer taskNo, String startCodeNum, String distCodeNum, Integer allDistance, Integer runDirection, Integer runSpeed, List<NavigateNode> nodes) {
         HashMap<String, Object> body = new HashMap<>();
         body.put("messageName", "runOrder");

--
Gitblit v1.9.1