From 4e1a8e484888b3d3f28dc9629904e6e54d90ebc5 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期五, 28 七月 2023 16:26:40 +0800
Subject: [PATCH] 穿梭车命令封装

---
 src/main/java/com/zy/asrs/controller/ShuttleController.java |   55 ++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 52 insertions(+), 3 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..896319a 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,52 @@
                 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 {

--
Gitblit v1.9.1