From 77401b95f2fc410ecc6d6f9f0052ca56ccc4910f Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期四, 10 八月 2023 12:49:30 +0800
Subject: [PATCH] 地图增加站点
---
src/main/java/com/zy/asrs/controller/ShuttleController.java | 63 +++++++++++++++++++++++++++++--
1 files changed, 58 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..99bf851 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 {
@@ -279,8 +328,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 +345,9 @@
if (pakMk != null) {
shuttleProtocol.setPakMk(pakMk.equals("Y"));
}
+ if (token != null) {
+ shuttleProtocol.setToken(token);
+ }
return R.ok();
}
--
Gitblit v1.9.1