From b13b323ff03225cf76e7ef12edf29ce253b73e3a Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期日, 07 四月 2024 15:39:40 +0800
Subject: [PATCH] #

---
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/map/websocket/MockScheduler.java |   76 ++++++++++++++++++++++++++++++++++---
 1 files changed, 69 insertions(+), 7 deletions(-)

diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/map/websocket/MockScheduler.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/map/websocket/MockScheduler.java
index 9396a06..1978188 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/map/websocket/MockScheduler.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/map/websocket/MockScheduler.java
@@ -7,6 +7,9 @@
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 
+import java.util.ArrayList;
+import java.util.List;
+
 /**
  * Created by vincent on 4/3/2024
  */
@@ -16,6 +19,7 @@
     private int row = 1;
     private int bay = 1;
     private int lev = 1;
+    private boolean shouldIncreaseBay = true;
 
     @Scheduled(cron = "0/1 * * * * ? ")
     public void mock() {
@@ -26,21 +30,79 @@
         shuttleVo.setShuttleNo("1");
 
 
-        if (bay < 30) {
-            bay ++;
-        } else {
-            bay = 1;
-            if (row < 10) {
-                row ++;
+
+        if (shouldIncreaseBay) {
+            if (bay < 30) {
+                bay++;
             } else {
-                row = 1;
+                // bay 杈惧埌 30 鍚庯紝row 鍏堝 1
+                if (row < 10) {
+                    row++;
+                } else {
+                    row = 1;  // 濡傛灉 row 宸茬粡鏄渶澶э紝鍒欏洖鍒拌捣濮嬩綅缃�
+                }
+                shouldIncreaseBay = false;
+            }
+        } else {
+            if (bay > 1) {
+                bay--;
+            } else {
+                // bay 鍑忓埌 1 鍚庯紝鍒� row 鍏堝 1
+                if (row < 10) {
+                    row++;
+                } else {
+                    row = 1;  // 濡傛灉 row 宸茬粡鏄渶澶э紝鍒欏洖鍒拌捣濮嬩綅缃�
+                }
+                shouldIncreaseBay = true;
             }
         }
 
+
         shuttleVo.setCurLocNo(Utils.getLocNo(row, bay, lev));
+        List<String> preTravelPath = generatePreTravelPath(row, bay, lev, shouldIncreaseBay, 10);
+        shuttleVo.setPreTravelPath(preTravelPath);
+
+
         wsVo.getShuttleVos().add(shuttleVo);
 
         MapWebSocket.broadcast(JSON.toJSONString(wsVo));
     }
 
+    private List<String> generatePreTravelPath(int currentRow, int currentBay, int currentLev, boolean increasingBay, int pathLength) {
+        List<String> path = new ArrayList<>();
+        int tempRow = currentRow;
+        int tempBay = currentBay;
+        boolean tempIncreaseBay = increasingBay;
+
+        for (int i = 0; i < pathLength; i++) {
+            if (tempIncreaseBay) {
+                if (tempBay < 30) {
+                    tempBay++;
+                } else {
+                    if (tempRow < 10) {
+                        tempRow++;
+                    } else {
+                        tempRow = 1;  // 濡傛灉 row 宸茬粡鏄渶澶э紝鍒欏洖鍒拌捣濮嬩綅缃�
+                    }
+                    tempIncreaseBay = false;
+                }
+            } else {
+                if (tempBay > 1) {
+                    tempBay--;
+                } else {
+                    if (tempRow < 10) {
+                        tempRow++;
+                    } else {
+                        tempRow = 1;  // 濡傛灉 row 宸茬粡鏄渶澶э紝鍒欏洖鍒拌捣濮嬩綅缃�
+                    }
+                    tempIncreaseBay = true;
+                }
+            }
+            // 灏嗙敓鎴愮殑搴撲綅鍙峰姞鍏ヨ矾寰勫垪琛�
+            path.add(Utils.getLocNo(tempRow, tempBay, currentLev));
+        }
+
+        return path;
+    }
+
 }

--
Gitblit v1.9.1