| | |
| | | import com.zy.asrs.service.LocMastService; |
| | | import com.zy.asrs.service.WrkMastService; |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.common.model.NyShuttleOperaResult; |
| | | import com.zy.common.service.CommonService; |
| | | import com.zy.common.utils.NyHttpUtils; |
| | | import com.zy.common.utils.NyShuttleOperaUtils; |
| | | import com.zy.common.utils.RedisUtil; |
| | | import com.zy.core.cache.MessageQueue; |
| | | import com.zy.core.cache.OutputQueue; |
| | |
| | | import com.zy.core.enums.*; |
| | | import com.zy.core.model.ShuttleSlave; |
| | | import com.zy.core.model.Task; |
| | | import com.zy.core.model.command.NyShuttleHttpCommand; |
| | | import com.zy.core.model.command.ShuttleAssignCommand; |
| | | import com.zy.core.model.command.ShuttleCommand; |
| | | import com.zy.core.model.command.ShuttleRedisCommand; |
| | | import com.zy.core.model.protocol.NyShuttleProtocol; |
| | | import com.zy.core.model.protocol.ShuttleProtocol; |
| | |
| | | } |
| | | ShuttleRedisCommand redisCommand = JSON.parseObject(o.toString(), ShuttleRedisCommand.class); |
| | | ShuttleAssignCommand assignCommand = redisCommand.getAssignCommand(); |
| | | List<ShuttleCommand> commands = assignCommand.getCommands(); |
| | | ShuttleCommand command = commands.get(commandStep); |
| | | List<NyShuttleHttpCommand> commands = assignCommand.getCommands(); |
| | | NyShuttleHttpCommand command = commands.get(commandStep); |
| | | command.setComplete(complete != 0); |
| | | redisUtil.set("shuttle_wrk_no_" + wrkNo, JSON.toJSONString(redisCommand)); |
| | | return R.ok(); |
| | |
| | | assignCommand.setTaskNo((short) commonService.getWorkNo(3));//获取任务号 |
| | | assignCommand.setAuto(false);//手动模式 |
| | | |
| | | if (shuttleTaskModeType == ShuttleTaskModeType.TRANSPORT) { |
| | | //搬运货物任务 |
| | | NyShuttleOperaResult result = NyShuttleOperaUtils.getShuttleTransportCommands(shuttleSlave.getId(), assignCommand.getTaskNo().intValue(), shuttleProtocol.getCurrentLocNo(), param.getSourceLocNo(), param.getDistLocNo()); |
| | | if (result == null) { |
| | | throw new CoolException("路径计算失败"); |
| | | } |
| | | |
| | | assignCommand.setCommands(result.getCommands()); |
| | | assignCommand.setNodes(result.getNodes()); |
| | | } else if (shuttleTaskModeType == ShuttleTaskModeType.MOVE_LOC_NO) { |
| | | //移动到目标库位 |
| | | NyShuttleOperaResult result = NyShuttleOperaUtils.getStartToTargetCommands(shuttleSlave.getId(), assignCommand.getTaskNo().intValue(), shuttleProtocol.getCurrentLocNo(), param.getDistLocNo()); |
| | | if (result == null) { |
| | | throw new CoolException("路径计算失败"); |
| | | } |
| | | |
| | | assignCommand.setCommands(result.getCommands()); |
| | | assignCommand.setNodes(result.getNodes()); |
| | | } else if (shuttleTaskModeType == ShuttleTaskModeType.PALLET_LIFT) { |
| | | //托盘顶升 |
| | | NyShuttleHttpCommand command = NyHttpUtils.getPalletLiftCommand(shuttleSlave.getId(), assignCommand.getTaskNo().intValue(), true); |
| | | ArrayList<NyShuttleHttpCommand> commands = new ArrayList<>(); |
| | | commands.add(command); |
| | | assignCommand.setCommands(commands); |
| | | } else if (shuttleTaskModeType == ShuttleTaskModeType.PALLET_DOWN) { |
| | | //托盘下降 |
| | | NyShuttleHttpCommand command = NyHttpUtils.getPalletLiftCommand(shuttleSlave.getId(), assignCommand.getTaskNo().intValue(), false); |
| | | ArrayList<NyShuttleHttpCommand> commands = new ArrayList<>(); |
| | | commands.add(command); |
| | | assignCommand.setCommands(commands); |
| | | } else if (shuttleTaskModeType == ShuttleTaskModeType.CHARGE) { |
| | | //充电开关 |
| | | NyShuttleHttpCommand command = NyHttpUtils.getChargeCommand(shuttleSlave.getId(), assignCommand.getTaskNo().intValue(), true); |
| | | ArrayList<NyShuttleHttpCommand> commands = new ArrayList<>(); |
| | | commands.add(command); |
| | | assignCommand.setCommands(commands); |
| | | } else if (shuttleTaskModeType == ShuttleTaskModeType.RESET) { |
| | | //复位 |
| | | shuttleProtocol.setTaskNo(0);//工作号清空 |
| | | shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.IDLE);//任务状态-空闲 |
| | | shuttleProtocol.setPakMk(true);//作业标记复位 |
| | | return R.ok(); |
| | | } else { |
| | | throw new CoolException("未知命令"); |
| | | } |
| | | |
| | | if (MessageQueue.offer(SlaveType.Shuttle, shuttleSlave.getId(), new Task(3, assignCommand))) { |
| | | return R.ok(); |
| | | } else { |
| | |
| | | @PostMapping("/detl/update") |
| | | @ManagerAuth(memo = "修改数据") |
| | | public R shuttleUpdate(@RequestParam Integer shuttleNo, |
| | | @RequestParam Integer workNo, |
| | | @RequestParam String pakMk){ |
| | | @RequestParam Integer workNo, |
| | | @RequestParam String pakMk, |
| | | @RequestParam Integer token) { |
| | | NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleNo); |
| | | if (shuttleThread == null) { |
| | | return R.error("plc已掉线"); |
| | |
| | | if (pakMk != null) { |
| | | shuttleProtocol.setPakMk(pakMk.equals("Y")); |
| | | } |
| | | if (token != null) { |
| | | shuttleProtocol.setToken(token); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |