| | |
| | | //解析json地图数据 |
| | | ArrayList arrayList = JSON.parseObject(basMap.getData(), ArrayList.class); |
| | | |
| | | List<List<MapNode>> lists = navigateMapData.filterMap(NavigationMapType.getMapTypes(NavigationMapType.NONE, NavigationMapType.PATH_LOCK), arrayList, lev, null, null);//过滤地图数据 |
| | | return R.ok().add(lists); |
| | | } |
| | | |
| | | /** |
| | | * 获取库位地图数据 |
| | | */ |
| | | @GetMapping("/locMap/{lev}/auth") |
| | | @ManagerAuth |
| | | public R getLocMap(@PathVariable Integer lev) { |
| | | Object data = redisUtil.get(RedisKeyType.MAP.key + lev); |
| | | if (data == null) { |
| | | return R.error(); |
| | | } |
| | | |
| | | BasMap basMap = JSON.parseObject(data.toString(), BasMap.class); |
| | | //解析json地图数据 |
| | | ArrayList arrayList = JSON.parseObject(basMap.getData(), ArrayList.class); |
| | | |
| | | List<List<MapNode>> lists = navigateMapData.filterMap(NavigationMapType.getMapTypes(NavigationMapType.NONE), arrayList, lev, null, null);//过滤地图数据 |
| | | return R.ok().add(lists); |
| | | } |
| | |
| | | |
| | | if (shuttleTaskModeType == ShuttleTaskModeType.MOVE_LOC_NO) { |
| | | //移动到目标库位 |
| | | List<NavigationMapType> mapTypes = NavigationMapType.getMapTypes(NavigationMapType.NORMAL); |
| | | List<NavigationMapType> mapTypes = NavigationMapType.getMapTypes(NavigationMapType.NORMAL, NavigationMapType.PATH_LOCK); |
| | | if (shuttleProtocol.getHasLift()) { |
| | | mapTypes = NavigationMapType.getMapTypes(NavigationMapType.DFX); |
| | | mapTypes = NavigationMapType.getMapTypes(NavigationMapType.DFX, NavigationMapType.PATH_LOCK); |
| | | } |
| | | List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(shuttleProtocol.getCurrentLocNo(), param.getDistLocNo(), mapTypes, assignCommand, shuttleThread); |
| | | if (commands == null) { |
| | |
| | | Object data = redisUtil.get(RedisKeyType.MAP.key + lev); |
| | | if (data == null) {//redis地图数据为空 |
| | | //载入地图 |
| | | List<List<MapNode>> lists = navigateMapData.getJsonData(lev, NavigationMapType.getMapTypes(NavigationMapType.NONE), null, null);//获取完整地图(包括入库出库) |
| | | List<List<MapNode>> lists = navigateMapData.getJsonOriginData(lev, NavigationMapType.getMapTypes(NavigationMapType.NONE), null, null);//获取完整地图(包括入库出库) |
| | | |
| | | //存入数据库 |
| | | basMap.setData(JSON.toJSONString(lists)); |
| | |
| | | assignCommand.setAuto(true);//自动模式 |
| | | |
| | | //计算近点位置 |
| | | String endLocation = navigateUtils.calcEndLocation(shuttleProtocol.getCurrentLocNo(), liftSta.getLocNo(), NavigationMapType.getMapTypes(NavigationMapType.NORMAL), null, null, 1); |
| | | String endLocation = navigateUtils.calcEndLocation(shuttleProtocol.getCurrentLocNo(), liftSta.getLocNo(), NavigationMapType.getMapTypes(NavigationMapType.NORMAL, NavigationMapType.PATH_LOCK), null, null, 1); |
| | | if (endLocation == null) { |
| | | News.taskInfo(wrkMast.getWrkNo(), "{}任务,小车近点位置计算失败", wrkMast.getWrkNo()); |
| | | return false; |
| | |
| | | R result = consoleController.getMapFromRedis(Integer.parseInt(socketMessage.getData())); |
| | | socketMessage.setData(JSON.toJSONString(result)); |
| | | this.sendMessage(JSON.toJSONString(socketMessage)); |
| | | } else if (socketMessage.getUrl().equals("/console/locMap/auth")) { |
| | | R result = consoleController.getLocMap(Integer.parseInt(socketMessage.getData())); |
| | | socketMessage.setData(JSON.toJSONString(result)); |
| | | this.sendMessage(JSON.toJSONString(socketMessage)); |
| | | } |
| | | // log.info("收到来自连接:" + sessionId + "的信息:" + message); |
| | | } |
| | |
| | | NORMAL(2, "地图携带库位状态X"), |
| | | SHUTTLE(3, "地图携带小车"), |
| | | LIFT(4, "地图携带提升机"), |
| | | PATH_LOCK(5, "路径锁"), |
| | | ; |
| | | |
| | | public Integer id; |
| | |
| | | } |
| | | |
| | | public static List<NavigationMapType> getDfxWithDevice() { |
| | | return getMapTypes(DFX, SHUTTLE, LIFT); |
| | | return getMapTypes(DFX, SHUTTLE, LIFT, PATH_LOCK); |
| | | } |
| | | |
| | | public static List<NavigationMapType> getNormalWithDevice() { |
| | | return getMapTypes(NORMAL, SHUTTLE, LIFT); |
| | | return getMapTypes(NORMAL, SHUTTLE, LIFT, PATH_LOCK); |
| | | } |
| | | |
| | | public static List<NavigationMapType> getMapTypes(NavigationMapType... types) { |
| | |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * A*算法地图获取类 |
| | |
| | | @Component |
| | | public class NavigateMapData { |
| | | |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | @Autowired |
| | | private DeviceConfigService deviceConfigService; |
| | | @Autowired |
| | |
| | | * 尝试从redis获取数据 |
| | | */ |
| | | public int[][] getDataFromRedis(Integer lev, List<NavigationMapType> mapTypes, List<int[]> whitePoints, List<int[]> shuttlePoints) { |
| | | RedisUtil redisUtil = SpringUtils.getBean(RedisUtil.class); |
| | | Object o = redisUtil.get(RedisKeyType.MAP.key + lev); |
| | | if (o == null) { |
| | | return null; |
| | |
| | | return map; |
| | | } |
| | | |
| | | //获取JSON格式数据 |
| | | //获取实时地图-JSON格式数据 |
| | | public List<List<MapNode>> getJsonData(Integer lev, List<NavigationMapType> mapTypes, List<int[]> whitePoints, List<int[]> shuttlePoints) { |
| | | try { |
| | | Object data = redisUtil.get(RedisKeyType.MAP.key + lev); |
| | | if (data == null) { |
| | | return null; |
| | | } |
| | | |
| | | BasMap basMap = JSON.parseObject(data.toString(), BasMap.class); |
| | | //解析json地图数据 |
| | | ArrayList arrayList = JSON.parseObject(basMap.getData(), ArrayList.class); |
| | | List<List<MapNode>> lists = filterMap(mapTypes, arrayList, lev, whitePoints, shuttlePoints);//过滤地图数据 |
| | | return lists; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | //获取原始地图-JSON格式数据 |
| | | public List<List<MapNode>> getJsonOriginData(Integer lev, List<NavigationMapType> mapTypes, List<int[]> whitePoints, List<int[]> shuttlePoints) { |
| | | try { |
| | | BasMap basMap = basMapService.selectLatestMap(lev); |
| | | String originData = basMap.getOriginData(); |
| | |
| | | lists = loadShuttle(lists, shuttlePoints); |
| | | } |
| | | |
| | | if (mapType.equals(NavigationMapType.SHUTTLE)) { |
| | | if (mapType.equals(NavigationMapType.LIFT)) { |
| | | //加载货叉提升机点位 |
| | | lists = loadForkLift(lists, lev); |
| | | } |
| | | |
| | | if(mapType.equals(NavigationMapType.PATH_LOCK)) { |
| | | //加载路径锁 |
| | | lists = loadPathLock(lists, lev); |
| | | } |
| | | } |
| | | |
| | |
| | | return lists; |
| | | } |
| | | |
| | | //加载路径锁 |
| | | public List<List<MapNode>> loadPathLock(List<List<MapNode>> lists, Integer lev) { |
| | | try { |
| | | HashMap<String, Object> lockMap = new HashMap<>(); |
| | | Object o = redisUtil.get(RedisKeyType.LOCK_MAP_NODES.key + lev); |
| | | if (o != null) { |
| | | lockMap = (HashMap<String, Object>) o; |
| | | } |
| | | |
| | | for (Map.Entry<String, Object> entry : lockMap.entrySet()) { |
| | | String key = entry.getKey(); |
| | | int row = Utils.getRow(key); |
| | | int bay = Utils.getBay(key); |
| | | |
| | | List<MapNode> list = lists.get(row); |
| | | MapNode mapNode = list.get(bay); |
| | | |
| | | //节点设置成路径锁 |
| | | mapNode.setValue(MapNodeType.LOCK.id); |
| | | |
| | | //更新list |
| | | list.set(bay, mapNode); |
| | | lists.set(row, list); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return lists; |
| | | } |
| | | |
| | | } |
| | |
| | | package com.zy.common.utils; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.core.common.SpringUtils; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.BasMap; |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.common.model.MapNode; |
| | | import com.zy.common.model.NavigateNode; |
| | | import com.zy.common.model.enums.NavigationMapType; |
| | | import com.zy.core.enums.MapNodeType; |
| | | import com.zy.core.enums.RedisKeyType; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | |
| | | @Component |
| | | public class NavigateMapUtils { |
| | | |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | |
| | | /** |
| | | * 写入路径节点数据到redis地图中 |
| | | * lock为true 禁用库位,lock为false恢复库位 |
| | | */ |
| | | public synchronized boolean writeNavigateNodeToRedisMap(Integer lev, Integer shuttleNo, List<NavigateNode> nodes, boolean lock) { |
| | | RedisUtil redisUtil = SpringUtils.getBean(RedisUtil.class); |
| | | NavigateMapData navigateMapData = SpringUtils.getBean(NavigateMapData.class); |
| | | try { |
| | | if (nodes.isEmpty()) { |
| | | return true; |
| | | } |
| | | |
| | | Object o = redisUtil.get(RedisKeyType.MAP.key + lev); |
| | | if (o == null) { |
| | | return false; |
| | | } |
| | | |
| | | //获取小车节点 |
| | | int[] shuttlePoint = Utils.getShuttlePoint(shuttleNo); |
| | | if (shuttlePoint == null) { |
| | | return false; |
| | | } |
| | | |
| | | //获取小车节点-获取除白名单外的指定楼层全部穿梭车xy坐标点 |
| | | List<int[]> shuttlePoints = Utils.getShuttlePoints(shuttleNo, lev); |
| | | |
| | | BasMap basMap = JSON.parseObject(o.toString(), BasMap.class); |
| | | ArrayList arrayList = JSON.parseObject(basMap.getData(), ArrayList.class); |
| | | //带小车地图 |
| | | List<NavigationMapType> mapTypes = new ArrayList<>(); |
| | | mapTypes.add(NavigationMapType.NONE); |
| | | mapTypes.add(NavigationMapType.SHUTTLE); |
| | | List<List<MapNode>> listsHasShuttle = navigateMapData.filterMap(mapTypes, arrayList, lev, null, shuttlePoints);//获取带小车地图数据 |
| | | |
| | | //获取全部地图数据 |
| | | List<List<MapNode>> lists = navigateMapData.rebuildData(arrayList); |
| | | //载入库位信息 |
| | | lists = navigateMapData.loadLocMast(NavigationMapType.NONE.id, lists, lev, null); |
| | | |
| | | //检测路径是否被锁定 |
| | | if (lock) { |
| | | for (NavigateNode node : nodes) { |
| | | //判断是否为当前小车 |
| | | if(shuttlePoint[0] == node.getX() && shuttlePoint[1] == node.getY()) { |
| | | continue; |
| | | } |
| | | |
| | | List<MapNode> listX = listsHasShuttle.get(node.getX()); |
| | | MapNode mapNode = listX.get(node.getY()); |
| | | if (mapNode.getValue() == MapNodeType.LOCK.id) { |
| | | return false;//路径被锁定过,禁止再次锁定 |
| | | } |
| | | if (mapNode.getValue() == MapNodeType.CAR.id) { |
| | | return false;//路径存在小车,禁止锁定 |
| | | } |
| | | } |
| | | } |
| | | |
| | | //尝试锁定/解锁路径 |
| | | for (NavigateNode node : nodes) { |
| | | if (node.getZ() != lev) { |
| | | continue; |
| | | } |
| | | |
| | | List<MapNode> listX = lists.get(node.getX()); |
| | | MapNode mapNode = listX.get(node.getY()); |
| | | if (lock) { |
| | | mapNode.setValue(MapNodeType.LOCK.id);//禁用库位 |
| | | } else { |
| | | mapNode.setValue(node.getNodeValue());//恢复原始节点数据 |
| | | } |
| | | |
| | | listX.set(node.getY(), mapNode); |
| | | lists.set(node.getX(), listX); |
| | | } |
| | | basMap.setData(JSON.toJSONString(lists)); |
| | | basMap.setUpdateTime(new Date()); |
| | | //将数据库地图数据存入redis |
| | | redisUtil.set(RedisKeyType.MAP.key + lev, JSON.toJSONString(basMap)); |
| | | return true; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | if (lock) { |
| | | return lockNodes(lev, shuttleNo, nodes); |
| | | }else { |
| | | return unlockNodes(lev, shuttleNo, nodes); |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | public synchronized boolean lockNodes(Integer lev, Integer shuttleNo, List<NavigateNode> nodes) { |
| | | if (nodes.isEmpty()) { |
| | | return false; |
| | | } |
| | | |
| | | 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<String> shuttleList = new ArrayList<>(); |
| | | //获取小车节点-获取除白名单外的指定楼层全部穿梭车xy坐标点 |
| | | List<int[]> shuttlePoints = Utils.getShuttlePoints(shuttleNo, lev); |
| | | for (int[] point : shuttlePoints) { |
| | | String key = Utils.getLocNo(point[0], point[1], lev); |
| | | shuttleList.add(key); |
| | | } |
| | | |
| | | HashMap<String, Object> tmpMap = new HashMap<>(); |
| | | for (NavigateNode node : nodes) { |
| | | String key = Utils.getLocNo(node.getX(), node.getY(), lev); |
| | | |
| | | //判断节点是否有小车 |
| | | if(shuttleList.contains(key)) { |
| | | return false; |
| | | } |
| | | |
| | | //判断节点是否被锁定 |
| | | if(lockMap.containsKey(key)) { |
| | | return false; |
| | | } |
| | | |
| | | tmpMap.put(key, shuttleNo); |
| | | } |
| | | |
| | | lockMap.putAll(tmpMap); |
| | | |
| | | redisUtil.set(RedisKeyType.LOCK_MAP_NODES.key + lev, lockMap); |
| | | return true; |
| | | } |
| | | |
| | | public synchronized boolean unlockNodes(Integer lev, Integer shuttleNo, List<NavigateNode> nodes) { |
| | | if (nodes.isEmpty()) { |
| | | return false; |
| | | } |
| | | |
| | | HashMap<String, Object> lockMap = new HashMap<>(); |
| | | Object o = redisUtil.get(RedisKeyType.LOCK_MAP_NODES.key + lev); |
| | | if (o != null) { |
| | | lockMap = (HashMap<String, Object>) o; |
| | | } |
| | | |
| | | for (NavigateNode node : nodes) { |
| | | String key = Utils.getLocNo(node.getX(), node.getY(), lev); |
| | | |
| | | if(!lockMap.containsKey(key)) { |
| | | continue; |
| | | } |
| | | |
| | | Integer deviceNo = (Integer) lockMap.get(key); |
| | | if(deviceNo.equals(shuttleNo)) { |
| | | lockMap.remove(key); |
| | | } |
| | | } |
| | | lockMap.putAll(lockMap); |
| | | redisUtil.set(RedisKeyType.LOCK_MAP_NODES.key + lev, lockMap); |
| | | return true; |
| | | } |
| | | |
| | | } |
| | |
| | | } |
| | | |
| | | public NavigateNode astarSearchJava(NavigateNode start, NavigateNode end) { |
| | | //默认地图母轨方向x |
| | | String mapDirection = "x"; |
| | | ConfigService configService = SpringUtils.getBean(ConfigService.class); |
| | | if (configService != null) { |
| | | Config config = configService.selectOne(new EntityWrapper<Config>() |
| | | .eq("code", "direction_map") |
| | | .eq("status", 1)); |
| | | if (config != null) { |
| | | mapDirection = config.getValue(); |
| | | } |
| | | } |
| | | |
| | | //把第一个开始的结点加入到Open表中 |
| | | this.Open.add(start); |
| | | //主循环 |
| | |
| | | //将这个结点加入到Close表中 |
| | | Close.add(current_node); |
| | | //对当前结点进行扩展,得到一个四周结点的数组 |
| | | ArrayList<NavigateNode> neighbour_node = extend_current_node(current_node); |
| | | ArrayList<NavigateNode> neighbour_node = extend_current_node(current_node, mapDirection); |
| | | //对这个结点遍历,看是否有目标结点出现 |
| | | for (NavigateNode node : neighbour_node) { |
| | | // G + H + E (对启发函数增加去拐点方案calcNodeExtraCost) |
| | |
| | | } |
| | | |
| | | |
| | | public ArrayList<NavigateNode> extend_current_node(NavigateNode current_node) { |
| | | //默认地图母轨方向x |
| | | String mapDirection = "x"; |
| | | ConfigService configService = SpringUtils.getBean(ConfigService.class); |
| | | if (configService != null) { |
| | | Config config = configService.selectOne(new EntityWrapper<Config>() |
| | | .eq("code", "direction_map") |
| | | .eq("status", 1)); |
| | | if (config != null) { |
| | | mapDirection = config.getValue(); |
| | | } |
| | | } |
| | | |
| | | public ArrayList<NavigateNode> extend_current_node(NavigateNode current_node, String mapDirection) { |
| | | //获取当前结点的x, y |
| | | int x = current_node.getX(); |
| | | int y = current_node.getY(); |
| | |
| | | if (mapDirection.equals("x")) {//母轨x方向 |
| | | if (map[x][y] == MapNodeType.MAIN_PATH.id) { |
| | | //母轨才能进行上下移动 |
| | | if (is_valid(x + 1, y)) |
| | | { |
| | | if (is_valid(x + 1, y)) { |
| | | NavigateNode node = new NavigateNode(x + 1, y); |
| | | node.setNodeValue(map[x + 1][y]); |
| | | neighbour_node.add(node); |
| | | } |
| | | if (is_valid(x - 1, y)) |
| | | { |
| | | if (is_valid(x - 1, y)) { |
| | | NavigateNode node = new NavigateNode(x - 1, y); |
| | | node.setNodeValue(map[x - 1][y]); |
| | | neighbour_node.add(node); |
| | |
| | | |
| | | if (map[x][y] == MapNodeType.NORMAL_PATH.id || map[x][y] == MapNodeType.MAIN_PATH.id || map[x][y] == MapNodeType.CONVEYOR_CAR_GO.id || map[x][y] == MapNodeType.CHARGE.id || map[x][y] == MapNodeType.LIFT.id) { |
| | | //子轨和母轨、小车可走输送线、充电桩、提升机才能进行左右移动 |
| | | if (is_valid(x, y + 1)) |
| | | { |
| | | if (is_valid(x, y + 1)) { |
| | | NavigateNode node = new NavigateNode(x, y + 1); |
| | | node.setNodeValue(map[x][y + 1]); |
| | | neighbour_node.add(node); |
| | | } |
| | | if (is_valid(x, y - 1)) |
| | | { |
| | | if (is_valid(x, y - 1)) { |
| | | NavigateNode node = new NavigateNode(x, y - 1); |
| | | node.setNodeValue(map[x][y - 1]); |
| | | neighbour_node.add(node); |
| | | } |
| | | } |
| | | }else if (mapDirection.equals("y")) {//母轨y方向 |
| | | } else if (mapDirection.equals("y")) {//母轨y方向 |
| | | if (map[x][y] == MapNodeType.MAIN_PATH.id) { |
| | | //母轨才能进行左右移动 |
| | | if (is_valid(x, y + 1)) |
| | | { |
| | | if (is_valid(x, y + 1)) { |
| | | NavigateNode node = new NavigateNode(x, y + 1); |
| | | node.setNodeValue(map[x][y + 1]); |
| | | neighbour_node.add(node); |
| | | } |
| | | if (is_valid(x, y - 1)) |
| | | { |
| | | if (is_valid(x, y - 1)) { |
| | | NavigateNode node = new NavigateNode(x, y - 1); |
| | | node.setNodeValue(map[x][y - 1]); |
| | | neighbour_node.add(node); |
| | |
| | | |
| | | if (map[x][y] == MapNodeType.NORMAL_PATH.id || map[x][y] == MapNodeType.MAIN_PATH.id || map[x][y] == MapNodeType.CONVEYOR_CAR_GO.id || map[x][y] == MapNodeType.CHARGE.id || map[x][y] == MapNodeType.LIFT.id) { |
| | | //子轨和母轨、小车可走输送线、充电桩、提升机才能进行上下移动 |
| | | if (is_valid(x + 1, y)) |
| | | { |
| | | if (is_valid(x + 1, y)) { |
| | | NavigateNode node = new NavigateNode(x + 1, y); |
| | | node.setNodeValue(map[x + 1][y]); |
| | | neighbour_node.add(node); |
| | | } |
| | | if (is_valid(x - 1, y)) |
| | | { |
| | | if (is_valid(x - 1, y)) { |
| | | NavigateNode node = new NavigateNode(x - 1, y); |
| | | node.setNodeValue(map[x - 1][y]); |
| | | neighbour_node.add(node); |
| | |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.core.common.SpringUtils; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.common.model.MapNode; |
| | |
| | | * 获取分段路径,每当有一个拐点则进行一次分段,最终返回总分段数据 |
| | | */ |
| | | public List<List<NavigateNode>> getSectionPath(List<NavigateNode> mapList) { |
| | | List<List<NavigateNode>> list = new ArrayList<>(); |
| | | NavigateNode firstNode = mapList.get(0); |
| | | //获取地图 |
| | | List<List<MapNode>> mapNodes = navigateMapData.getJsonData(firstNode.getZ(), NavigationMapType.getMapTypes(NavigationMapType.NONE), null, null); |
| | | |
| | | List<List<NavigateNode>> list = new ArrayList<>(); |
| | | List<NavigateNode> data = new ArrayList<>(); |
| | | String direction = mapList.get(0).getDirection();//行走方向 |
| | | String direction = firstNode.getDirection();//行走方向 |
| | | |
| | | for (NavigateNode navigateNode : mapList) { |
| | | data.add(navigateNode); |
| | |
| | | //直行线路 |
| | | navigateNode.setDirection(direction);//设置行走方向 |
| | | } |
| | | Integer distance = getXToNextDistance(navigateNode);//获取当前点到下一点的行走距离 |
| | | Integer distance = getXToNextDistance(mapNodes, navigateNode);//获取当前点到下一点的行走距离 |
| | | navigateNode.setMoveDistance(distance); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | //获取从x点到下一点的行走距离 |
| | | public Integer getXToNextDistance(NavigateNode xNode) { |
| | | NavigateMapData mapData = SpringUtils.getBean(NavigateMapData.class); |
| | | List<List<MapNode>> lists = mapData.getJsonData(xNode.getZ(), NavigationMapType.getMapTypes(NavigationMapType.NONE), null, null); |
| | | if (lists != null) { |
| | | MapNode mapNode = lists.get(xNode.getX()).get(xNode.getY()); |
| | | if (mapNode != null) { |
| | | switch (xNode.getDirection()) { |
| | | case "top": |
| | | return mapNode.getTop(); |
| | | case "bottom": |
| | | return mapNode.getBottom(); |
| | | case "left": |
| | | return mapNode.getLeft(); |
| | | case "right": |
| | | return mapNode.getRight(); |
| | | } |
| | | } |
| | | public Integer getXToNextDistance(List<List<MapNode>> mapLists, NavigateNode xNode) { |
| | | if (mapLists == null) { |
| | | return 0; |
| | | } |
| | | |
| | | if (mapLists.isEmpty()) { |
| | | return 0; |
| | | } |
| | | |
| | | MapNode mapNode = mapLists.get(xNode.getX()).get(xNode.getY()); |
| | | if (mapNode != null) { |
| | | switch (xNode.getDirection()) { |
| | | case "top": |
| | | return mapNode.getTop(); |
| | | case "bottom": |
| | | return mapNode.getBottom(); |
| | | case "left": |
| | | return mapNode.getLeft(); |
| | | case "right": |
| | | return mapNode.getRight(); |
| | | } |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | |
| | | import com.zy.core.enums.MapNodeType; |
| | | import com.zy.core.enums.ShuttleRunDirection; |
| | | import com.zy.core.enums.SlaveType; |
| | | import com.zy.core.model.ShuttleSlave; |
| | | import com.zy.core.model.command.ShuttleAssignCommand; |
| | | import com.zy.core.model.command.ShuttleCommand; |
| | | import com.zy.core.model.protocol.ShuttleProtocol; |
| | |
| | | lockNode.add(node.clone()); |
| | | } |
| | | |
| | | long startTime = System.currentTimeMillis(); |
| | | List<ShuttleCommand> commands = new ArrayList<>(); |
| | | //获取分段路径 |
| | | List<List<NavigateNode>> data = navigateUtils.getSectionPath(nodeList); |
| | | long endTime = System.currentTimeMillis(); |
| | | News.info("getSection path time:{}", (endTime - startTime)); |
| | | //将每一段路径分成command指令 |
| | | for (List<NavigateNode> nodes : data) { |
| | | //开始路径 |
| | |
| | | FORK_LIFT_PUT_COMPLETE("fork_lift_put_complete_"), |
| | | OUT_TASK_PREVIEW_DISPATCH_FORKLIFT("out_task_preview_dispatch_forklift_"), |
| | | |
| | | //地图锁定节点 |
| | | LOCK_MAP_NODES("lock_map_nodes_"), |
| | | |
| | | //设备消息KEY |
| | | DEVICE_SHUTTLE_MSG_KEY_("deviceShuttleMsgKey_"), |
| | | DEVICE_FORK_LIFT_MSG_KEY_("deviceForkLiftMsgKey_"), |
| | |
| | | //获取地图数据 |
| | | getMap(lev) { |
| | | this.sendWs(JSON.stringify({ |
| | | "url": "/console/map/auth", |
| | | "url": "/console/locMap/auth", |
| | | "data": lev |
| | | })) |
| | | }, |
| | |
| | | this.setSiteInfo(JSON.parse(result.data)) |
| | | }else if (result.url == "/console/map/auth") { |
| | | this.setMap(JSON.parse(result.data)) |
| | | }else if (result.url == "/console/locMap/auth") { |
| | | this.setMap(JSON.parse(result.data)) |
| | | }else if (result.url == "/console/barcode/output/site") { |
| | | this.setCodeData(JSON.parse(result.data)) |
| | | } |