|  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private WrkChargeMapper wrkChargeMapper; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private BasMapService basMapService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private ErpService erpService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private OrderMapper orderMapper; | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 实时更新地图 | 
|---|
|  |  |  | * 初始化实时地图 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public synchronized void refreshMap() { | 
|---|
|  |  |  | public synchronized void initRealtimeBasMap() { | 
|---|
|  |  |  | for (int i = 1; i <= 4; i++) {//总共四层楼 | 
|---|
|  |  |  | Object data = redisUtil.get("realtimeBasMap_" + i); | 
|---|
|  |  |  | if (data == null) {//redis地图数据为空,从数据库中获取 | 
|---|
|  |  |  | BasMap basMap = basMapService.selectLatestMap(i); | 
|---|
|  |  |  | if (basMap == null) { | 
|---|
|  |  |  | //数据库中也不存在地图数据,从地图文件中获取 | 
|---|
|  |  |  | //载入地图 | 
|---|
|  |  |  | NavigateMapData mapData = new NavigateMapData(i); | 
|---|
|  |  |  | List<List<MapNode>> lists = mapData.getJsonData(-1);//获取完整地图(包括入库出库) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //存入数据库 | 
|---|
|  |  |  | basMap = new BasMap(); | 
|---|
|  |  |  | basMap.setData(JSON.toJSONString(lists)); | 
|---|
|  |  |  | basMap.setCreateTime(new Date()); | 
|---|
|  |  |  | basMap.setUpdateTime(new Date()); | 
|---|
|  |  |  | basMap.setLev(i); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (!basMapService.insert(basMap)) { | 
|---|
|  |  |  | log.info("地图数据存储失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //将数据库地图数据存入redis | 
|---|
|  |  |  | redisUtil.set("realtimeBasMap_" + i, JSON.toJSONString(basMap)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | liftProtocol.setProtocolStatus(LiftProtocolStatusType.WORKING);//工作状态 | 
|---|
|  |  |  | liftProtocol.setLiftLock(true);//提升机锁定 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | }else {//四向穿梭车任务 | 
|---|
|  |  |  | }else if(key.toString().contains("shuttle_wrk_no_")){//四向穿梭车任务 | 
|---|
|  |  |  | ShuttleRedisCommand redisCommand = JSON.parseObject(map.get(key).toString(), ShuttleRedisCommand.class); | 
|---|
|  |  |  | if (redisCommand == null) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | 
|---|
|  |  |  | DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | StaProtocol staProtocol = devpThread.getStation().get(rackInStn.getStaNo()); | 
|---|
|  |  |  | StaProtocol staProtocol105 = devpThread.getStation().get(105); | 
|---|
|  |  |  | staProtocol105.setWorkNo((short) 752); | 
|---|
|  |  |  | staProtocol105.setStaNo((short) 100); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | StaProtocol staProtocol106 = devpThread.getStation().get(106); | 
|---|
|  |  |  | staProtocol106.setWorkNo((short) 753); | 
|---|
|  |  |  | staProtocol106.setStaNo((short) 100); | 
|---|
|  |  |  | //                StaProtocol staProtocol105 = devpThread.getStation().get(105); | 
|---|
|  |  |  | //                staProtocol105.setWorkNo((short) 752); | 
|---|
|  |  |  | //                staProtocol105.setStaNo((short) 100); | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //                StaProtocol staProtocol106 = devpThread.getStation().get(106); | 
|---|
|  |  |  | //                staProtocol106.setWorkNo((short) 753); | 
|---|
|  |  |  | //                staProtocol106.setStaNo((short) 100); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (staProtocol == null) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | 
|---|
|  |  |  | if (wrkMast.getWrkSts() == 8 || Boolean.parseBoolean(searchIdleShuttle.get("sameLay").toString())) { | 
|---|
|  |  |  | //同一层直接取货无需经过提升机 | 
|---|
|  |  |  | //直接计算车到提升机取货再到库位路径指令 | 
|---|
|  |  |  | List<ShuttleCommand> commands = this.shuttleAssignCommand(currentLocNo, liftLocNo, locNo); | 
|---|
|  |  |  | List<ShuttleCommand> commands = this.shuttleAssignCommand(currentLocNo, liftLocNo, locNo, assignCommand,shuttleThread); | 
|---|
|  |  |  | if (wrkMast.getWrkSts() == 8) { | 
|---|
|  |  |  | //此时车在提升机内部,需要多下达一步指令让车移动到提升机口 | 
|---|
|  |  |  | BasDevp basDevp = basDevpService.selectById(109);//获取提升机信息 | 
|---|
|  |  |  | ShuttleCommand moveCommand = new ShuttleCommand(); | 
|---|
|  |  |  | moveCommand.setCommandWord((short) 1); | 
|---|
|  |  |  | moveCommand.setStartCodeNum(Short.parseShort(basDevp.getQrCodeValue()));//提升机内部二维码 | 
|---|
|  |  |  | moveCommand.setDistCodeNum(commands.get(0).getStartCodeNum());//提升机口二维码 | 
|---|
|  |  |  | moveCommand.setStartToDistDistance(1300); | 
|---|
|  |  |  | moveCommand.setMiddleToDistDistance(0); | 
|---|
|  |  |  | moveCommand.setRunDirection(commands.get(0).getRunDirection()); | 
|---|
|  |  |  | moveCommand.setCommandEnd((short) 1); | 
|---|
|  |  |  | short startCode = Short.parseShort(basDevp.getQrCodeValue());//提升机内部二维码 | 
|---|
|  |  |  | Short distCode = commands.get(0).getStartCodeNum();//提升机口二维码 | 
|---|
|  |  |  | Short runDirection = commands.get(0).getRunDirection();//运行方向 | 
|---|
|  |  |  | //获取命令 | 
|---|
|  |  |  | ShuttleCommand moveCommand = shuttleThread.getMoveCommand(startCode, distCode, 1300, runDirection); | 
|---|
|  |  |  | commands.add(0, moveCommand);//将该指令添加到队头 | 
|---|
|  |  |  | } | 
|---|
|  |  |  | assignCommand.setCommands(commands); | 
|---|
|  |  |  | 
|---|
|  |  |  | //不同层,将目标库位分配成提升机库位号 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //小车移动到提升机口,计算路径 | 
|---|
|  |  |  | List<ShuttleCommand> commands = this.shuttleAssignCommand(currentLocNo, liftLocNo, ShuttleTaskModeType.PAK_IN.id); | 
|---|
|  |  |  | List<ShuttleCommand> commands = this.shuttleAssignCommand(currentLocNo, liftLocNo, ShuttleTaskModeType.PAK_IN.id, assignCommand, shuttleThread); | 
|---|
|  |  |  | //分配目标库位 | 
|---|
|  |  |  | shuttleProtocol.setLocNo(liftLocNo); | 
|---|
|  |  |  | //目标库位 | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //获取起点-终点指令。mapType:1=》无货地图,2=》有货地图 | 
|---|
|  |  |  | public synchronized List<ShuttleCommand> shuttleAssignCommand(String startLocNo, String locNO,Integer mapType) { | 
|---|
|  |  |  | public synchronized List<ShuttleCommand> shuttleAssignCommand(String startLocNo, String locNo, Integer mapType, ShuttleAssignCommand assignCommand, ShuttleThread shuttleThread) { | 
|---|
|  |  |  | //计算小车起点到中点所需命令 | 
|---|
|  |  |  | List<NavigateNode> calc = NavigateUtils.calc(startLocNo, locNO, mapType); | 
|---|
|  |  |  | List<NavigateNode> calc = NavigateUtils.calc(startLocNo, locNo, mapType); | 
|---|
|  |  |  | List<ShuttleCommand> commands = new ArrayList<>(); | 
|---|
|  |  |  | if (calc == null) { | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<NavigateNode> allNode = new ArrayList<>(); | 
|---|
|  |  |  | allNode.addAll(calc); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //获取分段路径 | 
|---|
|  |  |  | ArrayList<ArrayList<NavigateNode>> data = NavigateUtils.getSectionPath(calc); | 
|---|
|  |  |  | 
|---|
|  |  |  | //目标路径 | 
|---|
|  |  |  | NavigateNode endPath = nodes.get(nodes.size() - 1); | 
|---|
|  |  |  | Integer allDistance = NavigateUtils.getCurrentPathAllDistance(nodes);//计算当前路径行走总距离 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ShuttleCommand command = new ShuttleCommand(); | 
|---|
|  |  |  | command.setCommandWord((short) 1); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //通过xy坐标小车二维码 | 
|---|
|  |  |  | Short startCodeNum = NavigatePositionConvert.xyToPosition(startPath.getX(), startPath.getY(), startPath.getZ()); | 
|---|
|  |  |  | command.setStartCodeNum(startCodeNum); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | command.setMiddleCodeNum((short) 1); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //通过xy坐标小车二维码 | 
|---|
|  |  |  | Short distCodeNum = NavigatePositionConvert.xyToPosition(endPath.getX(), endPath.getY(), endPath.getZ()); | 
|---|
|  |  |  | command.setDistCodeNum(distCodeNum); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | command.setStartToDistDistance(allDistance); | 
|---|
|  |  |  | command.setMiddleToDistDistance(0); | 
|---|
|  |  |  | command.setRunDirection(ShuttleRunDirection.get(startPath.getDirection()).id); | 
|---|
|  |  |  | command.setPalletLift((short) 1); | 
|---|
|  |  |  | command.setForceMoveDistance(0); | 
|---|
|  |  |  | command.setChargeSwitch((short) 2); | 
|---|
|  |  |  | command.setIOControl((short) 0); | 
|---|
|  |  |  | command.setRadarTmp((short) 0); | 
|---|
|  |  |  | command.setCommandEnd((short) 1); | 
|---|
|  |  |  | //获取移动命令 | 
|---|
|  |  |  | ShuttleCommand command = shuttleThread.getMoveCommand(startCodeNum, distCodeNum, allDistance, ShuttleRunDirection.get(startPath.getDirection()).id); | 
|---|
|  |  |  | commands.add(command); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | assignCommand.setNodes(allNode);//当前任务所占用的节点list | 
|---|
|  |  |  | //所使用的路径进行锁定禁用 | 
|---|
|  |  |  | NavigateMapData navigateMapData = new NavigateMapData(Utils.getLev(startLocNo)); | 
|---|
|  |  |  | navigateMapData.writeNavigateNodeToRedisMap(allNode, true);////所使用的路径进行锁定禁用 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return commands; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //获取起点-中点-终点指令 | 
|---|
|  |  |  | public synchronized List<ShuttleCommand> shuttleAssignCommand(String startLocNo, String middleLocNo, String locNO) { | 
|---|
|  |  |  | public synchronized List<ShuttleCommand> shuttleAssignCommand(String startLocNo, String middleLocNo, String locNo, ShuttleAssignCommand assignCommand, ShuttleThread shuttleThread) { | 
|---|
|  |  |  | //计算小车起点到中点所需命令 | 
|---|
|  |  |  | List<NavigateNode> calc = NavigateUtils.calc(startLocNo, middleLocNo, 1);//小车无货,走入库地图 | 
|---|
|  |  |  | List<ShuttleCommand> commands = new ArrayList<>(); | 
|---|
|  |  |  | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<NavigateNode> allNode = new ArrayList<>(); | 
|---|
|  |  |  | allNode.addAll(calc); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //获取分段路径 | 
|---|
|  |  |  | ArrayList<ArrayList<NavigateNode>> data = NavigateUtils.getSectionPath(calc); | 
|---|
|  |  |  | //将每一段路径分成command指令 | 
|---|
|  |  |  | 
|---|
|  |  |  | NavigateNode endPath = nodes.get(nodes.size() - 1); | 
|---|
|  |  |  | Integer allDistance = NavigateUtils.getCurrentPathAllDistance(nodes);//计算当前路径行走总距离 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ShuttleCommand command = new ShuttleCommand(); | 
|---|
|  |  |  | command.setCommandWord((short) 1); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //通过xy坐标小车二维码 | 
|---|
|  |  |  | Short startCodeNum = NavigatePositionConvert.xyToPosition(startPath.getX(), startPath.getY(), startPath.getZ()); | 
|---|
|  |  |  | command.setStartCodeNum(startCodeNum); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | command.setMiddleCodeNum((short) 1); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //通过xy坐标小车二维码 | 
|---|
|  |  |  | Short distCodeNum = NavigatePositionConvert.xyToPosition(endPath.getX(), endPath.getY(), endPath.getZ()); | 
|---|
|  |  |  | command.setDistCodeNum(distCodeNum); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | command.setStartToDistDistance(allDistance); | 
|---|
|  |  |  | command.setMiddleToDistDistance(0); | 
|---|
|  |  |  | command.setRunDirection(ShuttleRunDirection.get(startPath.getDirection()).id); | 
|---|
|  |  |  | command.setPalletLift((short) 1); | 
|---|
|  |  |  | command.setForceMoveDistance(0); | 
|---|
|  |  |  | command.setChargeSwitch((short) 2); | 
|---|
|  |  |  | command.setIOControl((short) 0); | 
|---|
|  |  |  | command.setRadarTmp((short) 0); | 
|---|
|  |  |  | command.setCommandEnd((short) 1); | 
|---|
|  |  |  | //获取移动命令 | 
|---|
|  |  |  | ShuttleCommand command = shuttleThread.getMoveCommand(startCodeNum, distCodeNum, allDistance, ShuttleRunDirection.get(startPath.getDirection()).id); | 
|---|
|  |  |  | commands.add(command); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //小车指令到达目标位置后,再发出一条顶升指令 | 
|---|
|  |  |  | ShuttleCommand command = new ShuttleCommand(); | 
|---|
|  |  |  | command.setCommandWord((short) 2); | 
|---|
|  |  |  | command.setPalletLift((short) 1); | 
|---|
|  |  |  | command.setCommandEnd((short) 1); | 
|---|
|  |  |  | commands.add(command); | 
|---|
|  |  |  | commands.add(shuttleThread.getPalletCommand((short) 1)); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //计算小车中点到终点所需命令 | 
|---|
|  |  |  | List<NavigateNode> calc2 = NavigateUtils.calc(middleLocNo, locNO, 2);//小车有货,走出库地图(出库地图有专用货道) | 
|---|
|  |  |  | List<NavigateNode> calc2 = NavigateUtils.calc(middleLocNo, locNo, 2);//小车有货,走出库地图(出库地图有专用货道) | 
|---|
|  |  |  | if (calc2 == null) { | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | allNode.addAll(calc2); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //获取分段路径 | 
|---|
|  |  |  | ArrayList<ArrayList<NavigateNode>> data2 = NavigateUtils.getSectionPath(calc2); | 
|---|
|  |  |  | 
|---|
|  |  |  | NavigateNode endPath = nodes.get(nodes.size() - 1); | 
|---|
|  |  |  | Integer allDistance = NavigateUtils.getCurrentPathAllDistance(nodes);//计算当前路径行走总距离 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | command = new ShuttleCommand(); | 
|---|
|  |  |  | command.setCommandWord((short) 1); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //通过xy坐标小车二维码 | 
|---|
|  |  |  | Short startCodeNum = NavigatePositionConvert.xyToPosition(startPath.getX(), startPath.getY(), startPath.getZ()); | 
|---|
|  |  |  | command.setStartCodeNum(startCodeNum); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | command.setMiddleCodeNum((short) 1); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //通过xy坐标小车二维码 | 
|---|
|  |  |  | Short distCodeNum = NavigatePositionConvert.xyToPosition(endPath.getX(), endPath.getY(), endPath.getZ()); | 
|---|
|  |  |  | command.setDistCodeNum(distCodeNum); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | command.setStartToDistDistance(allDistance); | 
|---|
|  |  |  | command.setMiddleToDistDistance(0); | 
|---|
|  |  |  | command.setRunDirection(ShuttleRunDirection.get(startPath.getDirection()).id); | 
|---|
|  |  |  | command.setPalletLift((short) 1); | 
|---|
|  |  |  | command.setForceMoveDistance(0); | 
|---|
|  |  |  | command.setChargeSwitch((short) 2); | 
|---|
|  |  |  | command.setIOControl((short) 0); | 
|---|
|  |  |  | command.setRadarTmp((short) 0); | 
|---|
|  |  |  | command.setCommandEnd((short) 1); | 
|---|
|  |  |  | commands.add(command); | 
|---|
|  |  |  | ShuttleCommand moveCommand = shuttleThread.getMoveCommand(startCodeNum, distCodeNum, allDistance, ShuttleRunDirection.get(startPath.getDirection()).id); | 
|---|
|  |  |  | commands.add(moveCommand); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //小车指令到达目标位置后,再发出一条托盘下降指令 | 
|---|
|  |  |  | command = new ShuttleCommand(); | 
|---|
|  |  |  | command.setCommandWord((short) 2); | 
|---|
|  |  |  | command.setPalletLift((short) 2); | 
|---|
|  |  |  | command.setCommandEnd((short) 1); | 
|---|
|  |  |  | commands.add(command); | 
|---|
|  |  |  | commands.add(shuttleThread.getPalletCommand((short) 2)); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | assignCommand.setNodes(allNode);//当前任务所占用的节点list | 
|---|
|  |  |  | //所使用的路径进行锁定禁用 | 
|---|
|  |  |  | NavigateMapData navigateMapData = new NavigateMapData(Utils.getLev(startLocNo)); | 
|---|
|  |  |  | navigateMapData.writeNavigateNodeToRedisMap(allNode, true);////所使用的路径进行锁定禁用 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return commands; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | if (Boolean.parseBoolean(searchIdleShuttle.get("sameLay").toString())) { | 
|---|
|  |  |  | //同一层(将小车移动到货物位置) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<ShuttleCommand> commands = this.shuttleAssignCommand(currentLocNo, wrkMast.getSourceLocNo(), liftLocNo); | 
|---|
|  |  |  | List<ShuttleCommand> commands = this.shuttleAssignCommand(currentLocNo, wrkMast.getSourceLocNo(), liftLocNo, assignCommand, shuttleThread); | 
|---|
|  |  |  | //分配目标库位 | 
|---|
|  |  |  | shuttleProtocol.setLocNo(wrkMast.getSourceLocNo()); | 
|---|
|  |  |  | //目标库位 | 
|---|
|  |  |  | 
|---|
|  |  |  | //不同层,将目标库位分配成提升机库位号(将小车移动到提升机位置) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //小车到提升机口指令 | 
|---|
|  |  |  | List<ShuttleCommand> commands = this.shuttleAssignCommand(currentLocNo, liftLocNo, ShuttleTaskModeType.PAK_IN.id); | 
|---|
|  |  |  | List<ShuttleCommand> commands = this.shuttleAssignCommand(currentLocNo, liftLocNo, ShuttleTaskModeType.PAK_IN.id, assignCommand, shuttleThread); | 
|---|
|  |  |  | shuttleProtocol.setLocNo(liftLocNo); | 
|---|
|  |  |  | //目标库位 | 
|---|
|  |  |  | assignCommand.setLocNo(liftLocNo); | 
|---|
|  |  |  | 
|---|
|  |  |  | wrkMast.setWrkSts(22L);//小车迁移状态 | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } else if (wrkMast.getWrkSts() == 25) { | 
|---|
|  |  |  | List<ShuttleCommand> commands = this.shuttleAssignCommand(currentLocNo, wrkMast.getSourceLocNo(), liftLocNo); | 
|---|
|  |  |  | List<ShuttleCommand> commands = this.shuttleAssignCommand(currentLocNo, wrkMast.getSourceLocNo(), liftLocNo, assignCommand, shuttleThread); | 
|---|
|  |  |  | //此时车在提升机内部,需要多下达一步指令让车移动到提升机口 | 
|---|
|  |  |  | BasDevp basDevp = basDevpService.selectById(109);//获取提升机信息 | 
|---|
|  |  |  | ShuttleCommand moveCommand = new ShuttleCommand(); | 
|---|
|  |  |  | moveCommand.setCommandWord((short) 1);//小车移动指令字 | 
|---|
|  |  |  | moveCommand.setStartCodeNum(Short.parseShort(basDevp.getQrCodeValue()));//提升机二维码 | 
|---|
|  |  |  | moveCommand.setDistCodeNum(commands.get(0).getStartCodeNum()); | 
|---|
|  |  |  | moveCommand.setStartToDistDistance(1300); | 
|---|
|  |  |  | moveCommand.setMiddleToDistDistance(0); | 
|---|
|  |  |  | moveCommand.setRunDirection(commands.get(0).getRunDirection()); | 
|---|
|  |  |  | moveCommand.setCommandEnd((short) 1); | 
|---|
|  |  |  | short startCode = Short.parseShort(basDevp.getQrCodeValue());//提升机二维码 | 
|---|
|  |  |  | Short distCode = commands.get(0).getStartCodeNum();//目标二维码 | 
|---|
|  |  |  | //获取移动命令 | 
|---|
|  |  |  | ShuttleCommand moveCommand = shuttleThread.getMoveCommand(startCode, distCode, 1300, commands.get(0).getRunDirection()); | 
|---|
|  |  |  | commands.add(0, moveCommand);//将该指令添加到队头 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //分配目标库位 | 
|---|
|  |  |  | 
|---|
|  |  |  | //提升机当前楼层 | 
|---|
|  |  |  | int liftLev = liftProtocol.getLev().intValue(); | 
|---|
|  |  |  | if (liftLev != 1) { | 
|---|
|  |  |  | //提升机不在1层 | 
|---|
|  |  |  | LiftCommand command1 = new LiftCommand(); | 
|---|
|  |  |  | command1.setLiftNo(liftProtocol.getLiftNo());//提升机号 | 
|---|
|  |  |  | command1.setTaskNo(liftProtocol.getTaskNo());//任务号 | 
|---|
|  |  |  | command1.setRun((short) 1);//升降 | 
|---|
|  |  |  | command1.setDistPosition((short) 1);//目标楼层1层 | 
|---|
|  |  |  | command1.setLiftLock(true);//锁定提升机 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //提升机不在1层,获取到1层的提升机命令 | 
|---|
|  |  |  | LiftCommand command1 = liftThread.getLiftUpDownCommand(liftProtocol.getLiftNo(), liftProtocol.getTaskNo(), (short) 1); | 
|---|
|  |  |  | commands.add(command1);//将命令添加进list | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //输送线将货物运进来 | 
|---|
|  |  |  | LiftCommand command2 = new LiftCommand(); | 
|---|
|  |  |  | command2.setLiftNo(liftProtocol.getLiftNo());//提升机号 | 
|---|
|  |  |  | command2.setTaskNo(liftProtocol.getTaskNo());//任务号 | 
|---|
|  |  |  | command2.setRun((short) 6);//输送线运作 | 
|---|
|  |  |  | command2.setLiftLock(true);//锁定提升机 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //输送线将货物运进来(正转) | 
|---|
|  |  |  | LiftCommand command2 = liftThread.getLiftTurnCommand(liftProtocol.getLiftNo(), liftProtocol.getTaskNo(), 1); | 
|---|
|  |  |  | commands.add(command2);//将命令添加进list | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //提升机前往目标楼层 | 
|---|
|  |  |  | LiftCommand command3 = new LiftCommand(); | 
|---|
|  |  |  | command3.setLiftNo(liftProtocol.getLiftNo());//提升机号 | 
|---|
|  |  |  | command3.setTaskNo(liftProtocol.getTaskNo());//任务号 | 
|---|
|  |  |  | command3.setRun((short) 1);//升降 | 
|---|
|  |  |  | command3.setDistPosition((short) wrkMastLocNoLey);//工作档目标楼层 | 
|---|
|  |  |  | command3.setLiftLock(true);//锁定提升机 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //提升机前往目标楼层(工作档目标楼层) | 
|---|
|  |  |  | LiftCommand command3 = liftThread.getLiftUpDownCommand(liftProtocol.getLiftNo(), liftProtocol.getTaskNo(), (short) wrkMastLocNoLey); | 
|---|
|  |  |  | commands.add(command3);//将命令添加进list | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //提升机到达指定楼层,输送线将货物移出去 | 
|---|
|  |  |  | //提升机到达指定楼层,输送线将货物移出去(反转) | 
|---|
|  |  |  | //输送线将货物移出去 | 
|---|
|  |  |  | LiftCommand command4 = new LiftCommand(); | 
|---|
|  |  |  | command4.setLiftNo(liftProtocol.getLiftNo());//提升机号 | 
|---|
|  |  |  | command4.setTaskNo(liftProtocol.getTaskNo());//任务号 | 
|---|
|  |  |  | command4.setRun((short) 3);//输送线运作 | 
|---|
|  |  |  | command4.setLiftLock(true);//锁定提升机 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | LiftCommand command4 = liftThread.getLiftTurnCommand(liftProtocol.getLiftNo(), liftProtocol.getTaskNo(), 2); | 
|---|
|  |  |  | commands.add(command4);//将命令添加进list | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | liftProtocol.setShuttleNo(wrkMast.getShuttleNo().shortValue());//设置四向穿梭车号 | 
|---|
|  |  |  | 
|---|
|  |  |  | int liftLev = liftProtocol.getLev().intValue(); | 
|---|
|  |  |  | if (liftLev != currentLocNoLey) { | 
|---|
|  |  |  | //不同楼层 | 
|---|
|  |  |  | LiftCommand command1 = new LiftCommand(); | 
|---|
|  |  |  | command1.setLiftNo(liftProtocol.getLiftNo());//提升机号 | 
|---|
|  |  |  | command1.setTaskNo(liftProtocol.getTaskNo());//任务号 | 
|---|
|  |  |  | command1.setRun((short) 1);//升降 | 
|---|
|  |  |  | command1.setDistPosition((short) currentLocNoLey);//目标楼层(穿梭车所在楼层) | 
|---|
|  |  |  | command1.setLiftLock(true);//锁定提升机 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //获取目标楼层(穿梭车所在楼层)命令 | 
|---|
|  |  |  | LiftCommand command1 = liftThread.getLiftUpDownCommand(liftProtocol.getLiftNo(), liftProtocol.getTaskNo(), (short) currentLocNoLey); | 
|---|
|  |  |  | commands.add(command1);//将命令添加进list | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //输送线将四向穿梭车移动进来 | 
|---|
|  |  |  | LiftCommand command2 = new LiftCommand(); | 
|---|
|  |  |  | command2.setLiftNo(liftProtocol.getLiftNo());//提升机号 | 
|---|
|  |  |  | command2.setTaskNo(liftProtocol.getTaskNo());//任务号 | 
|---|
|  |  |  | command2.setRun((short) 6);//输送线运作 | 
|---|
|  |  |  | command2.setLiftLock(true);//锁定提升机 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //输送线将四向穿梭车移动进来(正转) | 
|---|
|  |  |  | LiftCommand command2 = liftThread.getLiftTurnCommand(liftProtocol.getLiftNo(), liftProtocol.getTaskNo(), 1); | 
|---|
|  |  |  | commands.add(command2);//将命令添加进list | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (liftLev != currentLocNoLey) { | 
|---|
|  |  |  | //提升机前往目标楼层 | 
|---|
|  |  |  | LiftCommand command3 = new LiftCommand(); | 
|---|
|  |  |  | command3.setLiftNo(liftProtocol.getLiftNo());//提升机号 | 
|---|
|  |  |  | command3.setTaskNo(liftProtocol.getTaskNo());//任务号 | 
|---|
|  |  |  | command3.setRun((short) 1);//升降 | 
|---|
|  |  |  | command3.setDistPosition((short) wrkMastLocNoLey);//工作档目标楼层 | 
|---|
|  |  |  | command3.setLiftLock(true);//锁定提升机 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //提升机前往目标楼层(工作档目标楼层) | 
|---|
|  |  |  | LiftCommand command3 = liftThread.getLiftUpDownCommand(liftProtocol.getLiftNo(), liftProtocol.getTaskNo(), (short) wrkMastLocNoLey); | 
|---|
|  |  |  | commands.add(command3);//将命令添加进list | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //提升机到达指定楼层,输送线将四向穿梭车移出去 | 
|---|
|  |  |  | //输送线将四向穿梭车移动出去 | 
|---|
|  |  |  | LiftCommand command4 = new LiftCommand(); | 
|---|
|  |  |  | command4.setLiftNo(liftProtocol.getLiftNo());//提升机号 | 
|---|
|  |  |  | command4.setTaskNo(liftProtocol.getTaskNo());//任务号 | 
|---|
|  |  |  | command4.setRun((short) 3);//输送线运作 | 
|---|
|  |  |  | command4.setLiftLock(true);//锁定提升机 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //输送线将四向穿梭车移动出去(反转) | 
|---|
|  |  |  | LiftCommand command4 = liftThread.getLiftTurnCommand(liftProtocol.getLiftNo(), liftProtocol.getTaskNo(), 2); | 
|---|
|  |  |  | commands.add(command4);//将命令添加进list | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | if (currentLev == chargeLocNoLev) { | 
|---|
|  |  |  | //同一层无需经过提升机 | 
|---|
|  |  |  | //直接计算车到充电库位 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ShuttleAssignCommand assignCommand = new ShuttleAssignCommand(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //获取小车到充电库位路径指令 | 
|---|
|  |  |  | List<ShuttleCommand> commands = this.shuttleAssignCommand(currentLocNo, chargeLocNo, ShuttleTaskModeType.PAK_IN.id); | 
|---|
|  |  |  | List<ShuttleCommand> commands = this.shuttleAssignCommand(currentLocNo, chargeLocNo, ShuttleTaskModeType.PAK_IN.id, assignCommand, shuttleThread); | 
|---|
|  |  |  | //进行充电中 | 
|---|
|  |  |  | shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.CHARGING); | 
|---|
|  |  |  | ShuttleAssignCommand assignCommand = new ShuttleAssignCommand(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | assignCommand.setShuttleNo(shuttleProtocol.getShuttleNo()); | 
|---|
|  |  |  | assignCommand.setTaskMode((short) 9);//充电 | 
|---|
|  |  |  | assignCommand.setTaskNo(wrkCharge.getWrkNo().shortValue()); | 
|---|
|  |  |  | assignCommand.setCharge(true);//充电任务 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //创建充电指令 | 
|---|
|  |  |  | ShuttleCommand command = new ShuttleCommand(); | 
|---|
|  |  |  | command.setCommandWord((short) 5);//充电 | 
|---|
|  |  |  | command.setShuttleNo(shuttleProtocol.getShuttleNo()); | 
|---|
|  |  |  | command.setChargeSwitch((short) 1);//开始充电 | 
|---|
|  |  |  | command.setCommandEnd((short) 1); | 
|---|
|  |  |  | ShuttleCommand command = shuttleThread.getChargeSwitchCommand((short) 1);//开始充电 | 
|---|
|  |  |  | commands.add(command); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //指令集分配 | 
|---|
|  |  |  | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | //不同层,将目标库位分配成提升机库位号 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ShuttleAssignCommand assignCommand = new ShuttleAssignCommand(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //小车移动到提升机口,计算路径 | 
|---|
|  |  |  | List<ShuttleCommand> commands = this.shuttleAssignCommand(currentLocNo, liftLocNo, ShuttleTaskModeType.PAK_IN.id); | 
|---|
|  |  |  | List<ShuttleCommand> commands = this.shuttleAssignCommand(currentLocNo, liftLocNo, ShuttleTaskModeType.PAK_IN.id, assignCommand, shuttleThread); | 
|---|
|  |  |  | //分配目标库位 | 
|---|
|  |  |  | shuttleProtocol.setLocNo(liftLocNo); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ShuttleAssignCommand assignCommand = new ShuttleAssignCommand(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | assignCommand.setShuttleNo(shuttleProtocol.getShuttleNo()); | 
|---|
|  |  |  | assignCommand.setTaskMode((short) 9);//充电 | 
|---|
|  |  |  | assignCommand.setTaskNo(wrkCharge.getWrkNo().shortValue()); | 
|---|
|  |  |  | 
|---|
|  |  |  | int liftLev = liftProtocol.getLev().intValue(); | 
|---|
|  |  |  | if (liftLev != currentLev) { | 
|---|
|  |  |  | //穿梭车和提升机处于不同楼层 | 
|---|
|  |  |  | LiftCommand command1 = new LiftCommand(); | 
|---|
|  |  |  | command1.setLiftNo(liftProtocol.getLiftNo());//提升机号 | 
|---|
|  |  |  | command1.setTaskNo(liftProtocol.getTaskNo());//任务号 | 
|---|
|  |  |  | command1.setRun((short) 1);//升降 | 
|---|
|  |  |  | command1.setDistPosition(currentLev.shortValue());//目标楼层(穿梭车所在楼层) | 
|---|
|  |  |  | command1.setLiftLock(true);//锁定提升机 | 
|---|
|  |  |  | //获取目标楼层(穿梭车所在楼层)命令 | 
|---|
|  |  |  | LiftCommand command1 = liftThread.getLiftUpDownCommand(liftProtocol.getLiftNo(), liftProtocol.getTaskNo(), currentLev.shortValue()); | 
|---|
|  |  |  | commands.add(command1);//将命令添加进list | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //输送线将四向穿梭车移动进来 | 
|---|
|  |  |  | LiftCommand command2 = new LiftCommand(); | 
|---|
|  |  |  | command2.setLiftNo(liftProtocol.getLiftNo());//提升机号 | 
|---|
|  |  |  | command2.setTaskNo(liftProtocol.getTaskNo());//任务号 | 
|---|
|  |  |  | command2.setRun((short) 6);//输送线运作 | 
|---|
|  |  |  | command2.setLiftLock(true);//锁定提升机 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //输送线将四向穿梭车移动进来(正转) | 
|---|
|  |  |  | LiftCommand command2 = liftThread.getLiftTurnCommand(liftProtocol.getLiftNo(), liftProtocol.getTaskNo(), 1); | 
|---|
|  |  |  | commands.add(command2);//将命令添加进list | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //提升机前往目标楼层 | 
|---|
|  |  |  | LiftCommand command3 = new LiftCommand(); | 
|---|
|  |  |  | command3.setLiftNo(liftProtocol.getLiftNo());//提升机号 | 
|---|
|  |  |  | command3.setTaskNo(liftProtocol.getTaskNo());//任务号 | 
|---|
|  |  |  | command3.setRun((short) 1);//升降 | 
|---|
|  |  |  | command3.setDistPosition(chargeLocNoLev.shortValue());//充电库位目标楼层 | 
|---|
|  |  |  | command3.setLiftLock(true);//锁定提升机 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //获取充电库位目标楼层命令 | 
|---|
|  |  |  | LiftCommand command3 = liftThread.getLiftUpDownCommand(liftProtocol.getLiftNo(), liftProtocol.getTaskNo(), chargeLocNoLev.shortValue()); | 
|---|
|  |  |  | commands.add(command3);//将命令添加进list | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //提升机到达指定楼层,输送线将四向穿梭车移出去 | 
|---|
|  |  |  | //输送线将四向穿梭车移动出去 | 
|---|
|  |  |  | LiftCommand command4 = new LiftCommand(); | 
|---|
|  |  |  | command4.setLiftNo(liftProtocol.getLiftNo());//提升机号 | 
|---|
|  |  |  | command4.setTaskNo(liftProtocol.getTaskNo());//任务号 | 
|---|
|  |  |  | command4.setRun((short) 3);//输送线运作 | 
|---|
|  |  |  | command4.setLiftLock(true);//锁定提升机 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //输送线将四向穿梭车移动出去(反转) | 
|---|
|  |  |  | LiftCommand command4 = liftThread.getLiftTurnCommand(liftProtocol.getLiftNo(), liftProtocol.getTaskNo(), 2); | 
|---|
|  |  |  | commands.add(command4);//将命令添加进list | 
|---|
|  |  |  |  | 
|---|
|  |  |  | wrkCharge.setWrkSts(54L);//提升机搬运中 | 
|---|
|  |  |  | 
|---|
|  |  |  | assignCommand.setCharge(true); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //创建充电指令 | 
|---|
|  |  |  | ShuttleCommand command = new ShuttleCommand(); | 
|---|
|  |  |  | command.setCommandWord((short) 5);//充电 | 
|---|
|  |  |  | command.setShuttleNo(shuttleProtocol.getShuttleNo()); | 
|---|
|  |  |  | command.setChargeSwitch((short) 2);//断开充电 | 
|---|
|  |  |  | command.setCommandEnd((short) 1); | 
|---|
|  |  |  | ShuttleCommand command = shuttleThread.getChargeSwitchCommand((short) 2);//断开充电 | 
|---|
|  |  |  | commands.add(command); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //指令集分配 | 
|---|