#
Junjie
2024-10-15 f43b508dda7334487a1640b0bbd908d7b3aa3cb6
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;
@@ -57,10 +58,10 @@
                for (NavigateNode node : nodes) {
                    List<MapNode> listX = listsHasShuttle.get(node.getX());
                    MapNode mapNode = listX.get(node.getY());
                    if (mapNode.getValue() == -999) {
                    if (mapNode.getValue() == MapNodeType.LOCK.id) {
                        return false;//路径被锁定过,禁止再次锁定
                    }
                    if (mapNode.getValue() == 66) {
                    if (mapNode.getValue() == MapNodeType.CAR.id) {
                        return false;//路径存在小车,禁止锁定
                    }
                }
@@ -77,7 +78,7 @@
                List<MapNode> listX = lists.get(node.getX());
                MapNode mapNode = listX.get(node.getY());
                if (lock) {
                    mapNode.setValue(-999);//禁用库位
                    mapNode.setValue(MapNodeType.LOCK.id);//禁用库位
                } else {
                    //获取原始节点数据
                    List<MapNode> rows = realMap.get(node.getX());
@@ -107,12 +108,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 +142,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 +162,6 @@
                throw new RuntimeException(e);
            }
        }
        return navigateNodes;
    }