From 36c6d6b39e2b76080480c5bc90a412d711b76144 Mon Sep 17 00:00:00 2001
From: zjj <3272660260@qq.com>
Date: 星期三, 19 六月 2024 15:54:24 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/Four-Way-Rack' into Four-Way-Rack
---
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/NavigateMapUtils.java | 65 ++++++++++++++++++++++++++++++--
1 files changed, 61 insertions(+), 4 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 9e34086..b6426ad 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
@@ -1,7 +1,10 @@
package com.zy.asrs.wcs.core.utils;
import com.alibaba.fastjson.JSON;
-import com.zy.asrs.framework.common.SpringUtils;
+import com.alibaba.fastjson.serializer.SerializerFeature;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
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;
@@ -19,13 +22,16 @@
@Autowired
private NavigateMapData navigateMapData;
+ @Autowired
+ private RedisUtil redisUtil;
+ @Autowired
+ private ObjectMapper objectMapper;
/**
* 鍐欏叆璺緞鑺傜偣鏁版嵁鍒皉edis鍦板浘涓�
* lock涓簍rue 绂佺敤搴撲綅锛宭ock涓篺alse鎭㈠搴撲綅
*/
public synchronized boolean writeNavigateNodeToRedisMap(Integer lev, Integer shuttleNo, List<NavigateNode> nodes, boolean lock) {
- RedisUtil redisUtil = SpringUtils.getBean(RedisUtil.class);
try {
if (nodes.isEmpty()) {
return true;
@@ -62,7 +68,7 @@
//灏濊瘯閿佸畾/瑙i攣璺緞
navigateMapData.setLev(nodes.get(0).getZ());
- List<List<MapNode>> realMap = navigateMapData.getJsonData(-1, null, null);//鑾峰彇瀹屾暣鍦板浘(鍖呮嫭鍏ュ簱鍑哄簱)
+ List<List<MapNode>> realMap = navigateMapData.getJsonDataFromDict(-1, null, null);//鑾峰彇瀹屾暣鍦板浘(鍖呮嫭鍏ュ簱鍑哄簱)
for (NavigateNode node : nodes) {
if (node.getZ() != lev) {
continue;
@@ -85,7 +91,10 @@
redisMap.setData(JSON.toJSONString(lists));
redisMap.setUpdateTime(new Date());
//灏嗘暟鎹簱鍦板浘鏁版嵁瀛樺叆redis
- redisUtil.set(DeviceRedisConstant.MAP + lev, JSON.toJSONString(redisMap));
+ redisUtil.set(DeviceRedisConstant.MAP + lev, JSON.toJSONString(redisMap, SerializerFeature.DisableCircularReferenceDetect));
+
+ //淇濆瓨璺緞閿佽妭鐐�
+ saveLockPath(lev, nodes, lock);
return true;
} catch (Exception e) {
e.printStackTrace();
@@ -93,4 +102,52 @@
return false;
}
+ //淇濆瓨璺緞閿佽妭鐐�
+ public void saveLockPath(Integer lev, List<NavigateNode> nodes, boolean lock) {
+ Object o = redisUtil.get(DeviceRedisConstant.LOCK_PATH + lev);
+ List<NavigateNode> navigateNodes = new ArrayList<>();
+ if (o != null) {
+ navigateNodes = JSON.parseArray(o.toString(), NavigateNode.class);
+ }
+
+ if (lock) {
+ navigateNodes.addAll(nodes);
+ redisUtil.set(DeviceRedisConstant.LOCK_PATH + lev, JSON.toJSONString(navigateNodes, SerializerFeature.DisableCircularReferenceDetect));
+ }else {
+ List<NavigateNode> tmp = new ArrayList<>();
+ for (NavigateNode navigateNode : navigateNodes) {
+ boolean flag = true;
+ for (NavigateNode node : nodes) {
+ if (navigateNode.getX() == node.getX()
+ && navigateNode.getY() == node.getY()
+ && navigateNode.getZ() == node.getZ()) {
+ flag = false;
+ break;
+ }
+ }
+
+ if (flag) {
+ tmp.add(navigateNode);
+ }
+ }
+
+ redisUtil.set(DeviceRedisConstant.LOCK_PATH + lev, JSON.toJSONString(tmp, SerializerFeature.DisableCircularReferenceDetect));
+ }
+ }
+
+ //鑾峰彇璺緞閿佽妭鐐�
+ public List<NavigateNode> getLockPath(Integer lev) {
+ Object obj = redisUtil.get(DeviceRedisConstant.LOCK_PATH + lev);
+ List<NavigateNode> navigateNodes = new ArrayList<>();
+ if (obj != null) {
+ try {
+ navigateNodes = objectMapper.readValue(obj.toString(), new TypeReference<List<NavigateNode>>() {});
+ } catch (JsonProcessingException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ return navigateNodes;
+ }
+
}
--
Gitblit v1.9.1