From 74e0eb7a7e84b5006903e79554c007d9d5fbbcbc Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期四, 05 十月 2023 17:04:32 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/asrs/controller/ShuttleController.java | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 101 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 896319a..dcf22ca 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;
@@ -16,10 +17,12 @@
import com.zy.asrs.service.WrkMastService;
import com.zy.asrs.utils.Utils;
import com.zy.common.model.NyShuttleOperaResult;
+import com.zy.common.model.enums.NavigationMapType;
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.common.utils.ShuttleDispatchUtils;
import com.zy.core.cache.MessageQueue;
import com.zy.core.cache.OutputQueue;
import com.zy.core.cache.SlaveConnection;
@@ -61,11 +64,13 @@
private CommonService commonService;
@Autowired
private RedisUtil redisUtil;
+ @Autowired
+ private ShuttleDispatchUtils shuttleDispatchUtils;
@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,10 +79,25 @@
continue;
}
NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol();
+ JSONObject shuttleData = JSON.parseObject(JSON.toJSONString(shuttleProtocol));
if (shuttleProtocol == null || shuttleProtocol.getShuttleNo()==null) {
+ if (shuttleData != null) {
+ list.add(shuttleData);
+ }
continue;
}
- list.add(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);
}
@@ -280,7 +300,7 @@
assignCommand.setNodes(result.getNodes());
} else if (shuttleTaskModeType == ShuttleTaskModeType.MOVE_LOC_NO) {
//绉诲姩鍒扮洰鏍囧簱浣�
- NyShuttleOperaResult result = NyShuttleOperaUtils.getStartToTargetCommands(shuttleSlave.getId(), assignCommand.getTaskNo().intValue(), shuttleProtocol.getCurrentLocNo(), param.getDistLocNo());
+ NyShuttleOperaResult result = NyShuttleOperaUtils.getStartToTargetCommands(shuttleSlave.getId(), assignCommand.getTaskNo().intValue(), shuttleProtocol.getCurrentLocNo(), param.getDistLocNo(), NavigationMapType.NORMAL.id);
if (result == null) {
throw new CoolException("璺緞璁$畻澶辫触");
}
@@ -301,15 +321,49 @@
assignCommand.setCommands(commands);
} else if (shuttleTaskModeType == ShuttleTaskModeType.CHARGE) {
//鍏呯數寮�鍏�
- NyShuttleHttpCommand command = NyHttpUtils.getChargeCommand(shuttleSlave.getId(), assignCommand.getTaskNo().intValue(), true);
+ boolean charge = false;
+ if (shuttleProtocol.getChargState() == 1) {
+ //宸插厖鐢碉紝鍏抽棴鍏呯數
+ charge = false;
+ }else {
+ //寮�鍚厖鐢�
+ charge = true;
+ }
+ NyShuttleHttpCommand command = NyHttpUtils.getChargeCommand(shuttleSlave.getId(), assignCommand.getTaskNo().intValue(), charge);
ArrayList<NyShuttleHttpCommand> commands = new ArrayList<>();
commands.add(command);
assignCommand.setCommands(commands);
} else if (shuttleTaskModeType == ShuttleTaskModeType.RESET) {
//澶嶄綅
shuttleProtocol.setTaskNo(0);//宸ヤ綔鍙锋竻绌�
+ shuttleProtocol.setToken(0);//浠ょ墝娓呯┖
shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.IDLE);//浠诲姟鐘舵��-绌洪棽
- shuttleProtocol.setPakMk(true);//浣滀笟鏍囪澶嶄綅
+ shuttleProtocol.setPakMk(false);//浣滀笟鏍囪澶嶄綅
+
+ shuttleProtocol.setMoveLoc(false);
+ shuttleProtocol.setMoveType(0);
+ shuttleProtocol.setXStart(0);
+ shuttleProtocol.setXTarget(0);
+ shuttleProtocol.setXCurrent(0);
+ shuttleProtocol.setYStart(0);
+ shuttleProtocol.setYTarget(0);
+ shuttleProtocol.setYCurrent(0);
+ 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 if (shuttleTaskModeType == ShuttleTaskModeType.MOVE_LOC_NO_WRK_MAST) {
+ //绉诲姩鍒扮洰鏍囧簱浣�(鐢熸垚绉诲姩浠诲姟)
+ shuttleDispatchUtils.dispatchShuttle(commonService.getWorkNo(3), param.getDistLocNo(), param.getShuttleNo());
return R.ok();
} else {
throw new CoolException("鏈煡鍛戒护");
@@ -328,8 +382,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宸叉帀绾�");
@@ -343,6 +398,9 @@
}
if (pakMk != null) {
shuttleProtocol.setPakMk(pakMk.equals("Y"));
+ }
+ if (token != null) {
+ shuttleProtocol.setToken(token);
}
return R.ok();
}
@@ -362,4 +420,40 @@
return R.ok();
}
+ /**
+ * 璺戝簱绋嬪簭
+ */
+ @PostMapping("/moveLoc")
+ @ManagerAuth
+ public R moveLoc(@RequestParam Integer shuttleNo,
+ @RequestParam Integer moveType,
+ @RequestParam Integer xStart,
+ @RequestParam Integer xTarget,
+ @RequestParam Integer yStart,
+ @RequestParam Integer yTarget) {
+ NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleNo);
+ if (shuttleThread == null) {
+ return R.error();
+ }
+
+ NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol();
+ if (shuttleProtocol == null) {
+ return R.error();
+ }
+
+ if (!shuttleProtocol.isIdle()) {
+ return R.error("灏忚溅蹇欑涓�");
+ }
+
+ shuttleProtocol.setMoveLoc(true);//寮�鍚窇搴�
+ shuttleProtocol.setMoveType(moveType);
+ shuttleProtocol.setXStart(xStart);
+ shuttleProtocol.setXTarget(xTarget);
+ shuttleProtocol.setXCurrent(xStart);
+ shuttleProtocol.setYStart(yStart);
+ shuttleProtocol.setYTarget(yTarget);
+ shuttleProtocol.setYCurrent(yStart);
+ return R.ok();
+ }
+
}
--
Gitblit v1.9.1