From 3979820ffea1120bc553accbdeba6445da91f277 Mon Sep 17 00:00:00 2001
From: qlsxk <qlsxk@qq.com>
Date: 星期四, 16 十月 2025 14:58:05 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/core/action/ShuttleAction.java | 424 ++++++----------------------------------------------
1 files changed, 53 insertions(+), 371 deletions(-)
diff --git a/src/main/java/com/zy/core/action/ShuttleAction.java b/src/main/java/com/zy/core/action/ShuttleAction.java
index d3e961f..42e4a3f 100644
--- a/src/main/java/com/zy/core/action/ShuttleAction.java
+++ b/src/main/java/com/zy/core/action/ShuttleAction.java
@@ -172,7 +172,7 @@
if (object == null) {
//鐢宠绠″埗
News.info("[RCS Debug] Execute apply control {},{}", shuttleNo, taskNo);
- redisUtil.set(RedisKeyType.TRAFFIC_CONTROL_LOCK_APPLY.key + shuttleNo, "lock", 10);
+ redisUtil.set(RedisKeyType.TRAFFIC_CONTROL_LOCK_APPLY.key + shuttleNo, "lock", 4);
applyTrafficControl(commands, nodes, shuttleNo, taskNo);
News.info("[RCS Debug] Execute apply control complete {},{}", shuttleNo, taskNo);
}
@@ -565,7 +565,7 @@
return;
}
- if (shuttleThread.isRequireCharge()) {
+ if (!shuttleThread.isRequireCharge().equals(ShuttleRequireChargeType.NONE)) {
return;
}
@@ -707,378 +707,60 @@
}
}
+ public synchronized void demoModeRunLoc(Integer shuttleNo) {
+ Config demoModeRunLocConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "demoModeRunLoc"));
+ if (demoModeRunLocConfig == null) {
+ return;
+ }
+
+ if (!demoModeRunLocConfig.getValue().equals("Y")) {
+ return;
+ }
+
+ ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleNo);
+ if (shuttleThread == null) {
+ return;
+ }
+
+ ShuttleProtocol shuttleProtocol = shuttleThread.getStatus();
+ if (shuttleProtocol == null) {
+ return;
+ }
+
+ if (!shuttleThread.isIdle()) {
+ return;
+ }
+
+ LocMast targetLoc = null;
+ EntityWrapper<LocMast> wrapper = new EntityWrapper<>();
+ wrapper.eq("lev1", Utils.getLev(shuttleProtocol.getCurrentLocNo()));
+ wrapper.notIn("loc_sts", "X");
+ wrapper.isNull("loc_type");
+ wrapper.last("ORDER BY RAND() LIMIT 1");
+ for (int i = 0; i < 3; i++) {
+ LocMast locMast = locMastService.selectOne(wrapper);
+ if(locMast == null) {
+ continue;
+ }
+
+ targetLoc = locMast;
+ break;
+ }
+
+ if(targetLoc == null) {
+ return;
+ }
+
+ boolean result = shuttleDispatchUtils.dispatchShuttle(null, targetLoc.getLocNo(), shuttleProtocol.getShuttleNo());
+ if (result) {
+ targetLoc.setLocType("Y");
+ locMastService.updateById(targetLoc);
+ }
+ }
+
public synchronized boolean clearPath(Integer shuttleNo) {
return navigateMapUtils.clearPath(shuttleNo);
}
-
-// //璺戝簱绋嬪簭
-// public synchronized void moveLoc(Integer shuttleNo) {
-// ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleNo);
-// if (shuttleThread == null) {
-// return;
-// }
-// ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(false);
-// if (shuttleProtocol == null) {
-// return;
-// }
-//
-// //灏忚溅寮�鍚窇搴撴ā寮�
-// if (!shuttleProtocol.getMoveLoc()) {
-// return;
-// }
-//
-// //灏忚溅绌洪棽
-// if (!shuttleThread.isIdle()) {
-// return;
-// }
-//
-// int lev = Utils.getLev(shuttleProtocol.getCurrentLocNo());//灏忚溅褰撳墠妤煎眰
-//
-// if (shuttleProtocol.getMoveType() == 0) {//璺戣建閬�
-// //鏍规嵁鍦板浘鏂瑰悜鍐冲畾璺憍鎴杫
-// Config config = configService.selectOne(new EntityWrapper<Config>()
-// .eq("code", "direction_map")
-// .eq("status", 1));
-// if (config == null) {
-// //璺戝簱缁撴潫
-// 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;
-// }
-// String direction = config.getValue();
-//
-// if (direction.equals("y")) {//璺憍杞存柟鍚戯紝璺戝畬x杞村啀鍒囨崲y杞�
-// ArrayList<String> locs = new ArrayList<>();
-// for (int i = shuttleProtocol.getXCurrent(); i <= shuttleProtocol.getXTarget(); i++) {
-// String locNo = Utils.getLocNo(i, shuttleProtocol.getYCurrent(), lev);
-// locs.add(locNo);
-// }
-//
-// List<LocMast> locList = locMastService.selectList(new EntityWrapper<LocMast>()
-// .eq("loc_sts", LocStsType.O.toString())
-// .in("loc_no", locs));
-// if (locList.isEmpty()) {
-// //绌哄簱浣�
-// shuttleProtocol.setYCurrent(shuttleProtocol.getYCurrent() + 1);
-// return;
-// }
-//
-// LocMast start = locList.get(0);
-// LocMast target = locList.get(locList.size() - 1);
-// //鍒ゆ柇灏忚溅鏄惁鍦ㄨ捣鐐逛綅缃�
-// if (!shuttleProtocol.getCurrentLocNo().equals(start.getLocNo())) {//涓嶅湪璧风偣浣嶇疆锛岃皟搴﹀幓璧风偣浣嶇疆
-// shuttleDispatcher.generateMoveTask(device, start.getLocNo());
-// }else {
-// //鍦ㄨ捣鐐逛綅缃紝璋冨害鍘荤洰鏍囦綅缃�
-// Task task = shuttleDispatcher.generateMoveTask(device, target.getLocNo());
-// if (task != null) {
-// shuttleProtocol.setYCurrent(shuttleProtocol.getYCurrent() + 1);//鍒囨崲y杞�
-// }
-//
-// if(shuttleProtocol.getYCurrent() > shuttleProtocol.getYTarget()) {
-// //y杞翠篃璺戝畬浜嗭紝缁撴潫璺戝簱
-// 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;
-// }
-// }
-// }else {//璺憏杞存柟鍚戯紝璺戝畬y杞村啀鍒囨崲x杞�
-// ArrayList<String> locs = new ArrayList<>();
-// for (int i = shuttleProtocol.getYCurrent(); i <= shuttleProtocol.getYTarget(); i++) {
-// String locNo = Utils.getLocNo(shuttleProtocol.getXCurrent(), i, lev);
-// locs.add(locNo);
-// }
-//
-// List<Loc> locList = locService.list(new LambdaQueryWrapper<Loc>()
-// .eq(Loc::getLocSts, LocStsType.O.val())
-// .in(Loc::getLocNo, locs));
-// if (locList.isEmpty()) {
-// //绌哄簱浣�
-// shuttleProtocol.setXCurrent(shuttleProtocol.getXCurrent() + 1);
-// return;
-// }
-//
-// Loc start = locList.get(0);
-// Loc target = locList.get(locList.size() - 1);
-// //鍒ゆ柇灏忚溅鏄惁鍦ㄨ捣鐐逛綅缃�
-// if (!shuttleProtocol.getCurrentLocNo().equals(start.getLocNo())) {//涓嶅湪璧风偣浣嶇疆锛岃皟搴﹀幓璧风偣浣嶇疆
-// shuttleDispatcher.generateMoveTask(device, start.getLocNo());
-// }else {
-// //鍦ㄨ捣鐐逛綅缃紝璋冨害鍘荤洰鏍囦綅缃�
-// Task task = shuttleDispatcher.generateMoveTask(device, target.getLocNo());
-// if (task != null) {
-// shuttleProtocol.setXCurrent(shuttleProtocol.getXCurrent() + 1);//鍒囨崲x杞�
-// }
-//
-// if(shuttleProtocol.getXCurrent() > shuttleProtocol.getXTarget()) {
-// //y杞翠篃璺戝畬浜嗭紝缁撴潫璺戝簱
-// 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;
-// }
-// }
-// }
-//
-// } else if (shuttleProtocol.getMoveType() == 1) {//璺戝簱浣�
-// //鏍规嵁鍦板浘鏂瑰悜鍐冲畾璺憍鎴杫
-// Dict dict = dictService.getOne(new LambdaQueryWrapper<Dict>()
-// .eq(Dict::getFlag, "direction_map")
-// .eq(Dict::getStatus, 1));
-// if (dict == null) {
-// //璺戝簱缁撴潫
-// 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;
-// }
-// String direction = dict.getValue();
-//
-// if (direction.equals("y")) {//璺憍杞存柟鍚戯紝璺戝畬x杞村啀鍒囨崲y杞�
-// Integer xCurrent = shuttleProtocol.getXCurrent();
-//
-// //鑾峰彇寰呰窇搴撲綅鍙�
-// String locNo = Utils.getLocNo(xCurrent, shuttleProtocol.getYCurrent(), lev);
-// Loc target = locService.getOne(new LambdaQueryWrapper<Loc>()
-// .eq(Loc::getLocNo, locNo)
-// .eq(Loc::getLocSts, LocStsType.O.val())
-// .eq(Loc::getHostId, device.getHostId()));
-// if (target == null || shuttleProtocol.getCurrentLocNo().equals(locNo)) {//搴撲綅涓嶅瓨鍦ㄦ垨灏忚溅宸插湪褰撳墠浣嶇疆
-// shuttleProtocol.setXCurrent(xCurrent + 1);
-// if (shuttleProtocol.getXCurrent() > shuttleProtocol.getXTarget()) {
-// //x杞磋窇瀹岋紝鍒囨崲y杞�
-// shuttleProtocol.setXCurrent(shuttleProtocol.getXStart());
-// shuttleProtocol.setYCurrent(shuttleProtocol.getYCurrent() + 1);
-//
-// if(shuttleProtocol.getYCurrent() > shuttleProtocol.getYTarget()) {
-// //y杞翠篃璺戝畬浜嗭紝缁撴潫璺戝簱
-// 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;
-// }
-// }
-// return;
-// }
-//
-// //璋冨害鍘诲簱浣�
-// Task task = shuttleDispatcher.generateMoveTask(device, locNo);
-// if (task == null) {
-// return;//璋冨害澶辫触
-// }
-//
-// shuttleProtocol.setXCurrent(xCurrent + 1);
-// if (shuttleProtocol.getXCurrent() > shuttleProtocol.getXTarget()) {
-// //x杞磋窇瀹岋紝鍒囨崲y杞�
-// shuttleProtocol.setXCurrent(shuttleProtocol.getXStart());
-// shuttleProtocol.setYCurrent(shuttleProtocol.getYCurrent() + 1);
-//
-// if(shuttleProtocol.getYCurrent() > shuttleProtocol.getYTarget()) {
-// //y杞翠篃璺戝畬浜嗭紝缁撴潫璺戝簱
-// 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;
-// }
-// }
-//
-// }else {//璺憏杞存柟鍚戯紝璺戝畬y杞村啀鍒囨崲x杞�
-// Integer yCurrent = shuttleProtocol.getYCurrent();
-//
-// //鑾峰彇寰呰窇搴撲綅鍙�
-// String locNo = Utils.getLocNo(shuttleProtocol.getXCurrent(), yCurrent, lev);
-// Loc target = locService.getOne(new LambdaQueryWrapper<Loc>()
-// .eq(Loc::getLocNo, locNo)
-// .eq(Loc::getLocSts, LocStsType.O.val())
-// .eq(Loc::getHostId, device.getHostId()));
-// if (target == null || shuttleProtocol.getCurrentLocNo().equals(locNo)) {//搴撲綅涓嶅瓨鍦ㄦ垨灏忚溅宸插湪褰撳墠浣嶇疆
-// shuttleProtocol.setYCurrent(yCurrent + 1);
-// if (shuttleProtocol.getYCurrent() > shuttleProtocol.getYTarget()) {
-// //y杞磋窇瀹岋紝鍒囨崲x杞�
-// shuttleProtocol.setYCurrent(shuttleProtocol.getYStart());
-// shuttleProtocol.setXCurrent(shuttleProtocol.getXCurrent() + 1);
-//
-// if(shuttleProtocol.getXCurrent() > shuttleProtocol.getXTarget()) {
-// //x杞翠篃璺戝畬浜嗭紝缁撴潫璺戝簱
-// 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;
-// }
-// }
-// return;
-// }
-//
-// //璋冨害鍘诲簱浣�
-// Task task = shuttleDispatcher.generateMoveTask(device, locNo);
-// if (task == null) {
-// return;//璋冨害澶辫触
-// }
-//
-// shuttleProtocol.setYCurrent(yCurrent + 1);
-// if (shuttleProtocol.getYCurrent() > shuttleProtocol.getYTarget()) {
-// //y杞磋窇瀹岋紝鍒囨崲x杞�
-// shuttleProtocol.setYCurrent(shuttleProtocol.getYStart());
-// shuttleProtocol.setXCurrent(shuttleProtocol.getXCurrent() + 1);
-//
-// if(shuttleProtocol.getXCurrent() > shuttleProtocol.getXTarget()) {
-// //x杞翠篃璺戝畬浜嗭紝缁撴潫璺戝簱
-// 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;
-// }
-// }
-//
-// }
-// } else if (shuttleProtocol.getMoveType() == 2) {//姣嶈建閬撳惊鐜窇
-// Integer xCurrent = shuttleProtocol.getXCurrent();
-// Integer yCurrent = shuttleProtocol.getYCurrent();
-//
-// String locNo = Utils.getLocNo(xCurrent, yCurrent, lev);
-// //璋冨害鍘荤洰鏍囦綅缃�
-// if (shuttleProtocol.getCurrentLocNo().equals(locNo)) {
-// if (yCurrent.equals(shuttleProtocol.getYStart())) {
-// shuttleProtocol.setYCurrent(shuttleProtocol.getYTarget());//灏忚溅鍜岀洰鏍囦綅缃竴鑷达紝鍒囨崲搴撲綅
-// } else {
-// shuttleProtocol.setYCurrent(shuttleProtocol.getYStart());//灏忚溅鍜岀洰鏍囦綅缃竴鑷达紝鍒囨崲搴撲綅
-// }
-// } else {
-// Task result = shuttleDispatcher.generateMoveTask(device, locNo);
-// if (result != null) {//璋冨害鎴愬姛
-// if (yCurrent.equals(shuttleProtocol.getYStart())) {
-// shuttleProtocol.setYCurrent(shuttleProtocol.getYTarget());//鍒囨崲搴撲綅
-// } else {
-// shuttleProtocol.setYCurrent(shuttleProtocol.getYStart());//鍒囨崲搴撲綅
-// }
-// }
-// }
-// } else if (shuttleProtocol.getMoveType() == 3) {//瀛愯建閬撳惊鐜窇
-// Integer xCurrent = shuttleProtocol.getXCurrent();
-// Integer yCurrent = shuttleProtocol.getYCurrent();
-//
-// String locNo = Utils.getLocNo(xCurrent, yCurrent, lev);
-// //璋冨害鍘荤洰鏍囦綅缃�
-// if (shuttleProtocol.getCurrentLocNo().equals(locNo)) {
-// if (xCurrent.equals(shuttleProtocol.getXStart())) {
-// shuttleProtocol.setXCurrent(shuttleProtocol.getXTarget());//灏忚溅鍜岀洰鏍囦綅缃竴鑷达紝鍒囨崲搴撲綅
-// } else {
-// shuttleProtocol.setXCurrent(shuttleProtocol.getXStart());//灏忚溅鍜岀洰鏍囦綅缃竴鑷达紝鍒囨崲搴撲綅
-// }
-// } else {
-// Task result = shuttleDispatcher.generateMoveTask(device, locNo);
-// if (result != null) {//璋冨害鎴愬姛
-// if (xCurrent.equals(shuttleProtocol.getXStart())) {
-// shuttleProtocol.setXCurrent(shuttleProtocol.getXTarget());//鍒囨崲搴撲綅
-// } else {
-// shuttleProtocol.setXCurrent(shuttleProtocol.getXStart());//鍒囨崲搴撲綅
-// }
-// }
-// }
-// } else if (shuttleProtocol.getMoveType() == 4) {//鍙栨斁璐�
-// Integer xCurrent = shuttleProtocol.getXCurrent();
-// if (xCurrent > shuttleProtocol.getXTarget()) {//褰揦鍊煎ぇ浜嶺鐩爣鍊�
-// shuttleProtocol.setXCurrent(shuttleProtocol.getXStart());
-// shuttleProtocol.setYCurrent(shuttleProtocol.getYStart());
-// return;
-// }
-//
-// //鍒ゆ柇x杞磋揣浣嶆槸鍚︽斁婊�
-// boolean flag = true;
-// for (Loc loc : locService.list(new LambdaQueryWrapper<Loc>()
-// .eq(Loc::getHostId, device.getHostId())
-// .eq(Loc::getRow, xCurrent)
-// .ge(Loc::getBay, shuttleProtocol.getYStart())
-// .le(Loc::getBay, shuttleProtocol.getYTarget()))) {
-// if (loc.getLocSts() != LocStsType.F.val()) {
-// flag = false;//鏈弧
-// break;
-// }
-// }
-// if (flag) {
-// shuttleProtocol.setXCurrent(shuttleProtocol.getXCurrent() + 1);
-// return;
-// }
-//
-// //鎼滅储鏈夎揣搴撲綅
-// List<Loc> list = locService.list(new LambdaQueryWrapper<Loc>()
-// .eq(Loc::getLocSts, LocStsType.F.val())
-// .eq(Loc::getHostId, device.getHostId())
-// .notIn(Loc::getRow, xCurrent)
-// .eq(Loc::getStatus, 1));
-// if (list.isEmpty()) {
-// return;
-// }
-//
-// Loc start = list.get(0);
-//
-// List<Loc> locList = locService.list(new LambdaQueryWrapper<Loc>()
-// .eq(Loc::getHostId, device.getHostId())
-// .eq(Loc::getStatus, 1)
-// .eq(Loc::getLocSts, LocStsType.O.val())
-// .eq(Loc::getRow, xCurrent)
-// .orderByDesc(Loc::getBay)
-// .orderByAsc(Loc::getRow));
-// if (locList.isEmpty()) {
-// return;
-// }
-//
-// Loc target = locList.get(0);
-// if (target == null) {
-// return;
-// }
-//
-// //璋冨害鍘荤洰鏍囦綅缃�
-// if (!shuttleProtocol.getCurrentLocNo().equals(target.getLocNo())) {
-// Task task = shuttleDispatcher.generateManuaTakeMoveTask(device, start.getLocNo(), target.getLocNo());
-//// if(task != null) {//璋冨害鎴愬姛
-//// shuttleProtocol.setXCurrent(shuttleProtocol.getXCurrent() + 1);
-//// }
-// }
-// }
-// }
private CommandResponse write(ShuttleCommand command, Integer shuttleNo) {
CommandResponse response = new CommandResponse(false);
--
Gitblit v1.9.1