#
Junjie
2024-10-17 d62c5c0eb2e28b7bf27d23de84a609b5a2e415e4
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/map/websocket/MockScheduler.java
@@ -5,7 +5,6 @@
import com.zy.asrs.wcs.core.map.entity.MapWsVo;
import com.zy.asrs.wcs.core.utils.Utils;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
@@ -13,7 +12,7 @@
/**
 * Created by vincent on 4/3/2024
 */
@Component
//@Component
public class MockScheduler {
    private int row = 1;
@@ -59,8 +58,8 @@
        shuttleVo.setCurLocNo(Utils.getLocNo(row, bay, lev));
        List<String> preTravelPath = generatePreTravelPath(row, bay, lev, shouldIncreaseBay, 10);
        shuttleVo.setPreTravelPath(preTravelPath);
        List<String> preTravelPath = generateFullTravelPath(10, 30, lev);
        shuttleVo.setTravelPath(preTravelPath);
        wsVo.getShuttleVos().add(shuttleVo);
@@ -68,41 +67,23 @@
        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;
    private List<String> generateFullTravelPath(int maxRow, int maxBay, int currentLev) {
        List<String> fullPath = new ArrayList<>();
        boolean increasingBay = true; // 假设从 bay = 1 开始递增
        for (int i = 0; i < pathLength; i++) {
            if (tempIncreaseBay) {
                if (tempBay < 30) {
                    tempBay++;
                } else {
                    if (tempRow < 10) {
                        tempRow++;
                    } else {
                        tempRow = 1;  // 如果 row 已经是最大,则回到起始位置
                    }
                    tempIncreaseBay = false;
        for (int currentRow = 1; currentRow <= maxRow; currentRow++) {
            if (increasingBay) {
                for (int currentBay = 1; currentBay <= maxBay; currentBay++) {
                    fullPath.add(Utils.getLocNo(currentRow, currentBay, currentLev));
                }
            } else {
                if (tempBay > 1) {
                    tempBay--;
                } else {
                    if (tempRow < 10) {
                        tempRow++;
                    } else {
                        tempRow = 1;  // 如果 row 已经是最大,则回到起始位置
                    }
                    tempIncreaseBay = true;
                for (int currentBay = maxBay; currentBay >= 1; currentBay--) {
                    fullPath.add(Utils.getLocNo(currentRow, currentBay, currentLev));
                }
            }
            // 将生成的库位号加入路径列表
            path.add(Utils.getLocNo(tempRow, tempBay, currentLev));
            increasingBay = !increasingBay; // 到达每行的末尾时改变bay的递增/递减方向
        }
        return path;
        return fullPath;
    }
}