| | |
| | | |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.common.model.NavigateNode; |
| | | import com.zy.common.model.NyShuttleOperaResult; |
| | | import com.zy.common.utils.*; |
| | | import com.zy.core.News; |
| | | import com.zy.core.ThreadHandler; |
| | |
| | | return false; |
| | | } |
| | | |
| | | WrkMastService wrkMastService = SpringUtils.getBean(WrkMastService.class); |
| | | WrkMastMapper wrkMastMapper = SpringUtils.getBean(WrkMastMapper.class); |
| | | |
| | | Object o = redisUtil.get("shuttle_wrk_no_" + wrkNo); |
| | | if (o == null) { |
| | | return false; |
| | | } |
| | | |
| | | ShuttleRedisCommand redisCommand = JSON.parseObject(o.toString(), ShuttleRedisCommand.class); |
| | | List<NyShuttleHttpCommand> commands = redisCommand.getAssignCommand().getCommands(); |
| | | ShuttleAssignCommand assignCommand = redisCommand.getAssignCommand(); |
| | | List<NyShuttleHttpCommand> commands = redisCommand.getAssignCommand().getCommands(); |
| | | //当前步序 |
| | | int commandStep = redisCommand.getCommandStep(); |
| | | if (commands.size() == 0) { |
| | |
| | | return false; |
| | | } |
| | | |
| | | //检查路径是否可行走(检查路径锁定状态,检测路径是否有其他小车) |
| | | //检测当前行走路径,和下一步路径 |
| | | boolean checkPathIsAvailable = NavigateUtils.checkPathIsAvailable(command.getNodes(), shuttleProtocol.getShuttleNo().intValue(), Utils.getLev(shuttleProtocol.getCurrentLocNo())); |
| | | boolean checkPathIsAvailable2 = NavigateUtils.checkPathIsAvailable(nextNodes, shuttleProtocol.getShuttleNo().intValue(), Utils.getLev(shuttleProtocol.getCurrentLocNo())); |
| | | if (!checkPathIsAvailable && !checkPathIsAvailable2) { |
| | | //检测路径是否可行走 |
| | | if (!checkPath(command.getNodes(), nextNodes, redisCommand)) { |
| | | return false; |
| | | } |
| | | |
| | | //锁定路径,锁定当前路径和下一步路径 |
| | | List<NavigateNode> nodes = command.getNodes(); |
| | | nodes.addAll(nextNodes); |
| | |
| | | return false; |
| | | } |
| | | |
| | | WrkMastMapper wrkMastMapper = SpringUtils.getBean(WrkMastMapper.class); |
| | | |
| | | ShuttleRedisCommand redisCommand = JSON.parseObject(o.toString(), ShuttleRedisCommand.class); |
| | | //当前步序 |
| | | int commandStep = redisCommand.getCommandStep(); |
| | |
| | | |
| | | if (liftProtocol.getLev().intValue() == Utils.getLev(shuttleProtocol.getCurrentLocNo())) { |
| | | return true;//提升机达到小车楼层,放行 |
| | | } |
| | | |
| | | //搜索是否有其他任务占用了提升机,如果占用提升机的任务和当前任务相同,则运行执行 |
| | | WrkMast wrkMast1 = wrkMastMapper.selectLiftWrkMast(liftProtocol.getLiftNo().intValue()); |
| | | if (wrkMast1 != null && wrkMast1.getWrkNo() != wrkNo.intValue()) { |
| | | return false; |
| | | } |
| | | |
| | | //提升机未到达小车楼层,呼叫提升机 |
| | |
| | | return false;//默认不放行 |
| | | } |
| | | |
| | | /** |
| | | * 检测路径是否可行走 |
| | | * 如果路径为目标库位,但不可行走,系统将尝试重新计算路径 |
| | | */ |
| | | private boolean checkPath(List<NavigateNode> currentNodes, List<NavigateNode> nextNodes, ShuttleRedisCommand redisCommand) { |
| | | //检测路径是否可行走(检查路径锁定状态,检测路径是否有其他小车) |
| | | //检测当前行走路径,和下一步路径 |
| | | boolean checkPathIsAvailable = NavigateUtils.checkPathIsAvailable(currentNodes, shuttleProtocol.getShuttleNo().intValue(), Utils.getLev(shuttleProtocol.getCurrentLocNo())); |
| | | boolean checkPathIsAvailable2 = NavigateUtils.checkPathIsAvailable(nextNodes, shuttleProtocol.getShuttleNo().intValue(), Utils.getLev(shuttleProtocol.getCurrentLocNo())); |
| | | if (checkPathIsAvailable && checkPathIsAvailable2) { |
| | | return true;//可行走 |
| | | } |
| | | |
| | | ShuttleAssignCommand assignCommand = redisCommand.getAssignCommand(); |
| | | NavigateNode currentTarget = currentNodes.get(currentNodes.size() - 1); |
| | | String currentLocNo = NavigatePositionConvert.nodeToLocNo(currentTarget); |
| | | NavigateNode nextTarget = nextNodes.get(nextNodes.size() - 1); |
| | | String nextLocNo = NavigatePositionConvert.nodeToLocNo(nextTarget); |
| | | if (assignCommand.getLocNo().equals(currentLocNo) || assignCommand.getLocNo().equals(nextLocNo)) { |
| | | //当前路径最后一个节点是目标库位,进行路径检测,如果不可行走,重新计算路径 |
| | | //不可行走,重新计算路径 |
| | | NyShuttleOperaResult result = NyShuttleOperaUtils.getStartToTargetCommands(shuttleProtocol.getShuttleNo().intValue(), shuttleProtocol.getTaskNo(), shuttleProtocol.getCurrentLocNo(), assignCommand.getLocNo()); |
| | | if (result == null) { |
| | | return false;//路径计算失败,不可行走 |
| | | } |
| | | |
| | | List<NyShuttleHttpCommand> newCommands = result.getCommands();//新路径 |
| | | |
| | | //当前步序 |
| | | int commandStep = redisCommand.getCommandStep(); |
| | | List<NyShuttleHttpCommand> commands = assignCommand.getCommands(); |
| | | |
| | | commands.remove(commandStep);//移除当前步序指令 |
| | | if (assignCommand.getLocNo().equals(currentLocNo)) { |
| | | //当前路径,需要再多移除下一步指令 |
| | | commands.remove(commandStep + 1); |
| | | } |
| | | |
| | | //将新路径添加进指令集合 |
| | | commands.addAll(commandStep, newCommands); |
| | | assignCommand.setCommands(commands); |
| | | redisCommand.setAssignCommand(assignCommand); |
| | | //任务数据保存到redis |
| | | redisUtil.set("shuttle_wrk_no_" + redisCommand.getWrkNo(), JSON.toJSONString(redisCommand)); |
| | | return false;//当前不可行走,等待下一次执行走新路径 |
| | | } |
| | | |
| | | return false;//不可行走 |
| | | } |
| | | |
| | | } |