自动化立体仓库 - WCS系统
Junjie
2024-12-21 802c12dcbc63ee1662c15723d27c8fc1f4fd36e6
src/main/java/com/zy/common/utils/NavigateMapData.java
@@ -5,12 +5,14 @@
import com.core.common.SpringUtils;
import com.zy.asrs.entity.BasMap;
import com.zy.asrs.entity.LocMast;
import com.zy.asrs.service.BasShuttleService;
import com.zy.asrs.service.LocMastService;
import com.zy.common.model.MapNode;
import com.zy.common.model.NavigateNode;
import com.zy.common.model.enums.NavigationMapType;
import com.zy.core.enums.RedisKeyType;
import com.zy.core.enums.ShuttleTaskModeType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ClassPathResource;
import org.springframework.stereotype.Component;
@@ -27,11 +29,11 @@
    private Integer lev;//地图楼层
    public NavigateMapData() {
        this.lev = 1;
    public Integer getLev() {
        return lev;
    }
    public NavigateMapData(Integer lev) {
    public void setLev(Integer lev) {
        this.lev = lev;
    }
@@ -41,6 +43,30 @@
    public int[][] getData(Integer mapType, List<int[]> whitePoints, List<int[]> shuttlePoints) {
        try {
//            RedisUtil redisUtil = SpringUtils.getBean(RedisUtil.class);
//            Object object = redisUtil.get(RedisKeyType.BASIC_MAP.key + lev);
//            if (object == null) {
//                return null;
//            }
//
//            //解析json地图数据
//            ArrayList arrayList = JSON.parseObject(object.toString(), ArrayList.class);
//            List<List<MapNode>> lists = filterMap(mapType, arrayList, lev, whitePoints, shuttlePoints);//过滤地图数据
//            int[][] map = new int[lists.size()][];
//            int j = 0;
//            for (List<MapNode> list : lists) {
//                int[] tmp = new int[list.size()];
//                int i = 0;
//                for (MapNode mapNode : list) {
//                    //将数据添加进二维数组
//                    tmp[i++] = mapNode.getValue();
//                }
//                //数据添加进一维数组
//                map[j++] = tmp;
//            }
//
//            return map;
            String mapFilename = "map_" + lev + ".json";
            ClassPathResource classPathResource = new ClassPathResource(mapFilename);
            InputStream inputStream = classPathResource.getInputStream();
@@ -84,8 +110,8 @@
            } else {
                System.out.println("文件不存在!");
            }
        } catch (IOException ioException) {
            ioException.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
@@ -129,6 +155,18 @@
    //获取JSON格式数据
    public List<List<MapNode>> getJsonData(Integer mapType, List<int[]> whitePoints, List<int[]> shuttlePoints) {
        try {
//            RedisUtil redisUtil = SpringUtils.getBean(RedisUtil.class);
//            Object object = redisUtil.get(RedisKeyType.BASIC_MAP.key + lev);
//            if (object == null) {
//                return null;
//            }
//
//            //解析json地图数据
//            ArrayList arrayList = JSON.parseObject(object.toString(), ArrayList.class);
//            List<List<MapNode>> lists = filterMap(mapType, arrayList, lev, whitePoints, shuttlePoints);//过滤地图数据
//            return lists;
            String mapFilename = "map_" + lev + ".json";
            ClassPathResource classPathResource = new ClassPathResource(mapFilename);
            InputStream inputStream = classPathResource.getInputStream();
@@ -161,8 +199,8 @@
            } else {
                System.out.println("文件不存在!");
            }
        } catch (IOException ioException) {
            ioException.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
@@ -170,6 +208,17 @@
    //获取JSON格式数据
    public List<List<MapNode>> getJsonData(Integer lev, Integer mapType, List<int[]> whitePoints, List<int[]> shuttlePoints) {
        try {
//            RedisUtil redisUtil = SpringUtils.getBean(RedisUtil.class);
//            Object object = redisUtil.get(RedisKeyType.BASIC_MAP.key + lev);
//            if (object == null) {
//                return null;
//            }
//
//            //解析json地图数据
//            ArrayList arrayList = JSON.parseObject(object.toString(), ArrayList.class);
//            List<List<MapNode>> lists = filterMap(mapType, arrayList, lev, whitePoints, shuttlePoints);//过滤地图数据
//            return lists;
            String mapFilename = "map_" + lev + ".json";
            ClassPathResource classPathResource = new ClassPathResource(mapFilename);
            InputStream inputStream = classPathResource.getInputStream();
@@ -202,8 +251,8 @@
            } else {
                System.out.println("文件不存在!");
            }
        } catch (IOException ioException) {
            ioException.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }