| | |
| | | |
| | | 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 { |
| | | |
| | | @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); |
| | | } |
| | | |
| | | /** |
| | | * 写入路径节点数据到redis地图中 |
| | |
| | | lockMap.remove(key); |
| | | } |
| | | } |
| | | lockMap.putAll(lockMap); |
| | | redisUtil.set(RedisKeyType.LOCK_MAP_NODES.key + lev, lockMap); |
| | | return true; |
| | | } |