| | |
| | | return R.error(); |
| | | } |
| | | |
| | | BasMap basMap = JSON.parseObject(data.toString(), BasMap.class); |
| | | //解析json地图数据 |
| | | ArrayList arrayList = JSON.parseObject(basMap.getData(), ArrayList.class); |
| | | |
| | | List<List<MapNode>> arrayList = (List<List<MapNode>>) data; |
| | | List<List<MapNode>> lists = navigateMapData.filterMap(NavigationMapType.getMapTypes(NavigationMapType.NONE, NavigationMapType.PATH_LOCK), arrayList, lev, null, null);//过滤地图数据 |
| | | return R.ok().add(lists); |
| | | } |
| | |
| | | return R.error(); |
| | | } |
| | | |
| | | BasMap basMap = JSON.parseObject(data.toString(), BasMap.class); |
| | | //解析json地图数据 |
| | | ArrayList arrayList = JSON.parseObject(basMap.getData(), ArrayList.class); |
| | | |
| | | List<List<MapNode>> arrayList = (List<List<MapNode>>) data; |
| | | List<List<MapNode>> lists = navigateMapData.filterMap(NavigationMapType.getMapTypes(NavigationMapType.NONE), arrayList, lev, null, null);//过滤地图数据 |
| | | return R.ok().add(lists); |
| | | } |
| | |
| | | @GetMapping("/map/resetMap/auth") |
| | | @ManagerAuth |
| | | public R resetMapToRedis() { |
| | | for (int i = 1; i <= 10; i++) {//总共10层楼 |
| | | redisUtil.del(RedisKeyType.MAP.key + i); |
| | | List<BasMap> basMaps = basMapService.selectList(new EntityWrapper<BasMap>().orderBy("lev", true)); |
| | | for (BasMap basMap : basMaps) { |
| | | Integer lev = basMap.getLev(); |
| | | redisUtil.del(RedisKeyType.MAP.key + lev); |
| | | } |
| | | return R.ok(); |
| | | } |
| | |
| | | } |
| | | |
| | | //将数据库地图数据存入redis |
| | | redisUtil.set(RedisKeyType.MAP.key + lev, JSON.toJSONString(basMap)); |
| | | redisUtil.set(RedisKeyType.MAP.key + lev, lists); |
| | | } |
| | | |
| | | } |
| | |
| | | @Autowired |
| | | private ObjectMapper objectMapper; |
| | | |
| | | public int[][] getData(Integer lev, List<NavigationMapType> mapTypes, List<int[]> whitePoints, List<int[]> shuttlePoints) { |
| | | try { |
| | | BasMap basMap = basMapService.selectLatestMap(lev); |
| | | String originData = basMap.getOriginData(); |
| | | |
| | | //解析json地图数据 |
| | | ArrayList arrayList = JSON.parseObject(originData, ArrayList.class); |
| | | List<List<MapNode>> lists = filterMap(mapTypes, 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; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 尝试从redis获取数据 |
| | | */ |
| | | public int[][] getDataFromRedis(Integer lev, List<NavigationMapType> mapTypes, List<int[]> whitePoints, List<int[]> shuttlePoints) { |
| | | Object o = redisUtil.get(RedisKeyType.MAP.key + lev); |
| | | if (o == null) { |
| | | Object data = redisUtil.get(RedisKeyType.MAP.key + lev); |
| | | if (data == null) { |
| | | return null; |
| | | } |
| | | |
| | | BasMap basMap = JSON.parseObject(o.toString(), BasMap.class); |
| | | return this.getDataFormString(lev, basMap.getData(), mapTypes, whitePoints, shuttlePoints); |
| | | List<List<MapNode>> arrayList = (List<List<MapNode>>) data; |
| | | return this.getDataFormString(lev, arrayList, mapTypes, whitePoints, shuttlePoints); |
| | | } |
| | | |
| | | /** |
| | | * 从List数据中获取地图 |
| | | */ |
| | | public int[][] getDataFormString(Integer lev, String data, List<NavigationMapType> mapTypes, List<int[]> whitePoints, List<int[]> shuttlePoints) { |
| | | ArrayList arrayList = JSON.parseObject(data, ArrayList.class); |
| | | public int[][] getDataFormString(Integer lev, List<List<MapNode>> arrayList, List<NavigationMapType> mapTypes, List<int[]> whitePoints, List<int[]> shuttlePoints) { |
| | | List<List<MapNode>> lists = filterMap(mapTypes, arrayList, lev, whitePoints, shuttlePoints);//过滤地图数据 |
| | | int[][] map = new int[lists.size()][]; |
| | | int j = 0; |
| | |
| | | return null; |
| | | } |
| | | |
| | | BasMap basMap = JSON.parseObject(data.toString(), BasMap.class); |
| | | //解析json地图数据 |
| | | ArrayList arrayList = JSON.parseObject(basMap.getData(), ArrayList.class); |
| | | List<List<MapNode>> arrayList = (List<List<MapNode>>) data; |
| | | List<List<MapNode>> lists = filterMap(mapTypes, arrayList, lev, whitePoints, shuttlePoints);//过滤地图数据 |
| | | return lists; |
| | | } catch (Exception e) { |
| | |
| | | * @param whitePoints 白名单节点,不需要被过滤 |
| | | * @param shuttlePoints 穿梭车节点,需要加载进地图 |
| | | */ |
| | | public List<List<MapNode>> filterMap(List<NavigationMapType> mapTypes, List arrayList, Integer lev, List<int[]> whitePoints, List<int[]> shuttlePoints) { |
| | | //重建数据格式 |
| | | List<List<MapNode>> lists = rebuildData(arrayList); |
| | | |
| | | public List<List<MapNode>> filterMap(List<NavigationMapType> mapTypes, List<List<MapNode>> lists, Integer lev, List<int[]> whitePoints, List<int[]> shuttlePoints) { |
| | | List<NavigationMapType> locMapType = new ArrayList<>(); |
| | | locMapType.add(NavigationMapType.NONE); |
| | | locMapType.add(NavigationMapType.DFX); |
| | | locMapType.add(NavigationMapType.NORMAL); |
| | | for (NavigationMapType mapType : mapTypes) { |
| | |
| | | import com.zy.asrs.service.LocMastService; |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.common.model.NavigateNode; |
| | | import com.zy.core.enums.RedisKeyType; |
| | | |
| | | import java.util.HashMap; |
| | | |
| | | /** |
| | | * 库位编号和A*算法的xy轴转换工具类 |
| | |
| | | |
| | | public static String xyToPosition(int x, int y, int z) { |
| | | String locNo = Utils.getLocNo(x, y, z); |
| | | String code = null; |
| | | |
| | | //库位号转小车二维码 |
| | | LocMastService locMastService = SpringUtils.getBean(LocMastService.class); |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>() |
| | | .eq("loc_no", locNo) |
| | | .eq("status", 1)); |
| | | if (locMast == null) { |
| | | return null; |
| | | RedisUtil redisUtil = SpringUtils.getBean(RedisUtil.class); |
| | | Object object = redisUtil.get(RedisKeyType.POINT_MAP.key); |
| | | |
| | | if(object == null) { |
| | | //库位号转小车二维码 |
| | | LocMastService locMastService = SpringUtils.getBean(LocMastService.class); |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>() |
| | | .eq("loc_no", locNo) |
| | | .eq("status", 1)); |
| | | if (locMast == null) { |
| | | return null; |
| | | } |
| | | |
| | | code = locMast.getQrCodeValue(); |
| | | }else { |
| | | HashMap<String, String> cache = (HashMap<String, String>) object; |
| | | code = cache.get(locNo); |
| | | } |
| | | return locMast.getQrCodeValue(); |
| | | return code; |
| | | } |
| | | |
| | | //小车条形码转路径算法节点 |
| | | public static NavigateNode codeToNode(String code) { |
| | | LocMastService locMastService = SpringUtils.getBean(LocMastService.class); |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>() |
| | | .eq("qr_code_value", code) |
| | | .eq("status", 1)); |
| | | if (locMast == null) { |
| | | return null; |
| | | NavigateNode node = null; |
| | | |
| | | RedisUtil redisUtil = SpringUtils.getBean(RedisUtil.class); |
| | | Object object = redisUtil.get(RedisKeyType.LOC_MAP.key); |
| | | |
| | | if (object == null) { |
| | | LocMastService locMastService = SpringUtils.getBean(LocMastService.class); |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>() |
| | | .eq("qr_code_value", code) |
| | | .eq("status", 1)); |
| | | if (locMast == null) { |
| | | return null; |
| | | } |
| | | node = new NavigateNode(locMast.getRow1(), locMast.getBay1()); |
| | | node.setZ(locMast.getLev1()); |
| | | } else { |
| | | HashMap<String, String> cache = (HashMap<String, String>) object; |
| | | String locNo = cache.get(code); |
| | | |
| | | node = new NavigateNode(Utils.getRow(locNo), Utils.getBay(locNo)); |
| | | node.setZ(Utils.getLev(locNo)); |
| | | } |
| | | NavigateNode node = new NavigateNode(locMast.getRow1(), locMast.getBay1()); |
| | | node.setZ(locMast.getLev1()); |
| | | return node; |
| | | } |
| | | |
| | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.common.SpringUtils; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.BasShuttle; |
| | | import com.zy.asrs.entity.DeviceConfig; |
| | | import com.zy.asrs.service.BasShuttleService; |
| | | import com.zy.asrs.service.DeviceConfigService; |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.common.model.MapNode; |
| | |
| | | import com.zy.core.cache.SlaveConnection; |
| | | import com.zy.core.dispatcher.ShuttleDispatchUtils; |
| | | import com.zy.core.enums.MapNodeType; |
| | | import com.zy.core.enums.RedisKeyType; |
| | | import com.zy.core.enums.ShuttleRunDirection; |
| | | import com.zy.core.enums.SlaveType; |
| | | import com.zy.core.model.command.ShuttleAssignCommand; |
| | |
| | | public class ShuttleOperaUtils { |
| | | |
| | | @Autowired |
| | | private BasShuttleService basShuttleService; |
| | | @Autowired |
| | | private NavigateUtils navigateUtils; |
| | | @Autowired |
| | | private NavigateMapUtils navigateMapUtils; |
| | | @Autowired |
| | | private NavigateMapData navigateMapData; |
| | | @Autowired |
| | |
| | | private ShuttleDispatchUtils shuttleDispatchUtils; |
| | | @Autowired |
| | | private DeviceConfigService deviceConfigService; |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | |
| | | public synchronized List<ShuttleCommand> getStartToTargetCommands(String startLocNo, String endLocNo, List<NavigationMapType> mapTypes, ShuttleAssignCommand assignCommand, ShuttleThread shuttleThread) { |
| | | return getStartToTargetCommands(startLocNo, endLocNo, mapTypes, null, assignCommand, shuttleThread, "move"); |
| | |
| | | } |
| | | Integer shuttleNo = shuttleProtocol.getShuttleNo(); |
| | | //获取小车移动速度 |
| | | Integer runSpeed = Optional.ofNullable(basShuttleService.selectOne(new EntityWrapper<BasShuttle>().eq("shuttle_no", shuttleNo)).getRunSpeed()).orElse(1000); |
| | | Integer runSpeed = 1000; |
| | | Object speedObj = redisUtil.get(RedisKeyType.SHUTTLE_SPEED_MAP.key); |
| | | if (speedObj != null) { |
| | | HashMap<Integer, Integer> shuttleSpeedMap = (HashMap<Integer, Integer>) speedObj; |
| | | Integer speed = shuttleSpeedMap.get(shuttleNo); |
| | | if (speed != null) { |
| | | runSpeed = speed; |
| | | } |
| | | } |
| | | |
| | | long calcStartTime = System.currentTimeMillis(); |
| | | List<NavigateNode> nodeList = navigateUtils.calc(startLocNo, endLocNo, mapTypes, Utils.getShuttlePoints(shuttleNo, Utils.getLev(startLocNo)), whites); |
| | | if (nodeList == null) { |
| | |
| | | List<List<NavigateNode>> data = navigateUtils.getSectionPath(nodeList); |
| | | long endTime = System.currentTimeMillis(); |
| | | News.info("[RCS Debug] getSection path time:{}", (endTime - startTime)); |
| | | |
| | | long startGetSectionCommandTime = System.currentTimeMillis(); |
| | | //将每一段路径分成command指令 |
| | | for (int i = 0; i < data.size(); i++) { |
| | | long startGetStartAndEndPathTime = System.currentTimeMillis(); |
| | | List<NavigateNode> nodes = data.get(i); |
| | | |
| | | //开始路径 |
| | | NavigateNode startPath = nodes.get(0); |
| | | |
| | | //目标路径 |
| | | NavigateNode endPath = nodes.get(nodes.size() - 1); |
| | | News.info("[RCS Debug] getStartAndEndPath idx:{} time:{}", i, (System.currentTimeMillis() - startGetStartAndEndPathTime)); |
| | | |
| | | long startAllDistanceTime = System.currentTimeMillis(); |
| | | Integer allDistance = navigateUtils.getCurrentPathAllDistance(nodes);//计算当前路径行走总距离 |
| | | News.info("[RCS Debug] getAllDistance idx:{} time:{}", i, (System.currentTimeMillis() - startAllDistanceTime)); |
| | | |
| | | long startGetPosition = System.currentTimeMillis(); |
| | | //通过xy坐标小车二维码 |
| | | String startCodeNum = NavigatePositionConvert.xyToPosition(startPath.getX(), startPath.getY(), startPath.getZ()); |
| | | //通过xy坐标小车二维码 |
| | | String distCodeNum = NavigatePositionConvert.xyToPosition(endPath.getX(), endPath.getY(), endPath.getZ()); |
| | | News.info("[RCS Debug] xyToPosition idx:{} time:{}", i, (System.currentTimeMillis() - startGetPosition)); |
| | | |
| | | long startGetMoveCommandTime = System.currentTimeMillis(); |
| | | //获取移动命令 |
| | | ShuttleCommand command = shuttleThread.getMoveCommand(assignCommand.getDeviceTaskNo(), startCodeNum, distCodeNum, allDistance, ShuttleRunDirection.get(startPath.getDirection()).id.intValue(), runSpeed, nodes); |
| | | News.info("[RCS Debug] getMoveCommand idx:{} time:{}", i, (System.currentTimeMillis() - startGetMoveCommandTime)); |
| | | |
| | | if (i + 1 == data.size()) { |
| | | long startGetInOutLiftTime = System.currentTimeMillis(); |
| | | if (moveType.equals("inLift")) { |
| | | command = shuttleThread.getMoveLiftCommand(assignCommand.getDeviceTaskNo(), startCodeNum, distCodeNum, allDistance, ShuttleRunDirection.get(startPath.getDirection()).id.intValue(), runSpeed, nodes, true); |
| | | }else if (moveType.equals("outLift")) { |
| | | command = shuttleThread.getMoveLiftCommand(assignCommand.getDeviceTaskNo(), startCodeNum, distCodeNum, allDistance, ShuttleRunDirection.get(startPath.getDirection()).id.intValue(), runSpeed, nodes, false); |
| | | } |
| | | News.info("[RCS Debug] getInOutLiftTime idx:{} time:{}", i, (System.currentTimeMillis() - startGetInOutLiftTime)); |
| | | } |
| | | |
| | | command.setNodes(nodes);//将行走节点添加到每一步命令中 |
| | | commands.add(command); |
| | | } |
| | | News.info("[RCS Debug] getSectionCommand path time:{}", (System.currentTimeMillis() - startGetSectionCommandTime)); |
| | | |
| | | assignCommand.setNodes(allNode);//当前任务所占用的节点list |
| | | assignCommand.setMapTypes(mapTypes); |
| | | |
| | | //小车移动连续下发指令 |
| | | boolean shuttleMoveCommandsContinuously = false; |
| | | Config shuttleMoveCommandsContinuouslyConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "shuttleMoveCommandsContinuously")); |
| | | if (shuttleMoveCommandsContinuouslyConfig != null) { |
| | | if (shuttleMoveCommandsContinuouslyConfig.getValue().equals("Y")) { |
| | | Object object = redisUtil.get(RedisKeyType.SYSTEM_CONFIG_MAP.key); |
| | | if (object != null) { |
| | | HashMap<String, String> systemConfigMap = (HashMap<String, String>) object; |
| | | String shuttleMoveCommandsContinuouslyConfig = systemConfigMap.get("shuttleMoveCommandsContinuously"); |
| | | if (shuttleMoveCommandsContinuouslyConfig != null && shuttleMoveCommandsContinuouslyConfig.equals("Y")) { |
| | | shuttleMoveCommandsContinuously = true; |
| | | } |
| | | } |
| | |
| | | return; |
| | | } |
| | | } |
| | | log.info(format, arguments); |
| | | offer(NewsLevel.INFO, format, arguments); |
| | | return; |
| | | } |
| | | |
| | | RedisUtil redisUtil = null; |
| | | try { |
| | | redisUtil = SpringUtils.getBean(RedisUtil.class); |
| | |
| | | return; |
| | | } |
| | | } |
| | | log.warn(format, arguments); |
| | | offer(NewsLevel.WARN, format, arguments); |
| | | return; |
| | | } |
| | | |
| | | RedisUtil redisUtil = null; |
| | | try { |
| | | redisUtil = SpringUtils.getBean(RedisUtil.class); |
| | |
| | | return; |
| | | } |
| | | } |
| | | log.error(format, arguments); |
| | | offer(NewsLevel.ERROR, format, arguments); |
| | | return; |
| | | } |
| | | |
| | | RedisUtil redisUtil = null; |
| | | try { |
| | | redisUtil = SpringUtils.getBean(RedisUtil.class); |
New file |
| | |
| | | package com.zy.core.config; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.zy.asrs.entity.LocMast; |
| | | import com.zy.asrs.service.LocMastService; |
| | | import com.zy.common.utils.RedisUtil; |
| | | import com.zy.core.enums.RedisKeyType; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.PostConstruct; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | |
| | | @Component |
| | | public class PointInitializer { |
| | | |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | @Autowired |
| | | private LocMastService locMastService; |
| | | |
| | | @PostConstruct |
| | | public void init() { |
| | | HashMap<String, String> pointMap = new HashMap<>(); |
| | | HashMap<String, String> locMap = new HashMap<>(); |
| | | |
| | | List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<>()); |
| | | for (LocMast locMast : locMasts) { |
| | | String locNo = locMast.getLocNo(); |
| | | String qrCodeValue = locMast.getQrCodeValue(); |
| | | pointMap.put(locNo, qrCodeValue); |
| | | locMap.put(qrCodeValue, locNo); |
| | | } |
| | | |
| | | redisUtil.set(RedisKeyType.POINT_MAP.key, pointMap); |
| | | redisUtil.set(RedisKeyType.LOC_MAP.key, locMap); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.core.config; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.zy.asrs.entity.BasShuttle; |
| | | import com.zy.asrs.entity.DeviceConfig; |
| | | import com.zy.asrs.service.BasShuttleService; |
| | | import com.zy.asrs.service.DeviceConfigService; |
| | | import com.zy.common.utils.RedisUtil; |
| | | import com.zy.core.enums.RedisKeyType; |
| | | import com.zy.core.enums.SlaveType; |
| | | import com.zy.system.entity.Config; |
| | | import com.zy.system.service.ConfigService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.PostConstruct; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Optional; |
| | | |
| | | @Component |
| | | public class ShuttleConfigInitializer { |
| | | |
| | | @Autowired |
| | | private DeviceConfigService deviceConfigService; |
| | | @Autowired |
| | | private BasShuttleService basShuttleService; |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | |
| | | @PostConstruct |
| | | public void shuttleSpeedInit() { |
| | | HashMap<Integer, Integer> shuttleSpeedMap = new HashMap<>(); |
| | | |
| | | List<DeviceConfig> shuttleList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>() |
| | | .eq("device_type", String.valueOf(SlaveType.Shuttle))); |
| | | for (DeviceConfig shuttle : shuttleList) { |
| | | //获取小车移动速度 |
| | | Integer runSpeed = Optional.ofNullable(basShuttleService.selectOne(new EntityWrapper<BasShuttle>().eq("shuttle_no", shuttle.getDeviceNo())).getRunSpeed()).orElse(1000); |
| | | shuttleSpeedMap.put(shuttle.getDeviceNo(), runSpeed); |
| | | } |
| | | |
| | | redisUtil.set(RedisKeyType.SHUTTLE_SPEED_MAP.key, shuttleSpeedMap); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.core.config; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.zy.common.utils.RedisUtil; |
| | | import com.zy.core.enums.RedisKeyType; |
| | | import com.zy.system.entity.Config; |
| | | import com.zy.system.service.ConfigService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.PostConstruct; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | |
| | | @Component |
| | | public class SystemConfigInitializer { |
| | | |
| | | @Autowired |
| | | private ConfigService configService; |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | |
| | | @PostConstruct |
| | | public void init() { |
| | | HashMap<String, String> systemConfigMap = new HashMap<>(); |
| | | |
| | | List<Config> configList = configService.selectList(new EntityWrapper<>()); |
| | | for (Config config : configList) { |
| | | systemConfigMap.put(config.getName(), config.getValue()); |
| | | } |
| | | |
| | | redisUtil.set(RedisKeyType.SYSTEM_CONFIG_MAP.key, systemConfigMap); |
| | | } |
| | | |
| | | } |
| | |
| | | FAKE_DEVICE_CONFIG("fakeDeviceConfig"), |
| | | |
| | | LOG_LIMIT("log_limit_"), |
| | | |
| | | POINT_MAP("point_map"), |
| | | LOC_MAP("loc_map"), |
| | | SHUTTLE_SPEED_MAP("shuttle_speed_map"), |
| | | SYSTEM_CONFIG_MAP("system_config_map"), |
| | | ; |
| | | |
| | | public String key; |
| | |
| | | |
| | | @Override |
| | | public CommandResponse reset() { |
| | | CommandResponse response = new CommandResponse(false); |
| | | try { |
| | | LiftCommand resetCommand = getResetCommand(9999); |
| | | |
| | | //发出请求 |
| | | String resultKey = requestCommand(resetCommand); |
| | | //查询请求结果 |
| | | JSONObject result = queryCommandStatus(resultKey); |
| | | if (result == null) { |
| | | return response;//请求失败 |
| | | } |
| | | if(!result.getString("result").equals("success")) { |
| | | return response;//请求失败 |
| | | } |
| | | |
| | | this.liftProtocol.setSendTime(System.currentTimeMillis());//指令下发时间 |
| | | this.setSyncTaskNo(0); |
| | | this.setProtocolStatus(LiftProtocolStatusType.IDLE); |
| | | response.setMessage(JSON.toJSONString(result)); |
| | | response.setResult(true); |
| | | return response; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | response.setMessage(e.getMessage()); |
| | | return response; |
| | | } |
| | | CommandResponse response = new CommandResponse(true); |
| | | this.setSyncTaskNo(0); |
| | | this.setProtocolStatus(LiftProtocolStatusType.IDLE); |
| | | return response; |
| | | } |
| | | |
| | | @Override |
| | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.common.DateUtils; |
| | | import com.core.common.SpringUtils; |
| | | import com.core.exception.CoolException; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.zy.asrs.entity.BasShuttle; |
| | | import com.zy.asrs.entity.DeviceConfig; |
| | |
| | | request.setBody(body); |
| | | |
| | | NavigateNode startNode = nodes.get(0); |
| | | List<List<MapNode>> mapData = navigateMapData.getJsonData(startNode.getZ(), NavigationMapType.getMapTypes(NavigationMapType.NONE), null, null); |
| | | for (NavigateNode node : nodes) { |
| | | HashMap<String, Object> data = new HashMap<>(); |
| | | String codeNum = NavigatePositionConvert.xyToPosition(node.getX(), node.getY(), node.getZ()); |
| | |
| | | int yp = Integer.parseInt(String.valueOf(nyNode.get("x"))); |
| | | int z = Integer.parseInt(String.valueOf(nyNode.get("z"))); |
| | | |
| | | List<List<MapNode>> mapData = navigateMapData.getJsonData(startNode.getZ(), NavigationMapType.getMapTypes(NavigationMapType.NONE), null, null); |
| | | List<MapNode> mapNodes = mapData.get(node.getX()); |
| | | MapNode mapNode = mapNodes.get(node.getY()); |
| | | |
| | |
| | | |
| | | httpStandard.setRequest(request); |
| | | |
| | | LocMastService locMastService = SpringUtils.getBean(LocMastService.class); |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>() |
| | | .eq("qr_code_value", distCodeNum)); |
| | | if (locMast == null) { |
| | | throw new CoolException("库位信息不存在"); |
| | | } |
| | | Object object = redisUtil.get(RedisKeyType.LOC_MAP.key); |
| | | HashMap<String, String> locMap = (HashMap<String, String>) object; |
| | | String targetLocNo = locMap.get(distCodeNum); |
| | | |
| | | ShuttleCommand command = new ShuttleCommand(); |
| | | command.setShuttleNo(deviceConfig.getDeviceNo()); |
| | | command.setBody(JSON.toJSONString(httpStandard)); |
| | | command.setMode(ShuttleCommandModeType.MOVE.id); |
| | | command.setTargetLocNo(locMast.getLocNo()); |
| | | command.setTargetLocNo(targetLocNo); |
| | | command.setTaskNo(taskId); |
| | | return command; |
| | | } |
| | |
| | | request.setBody(body); |
| | | |
| | | NavigateNode startNode = nodes.get(0); |
| | | List<List<MapNode>> mapData = navigateMapData.getJsonData(startNode.getZ(), NavigationMapType.getMapTypes(NavigationMapType.NONE), null, null); |
| | | for (NavigateNode node : nodes) { |
| | | HashMap<String, Object> data = new HashMap<>(); |
| | | String codeNum = NavigatePositionConvert.xyToPosition(node.getX(), node.getY(), node.getZ()); |
| | |
| | | int yp = Integer.parseInt(String.valueOf(nyNode.get("x"))); |
| | | int z = Integer.parseInt(String.valueOf(nyNode.get("z"))); |
| | | |
| | | List<List<MapNode>> mapData = navigateMapData.getJsonData(startNode.getZ(), NavigationMapType.getMapTypes(NavigationMapType.NONE), null, null); |
| | | List<MapNode> mapNodes = mapData.get(node.getX()); |
| | | MapNode mapNode = mapNodes.get(node.getY()); |
| | | |
| | |
| | | |
| | | httpStandard.setRequest(request); |
| | | |
| | | LocMastService locMastService = SpringUtils.getBean(LocMastService.class); |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>() |
| | | .eq("qr_code_value", distCodeNum)); |
| | | if (locMast == null) { |
| | | throw new CoolException("库位信息不存在"); |
| | | } |
| | | Object object = redisUtil.get(RedisKeyType.LOC_MAP.key); |
| | | HashMap<String, String> locMap = (HashMap<String, String>) object; |
| | | String targetLocNo = locMap.get(distCodeNum); |
| | | |
| | | ShuttleCommand command = new ShuttleCommand(); |
| | | command.setShuttleNo(deviceConfig.getDeviceNo()); |
| | | command.setBody(JSON.toJSONString(httpStandard)); |
| | | command.setMode(ShuttleCommandModeType.MOVE.id); |
| | | command.setTargetLocNo(locMast.getLocNo()); |
| | | command.setTargetLocNo(targetLocNo); |
| | | command.setTaskNo(taskId); |
| | | return command; |
| | | } |
| | |
| | | |
| | | //获取小车复位响应命令 |
| | | public ShuttleCommand getInitCommand(Integer taskNo, Integer code) { |
| | | LocMastService locMastService = SpringUtils.getBean(LocMastService.class); |
| | | NavigateMapData navigateMapData = SpringUtils.getBean(NavigateMapData.class); |
| | | NyShuttleHttpCommand httpStandard = getHttpStandard(deviceConfig.getDeviceNo(), taskNo); |
| | | NyShuttleHttpCommand.NyRequest request = httpStandard.getRequest(); |
| | |
| | | map.put("z", lev); |
| | | |
| | | String mapStr = JSON.toJSONString(map); |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>() |
| | | .eq("qr_code_value", mapStr)); |
| | | if (locMast == null) { |
| | | throw new CoolException("地址码不存在"); |
| | | } |
| | | |
| | | Object object = redisUtil.get(RedisKeyType.LOC_MAP.key); |
| | | HashMap<String, String> locMap = (HashMap<String, String>) object; |
| | | String targetLocNo = locMap.get(mapStr); |
| | | |
| | | List<List<MapNode>> mapData = navigateMapData.getJsonData(lev, NavigationMapType.getMapTypes(NavigationMapType.NONE), null, null); |
| | | List<MapNode> mapNodes = mapData.get(locMast.getRow1()); |
| | | MapNode mapNode = mapNodes.get(locMast.getBay1()); |
| | | List<MapNode> mapNodes = mapData.get(Utils.getRow(targetLocNo)); |
| | | MapNode mapNode = mapNodes.get(Utils.getBay(targetLocNo)); |
| | | |
| | | HashMap<String, Object> location = new HashMap<>(); |
| | | location.put("xp", row); |