From 0f69561e397093b5165c4aac58530721d5c62178 Mon Sep 17 00:00:00 2001 From: zjj <3272660260@qq.com> Date: 星期一, 25 十一月 2024 11:03:16 +0800 Subject: [PATCH] #led --- zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/NavigateMapUtils.java | 44 +++++++++++++++++++++++++++++++++++++------- 1 files changed, 37 insertions(+), 7 deletions(-) diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/NavigateMapUtils.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/NavigateMapUtils.java index b6426ad..2b872d7 100644 --- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/NavigateMapUtils.java +++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/NavigateMapUtils.java @@ -8,6 +8,7 @@ import com.zy.asrs.wcs.core.domain.dto.RedisMapDto; import com.zy.asrs.wcs.core.model.MapNode; import com.zy.asrs.wcs.core.model.NavigateNode; +import com.zy.asrs.wcs.core.model.enums.MapNodeType; import com.zy.asrs.wcs.core.model.enums.NavigationMapType; import com.zy.asrs.wcs.rcs.constant.DeviceRedisConstant; import org.springframework.beans.factory.annotation.Autowired; @@ -52,15 +53,28 @@ List<List<MapNode>> listsHasShuttle = navigateMapData.filterMap(NavigationMapType.NONE.id, arrayList, lev, null, shuttlePoints);//鑾峰彇甯﹀皬杞﹀湴鍥炬暟鎹� List<List<MapNode>> lists = navigateMapData.filterMap(NavigationMapType.NONE.id, arrayList, lev, null, null);//鑾峰彇鍏ㄩ儴鍦板浘鏁版嵁 + //妫�娴嬭妭鐐规槸鍚︿负褰撳墠璁惧 + for (NavigateNode node : nodes) { + List<MapNode> listX = listsHasShuttle.get(node.getX()); + MapNode mapNode = listX.get(node.getY()); + if (mapNode.getLockDeviceNo() == null) { + continue; + } + + if (!mapNode.getLockDeviceNo().equals(shuttleNo)) { + return false;//璺緞鎵�灞炴潈涓嶆槸褰撳墠璁惧 + } + } + //妫�娴嬭矾寰勬槸鍚﹁閿佸畾 if (lock) { for (NavigateNode node : nodes) { List<MapNode> listX = listsHasShuttle.get(node.getX()); MapNode mapNode = listX.get(node.getY()); - if (mapNode.getValue() == -999) { + if (mapNode.getValue().equals(MapNodeType.LOCK.id)) { return false;//璺緞琚攣瀹氳繃锛岀姝㈠啀娆¢攣瀹� } - if (mapNode.getValue() == 66) { + if (mapNode.getValue().equals(MapNodeType.CAR.id)) { return false;//璺緞瀛樺湪灏忚溅锛岀姝㈤攣瀹� } } @@ -77,12 +91,14 @@ List<MapNode> listX = lists.get(node.getX()); MapNode mapNode = listX.get(node.getY()); if (lock) { - mapNode.setValue(-999);//绂佺敤搴撲綅 + mapNode.setValue(MapNodeType.LOCK.id);//绂佺敤搴撲綅 + mapNode.setLockDeviceNo(shuttleNo); } else { //鑾峰彇鍘熷鑺傜偣鏁版嵁 List<MapNode> rows = realMap.get(node.getX()); MapNode col = rows.get(node.getY()); mapNode.setValue(col.getValue());//鎭㈠搴撲綅 + mapNode.setLockDeviceNo(null); } listX.set(node.getY(), mapNode); @@ -107,12 +123,22 @@ Object o = redisUtil.get(DeviceRedisConstant.LOCK_PATH + lev); List<NavigateNode> navigateNodes = new ArrayList<>(); if (o != null) { - navigateNodes = JSON.parseArray(o.toString(), NavigateNode.class); + try { + navigateNodes = objectMapper.readValue(o.toString(), new TypeReference<List<NavigateNode>>() {}); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } } + String nodeStr = null; if (lock) { navigateNodes.addAll(nodes); - redisUtil.set(DeviceRedisConstant.LOCK_PATH + lev, JSON.toJSONString(navigateNodes, SerializerFeature.DisableCircularReferenceDetect)); + try { + nodeStr = objectMapper.writeValueAsString(navigateNodes); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } + redisUtil.set(DeviceRedisConstant.LOCK_PATH + lev, nodeStr); }else { List<NavigateNode> tmp = new ArrayList<>(); for (NavigateNode navigateNode : navigateNodes) { @@ -131,7 +157,12 @@ } } - redisUtil.set(DeviceRedisConstant.LOCK_PATH + lev, JSON.toJSONString(tmp, SerializerFeature.DisableCircularReferenceDetect)); + try { + nodeStr = objectMapper.writeValueAsString(tmp); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } + redisUtil.set(DeviceRedisConstant.LOCK_PATH + lev, nodeStr); } } @@ -146,7 +177,6 @@ throw new RuntimeException(e); } } - return navigateNodes; } -- Gitblit v1.9.1