| | |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.service.*; |
| | | |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.common.model.NavigateNode; |
| | | import com.zy.common.utils.*; |
| | | import com.zy.core.News; |
| | |
| | | if (commands.size() == 0) { |
| | | return false; |
| | | } |
| | | |
| | | NavigateMapData navigateMapData = new NavigateMapData(Utils.getLev(shuttleProtocol.getCurrentLocNo())); |
| | | //取出命令 |
| | | NyShuttleHttpCommand command = commands.get(commandStep); |
| | | NyShuttleHttpCommand command = commands.get(commandStep);//当前命令 |
| | | if (commandStep != 0) { |
| | | //判断上一条指令是否完成 |
| | | NyShuttleHttpCommand lastCommand = commands.get(commandStep - 1); |
| | | String requestType = lastCommand.getRequest().getBody().get("requestType").toString(); |
| | | if (requestType.equals("move") || requestType.equals("intoLift") || requestType.equals("outLift")) { |
| | | //移动命令、出入提升机命令 |
| | | NyShuttleProtocol.NyShuttlePointClass target = JSON.parseObject(lastCommand.getRequest().getBody().get("target").toString(), NyShuttleProtocol.NyShuttlePointClass.class); |
| | | if (shuttleProtocol.getPoint().equals(target)) { |
| | | //上一条指令的目标位置和当前小车位置相同,则认定上一条任务完成 |
| | | lastCommand.setComplete(true); |
| | | //解锁锁定路径,上一条路径和当前路径 |
| | | List<NavigateNode> nodes = lastCommand.getNodes(); |
| | | nodes.addAll(command.getNodes()); |
| | | navigateMapData.writeNavigateNodeToRedisMap(nodes, false);//解锁路径 |
| | | } |
| | | }else { |
| | | lastCommand.setComplete(true);//其他命令默认认为完成 |
| | | } |
| | | //任务数据保存到redis |
| | | redisUtil.set("shuttle_wrk_no_" + redisCommand.getWrkNo(), JSON.toJSONString(redisCommand)); |
| | | |
| | | if (!lastCommand.getComplete()) { |
| | | //上一条任务未完成,禁止下发命令 |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | List<NavigateNode> nextNodes = null;//下一步命令行走路径 |
| | | if (commandStep + 1 < commands.size()) { |
| | | NyShuttleHttpCommand nextCommand = commands.get(commandStep + 1);//下一步命令 |
| | | nextNodes = nextCommand.getNodes();//下一步命令行走路径 |
| | | } |
| | | |
| | | if (shuttleProtocol.getFree() == ShuttleStatusType.BUSY.id) { |
| | | 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) { |
| | | return false; |
| | | } |
| | | //锁定路径,锁定当前路径和下一步路径 |
| | | List<NavigateNode> nodes = command.getNodes(); |
| | | nodes.addAll(nextNodes); |
| | | navigateMapData.writeNavigateNodeToRedisMap(nodes, true);//所使用的路径进行锁定禁用 |
| | | |
| | | //可执行命令 |
| | | if (!write(command)) { |