| | |
| | | import com.zy.asrs.service.BasShuttleOptService; |
| | | import com.zy.asrs.service.BasShuttleService; |
| | | import com.zy.asrs.service.LocMastService; |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.common.model.NavigateNode; |
| | | import com.zy.common.utils.CommonUtils; |
| | | import com.zy.common.utils.NavigatePositionConvert; |
| | | import com.zy.common.utils.NavigateUtils; |
| | | import com.zy.common.utils.RedisUtil; |
| | | import com.zy.common.utils.*; |
| | | import com.zy.core.News; |
| | | import com.zy.core.ThreadHandler; |
| | | import com.zy.core.cache.MessageQueue; |
| | |
| | | |
| | | if (shuttleProtocol.getErrorCode() != 0 && shuttleProtocol.getProtocolStatusType() == ShuttleProtocolStatusType.WORKING) { |
| | | //出现错误 |
| | | reset(shuttleProtocol.getTaskNo()); |
| | | resetAndTryFix(shuttleProtocol.getTaskNo()); |
| | | } |
| | | |
| | | if(shuttleProtocol.getProtocolStatusType() == ShuttleProtocolStatusType.FIXING |
| | |
| | | //检测是否有提升机锁定标记,有则检测提升机是否到位,是否能走下一步命令 |
| | | if (shuttleProtocol.getBusyStatusType() == ShuttleStatusType.IDLE |
| | | && shuttleProtocol.getTaskNo() != 0) { |
| | | Object o = redisUtil.get("wrk_no_" + shuttleProtocol.getTaskNo()); |
| | | Object o = redisUtil.get("shuttle_wrk_no_" + shuttleProtocol.getTaskNo()); |
| | | if (o != null) { |
| | | ShuttleRedisCommand redisCommand = JSON.parseObject(o.toString(), ShuttleRedisCommand.class); |
| | | if (redisCommand.getLiftSecurityMk()) { |
| | |
| | | //分配任务 |
| | | private void assignWork(ShuttleAssignCommand assignCommand) { |
| | | if (!assignCommand.getAuto()) { |
| | | List<NavigateNode> allNode = new ArrayList<>(); |
| | | List<ShuttleCommand> commands = new ArrayList<>(); |
| | | ShuttleCommand command = new ShuttleCommand(); |
| | | LocMastService locMastService = SpringUtils.getBean(LocMastService.class); |
| | | NavigateMapData navigateMapData; |
| | | switch (assignCommand.getTaskMode()) { |
| | | case 1://入库 |
| | | case 2://出库 |
| | |
| | | //计算小车起点到中点所需命令 |
| | | LocMast currentLocMast = locMastService.queryByQrCode(shuttleProtocol.getCurrentCode().toString()); |
| | | List<NavigateNode> firstMastResult = NavigateUtils.calc(currentLocMast.getLocNo(), assignCommand.getSourceLocNo(), ShuttleTaskModeType.PAK_IN.id); |
| | | //所使用的路径进行锁定禁用 |
| | | navigateMapData = new NavigateMapData(Utils.getLev(currentLocMast.getLocNo())); |
| | | navigateMapData.writeNavigateNodeToRedisMap(firstMastResult, true);////所使用的路径进行锁定禁用 |
| | | |
| | | if (firstMastResult != null) { |
| | | allNode.addAll(firstMastResult);//将节点进行保存 |
| | | //获取分段路径 |
| | | ArrayList<ArrayList<NavigateNode>> data = NavigateUtils.getSectionPath(firstMastResult); |
| | | //将每一段路径分成command指令 |
| | |
| | | |
| | | //计算中点到终点路径 |
| | | List<NavigateNode> secMastResult = NavigateUtils.calc(assignCommand.getSourceLocNo(), assignCommand.getLocNo(), ShuttleTaskModeType.PAK_IN.id); |
| | | navigateMapData.writeNavigateNodeToRedisMap(firstMastResult, true);////所使用的路径进行锁定禁用 |
| | | |
| | | if (secMastResult != null) { |
| | | allNode.addAll(secMastResult);//将节点进行保存 |
| | | //获取分段路径 |
| | | ArrayList<ArrayList<NavigateNode>> data = NavigateUtils.getSectionPath(secMastResult); |
| | | //将每一段路径分成command指令 |
| | |
| | | case 14://移动到目标库位 |
| | | LocMast locMast = locMastService.queryByQrCode(shuttleProtocol.getCurrentCode().toString()); |
| | | List<NavigateNode> result = NavigateUtils.calc(locMast.getLocNo(), assignCommand.getLocNo(), ShuttleTaskModeType.PAK_IN.id); |
| | | //所使用的路径进行锁定禁用 |
| | | navigateMapData = new NavigateMapData(Utils.getLev(locMast.getLocNo())); |
| | | navigateMapData.writeNavigateNodeToRedisMap(result, true);////所使用的路径进行锁定禁用 |
| | | |
| | | if (result != null) { |
| | | allNode.addAll(result);//将节点进行保存 |
| | | //获取分段路径 |
| | | ArrayList<ArrayList<NavigateNode>> data = NavigateUtils.getSectionPath(result); |
| | | //将每一段路径分成command指令 |
| | |
| | | default: |
| | | } |
| | | assignCommand.setCommands(commands); |
| | | assignCommand.setNodes(allNode);//当前任务所占用的节点list |
| | | } |
| | | |
| | | ShuttleRedisCommand redisCommand = new ShuttleRedisCommand(); |
| | |
| | | shuttleProtocol.setAssignCommand(assignCommand); |
| | | shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.WORKING); |
| | | //任务数据保存到redis |
| | | redisUtil.set("wrk_no_" + assignCommand.getTaskNo(), JSON.toJSONString(redisCommand)); |
| | | redisUtil.set("shuttle_wrk_no_" + assignCommand.getTaskNo(), JSON.toJSONString(redisCommand)); |
| | | //执行下发任务 |
| | | executeWork(assignCommand.getTaskNo()); |
| | | } |
| | |
| | | return false; |
| | | } |
| | | |
| | | Object o = redisUtil.get("wrk_no_" + wrkNo); |
| | | Object o = redisUtil.get("shuttle_wrk_no_" + wrkNo); |
| | | if (o == null) { |
| | | return false; |
| | | } |
| | |
| | | commandStep--; |
| | | redisCommand.setCommandStep(commandStep); |
| | | //任务数据保存到redis |
| | | redisUtil.set("wrk_no_" + wrkNo, JSON.toJSONString(redisCommand)); |
| | | redisUtil.set("shuttle_wrk_no_" + wrkNo, JSON.toJSONString(redisCommand)); |
| | | shuttleProtocol.setPakMk(true); |
| | | return true; |
| | | }else { |
| | |
| | | errorCommands.remove(0); |
| | | redisCommand.setErrorCommands(errorCommands); |
| | | //任务数据保存到redis |
| | | redisUtil.set("wrk_no_" + wrkNo, JSON.toJSONString(redisCommand)); |
| | | redisUtil.set("shuttle_wrk_no_" + wrkNo, JSON.toJSONString(redisCommand)); |
| | | return true; |
| | | } |
| | | } |
| | |
| | | commandStep++; |
| | | redisCommand.setCommandStep(commandStep); |
| | | //任务数据保存到redis |
| | | redisUtil.set("wrk_no_" + redisCommand.getWrkNo(), JSON.toJSONString(redisCommand)); |
| | | redisUtil.set("shuttle_wrk_no_" + redisCommand.getWrkNo(), JSON.toJSONString(redisCommand)); |
| | | }else { |
| | | //已执行完成 |
| | | //保存数据到数据库做流水 |
| | |
| | | } |
| | | } |
| | | |
| | | String locNo = shuttleProtocol.getLocNo() == null ? shuttleProtocol.getSourceLocNo() : shuttleProtocol.getLocNo(); |
| | | //解除锁定的库位路径 |
| | | NavigateMapData navigateMapData = new NavigateMapData(Utils.getLev(locNo)); |
| | | navigateMapData.writeNavigateNodeToRedisMap(redisCommand.getAssignCommand().getNodes(), false); |
| | | |
| | | //删除redis |
| | | redisUtil.del("wrk_no_" + redisCommand.getWrkNo()); |
| | | redisUtil.del("shuttle_wrk_no_" + redisCommand.getWrkNo()); |
| | | |
| | | if (!assignCommand.getAuto()) { |
| | | //手动模式不抛出等待状态,直接复位 |
| | |
| | | return false; |
| | | } |
| | | |
| | | Object o = redisUtil.get("wrk_no_" + wrkNo); |
| | | Object o = redisUtil.get("shuttle_wrk_no_" + wrkNo); |
| | | if (o == null) { |
| | | return false; |
| | | } |
| | |
| | | liftProtocol.setSecurityMk(true);//标记置为true,防止其他任务占用当前提升机 |
| | | redisCommand.setLiftSecurityMk(true);//标记置为true,防止其他任务占用当前提升机 |
| | | //任务数据保存到redis |
| | | redisUtil.set("wrk_no_" + wrkNo, JSON.toJSONString(redisCommand)); |
| | | redisUtil.set("shuttle_wrk_no_" + wrkNo, JSON.toJSONString(redisCommand)); |
| | | |
| | | //命令list |
| | | ArrayList<LiftCommand> liftCommands = new ArrayList<>(); |
| | |
| | | /** |
| | | * 复位并尝试修复错误 |
| | | */ |
| | | private boolean reset(Short wrkNo) { |
| | | private boolean resetAndTryFix(Short wrkNo) { |
| | | //读取redis数据 |
| | | if (wrkNo == null) { |
| | | return false; |
| | | } |
| | | |
| | | Object o = redisUtil.get("wrk_no_" + wrkNo); |
| | | Object o = redisUtil.get("shuttle_wrk_no_" + wrkNo); |
| | | if (o == null) { |
| | | return false; |
| | | } |
| | |
| | | |
| | | redisCommand.setErrorCommands(list); |
| | | //任务数据保存到redis |
| | | redisUtil.set("wrk_no_" + wrkNo, JSON.toJSONString(redisCommand)); |
| | | redisUtil.set("shuttle_wrk_no_" + wrkNo, JSON.toJSONString(redisCommand)); |
| | | shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.FIXING); |
| | | return true; |
| | | } |