From 8bd6a3d7574f0ed50e52424d55a9767a0a3f03e4 Mon Sep 17 00:00:00 2001 From: Junjie <fallin.jie@qq.com> Date: 星期一, 21 八月 2023 15:18:05 +0800 Subject: [PATCH] # --- src/main/java/com/zy/asrs/controller/ShuttleController.java | 75 +++++++++++++++++++++++++++++++++++-- 1 files changed, 70 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/zy/asrs/controller/ShuttleController.java b/src/main/java/com/zy/asrs/controller/ShuttleController.java index 1614b21..ce4aa87 100644 --- a/src/main/java/com/zy/asrs/controller/ShuttleController.java +++ b/src/main/java/com/zy/asrs/controller/ShuttleController.java @@ -15,7 +15,10 @@ 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; @@ -23,8 +26,8 @@ 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; @@ -184,8 +187,8 @@ } 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(); @@ -266,6 +269,64 @@ 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 if (shuttleTaskModeType == ShuttleTaskModeType.SHUTTLE_CONTROL) { + //灏忚溅绠″埗 + NyShuttleHttpCommand suspendCommand = NyHttpUtils.getSuspendCommand(shuttleSlave.getId(), assignCommand.getTaskNo().intValue(), true); + ArrayList<NyShuttleHttpCommand> commands = new ArrayList<>(); + commands.add(suspendCommand); + assignCommand.setCommands(commands); + } else if (shuttleTaskModeType == ShuttleTaskModeType.SHUTTLE_CANCEL_CONTROL) { + //灏忚溅鍙栨秷绠″埗 + NyShuttleHttpCommand suspendCommand = NyHttpUtils.getSuspendCommand(shuttleSlave.getId(), assignCommand.getTaskNo().intValue(), false); + ArrayList<NyShuttleHttpCommand> commands = new ArrayList<>(); + commands.add(suspendCommand); + assignCommand.setCommands(commands); + } else { + throw new CoolException("鏈煡鍛戒护"); + } + if (MessageQueue.offer(SlaveType.Shuttle, shuttleSlave.getId(), new Task(3, assignCommand))) { return R.ok(); } else { @@ -279,8 +340,9 @@ @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宸叉帀绾�"); @@ -295,6 +357,9 @@ if (pakMk != null) { shuttleProtocol.setPakMk(pakMk.equals("Y")); } + if (token != null) { + shuttleProtocol.setToken(token); + } return R.ok(); } -- Gitblit v1.9.1