From 5dcd40b2afb66e82b5e9f0b94fb0816d1d468fc4 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期三, 06 九月 2023 10:26:39 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/asrs/controller/ShuttleController.java | 92 ++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 85 insertions(+), 7 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..2548cce 100644
--- a/src/main/java/com/zy/asrs/controller/ShuttleController.java
+++ b/src/main/java/com/zy/asrs/controller/ShuttleController.java
@@ -1,6 +1,7 @@
package com.zy.asrs.controller;
import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.core.annotations.ManagerAuth;
import com.core.common.BaseRes;
@@ -15,7 +16,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 +27,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;
@@ -62,7 +66,7 @@
@PostMapping("/table/shuttle/state")
@ManagerAuth(memo = "鍥涘悜绌挎杞︿俊鎭〃")
public R shuttleStateTable(){
- ArrayList<NyShuttleProtocol> list = new ArrayList<>();
+ ArrayList<JSONObject> list = new ArrayList<>();
List<BasShuttle> shuttles = basShuttleService.selectList(new EntityWrapper<BasShuttle>().orderBy("shuttle_no"));
for (BasShuttle basShuttle : shuttles) {
// 鑾峰彇鍥涘悜绌挎杞︿俊鎭�
@@ -74,7 +78,19 @@
if (shuttleProtocol == null || shuttleProtocol.getShuttleNo()==null) {
continue;
}
- list.add(shuttleProtocol);
+ JSONObject shuttleData = JSON.parseObject(JSON.toJSONString(shuttleProtocol));
+
+ shuttleData.put("moveAdvancePath", null);//绌挎杞﹂璁¤矾寰�
+ if (shuttleProtocol.getTaskNo() != 0) {
+ //瀛樺湪浠诲姟锛岃幏鍙栨寚浠�
+ Object object = redisUtil.get("shuttle_wrk_no_" + shuttleProtocol.getTaskNo());
+ if (object != null) {
+ ShuttleRedisCommand redisCommand = JSON.parseObject(object.toString(), ShuttleRedisCommand.class);
+ shuttleData.put("moveAdvancePath", redisCommand.getAssignCommand().getNodes());//绌挎杞﹂璁¤矾寰�
+ }
+ }
+
+ list.add(shuttleData);
}
return R.ok().add(list);
}
@@ -184,8 +200,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 +282,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(false);//浣滀笟鏍囪澶嶄綅
+ 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 +353,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 +370,9 @@
if (pakMk != null) {
shuttleProtocol.setPakMk(pakMk.equals("Y"));
}
+ if (token != null) {
+ shuttleProtocol.setToken(token);
+ }
return R.ok();
}
--
Gitblit v1.9.1