| | |
| | | if (true || staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.isInEnable()) { |
| | | WrkMast wrkMast = wrkMastMapper.selectRackInStep48(workNo, staProtocol.getSiteId()); |
| | | if (wrkMast != null) { |
| | | if (wrkMast.getWrkSts() == 4) { |
| | | //寻找最近且空闲的四向穿梭车 |
| | | HashMap<String, Object> searchIdleShuttle = this.searchIdleShuttle(wrkMast); |
| | | ShuttleThread shuttleThread = (ShuttleThread) searchIdleShuttle.get("result"); |
| | | if (wrkMast.getWrkSts() == 4 || wrkMast.getWrkSts() == 8) { |
| | | ShuttleThread shuttleThread = null; |
| | | HashMap<String, Object> searchIdleShuttle = null; |
| | | if (wrkMast.getWrkSts() == 4) { |
| | | //寻找最近且空闲的四向穿梭车 |
| | | searchIdleShuttle = this.searchIdleShuttle(wrkMast); |
| | | shuttleThread = (ShuttleThread) searchIdleShuttle.get("result"); |
| | | }else { |
| | | //状态8,四向穿梭车已在提升机口,等待命令进行入库搬运动作 |
| | | Integer shuttleNo = wrkMast.getShuttleNo();//四向穿梭车号 |
| | | shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleNo); |
| | | } |
| | | |
| | | if (shuttleThread == null) { |
| | | continue; |
| | | } |
| | | |
| | | ShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol(); |
| | | if (!shuttleProtocol.isIdle()) { |
| | | continue; |
| | | } |
| | | |
| | | wrkMast.setShuttleNo(shuttleProtocol.getShuttleNo().intValue());//给工作档分配四向穿梭车号 |
| | | |
| | | //分配任务号 |
| | |
| | | LocMast currentLocMast = locMastService.queryByQrCode(currentCode.toString()); |
| | | assignCommand.setSourceLocNo(currentLocMast.getLocNo()); |
| | | |
| | | if (Boolean.parseBoolean(searchIdleShuttle.get("sameLay").toString())) { |
| | | if (wrkMast.getWrkSts() == 8 || Boolean.parseBoolean(searchIdleShuttle.get("sameLay").toString())) { |
| | | //同一层 |
| | | //分配目标库位 |
| | | shuttleProtocol.setLocNo(wrkMast.getLocNo()); |
| | | //目标库位 |
| | | assignCommand.setDistLocNo(wrkMast.getLocNo()); |
| | | assignCommand.setLocNo(wrkMast.getLocNo()); |
| | | wrkMast.setWrkSts(9L);//小车入库中 |
| | | }else { |
| | | //不同层,将目标库位分配成提升机库位号 |
| | | //分配目标库位 |
| | | shuttleProtocol.setLocNo("1800201"); |
| | | |
| | | //小车当前层高 |
| | | String currentLocNo = currentLocMast.getLocNo(); |
| | | Integer currentLev = Integer.parseInt(currentLocNo.substring(currentLocNo.length() - 2, currentLocNo.length())); |
| | | |
| | | //获取提升机 |
| | | LiftSlave liftSlave = slaveProperties.getLift().get(0); |
| | | //提升机库位号 |
| | | String liftLocNo = liftSlave.getLiftLocNo(currentLev); |
| | | shuttleProtocol.setLocNo(liftLocNo); |
| | | //目标库位 |
| | | assignCommand.setDistLocNo("1800201"); |
| | | assignCommand.setLocNo(liftLocNo); |
| | | wrkMast.setWrkSts(5L);//小车迁移状态 |
| | | } |
| | | |
| | | if (wrkMastMapper.updateById(wrkMast) > 0) { |
| | | //下发任务 |
| | | MessageQueue.offer(SlaveType.Shuttle, assignCommand.getShuttleNo().intValue(), new Task(3, assignCommand)); |
| | | } |
| | | }else { |
| | | //状态8,四向穿梭车已在提升机口,等待命令进行入库搬运动作 |
| | | Integer shuttleNo = wrkMast.getShuttleNo();//四向穿梭车号 |
| | | ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleNo); |
| | | if (shuttleThread == null) { |
| | | continue; |
| | | } |
| | | ShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol(); |
| | | |
| | | //分配目标库位 |
| | | shuttleProtocol.setLocNo(wrkMast.getLocNo()); |
| | | |
| | | ShuttleAssignCommand assignCommand = new ShuttleAssignCommand(); |
| | | //四向穿梭车号 |
| | | assignCommand.setShuttleNo(shuttleNo.shortValue()); |
| | | //任务号 |
| | | assignCommand.setTaskNo(wrkMast.getWrkNo().shortValue()); |
| | | //入出库模式 |
| | | assignCommand.setTaskMode(ShuttleTaskModeType.PAK_IN.id.shortValue()); |
| | | //源库位(小车当前位置) |
| | | Short currentCode = shuttleProtocol.getCurrentCode(); |
| | | LocMast currentLocMast = locMastService.queryByQrCode(currentCode.toString()); |
| | | assignCommand.setSourceLocNo(currentLocMast.getLocNo()); |
| | | //目标库位 |
| | | assignCommand.setDistLocNo(wrkMast.getLocNo()); |
| | | wrkMast.setWrkSts(9L);//小车入库中 |
| | | if (wrkMastMapper.updateById(wrkMast) > 0) { |
| | | //下发任务 |
| | | MessageQueue.offer(SlaveType.Shuttle, assignCommand.getShuttleNo().intValue(), new Task(3, assignCommand)); |
| | |
| | | //楼层相同情况 |
| | | //找距离出库点最近的车 |
| | | |
| | | if (!(recentShuttleProtocol.isIdle() && shuttleProtocol.isIdle())) { |
| | | //只要有一辆车不是空闲则不进行调度 |
| | | map.put("sameLay", false);//不同层 |
| | | map.put("result", null); |
| | | return map; |
| | | } |
| | | |
| | | //获取提升机 |
| | | LiftSlave liftSlave = slaveProperties.getLift().get(0); |
| | | //提升机库位号 |
| | | String recentLiftLocNo = liftSlave.getLiftLocNo(recentShuttleLocNoLayInt); |
| | | String shuttleLiftLocNo = liftSlave.getLiftLocNo(shuttleLocNoLayInt); |
| | | |
| | | //当前最近四向穿梭车到提升机路径 |
| | | List<NavigateNode> recentShuttlePath = NavigateUtils.calc(recentShuttleLocNo, "1800201", ShuttleTaskModeType.PAK_IN.id); |
| | | List<NavigateNode> recentShuttlePath = NavigateUtils.calc(recentShuttleLocNo, recentLiftLocNo, ShuttleTaskModeType.PAK_IN.id); |
| | | //当前楼层四向穿梭车到提升机路径 |
| | | List<NavigateNode> shuttlePath = NavigateUtils.calc(shuttleLocNo, "1800201", ShuttleTaskModeType.PAK_IN.id); |
| | | List<NavigateNode> shuttlePath = NavigateUtils.calc(shuttleLocNo, shuttleLiftLocNo, ShuttleTaskModeType.PAK_IN.id); |
| | | //判断哪一个路径最短 |
| | | if (shuttlePath.size() < recentShuttlePath.size()) { |
| | | //如果当前楼层的车路径更小,则更新最近穿梭车 |
| | |
| | | //四向穿梭车状态为等待确认 |
| | | if (shuttleProtocol.getProtocolStatus() == ShuttleProtocolStatusType.WAITING.id && shuttleProtocol.getTaskNo() != 0) { |
| | | //将任务档标记为完成 |
| | | WrkMast wrkMast = wrkMastMapper.selectByWorkNo9(shuttleProtocol.getTaskNo().intValue()); |
| | | WrkMast wrkMast = wrkMastMapper.selectByWorkNo59(shuttleProtocol.getTaskNo().intValue()); |
| | | if (wrkMast != null) { |
| | | wrkMast.setWrkSts(14L); |
| | | switch (wrkMast.getWrkSts().intValue()) { |
| | | case 9: |
| | | wrkMast.setWrkSts(14L); |
| | | break; |
| | | case 5: |
| | | wrkMast.setWrkSts(6L); |
| | | break; |
| | | default: |
| | | } |
| | | |
| | | if (wrkMastMapper.updateById(wrkMast) > 0) { |
| | | //设置四向穿梭车为空闲状态 |
| | | shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.IDLE); |
| | |
| | | shuttleProtocol.setLocNo(null); |
| | | //标记复位 |
| | | shuttleProtocol.setPakMk(true); |
| | | News.error("四向穿梭车已确认且任务完成状态,复位。堆垛机号={}", shuttleProtocol.getShuttleNo()); |
| | | News.info("四向穿梭车已确认且任务完成状态,复位。堆垛机号={}", shuttleProtocol.getShuttleNo()); |
| | | } else { |
| | | News.error("四向穿梭车已确认且任务完成状态,复位失败,但未找到工作档。四向穿梭车号={},工作号={}", shuttleProtocol.getShuttleNo(), shuttleProtocol.getTaskNo()); |
| | | } |