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/service/impl/MainServiceImpl.java | 80 +++++++++++++++++++++++++++++++++-------
1 files changed, 66 insertions(+), 14 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 db25c37..c4cb96a 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
@@ -9,6 +9,7 @@
import com.zy.asrs.common.utils.HttpHandler;
import com.zy.asrs.framework.common.Cools;
import com.zy.asrs.framework.common.SnowflakeIdWorker;
+import com.zy.asrs.framework.exception.CoolException;
import com.zy.asrs.wcs.core.domain.dto.MatDto;
import com.zy.asrs.wcs.core.domain.dto.RedisMapDto;
import com.zy.asrs.wcs.core.domain.dto.StaDto;
@@ -78,6 +79,8 @@
private RedisUtil redisUtil;
@Autowired
private BasConveyorService basConveyorService;
+ @Autowired
+ private BasConveyorStaService basConveyorStaService;
@Autowired
private BasLedService basLedService;
@@ -267,6 +270,11 @@
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
JSONArray value = JSON.parseArray(dict.getValue());
@@ -372,6 +380,19 @@
list.add(mapNode.clone());
}
+ //鏈�鍚庝竴娆℃娴嬪湴鍥捐妭鐐规槸鍚﹀畬鏁达紝鍦板浘鐭╅樀row鍧囪杈惧埌鏈�闀縭ow
+ for (ArrayList<MapNode> list : lists) {
+ int len = (row + 2);//row+2鏄洜涓哄ご鑺傜偣鍜屽熬鑺傜偣瀛樺湪浜轰负娣诲姞鐨�-1鑺傜偣
+ if (list.size() == len) {
+ continue;
+ }
+ //鑺傜偣闀垮害涓嶆弧瓒筹紝杩涜琛ヨ冻
+ for (int i = list.size(); i < len; i++) {
+ list.add(mapNode.clone());
+ }
+ }
+
+
ArrayList<MapNode> headNodes = new ArrayList<>();
ArrayList<MapNode> footerNodes = new ArrayList<>();
for (int i = 0; i < row+2; i++) {
@@ -390,11 +411,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();
@@ -423,14 +441,19 @@
/**
* 鍑哄簱 ====>> 鍚屼竴鏃堕棿涓�鍙扮┛姊溅鍙兘鏈変竴涓嚭搴撲换鍔�
*/
- public synchronized void generateOutboundWrkMast() {
+ public synchronized void analyzeOutBoundTask() {
List<Task> tasks = taskService.selectPakOut();
if (tasks.isEmpty()) {
return;
}
for (Task task : tasks) {
- DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Conveyor, 1);
+ BasConveyorSta originStaObj = basConveyorStaService.selectBySiteNo(task.getOriginSite());//鑾峰彇婧愮珯
+ if (originStaObj == null) {
+ continue;
+ }
+
+ DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Conveyor, originStaObj.getConveyorId().intValue());
StaProtocol staProtocol = devpThread.getStation().get(Integer.parseInt(task.getOriginSite()));//婧愮珯
StaProtocol staProtocol1 = devpThread.getStation().get(Integer.parseInt(task.getDestSite()));//鐩爣绔�
if (staProtocol == null || staProtocol1 == null) {
@@ -440,15 +463,8 @@
staProtocol1 = staProtocol1.clone();
}
-// // 鏌ヨ绔欑偣璇︾粏淇℃伅
-// BasDevp staDetl = basDevpService.selectById(outSta.getStaNo());
-// if (staDetl == null) {
-// log.error("鍑哄簱 ===>> 绔欑偣鍦ㄦ暟鎹簱涓嶅瓨鍦�, 绔欑偣缂栧彿={}", outSta.getStaNo());
-// continue;
-// }
// 鍒ゆ柇鍫嗗灈鏈哄嚭搴撶珯鐘舵��
if (staProtocol.isAutoing() && !staProtocol.isLoading() && staProtocol.getWorkNo() == 0 && staProtocol.isOutEnable()) {
-
if (!(staProtocol1.isAutoing() && !staProtocol1.isLoading() && staProtocol1.getWorkNo() == 0 && staProtocol1.isOutEnable())) {
continue;
}
@@ -460,6 +476,23 @@
// News.info("{}浠诲姟锛屾祬搴撲綅瀛樺湪璐х墿锛岀郴缁熺瓑寰呬腑", wrkMast.getWrkNo());
// 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);
@@ -480,6 +513,25 @@
}
}
+ // 瑙f瀽灏忚溅绉诲姩宸ヤ綔妗�
+ public synchronized void analyzeMoveTask() {
+ for (Task task : taskService.selectWaitAnalyzeMoveTask()) {
+ // 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());
+ }
+ }
+ }
+
/**
* 鍥涘悜绌挎杞︾數閲忔娴� ===>> 鍙戣捣鍏呯數
*/
--
Gitblit v1.9.1