From 36c6d6b39e2b76080480c5bc90a412d711b76144 Mon Sep 17 00:00:00 2001
From: zjj <3272660260@qq.com>
Date: 星期三, 19 六月 2024 15:54:24 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/Four-Way-Rack' into Four-Way-Rack
---
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/service/impl/MainServiceImpl.java | 141 ++++++++++++++++++++++++++++++++++++++---------
1 files changed, 114 insertions(+), 27 deletions(-)
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/service/impl/MainServiceImpl.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/service/impl/MainServiceImpl.java
index ad43e7a..41fe225 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/service/impl/MainServiceImpl.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/service/impl/MainServiceImpl.java
@@ -17,6 +17,7 @@
import com.zy.asrs.wcs.core.model.MapNode;
import com.zy.asrs.wcs.core.model.enums.DeviceCtgType;
import com.zy.asrs.wcs.core.model.enums.MotionStsType;
+import com.zy.asrs.wcs.core.model.enums.TaskCtgType;
import com.zy.asrs.wcs.core.model.enums.TaskStsType;
import com.zy.asrs.wcs.core.service.*;
import com.zy.asrs.wcs.core.utils.RedisUtil;
@@ -80,6 +81,8 @@
private BasConveyorService basConveyorService;
@Autowired
private BasConveyorStaService basConveyorStaService;
+ @Autowired
+ private BasConveyorPathService basConveyorPathService;
@Autowired
private BasLedService basLedService;
@@ -179,7 +182,7 @@
//鑾峰彇鍏ュ簱浠诲姟绫诲瀷
TaskCtg taskCtg = taskCtgService.getOne(new LambdaQueryWrapper<TaskCtg>()
- .eq(TaskCtg::getFlag, "IN")
+ .eq(TaskCtg::getFlag, String.valueOf(TaskCtgType.IN))
.eq(TaskCtg::getStatus, 1));
// 鍒ゆ柇閲嶅宸ヤ綔妗�
@@ -218,10 +221,19 @@
Integer code = jsonObject.getInteger("code");
if (code.equals(200)) {
StartupDto dto = jsonObject.getObject("data", StartupDto.class);
- devpThread.writeWorkSta(staProtocol.getSiteId(), dto.getWorkNo().shortValue(), dto.getStaNo().shortValue());
- devpThread.setPakMk(staProtocol.getSiteId(), false);
- } else if (code == 500) {
+ //鑾峰彇杈撻�佽矾寰�
+ BasConveyorPath conveyorPath = basConveyorPathService.getOne(new LambdaQueryWrapper<BasConveyorPath>()
+ .eq(BasConveyorPath::getTypeNo, TaskCtgType.IN.val())
+ .eq(BasConveyorPath::getDeviceId, devp.getId())
+ .eq(BasConveyorPath::getStnNo, staProtocol.getSiteId()));
+ if (conveyorPath == null) {
+ News.error("杈撻�佽矾寰勪笉瀛樺湪");
+ }else {
+ devpThread.writeWorkSta(staProtocol.getSiteId(), dto.getWorkNo().shortValue(), conveyorPath.getDeviceStn().shortValue());
+ devpThread.setPakMk(staProtocol.getSiteId(), false);
+ }
+ }else {
if (ledThread != null) {
String errorMsg = jsonObject.getString("msg");
if (!Cools.isEmpty(errorMsg)) {
@@ -230,18 +242,6 @@
}
}
News.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + "/rpc/pakin/loc/v2", JSON.toJSONString(param), response);
- } else if (code == 700) {
-// staProtocol.setWorkNo((short) 32002);
-// staProtocol.setRollback102(1);//102绔欏洖閫�淇″彿
-// devpThread.setPakMk(staProtocol.getSiteId(), false);
-// MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(5, staProtocol));
-
- // led 寮傚父鏄剧ず
- if (ledThread != null) {
- String errorMsg = barcode + "鎵樼洏璇嗗埆寮傚父锛岃鍏堣繘琛岀粍鎵橈紒";
- ledThread.error(errorMsg);
- ledThread.setLedMk(false);
- }
}
} catch (Exception e) {
e.printStackTrace();
@@ -268,6 +268,11 @@
for (Dict dict : dicts) {
String[] split = dict.getFlag().split("-");
int lev = Integer.parseInt(split[1]);
+
+ Object data = redisUtil.get(DeviceRedisConstant.MAP + lev);
+ if (data != null) {
+ continue;
+ }
TreeMap<Integer, List<JSONObject>> rows = new TreeMap<>();
//鎺掑簭Row
@@ -405,11 +410,8 @@
map.setUpdateTime(now);
map.setLev(lev);
- Object data = redisUtil.get(DeviceRedisConstant.MAP + lev);
- if (data == null) {
- //灏嗗湴鍥炬暟鎹瓨鍏edis
- redisUtil.set(DeviceRedisConstant.MAP + lev, JSON.toJSONString(map));
- }
+ //灏嗗湴鍥炬暟鎹瓨鍏edis
+ redisUtil.set(DeviceRedisConstant.MAP + lev, JSON.toJSONString(map));
}
} catch (Exception e) {
e.printStackTrace();
@@ -419,6 +421,23 @@
// 瑙f瀽鍏ュ簱宸ヤ綔妗�
public synchronized void analyzeInBoundTask() {
for (Task task : taskService.selectWaitAnalyzeInBoundTask()) {
+ if (Cools.isEmpty(task.getShuttleNo())) {
+ //鍒嗛厤灏忚溅
+ //鎼滅储绌洪棽杞�
+ ShuttleThread shuttleThread = shuttleDispatcher.searchIdleShuttle(task);
+ if (shuttleThread == null) {
+ News.info("{}浠诲姟鏈壘鍒扮┖闂茬┛姊溅", task.getTaskNo());
+ continue;
+ }
+
+ task.setShuttleNo(Integer.valueOf(shuttleThread.getDevice().getDeviceNo()));//淇濆瓨绌挎杞﹀彿
+ task.setUpdateTime(new Date());
+ if (!taskService.updateById(task)) {
+ News.info("{}浠诲姟鏇存柊绌挎杞﹀彿澶辫触", task.getTaskNo());
+ }
+ continue;
+ }
+
// generate motion list
List<Motion> motionList = analyzeService.generateMotion(task);
if (motionList.isEmpty()) {
@@ -438,7 +457,7 @@
/**
* 鍑哄簱 ====>> 鍚屼竴鏃堕棿涓�鍙扮┛姊溅鍙兘鏈変竴涓嚭搴撲换鍔�
*/
- public synchronized void generateOutboundWrkMast() {
+ public synchronized void analyzeOutBoundTask() {
List<Task> tasks = taskService.selectPakOut();
if (tasks.isEmpty()) {
return;
@@ -474,6 +493,23 @@
// continue;//娴呭簱浣嶅瓨鍦ㄦ湭鎵ц浠诲姟
// }
+ if (Cools.isEmpty(task.getShuttleNo())) {
+ //鍒嗛厤灏忚溅
+ //鎼滅储绌洪棽杞�
+ ShuttleThread shuttleThread = shuttleDispatcher.searchIdleShuttle(task);
+ if (shuttleThread == null) {
+ News.info("{}浠诲姟鏈壘鍒扮┖闂茬┛姊溅", task.getTaskNo());
+ continue;
+ }
+
+ task.setShuttleNo(Integer.valueOf(shuttleThread.getDevice().getDeviceNo()));//淇濆瓨绌挎杞﹀彿
+ task.setUpdateTime(new Date());
+ if (!taskService.updateById(task)) {
+ News.info("{}浠诲姟鏇存柊绌挎杞﹀彿澶辫触", task.getTaskNo());
+ }
+ continue;
+ }
+
// generate motion list
List<Motion> motionList = analyzeService.generateMotion(task);
if (Cools.isEmpty(motionList)) {
@@ -493,6 +529,42 @@
}
}
+ // 瑙f瀽灏忚溅绉诲姩宸ヤ綔妗�
+ public synchronized void analyzeMoveTask() {
+ for (Task task : taskService.selectWaitAnalyzeMoveTask()) {
+ if (Cools.isEmpty(task.getShuttleNo())) {
+ //鍒嗛厤灏忚溅
+ //鎼滅储绌洪棽杞�
+ ShuttleThread shuttleThread = shuttleDispatcher.searchIdleShuttle(task);
+ if (shuttleThread == null) {
+ News.info("{}浠诲姟鏈壘鍒扮┖闂茬┛姊溅", task.getTaskNo());
+ continue;
+ }
+
+ task.setShuttleNo(Integer.valueOf(shuttleThread.getDevice().getDeviceNo()));//淇濆瓨绌挎杞﹀彿
+ task.setUpdateTime(new Date());
+ if (!taskService.updateById(task)) {
+ News.info("{}浠诲姟鏇存柊绌挎杞﹀彿澶辫触", task.getTaskNo());
+ }
+ continue;
+ }
+
+ // generate motion list
+ List<Motion> motionList = analyzeService.generateMotion(task);
+ if (motionList.isEmpty()) {
+ continue;
+ }
+ motionService.batchInsert(motionList, task.getUuid(), Integer.valueOf(task.getTaskNo()));
+
+ // 鏇存柊宸ヤ綔涓绘。
+ task.setTaskSts(TaskStsType.ANALYZE_MOVE.sts); // 宸ヤ綔鐘舵��
+ task.setUpdateTime(new Date());
+ if (!taskService.updateById(task)) {
+ News.error("鏇存柊宸ヤ綔妗eけ璐ワ紒锛侊紒 [宸ヤ綔鍙凤細{}]", task.getTaskNo());
+ }
+ }
+ }
+
/**
* 鍥涘悜绌挎杞︾數閲忔娴� ===>> 鍙戣捣鍏呯數
*/
@@ -507,7 +579,7 @@
//鑾峰彇鍏呯數浠诲姟绫诲瀷
TaskCtg taskCtg = taskCtgService.getOne(new LambdaQueryWrapper<TaskCtg>()
- .eq(TaskCtg::getFlag, "CHARGE")
+ .eq(TaskCtg::getFlag, String.valueOf(TaskCtgType.CHARGE))
.eq(TaskCtg::getStatus, 1));
if (taskCtg == null) {
return;
@@ -651,7 +723,7 @@
//鑾峰彇杩佺Щ浠诲姟绫诲瀷
TaskCtg taskCtg = taskCtgService.getOne(new LambdaQueryWrapper<TaskCtg>()
- .eq(TaskCtg::getFlag, "MOVE")
+ .eq(TaskCtg::getFlag, String.valueOf(TaskCtgType.MOVE))
.eq(TaskCtg::getStatus, 1));
if (taskCtg == null) {
return;
@@ -749,8 +821,13 @@
.eq(BasLed::getDeviceId, ledDevice.getId()));
List<Integer> staArr = JSON.parseArray(led.getSta(), Integer.class);
+ BasConveyor basConveyor = basConveyorService.getById(led.getConveyorId().intValue());
+ if (basConveyor == null) {
+ continue;
+ }
+
// 鑾峰彇杈撻�佺嚎plc绾跨▼
- DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Conveyor, led.getConveyorId().intValue());
+ DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Conveyor, basConveyor.getDeviceId().intValue());
// 鍛戒护闆嗗悎
List<LedCommand> commands = new ArrayList<>();
// 宸ヤ綔妗i泦鍚�
@@ -830,8 +907,13 @@
.eq(BasLed::getDeviceId, ledDevice.getId()));
List<Integer> staArr = JSON.parseArray(led.getSta(), Integer.class);
+ BasConveyor basConveyor = basConveyorService.getById(led.getConveyorId().intValue());
+ if (basConveyor == null) {
+ continue;
+ }
+
// 鑾峰彇杈撻�佺嚎plc绾跨▼
- DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Conveyor, led.getConveyorId().intValue());
+ DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Conveyor, basConveyor.getDeviceId().intValue());
// 鍛戒护闆嗗悎
boolean reset = true;
for (Integer staNo : staArr) {
@@ -860,8 +942,13 @@
.eq(BasLed::getDeviceId, ledDevice.getId()));
List<Integer> staArr = JSON.parseArray(led.getSta(), Integer.class);
+ BasConveyor basConveyor = basConveyorService.getById(led.getConveyorId());
+ if (basConveyor == null) {
+ continue;
+ }
+
// 鑾峰彇杈撻�佺嚎plc绾跨▼
- DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Conveyor, led.getConveyorId().intValue());
+ DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Conveyor, basConveyor.getDeviceId().intValue());
// 鍛戒护闆嗗悎
boolean reset = true;
for (Integer staNo : staArr) {
--
Gitblit v1.9.1