From 42af11ca3a84e13d1f55207b2770e2454a861983 Mon Sep 17 00:00:00 2001 From: Junjie <540245094@qq.com> Date: 星期五, 01 八月 2025 17:05:03 +0800 Subject: [PATCH] # --- src/main/java/com/zy/common/utils/NavigateMapUtils.java | 38 ++++++++++++++++++++++++++++++++++++++ 1 files changed, 38 insertions(+), 0 deletions(-) diff --git a/src/main/java/com/zy/common/utils/NavigateMapUtils.java b/src/main/java/com/zy/common/utils/NavigateMapUtils.java index ea621f2..49c72a9 100644 --- a/src/main/java/com/zy/common/utils/NavigateMapUtils.java +++ b/src/main/java/com/zy/common/utils/NavigateMapUtils.java @@ -2,13 +2,18 @@ import com.zy.asrs.utils.Utils; import com.zy.common.model.NavigateNode; +import com.zy.core.cache.SlaveConnection; import com.zy.core.enums.RedisKeyType; +import com.zy.core.enums.SlaveType; +import com.zy.core.model.protocol.ShuttleProtocol; +import com.zy.core.thread.ShuttleThread; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.Map; @Component public class NavigateMapUtils { @@ -16,6 +21,39 @@ @Autowired private RedisUtil redisUtil; + public synchronized boolean clearPath(Integer shuttleNo) { + ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleNo); + if (shuttleThread == null) { + return false; + } + + ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(); + if (shuttleProtocol == null) { + return false; + } + + String currentLocNo = shuttleProtocol.getCurrentLocNo(); + int lev = Utils.getLev(currentLocNo); + + HashMap<String, Object> lockMap = new HashMap<>(); + Object o = redisUtil.get(RedisKeyType.LOCK_MAP_NODES.key + lev); + if (o != null) { + lockMap = (HashMap<String, Object>) o; + } + + List<NavigateNode> list = new ArrayList<>(); + for (Map.Entry<String, Object> entry : lockMap.entrySet()) { + String locNo = entry.getKey(); + Integer value = (Integer) entry.getValue(); + if (value.equals(shuttleNo)) { + NavigateNode navigateNode = NavigatePositionConvert.locNoToNode(locNo); + list.add(navigateNode); + } + } + + return writeNavigateNodeToRedisMap(lev, shuttleNo, list, false); + } + /** * 鍐欏叆璺緞鑺傜偣鏁版嵁鍒皉edis鍦板浘涓� * lock涓簍rue 绂佺敤搴撲綅锛宭ock涓篺alse鎭㈠搴撲綅 -- Gitblit v1.9.1