| | |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.common.model.*; |
| | | import com.zy.common.model.enums.NavigationMapType; |
| | | import com.zy.common.model.enums.WrkChargeType; |
| | | import com.zy.common.service.CommonService; |
| | | import com.zy.common.service.erp.ErpService; |
| | |
| | | //数据库中也不存在地图数据,从地图文件中获取 |
| | | //载入地图 |
| | | NavigateMapData mapData = new NavigateMapData(i); |
| | | List<List<MapNode>> lists = mapData.getJsonData(-1);//获取完整地图(包括入库出库) |
| | | List<List<MapNode>> lists = mapData.getJsonData(-1, null);//获取完整地图(包括入库出库) |
| | | |
| | | //存入数据库 |
| | | basMap = new BasMap(); |
| | |
| | | continue;//提升机不在目标楼层跳过 |
| | | } |
| | | |
| | | Integer staNo = Utils.levToOutInStaNo(lev); |
| | | Integer staNo = Utils.levToOutInStaNo(lev >= 2 ? lev + 1 : lev); |
| | | //获取目标站信息 |
| | | StaProtocol staProtocol1 = devpThread.getStation().get(staNo); |
| | | if (staProtocol1 == null) { |
| | |
| | | //同一层直接取货无需经过提升机 |
| | | //直接计算车到提升机取货再到库位路径指令 |
| | | List<ShuttleCommand> commands = this.shuttleAssignCommand(wrkMast.getWrkSts() == 4 ? currentLocNo : liftSiteLocNo, liftSiteLocNo, locNo, assignCommand, shuttleThread); |
| | | if (commands == null) { |
| | | continue;//找不到路径等待下一次 |
| | | } |
| | | if (wrkMast.getWrkSts() == 8) { |
| | | //此时车在提升机内部,下达一步指令让车移动到提升机口 |
| | | Integer staNo = Utils.levToOutInStaNo(currentLev);//站点号 |
| | | Integer staNo = Utils.levToOutInStaNo(currentLev >= 2 ? currentLev + 1 : currentLev);//站点号 |
| | | BasDevp basDevp = basDevpService.selectById(staNo); |
| | | |
| | | short startCode = liftProtocol.getBarcode();//提升机内部二维码 |
| | | Short distCode = Short.parseShort(basDevp.getQrCodeValue());//提升机口站点二维码 |
| | | Short runDirection = ShuttleRunDirection.BOTTOM.id;//运行方向 |
| | | //获取命令 |
| | | ShuttleCommand moveCommand = shuttleThread.getMoveCommand(startCode, distCode, 1400, runDirection, startCode, 1400, 1000); |
| | | ShuttleCommand moveCommand = shuttleThread.getMoveCommand(startCode, distCode, 1400, runDirection, startCode, 1400, 500); |
| | | commands.add(0, moveCommand);//将该指令添加到队头 |
| | | } |
| | | assignCommand.setCommands(commands); |
| | |
| | | Short endStartCode = Short.parseShort(basDevp.getQrCodeValue());//站点二维码 |
| | | |
| | | //增加移动进提升机命令 |
| | | ShuttleCommand moveCommand = shuttleThread.getMoveCommand(endStartCode, liftProtocol.getBarcode(), 1400, ShuttleRunDirection.TOP.id, endStartCode, 1400, 1000); |
| | | ShuttleCommand moveCommand = shuttleThread.getMoveCommand(endStartCode, liftProtocol.getBarcode(), 1400, ShuttleRunDirection.TOP.id, endStartCode, 1400, 500); |
| | | commands.add(moveCommand); |
| | | |
| | | //分配目标库位 |
| | |
| | | |
| | | } |
| | | |
| | | //获取起点-终点指令。mapType:0=>无货物地图,1=》携带货物出入库地图 |
| | | //获取起点-终点指令 |
| | | public synchronized List<ShuttleCommand> shuttleAssignCommand(String startLocNo, String locNo, Integer mapType, ShuttleAssignCommand assignCommand, ShuttleThread shuttleThread) { |
| | | //获取小车移动速度 |
| | | BasShuttle basShuttle = basShuttleService.selectById(assignCommand.getShuttleNo()); |
| | |
| | | List<NavigateNode> allNode = new ArrayList<>(); |
| | | |
| | | //计算小车起点到中点所需命令 |
| | | List<NavigateNode> calc = NavigateUtils.calc(startLocNo, middleLocNo, 1);//小车无货,走入库地图 |
| | | List<NavigateNode> calc = NavigateUtils.calc(startLocNo, middleLocNo, NavigationMapType.NORMAL.id);//小车无货,走正常库位通道 |
| | | List<ShuttleCommand> commands = new ArrayList<>(); |
| | | |
| | | if (calc != null) { |
| | |
| | | commands.add(shuttleThread.getPalletCommand((short) 1)); |
| | | |
| | | //计算小车中点到终点所需命令 |
| | | List<NavigateNode> calc2 = NavigateUtils.calc(middleLocNo, locNo, 2);//小车有货,走出库地图(出库地图有专用货道) |
| | | List<NavigateNode> calc2 = NavigateUtils.calc(middleLocNo, locNo, NavigationMapType.DFX.id);//小车有货,走禁用过DFX库位的地图通道 |
| | | if (calc2 == null) { |
| | | return null; |
| | | } |
| | |
| | | Short endStartCode = Short.parseShort(basDevp.getQrCodeValue());//站点二维码 |
| | | |
| | | //增加移动进提升机命令 |
| | | ShuttleCommand moveCommand = shuttleThread.getMoveCommand(endStartCode, liftProtocol.getBarcode(), 1400, ShuttleRunDirection.TOP.id, endStartCode, 1400, 1000); |
| | | ShuttleCommand moveCommand = shuttleThread.getMoveCommand(endStartCode, liftProtocol.getBarcode(), 1400, ShuttleRunDirection.TOP.id, endStartCode, 1400, 500); |
| | | commands.add(moveCommand); |
| | | |
| | | //目标库位 |
| | |
| | | String recentLocNo = recentShuttle.getShuttleProtocol().getCurrentLocNo(); |
| | | |
| | | //当前最近四向穿梭车到目标地点距离 |
| | | List<NavigateNode> recentShuttlePath = NavigateUtils.calc(recentLocNo, distLocNo, ShuttleTaskModeType.PAK_IN.id); |
| | | List<NavigateNode> recentShuttlePath = NavigateUtils.calc(recentLocNo, distLocNo, NavigationMapType.NORMAL.id);//搜索空闲穿梭车,使用正常通道地图 |
| | | //当前穿梭车线程到目标地点距离 |
| | | List<NavigateNode> currentShuttlePath = NavigateUtils.calc(currentLocNo, distLocNo, ShuttleTaskModeType.PAK_IN.id); |
| | | List<NavigateNode> currentShuttlePath = NavigateUtils.calc(currentLocNo, distLocNo, NavigationMapType.NORMAL.id);//搜索空闲穿梭车,使用正常通道地图 |
| | | if (recentShuttlePath == null || currentShuttlePath == null) { |
| | | continue; |
| | | } |
| | |
| | | int recentLev = Utils.getLev(recentLocNo); |
| | | |
| | | //当前最近四向穿梭车到当前车子所在楼层的提升机口距离 |
| | | List<NavigateNode> recentShuttlePath = NavigateUtils.calc(recentLocNo, Utils.levToOutInStaLocNo(recentLev), ShuttleTaskModeType.PAK_IN.id); |
| | | List<NavigateNode> recentShuttlePath = NavigateUtils.calc(recentLocNo, Utils.levToOutInStaLocNo(recentLev), NavigationMapType.NORMAL.id);//搜索空闲穿梭车,使用正常通道地图 |
| | | //当前穿梭车线程到当前车子所在楼层的提升机口距离 |
| | | List<NavigateNode> currentShuttlePath = NavigateUtils.calc(currentLocNo, Utils.levToOutInStaLocNo(currentLev), ShuttleTaskModeType.PAK_IN.id); |
| | | List<NavigateNode> currentShuttlePath = NavigateUtils.calc(currentLocNo, Utils.levToOutInStaLocNo(currentLev), NavigationMapType.NORMAL.id);//搜索空闲穿梭车,使用正常通道地图 |
| | | if (recentShuttlePath == null || currentShuttlePath == null) { |
| | | continue; |
| | | } |
| | |
| | | command4.setOperaStaNo(distStaNo.shortValue());//操作目标楼层站点 |
| | | command4.setRotationDire(1);//给输送线下发链条转动信号,正转 |
| | | command4.setDevpId(devpId); |
| | | command4.setStaNo(distStaNo.shortValue());//设置目标站 |
| | | commands.add(command4);//将命令添加进list |
| | | |
| | | wrkMast.setWrkSts(3L);//3.提升机搬运中 |
| | | } else if (wrkMast.getWrkSts() == 6) {//6.迁移小车至提升机口完成 => 7.提升机迁移小车中 |
| | | liftProtocol.setShuttleNo(wrkMast.getShuttleNo().shortValue());//设置四向穿梭车号 |
| | | |
| | | //判断小车是否在提升机内,且处于空闲状态 |
| | | ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkMast.getShuttleNo()); |
| | | if (shuttleThread == null) { |
| | | continue; |
| | | } |
| | | ShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol(); |
| | | if (shuttleProtocol == null) { |
| | | continue; |
| | | } |
| | | if (!shuttleProtocol.isIdle()) { |
| | | continue;//小车状态忙 |
| | | } |
| | | if (shuttleProtocol.getCurrentCode().intValue() != liftProtocol.getBarcode().intValue()) { |
| | | continue;//小车当前二维码和提升机内部二维码不一致,不允许执行 |
| | | } |
| | | |
| | | //工作档目标库位号 |
| | | String wrkMastLocNo = wrkMast.getIoType() == 101 ? wrkMast.getSourceLocNo() : wrkMast.getLocNo(); |
| | | //工作档目标库位楼层 |
| | | int wrkMastLocNoLey = Utils.getLev(wrkMastLocNo); |
| | | if (wrkMastLocNoLey >= 2) { |
| | | wrkMastLocNoLey++; |
| | | } |
| | | |
| | | //提升机前往目标楼层(工作档目标楼层) |
| | | LiftCommand command1 = liftThread.getLiftUpDownCommand(liftProtocol.getLiftNo(), liftProtocol.getTaskNo(), wrkMastLocNoLey); |
| | |
| | | } else if(wrkMast.getWrkSts() == 23) {//23.迁移小车至提升机口完成 => 24.提升机迁移小车中 |
| | | liftProtocol.setShuttleNo(wrkMast.getShuttleNo().shortValue());//设置四向穿梭车号 |
| | | |
| | | //找到四向穿梭车的线程 |
| | | //判断小车是否在提升机内,且处于空闲状态 |
| | | ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkMast.getShuttleNo()); |
| | | if (shuttleThread == null) { |
| | | continue; |
| | |
| | | continue; |
| | | } |
| | | |
| | | //当前穿梭车库位号 |
| | | String currentLocNo = shuttleProtocol.getCurrentLocNo(); |
| | | //当前穿梭车楼层 |
| | | int currentLocNoLey = Utils.getLev(currentLocNo); |
| | | if (!shuttleProtocol.isIdle()) { |
| | | continue;//小车状态忙 |
| | | } |
| | | if (shuttleProtocol.getCurrentCode().intValue() != liftProtocol.getBarcode().intValue()) { |
| | | continue;//小车当前二维码和提升机内部二维码不一致,不允许执行 |
| | | } |
| | | |
| | | //工作档目标库位号 |
| | | String wrkMastLocNo = wrkMast.getIoType() == 101 ? wrkMast.getSourceLocNo() : wrkMast.getLocNo(); |
| | | //工作档目标库位楼层 |
| | | int wrkMastLocNoLey = Utils.getLev(wrkMastLocNo); |
| | | |
| | | //提升机当前楼层 |
| | | int liftLev = liftProtocol.getLev().intValue(); |
| | | if (liftLev == 0) {//提升机当前楼层为0,提升机失去位置信息,让提升机前往一楼 |
| | | LiftCommand command = liftThread.getLiftUpDownCommand(liftProtocol.getLiftNo(), liftProtocol.getTaskNo(), LiftLevType.ONE.lev); |
| | | commands.add(command);//将命令添加进list |
| | | if (wrkMastLocNoLey >= 2) { |
| | | wrkMastLocNoLey++; |
| | | } |
| | | |
| | | if (liftLev != currentLocNoLey) { |
| | | //不同楼层 |
| | | //获取目标楼层(穿梭车所在楼层)命令 |
| | | LiftCommand command1 = liftThread.getLiftUpDownCommand(liftProtocol.getLiftNo(), liftProtocol.getTaskNo(), currentLocNoLey); |
| | | commands.add(command1);//将命令添加进list |
| | | } |
| | | |
| | | //输送线将四向穿梭车移动进来(反转) |
| | | LiftCommand command2 = liftThread.getLiftTurnCommand(liftProtocol.getLiftNo(), liftProtocol.getTaskNo(), 4); |
| | | commands.add(command2);//将命令添加进list |
| | | |
| | | if (liftLev != currentLocNoLey) { |
| | | //提升机前往目标楼层(工作档目标楼层) |
| | | LiftCommand command3 = liftThread.getLiftUpDownCommand(liftProtocol.getLiftNo(), liftProtocol.getTaskNo(), wrkMastLocNoLey); |
| | | commands.add(command3);//将命令添加进list |
| | | } |
| | | |
| | | //提升机到达指定楼层,输送线将四向穿梭车移出去 |
| | | //输送线将四向穿梭车移动出去(正转) |
| | | LiftCommand command4 = liftThread.getLiftTurnCommand(liftProtocol.getLiftNo(), liftProtocol.getTaskNo(), 1); |
| | | commands.add(command4);//将命令添加进list |
| | | //提升机前往目标楼层(工作档目标楼层) |
| | | LiftCommand command1 = liftThread.getLiftUpDownCommand(liftProtocol.getLiftNo(), liftProtocol.getTaskNo(), wrkMastLocNoLey); |
| | | commands.add(command1);//将命令添加进list |
| | | |
| | | wrkMast.setWrkSts(24L);//23.迁移小车至提升机口完成 => 24.提升机迁移小车中 |
| | | } else if (wrkMast.getWrkSts() == 27) {//27.小车出库搬运完成 |