From ad79ba405b2d1ac96423f88f4e8a76c584b9d38a Mon Sep 17 00:00:00 2001
From: zwl <1051256694@qq.com>
Date: 星期一, 09 二月 2026 15:57:06 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/core/utils/StationOperateProcessUtils.java | 150 ++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 127 insertions(+), 23 deletions(-)
diff --git a/src/main/java/com/zy/core/utils/StationOperateProcessUtils.java b/src/main/java/com/zy/core/utils/StationOperateProcessUtils.java
index f0ed359..4a14a33 100644
--- a/src/main/java/com/zy/core/utils/StationOperateProcessUtils.java
+++ b/src/main/java/com/zy/core/utils/StationOperateProcessUtils.java
@@ -4,8 +4,10 @@
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.core.exception.CoolException;
+import com.zy.asrs.domain.enums.NotifyMsgType;
import com.zy.asrs.entity.*;
import com.zy.asrs.service.*;
+import com.zy.asrs.utils.NotifyUtils;
import com.zy.common.entity.FindCrnNoResult;
import com.zy.common.model.StartupDto;
import com.zy.common.service.CommonService;
@@ -13,14 +15,13 @@
import com.zy.core.News;
import com.zy.core.cache.MessageQueue;
import com.zy.core.cache.SlaveConnection;
-import com.zy.core.enums.RedisKeyType;
-import com.zy.core.enums.SlaveType;
-import com.zy.core.enums.StationCommandType;
-import com.zy.core.enums.WrkStsType;
+import com.zy.core.enums.*;
import com.zy.core.model.StationObjModel;
import com.zy.core.model.Task;
import com.zy.core.model.command.StationCommand;
+import com.zy.core.model.protocol.CrnProtocol;
import com.zy.core.model.protocol.StationProtocol;
+import com.zy.core.thread.CrnThread;
import com.zy.core.thread.StationThread;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -46,13 +47,15 @@
private LocMastService locMastService;
@Autowired
private WmsOperateUtils wmsOperateUtils;
+ @Autowired
+ private NotifyUtils notifyUtils;
//鎵ц杈撻�佺珯鐐瑰叆搴撲换鍔�
public synchronized void stationInExecute() {
List<BasDevp> basDevps = basDevpService.selectList(new EntityWrapper<>());
for (BasDevp basDevp : basDevps) {
StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, basDevp.getDevpNo());
- if(stationThread == null){
+ if (stationThread == null) {
continue;
}
@@ -61,7 +64,7 @@
List<StationObjModel> list = basDevp.getBarcodeStationList$();
for (StationObjModel entity : list) {
Integer stationId = entity.getStationId();
- if(!stationMap.containsKey(stationId)){
+ if (!stationMap.containsKey(stationId)) {
continue;
}
@@ -71,7 +74,7 @@
}
Object lock = redisUtil.get(RedisKeyType.STATION_IN_EXECUTE_LIMIT.key + stationId);
- if(lock != null){
+ if (lock != null) {
continue;
}
@@ -104,7 +107,7 @@
}
StationCommand command = stationThread.getCommand(StationCommandType.MOVE, wrkMast.getWrkNo(), stationId, targetStationId, 0);
- if(command == null){
+ if (command == null) {
News.taskInfo(wrkMast.getWrkNo(), "{}宸ヤ綔,鑾峰彇杈撻�佺嚎鍛戒护澶辫触", wrkMast.getWrkNo());
continue;
}
@@ -133,7 +136,7 @@
BasCrnp basCrnp = basCrnpService.selectOne(new EntityWrapper<BasCrnp>().eq("crn_no", wrkMast.getCrnNo()));
if (basCrnp != null) {
outStationList = basCrnp.getOutStationList$();
- if(outStationList.isEmpty()){
+ if (outStationList.isEmpty()) {
News.info("鍫嗗灈鏈�:{} 鍑哄簱绔欑偣鏈缃�", basCrnp.getCrnNo());
continue;
}
@@ -142,7 +145,7 @@
BasDualCrnp basDualCrnp = basDualCrnpService.selectOne(new EntityWrapper<BasDualCrnp>().eq("crn_no", wrkMast.getDualCrnNo()));
if (basDualCrnp != null) {
outStationList = basDualCrnp.getOutStationList$();
- if(outStationList.isEmpty()){
+ if (outStationList.isEmpty()) {
News.info("鍙屽伐浣嶅爢鍨涙満:{} 鍑哄簱绔欑偣鏈缃�", basDualCrnp.getCrnNo());
continue;
}
@@ -150,7 +153,7 @@
for (StationObjModel stationObjModel : outStationList) {
StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, stationObjModel.getDeviceNo());
- if(stationThread == null){
+ if (stationThread == null) {
continue;
}
@@ -171,7 +174,7 @@
&& stationProtocol.getTaskNo() == 0
) {
StationCommand command = stationThread.getCommand(StationCommandType.MOVE, wrkMast.getWrkNo(), stationProtocol.getStationId(), wrkMast.getStaNo(), 0);
- if(command == null){
+ if (command == null) {
News.taskInfo(wrkMast.getWrkNo(), "鑾峰彇杈撻�佺嚎鍛戒护澶辫触");
continue;
}
@@ -184,15 +187,96 @@
News.info("杈撻�佺珯鐐瑰嚭搴撳懡浠や笅鍙戞垚鍔燂紝绔欑偣鍙�={}锛屽伐浣滃彿={}锛屽懡浠ゆ暟鎹�={}", stationProtocol.getStationId(), wrkMast.getWrkNo(), JSON.toJSONString(command));
redisUtil.set(RedisKeyType.STATION_OUT_EXECUTE_LIMIT.key + stationProtocol.getStationId(), "lock", 5);
redisUtil.set(RedisKeyType.STATION_OUT_EXECUTE_COMPLETE_LIMIT.key + wrkMast.getWrkNo(), "lock", 60 * 5);
+ redisUtil.set(RedisKeyType.STATION_OUT_EXECUTE_DESTINATION_LIMIT.key + wrkMast.getWrkNo(), "lock", 60 * 5);
}
}
}
}
}
+ //妫�娴嬪嚭搴撲换鍔″埌杈剧洰鐨勫湴
+ public synchronized void arriveAtTheDestination() {
+ List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts", WrkStsType.STATION_RUN.sts));
+ for (WrkMast wrkMast : wrkMasts) {
+ Integer wrkNo = wrkMast.getWrkNo();
+
+// Object lock = redisUtil.get(RedisKeyType.STATION_OUT_EXECUTE_DESTINATION_LIMIT.key + wrkNo);
+// if (lock != null) {
+// continue;
+// }
+
+ boolean complete = false;
+
+ StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, 1);
+ if (stationThread == null) {
+ continue;
+ }
+ List<StationProtocol> list = stationThread.getStatus();
+ for (StationProtocol stationProtocol : list) {
+ if (stationProtocol.getTaskNo().equals(wrkNo)&&stationProtocol.getStationId().equals(wrkMast.getStaNo())) {
+ complete = true;
+ }
+ }
+ if (complete) {
+ //涓婃姤--鍒拌揪鐩殑鍦颁笂鎶ms
+ notifyUtils.notify("task", 1, String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.ARRIVE_AT_THE_DESTINATION, JSON.toJSONString(wrkMast));
+ wrkMast.setWrkSts(WrkStsType.ARRIVE_AT_THE_DESTINATION.sts);
+ wrkMast.setIoTime(new Date());
+ wrkMastService.updateById(wrkMast);
+ }
+ }
+ }
+
+ //妫�娴嬪簱浣嶆鑹叉寜閽俊鍙� 1锛氬憳宸ョ‘璁わ紙甯镐寒锛� 2 锛氫笂浣嶆満纭锛堥棯鐑侊級0 锛氱唲鐏�
+ public synchronized void locNo() {
+ List<BasCrnp> basCrnps = basCrnpService.selectList(null);
+ for (BasCrnp basCrnp : basCrnps) {
+ CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, basCrnp.getCrnNo());
+ if(crnThread == null){
+ continue;
+ }
+
+ CrnProtocol crnProtocol = crnThread.getStatus();
+ if(crnProtocol == null){
+ continue;
+ }
+
+
+ }
+// List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts", WrkStsType.ARRIVE_AT_THE_DESTINATION.sts));
+// for (WrkMast wrkMast : wrkMasts) {
+// Integer wrkNo = wrkMast.getWrkNo();
+//
+// Object lock = redisUtil.get(RedisKeyType.STATION_OUT_EXECUTE_COMPLETE_LIMIT.key + wrkNo);
+// if (lock != null) {
+// continue;
+// }
+//
+// boolean complete = false;
+//
+// StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, wrkMast.getStaNo());
+// if (stationThread == null) {
+// continue;
+// }
+// List<StationProtocol> list = stationThread.getStatus();
+// for (StationProtocol stationProtocol : list) {
+// if (stationProtocol.getTaskNo().equals(wrkNo)) {
+// complete = true;
+// }
+// }
+// if (complete) {
+// //涓婃姤--鍒拌揪鐩殑鍦颁笂鎶ms
+// notifyUtils.notify("task", 1, String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.ARRIVE_AT_THE_DESTINATION, JSON.toJSONString(wrkMast));
+// wrkMast.setWrkSts(WrkStsType.ARRIVE_AT_THE_DESTINATION.sts);
+// wrkMast.setIoTime(new Date());
+// wrkMastService.updateById(wrkMast);
+// }
+// }
+ }
+
//妫�娴嬭緭閫佺珯鐐瑰嚭搴撲换鍔℃墽琛屽畬鎴�
public synchronized void stationOutExecuteFinish() {
- List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts", WrkStsType.STATION_RUN.sts));
+ List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts", WrkStsType.ARRIVE_AT_THE_DESTINATION.sts));
for (WrkMast wrkMast : wrkMasts) {
Integer wrkNo = wrkMast.getWrkNo();
@@ -230,7 +314,7 @@
List<BasDevp> basDevps = basDevpService.selectList(new EntityWrapper<>());
for (BasDevp basDevp : basDevps) {
StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, basDevp.getDevpNo());
- if(stationThread == null){
+ if (stationThread == null) {
continue;
}
@@ -241,10 +325,10 @@
List<StationProtocol> list = stationThread.getStatus();
for (StationProtocol stationProtocol : list) {
- if(stationProtocol.isAutoing()
- && stationProtocol.isLoading()
- && stationProtocol.getTaskNo() > 0
- && stationProtocol.isRunBlock()
+ if (stationProtocol.isAutoing()
+ && stationProtocol.isLoading()
+ && stationProtocol.getTaskNo() > 0
+ && stationProtocol.isRunBlock()
) {
WrkMast wrkMast = wrkMastService.selectByWorkNo(stationProtocol.getTaskNo());
if (wrkMast == null) {
@@ -258,7 +342,7 @@
}
redisUtil.set(RedisKeyType.CHECK_STATION_RUN_BLOCK_LIMIT_.key + stationProtocol.getTaskNo(), "lock", 15);
- if (runBlockReassignLocStationList.contains(stationProtocol.getStationId())) {
+ if (wrkMast.getIoType() == WrkIoType.IN.id && runBlockReassignLocStationList.contains(stationProtocol.getStationId())) {
//绔欑偣澶勪簬閲嶆柊鍒嗛厤搴撲綅鍖哄煙
//杩愯鍫靛锛岄噸鏂扮敵璇蜂换鍔�
String response = wmsOperateUtils.applyReassignTaskLocNo(wrkMast.getWrkNo(), stationProtocol.getStationId());
@@ -309,7 +393,7 @@
}
StationCommand command = stationThread.getCommand(StationCommandType.MOVE, wrkMast.getWrkNo(), stationProtocol.getStationId(), targetStationId, 0);
- if(command == null){
+ if (command == null) {
News.taskInfo(wrkMast.getWrkNo(), "{}宸ヤ綔,鑾峰彇杈撻�佺嚎鍛戒护澶辫触", wrkMast.getWrkNo());
continue;
}
@@ -332,7 +416,7 @@
wrkMast.setCrnNo(crnNo);
} else if (findCrnNoResult.getCrnType().equals(SlaveType.DualCrn)) {
wrkMast.setDualCrnNo(crnNo);
- }else {
+ } else {
throw new CoolException("鏈煡璁惧绫诲瀷");
}
@@ -342,10 +426,10 @@
} else {
News.error("璇锋眰WMS鎺ュ彛澶辫触锛侊紒锛乺esponse锛歿}", response);
}
- }else {
+ } else {
//杩愯鍫靛锛岄噸鏂拌绠楄矾绾�
StationCommand command = stationThread.getCommand(StationCommandType.MOVE, wrkMast.getWrkNo(), stationProtocol.getStationId(), wrkMast.getStaNo(), 0);
- if(command == null){
+ if (command == null) {
News.taskInfo(wrkMast.getWrkNo(), "鑾峰彇杈撻�佺嚎鍛戒护澶辫触");
continue;
}
@@ -358,5 +442,25 @@
}
}
+ //鑾峰彇杈撻�佺嚎浠诲姟鏁伴噺
+ public synchronized int getCurrentStationTaskCount() {
+ int currentStationTaskCount = 0;
+ List<BasDevp> basDevps = basDevpService.selectList(new EntityWrapper<BasDevp>());
+ for (BasDevp basDevp : basDevps) {
+ StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, basDevp.getId());
+ if (stationThread == null) {
+ continue;
+ }
+
+ for (StationProtocol stationProtocol : stationThread.getStatus()) {
+ if (stationProtocol.getTaskNo() > 0) {
+ currentStationTaskCount++;
+ }
+ }
+ }
+
+ return currentStationTaskCount;
+ }
+
}
--
Gitblit v1.9.1