From 0a9ca0a0c1dc8a364fe1ce71af37f880a0365b36 Mon Sep 17 00:00:00 2001
From: Junjie <540245094@qq.com>
Date: 星期六, 08 六月 2024 12:32:32 +0800
Subject: [PATCH] #
---
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/ShuttleDispatcher.java | 144 +++++++++++++++++++----------------------------
1 files changed, 59 insertions(+), 85 deletions(-)
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/ShuttleDispatcher.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/ShuttleDispatcher.java
index 1135d69..991898e 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/ShuttleDispatcher.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/ShuttleDispatcher.java
@@ -4,13 +4,13 @@
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zy.asrs.framework.common.Cools;
+import com.zy.asrs.framework.common.R;
import com.zy.asrs.framework.common.SnowflakeIdWorker;
import com.zy.asrs.framework.exception.CoolException;
import com.zy.asrs.wcs.core.entity.*;
import com.zy.asrs.wcs.core.kernel.AnalyzeService;
import com.zy.asrs.wcs.core.model.NavigateNode;
import com.zy.asrs.wcs.core.model.enums.DeviceCtgType;
-import com.zy.asrs.wcs.core.model.enums.LiftCodeType;
import com.zy.asrs.wcs.core.model.enums.NavigationMapType;
import com.zy.asrs.wcs.core.model.enums.TaskStsType;
import com.zy.asrs.wcs.core.service.*;
@@ -53,85 +53,6 @@
private TaskCtgService taskCtgService;
@Autowired
private ShuttleStandbyService shuttleStandbyService;
-
- public ShuttleThread queryShuttleWhichConvenient(Task task, Integer liftNo) {
- String locNo = taskService.judgeInbound(task) ? task.getDestLoc() : task.getOriginLoc();
- ShuttleThread resThread = null;
- Integer finalDistance = ShuttleDispatcher.INF;
-
- List<Device> list = deviceService.list(new LambdaQueryWrapper<Device>()
- .eq(Device::getDeviceType, DeviceCtgType.SHUTTLE.val())
- .eq(Device::getHostId, task.getHostId())
- .eq(Device::getStatus, 1));
-
- for (Device device : list) {
- if (taskService.hasBusyOutboundByShuttle(Integer.parseInt(device.getDeviceNo()))) {
- continue;
- }
- //鑾峰彇鍥涘悜绌挎杞︾嚎绋�
- ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, device.getId().intValue());
- ShuttleProtocol shuttleProtocol = shuttleThread.getStatus();
- if (shuttleProtocol == null || shuttleProtocol.getShuttleNo() == null) {
- continue;
- }
-
- if (!shuttleThread.isIdle()) {
- continue;
- }
-
- //妫�娴嬫槸鍚﹀瓨鍦ㄥ厖鐢典换鍔�
- Task taskCharge = taskService.selectChargeWorking(Integer.valueOf(device.getDeviceNo()));
- if (taskCharge != null) {
- continue;
- }
-
- // 鏈夋病鏈夎鍏朵粬浠诲姟璋冨害
- int currentLev = Utils.getLev(shuttleProtocol.getCurrentLocNo());//灏忚溅褰撳墠灞傞珮
- String currentLocNo = shuttleProtocol.getCurrentLocNo();//灏忚溅褰撳墠搴撲綅鍙�
-
- if (currentLocNo.equals(locNo)) {
- resThread = shuttleThread;
- break;
- }
-
- String targetLocNo = LiftCodeType.getStandbyLocNo(liftNo, currentLev);//榛樿鍒版彁鍗囨満寰呮満浣�
- // 鍚屾ゼ灞傜洿鎺ヨ绠楀埌鐩爣搴撲綅
- if (currentLev == Utils.getLev(locNo)) {
- targetLocNo = locNo;
- }
-
- //褰撳墠绌挎杞︾嚎绋嬪埌褰撳墠杞﹀瓙鎵�鍦ㄦゼ灞傜殑鎻愬崌鏈哄彛璺濈
- List<NavigateNode> currentShuttlePath = NavigateUtils.calc(
- currentLocNo
- , targetLocNo
- , NavigationMapType.NORMAL.id
- , Utils.getShuttlePoints(Integer.parseInt(shuttleThread.getDevice().getDeviceNo()), currentLev)
- );//鎼滅储绌洪棽绌挎杞︼紝浣跨敤姝e父閫氶亾鍦板浘
- if (currentShuttlePath == null) {
- continue;
- }
-
- Integer currDistance = NavigateUtils.getOriginPathAllDistance(currentShuttlePath);//璁$畻褰撳墠璺緞琛岃蛋鎬昏窛绂�
-
- // 涓嶅悓妤煎眰鏉冮噸
- if (currentLev != Utils.getLev(locNo)) {
- currDistance += WEIGHT;
- }
-
- // 鎸傝浇浠诲姟鏉冮噸
- List<Task> tasks = taskService.selectWorkingByShuttle(Integer.valueOf(device.getDeviceNo()));
- if (!Cools.isEmpty(tasks)) {
- currDistance += tasks.size() * WEIGHT;
- }
-
- if (currDistance < finalDistance) {
- finalDistance = currDistance;
- resThread = shuttleThread;
- }
- }
-
- return resThread;
- }
public synchronized ShuttleThread searchIdleShuttle(Task task) {
String locNo = taskService.judgeInbound(task) ? task.getDestLoc() : task.getOriginLoc();
@@ -244,9 +165,6 @@
return null;
}
- //鑾峰彇閬胯浣嶇疆
- String standByLocNo = this.searchStandByLocNo(Integer.valueOf(device.getDeviceNo()), device.getHostId(), shuttleThread.getStatus().getCurrentLocNo());
-
Task task = new Task();
task.setUuid(String.valueOf(snowflakeIdWorker.nextId()));
task.setTaskNo(String.valueOf(Utils.getTaskNo("MOVE")));
@@ -256,7 +174,7 @@
task.setOriginSite(null);
task.setOriginLoc(null);
task.setDestSite(null);
- task.setDestLoc(standByLocNo); // 閬胯浣嶇疆
+ task.setDestLoc(locNo); // 杩佺Щ浣嶇疆
task.setIoTime(new Date());
task.setStartTime(new Date());
task.setHostId(device.getHostId());
@@ -269,7 +187,7 @@
News.error("淇濆瓨{}鍙峰洓鍚戠┛姊溅杩佺Щ浠诲姟澶辫触!!!", device.getDeviceNo());
return null;
}
- motionService.batchInsert(motionList, task.getUuid(), Integer.valueOf(task.getTaskNo()));
+ motionService.batchInsert(motionList, task.getUuid(), Integer.valueOf(task.getTaskNo()), device.getHostId());
task.setTaskSts(TaskStsType.ANALYZE_MOVE.sts);
@@ -281,6 +199,62 @@
return task;
}
+ //鐢熸垚鎵嬪姩鍙栨斁璐т换鍔�
+ public synchronized Task generateManuaTakeMoveTask(Device device, String sourceLocNo, String locNo) {
+ // 宸叉湁鎵嬪姩浠诲姟
+ if (taskService.selectManualWorking(Integer.valueOf(device.getDeviceNo())) != null) {
+ return null;
+ }
+
+ //鑾峰彇鎵嬪姩浠诲姟绫诲瀷
+ TaskCtg taskCtg = taskCtgService.getOne(new LambdaQueryWrapper<TaskCtg>()
+ .eq(TaskCtg::getFlag, "MANUAL")
+ .eq(TaskCtg::getStatus, 1));
+ if (taskCtg == null) {
+ return null;
+ }
+
+ ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, device.getId().intValue());
+ if (shuttleThread == null) {
+ return null;
+ }
+
+ Task task = new Task();
+ task.setUuid(String.valueOf(snowflakeIdWorker.nextId()));
+ task.setTaskNo(String.valueOf(Utils.getTaskNo("MANUAL")));
+ task.setTaskSts(TaskStsType.NEW_MANUAL.sts);
+ task.setTaskCtg(taskCtg.getId());
+ task.setPriority(10);
+ task.setOriginSite(null);
+ task.setOriginLoc(sourceLocNo);
+ task.setDestSite("takeMove");
+ task.setDestLoc(locNo);
+ task.setIoTime(new Date());
+ task.setStartTime(new Date());
+ task.setStatus(1);
+ task.setMemo("manual");
+ task.setShuttleNo(Integer.valueOf(device.getDeviceNo()));
+ task.setRecordLoc("Y");//璁板綍搴撳瓨淇℃伅
+ task.setHostId(device.getHostId());
+
+ // generate motion list
+ List<Motion> motionList = analyzeService.generateShuttleManualMotion(task);
+ if (Cools.isEmpty(motionList)) {
+ News.error("淇濆瓨{}鍙峰洓鍚戠┛姊溅鎵嬪姩浠诲姟澶辫触!!!", device.getDeviceNo());
+ return null;
+ }
+ motionService.batchInsert(motionList, task.getUuid(), Integer.valueOf(task.getTaskNo()), device.getHostId());
+
+ task.setTaskSts(TaskStsType.ANALYZE_MANUAL.sts);
+
+ if (!taskService.save(task)) {
+ News.error("淇濆瓨{}鍙峰洓鍚戠┛姊溅鎵嬪姩浠诲姟澶辫触!!!", device.getDeviceNo());
+ return null;
+ }
+
+ return task;
+ }
+
/**
* 鎼滅储閬胯搴撲綅锛岄�氳繃灏忚溅鍙峰拰鐩爣搴撲綅
*/
--
Gitblit v1.9.1