From a40b27c3e22a152d7514d3148835238c23be303e Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期三, 10 四月 2024 14:41:14 +0800
Subject: [PATCH] Merge branch 'Four-Way-Rack' of http://47.97.1.152:5880/r/zy-asrs-master into Four-Way-Rack
---
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/MainProcess.java | 4
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SurayShuttleThread.java | 2
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/MapNode.java | 7 ++
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/service/impl/MainServiceImpl.java | 92 +++++++++++++++++++++++++++++-
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/timer/MotionTimer.java | 4
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/command/ShuttleCommandService.java | 13 ----
6 files changed, 103 insertions(+), 19 deletions(-)
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/MainProcess.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/MainProcess.java
index 3c7dae4..cad6634 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/MainProcess.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/MainProcess.java
@@ -47,8 +47,8 @@
// 闂撮殧
Thread.sleep(500);
-// //鍒濆鍖栧疄鏃跺湴鍥�
-// mainService.initRealtimeBasMap();
+ //鍒濆鍖栧疄鏃跺湴鍥�
+ mainService.initRealtimeBasMap();
// // 鎷f枡銆佸苟鏉裤�佺洏鐐瑰啀鍏ュ簱
//// mainService.stnToCrnStnPick();
// 鍑哄簱 =====>>
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/command/ShuttleCommandService.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/command/ShuttleCommandService.java
index b805fc3..1ef90fd 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/command/ShuttleCommandService.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/command/ShuttleCommandService.java
@@ -70,10 +70,7 @@
if (null == shuttleProtocol) {
return false;
}
- if (!shuttleProtocol.getIdle()) {//璁惧涓嶇┖闂�
- return false;
- }
- if (!shuttleProtocol.getPakMk()) {
+ if (!shuttleThread.isIdle()) {//璁惧涓嶇┖闂�
return false;
}
if (motionService.count(new LambdaQueryWrapper<Motion>()
@@ -94,14 +91,6 @@
LiftThread liftThread = null;
LiftProtocol liftProtocol = null;
-
- //鍒ゆ柇灏忚溅鐘舵��
- if (shuttleProtocol.getIdle()
- && shuttleProtocol.getProtocolStatusType().equals(ShuttleProtocolStatusType.IDLE)
- && shuttleProtocol.getTaskNo() != 0
- ) {
- return false;
- }
switch (Objects.requireNonNull(MotionCtgType.get(motion.getMotionCtgEl()))){
case SHUTTLE_MOVE:
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/MapNode.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/MapNode.java
index 9cbc7cb..3219680 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/MapNode.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/MapNode.java
@@ -15,6 +15,7 @@
* 4 鍏呯數妗�
* 5 鍏呯數妗�
* 66 绌挎杞﹀潗鏍�
+ * 67 鎻愬崌鏈哄潗鏍�
* -999 閿佸畾鑺傜偣
*/
private Integer value;
@@ -29,4 +30,10 @@
private Integer right;
+ private String no;
+
+ private Integer row;
+
+ private Integer bay;
+
}
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 e7c5592..6901e42 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
@@ -1,18 +1,24 @@
package com.zy.asrs.wcs.core.service.impl;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zy.asrs.framework.common.Cools;
import com.zy.asrs.framework.common.SnowflakeIdWorker;
import com.zy.asrs.wcs.core.entity.*;
import com.zy.asrs.wcs.core.kernel.AnalyzeService;
+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.TaskStsType;
import com.zy.asrs.wcs.core.service.*;
+import com.zy.asrs.wcs.core.utils.RedisUtil;
import com.zy.asrs.wcs.core.utils.ShuttleDispatcher;
import com.zy.asrs.wcs.core.utils.Utils;
import com.zy.asrs.wcs.rcs.News;
import com.zy.asrs.wcs.rcs.cache.SlaveConnection;
+import com.zy.asrs.wcs.rcs.constant.DeviceRedisConstant;
import com.zy.asrs.wcs.rcs.entity.Device;
import com.zy.asrs.wcs.rcs.entity.DeviceType;
import com.zy.asrs.wcs.rcs.model.enums.ShuttleProtocolStatusType;
@@ -30,9 +36,7 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
/**
* 绔嬩綋浠撳簱WCS绯荤粺涓绘祦绋嬩笟鍔�
@@ -65,6 +69,8 @@
private DictService dictService;
@Autowired
private ShuttleDispatcher shuttleDispatcher;
+ @Autowired
+ private RedisUtil redisUtil;
/**
* 缁勬墭
@@ -74,6 +80,86 @@
}
+ /**
+ * 鍒濆鍖栧疄鏃跺湴鍥�
+ */
+ public synchronized void initRealtimeBasMap() {
+ try {
+ List<Dict> dicts = dictService.list(new LambdaQueryWrapper<Dict>()
+ .like(Dict::getFlag, "map")
+ .eq(Dict::getStatus, 1));
+
+ TreeMap<Integer, ArrayList<ArrayList<MapNode>>> levData = new TreeMap<>();
+ for (Dict dict : dicts) {
+ String[] split = dict.getFlag().split("-");
+ int lev = Integer.parseInt(split[1]);
+
+ TreeMap<Integer, List<JSONObject>> rows = new TreeMap<>();
+ //鎺掑簭Row
+ JSONArray value = JSON.parseArray(dict.getValue());
+ for (Object o : value) {
+ JSONObject item = JSON.parseObject(o.toString());
+ if (item.getString("type").equals("SHELF")) {
+ JSONObject property = JSON.parseObject(item.getString("property"));
+ Integer row1 = property.getInteger("row");
+ ArrayList<JSONObject> bays = new ArrayList<>();
+ if (rows.containsKey(row1)) {
+ bays.addAll(rows.get(row1));
+ }
+ bays.add(property);
+ rows.put(row1, bays);
+ }
+ }
+
+ ArrayList<ArrayList<MapNode>> list = new ArrayList<>();
+ //鎺掑簭Bay
+ for (Map.Entry<Integer, List<JSONObject>> entry : rows.entrySet()) {
+ ArrayList<MapNode> nodes = new ArrayList<>();
+ for (JSONObject object : entry.getValue()) {
+ MapNode mapNode = new MapNode();
+ mapNode.setValue(object.getInteger("value"));
+ mapNode.setTop(object.getInteger("top"));
+ mapNode.setBottom(object.getInteger("bottom"));
+ mapNode.setLeft(object.getInteger("left"));
+ mapNode.setRight(object.getInteger("right"));
+ mapNode.setRow(object.getInteger("row"));
+ mapNode.setBay(object.getInteger("bay"));
+ mapNode.setNo(object.getString("row") + "-" + object.getString("bay"));
+ nodes.add(mapNode);
+ }
+
+ Collections.sort(nodes, new Comparator<MapNode>() {
+ @Override
+ public int compare(MapNode o1, MapNode o2) {
+ return Integer.compare(o1.getBay(), o2.getBay());
+ }
+ });
+
+ list.add(nodes);
+ }
+
+ levData.put(lev, list);
+ }
+
+ for (Map.Entry<Integer, ArrayList<ArrayList<MapNode>>> entry : levData.entrySet()) {
+ ArrayList<ArrayList<MapNode>> lists = entry.getValue();//鑾峰彇鍦板浘
+
+ Integer lev = entry.getKey();
+ Date now = new Date();
+ HashMap<String, Object> map = new HashMap<>();
+ map.put("data", JSON.toJSONString(lists));
+ map.put("create_time", now);
+ map.put("update_time", now);
+ map.put("lev", lev);
+
+ //灏嗗湴鍥炬暟鎹瓨鍏edis
+ redisUtil.set(DeviceRedisConstant.MAP + lev, JSON.toJSONString(map));
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
// 瑙f瀽鍏ュ簱宸ヤ綔妗�
public synchronized void analyzeInBoundTask() {
for (Task task : taskService.selectWaitAnalyzeInBoundTask()) {
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/timer/MotionTimer.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/timer/MotionTimer.java
index 362443f..10f3f7d 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/timer/MotionTimer.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/timer/MotionTimer.java
@@ -237,7 +237,7 @@
Boolean executeRes = Boolean.FALSE;
switch (Objects.requireNonNull(MotionCtgType.get(motion.getMotionCtgEl())).deviceCtg) {
case CONVEYOR:
-// executeRes = conveyorCommandService.accept(motion);
+ executeRes = conveyorCommandService.accept(motion);
break;
case CRANE:
executeRes = craneCommandService.accept(motion);
@@ -284,7 +284,7 @@
executeRes = shuttleCommandService.finish(motion);
break;
case CONVEYOR:
-// executeRes = conveyorCommandService.finish(motion);
+ executeRes = conveyorCommandService.finish(motion);
break;
default:
break;
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SurayShuttleThread.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SurayShuttleThread.java
index fe13fcb..d4b9e83 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SurayShuttleThread.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SurayShuttleThread.java
@@ -374,6 +374,7 @@
|| this.shuttleProtocol.getPakMk() == null
|| this.shuttleProtocol.getErrorCode() == null
|| this.shuttleProtocol.getProtocolStatus() == null
+ || this.shuttleProtocol.getTaskNo() == null
) {
return false;
}
@@ -382,6 +383,7 @@
&& this.shuttleProtocol.getPakMk()
&& this.shuttleProtocol.getErrorCode().equals("0")
&& this.shuttleProtocol.getProtocolStatus() == ShuttleProtocolStatusType.IDLE.id
+ && this.shuttleProtocol.getTaskNo() == 0
;
return res;
}
--
Gitblit v1.9.1