From 53332ecb0edc651bae91f1e7a74a795d76d87cb2 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期三, 04 三月 2026 17:18:07 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/core/utils/CrnOperateProcessUtils.java | 84 +++++++++++++++++++++++++++++++----------
1 files changed, 63 insertions(+), 21 deletions(-)
diff --git a/src/main/java/com/zy/core/utils/CrnOperateProcessUtils.java b/src/main/java/com/zy/core/utils/CrnOperateProcessUtils.java
index 5bcb5f5..85dd39c 100644
--- a/src/main/java/com/zy/core/utils/CrnOperateProcessUtils.java
+++ b/src/main/java/com/zy/core/utils/CrnOperateProcessUtils.java
@@ -54,6 +54,8 @@
private CommonService commonService;
@Autowired
private NotifyUtils notifyUtils;
+ @Autowired
+ private StationOperateProcessUtils stationOperateProcessUtils;
public synchronized void crnIoExecute() {
Object systemConfigMapObj = redisUtil.get(RedisKeyType.SYSTEM_CONFIG_MAP.key);
@@ -84,6 +86,7 @@
List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>()
.eq("crn_no", basCrnp.getCrnNo())
.in("wrk_sts", WrkStsType.INBOUND_RUN.sts, WrkStsType.OUTBOUND_RUN.sts)
+ .orderBy("batch_seq", false)
);
if(!wrkMasts.isEmpty()){
continue;
@@ -97,48 +100,68 @@
&& crnProtocol.getForkPos() == 0
&& crnProtocol.getAlarm() == 0
) {
+ Object clearLock = redisUtil.get(RedisKeyType.CLEAR_CRN_TASK_LIMIT.key + basCrnp.getCrnNo());
+ if (clearLock != null) {
+ continue;
+ }
+
// 濡傛灉鏈�杩戜竴娆℃槸鍏ュ簱妯″紡
if (crnProtocol.getLastIo().equals("I")) {
if (basCrnp.getInEnable().equals("Y")) {
- this.crnExecuteIn(basCrnp, crnThread); // 鍏ュ簱
+ boolean result = this.crnExecuteIn(basCrnp, crnThread);// 鍏ュ簱
crnProtocol.setLastIo("O");
+ if (result) {
+ break;
+ }
} else if (basCrnp.getOutEnable().equals("Y")) {
- this.crnExecuteOut(basCrnp, crnThread); // 鍑哄簱
+ boolean result = this.crnExecuteOut(basCrnp, crnThread);// 鍑哄簱
crnProtocol.setLastIo("I");
+ if (result) {
+ break;
+ }
}
}
// 濡傛灉鏈�杩戜竴娆℃槸鍑哄簱妯″紡
else if (crnProtocol.getLastIo().equals("O")) {
if (basCrnp.getOutEnable().equals("Y")) {
- this.crnExecuteOut(basCrnp, crnThread); // 鍑哄簱
+ boolean result = this.crnExecuteOut(basCrnp, crnThread);// 鍑哄簱
crnProtocol.setLastIo("I");
+ if (result) {
+ break;
+ }
} else if (basCrnp.getInEnable().equals("Y")) {
- this.crnExecuteIn(basCrnp, crnThread); // 鍏ュ簱
+ boolean result = this.crnExecuteIn(basCrnp, crnThread);// 鍏ュ簱
crnProtocol.setLastIo("O");
+ if (result) {
+ break;
+ }
}
}
//搴撲綅绉昏浆
- this.crnExecuteLocTransfer(basCrnp, crnThread);
+ boolean transfer = this.crnExecuteLocTransfer(basCrnp, crnThread);
+ if (transfer) {
+ break;
+ }
}
}
}
- private synchronized void crnExecuteIn(BasCrnp basCrnp, CrnThread crnThread) {
+ private synchronized boolean crnExecuteIn(BasCrnp basCrnp, CrnThread crnThread) {
CrnProtocol crnProtocol = crnThread.getStatus();
if(crnProtocol == null){
- return;
+ return false;
}
if(!basCrnp.getInEnable().equals("Y")){
News.info("鍫嗗灈鏈�:{} 鍙叆淇″彿涓嶆弧瓒�", basCrnp.getCrnNo());
- return;
+ return false;
}
List<StationObjModel> inStationList = basCrnp.getInStationList$();
if(inStationList.isEmpty()){
News.info("鍫嗗灈鏈�:{} 鍏ュ簱绔欑偣鏈缃�", basCrnp.getCrnNo());
- return;
+ return false;
}
Integer crnNo = basCrnp.getCrnNo();
@@ -214,25 +237,42 @@
MessageQueue.offer(SlaveType.Crn, crnNo, new Task(2, command));
notifyUtils.notify(String.valueOf(SlaveType.Crn), crnNo, String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.CRN_IN_TASK_RUN, null);
News.info("鍫嗗灈鏈哄懡浠や笅鍙戞垚鍔燂紝鍫嗗灈鏈哄彿={}锛屼换鍔℃暟鎹�={}", crnNo, JSON.toJSON(command));
+ return true;
}
}
+ return false;
}
- private synchronized void crnExecuteOut(BasCrnp basCrnp, CrnThread crnThread) {
+ private synchronized boolean crnExecuteOut(BasCrnp basCrnp, CrnThread crnThread) {
CrnProtocol crnProtocol = crnThread.getStatus();
if(crnProtocol == null){
- return;
+ return false;
}
if(!basCrnp.getOutEnable().equals("Y")){
News.info("鍫嗗灈鏈�:{} 鍙嚭淇″彿涓嶆弧瓒�", basCrnp.getCrnNo());
- return;
+ return false;
}
List<StationObjModel> outStationList = basCrnp.getOutStationList$();
if(outStationList.isEmpty()){
News.info("鍫嗗灈鏈�:{} 鍑哄簱绔欑偣鏈缃�", basCrnp.getCrnNo());
- return;
+ return false;
+ }
+
+ int stationMaxTaskCount = 30;
+ Object systemConfigMapObj = redisUtil.get(RedisKeyType.SYSTEM_CONFIG_MAP.key);
+ if (systemConfigMapObj != null) {
+ try {
+ HashMap<String, String> systemConfigMap = (HashMap<String, String>) systemConfigMapObj;
+ stationMaxTaskCount = Integer.parseInt(systemConfigMap.getOrDefault("stationMaxTaskCountLimit", "30"));
+ } catch (Exception ignore) {}
+ }
+
+ int currentStationTaskCount = stationOperateProcessUtils.getCurrentStationTaskCount();
+ if (stationMaxTaskCount > 0 && currentStationTaskCount >= stationMaxTaskCount) {
+ News.warn("杈撻�佺珯鐐逛换鍔℃暟閲忚揪鍒颁笂闄愶紝宸插仠姝换鍔′笅鍙戙�傚綋鍓嶄换鍔℃暟={}锛屼笂闄�={}", currentStationTaskCount, stationMaxTaskCount);
+ return false;
}
Integer crnNo = basCrnp.getCrnNo();
@@ -240,6 +280,7 @@
List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>()
.eq("crn_no", crnNo)
.eq("wrk_sts", WrkStsType.NEW_OUTBOUND.sts)
+ .orderBy("batch_seq", false)
);
for (WrkMast wrkMast : wrkMasts) {
@@ -303,10 +344,11 @@
MessageQueue.offer(SlaveType.Crn, crnNo, new Task(2, command));
notifyUtils.notify(String.valueOf(SlaveType.Crn), crnNo, String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.CRN_OUT_TASK_RUN, null);
News.info("鍫嗗灈鏈哄懡浠や笅鍙戞垚鍔燂紝鍫嗗灈鏈哄彿={}锛屼换鍔℃暟鎹�={}", crnNo, JSON.toJSON(command));
- return;
+ return true;
}
}
}
+ return false;
}
private synchronized boolean crnExecuteInPlanner(BasCrnp basCrnp, CrnThread crnThread, WrkMast wrkMast) {
@@ -487,10 +529,10 @@
return false;
}
- private synchronized void crnExecuteLocTransfer(BasCrnp basCrnp, CrnThread crnThread) {
+ private synchronized boolean crnExecuteLocTransfer(BasCrnp basCrnp, CrnThread crnThread) {
CrnProtocol crnProtocol = crnThread.getStatus();
if(crnProtocol == null){
- return;
+ return false;
}
Integer crnNo = basCrnp.getCrnNo();
@@ -535,9 +577,10 @@
MessageQueue.offer(SlaveType.Crn, crnNo, new Task(2, command));
notifyUtils.notify(String.valueOf(SlaveType.Crn), crnNo, String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.CRN_TRANSFER_TASK_RUN, null);
News.info("鍫嗗灈鏈哄懡浠や笅鍙戞垚鍔燂紝鍫嗗灈鏈哄彿={}锛屼换鍔℃暟鎹�={}", crnNo, JSON.toJSON(command));
- return;
+ return true;
}
}
+ return false;
}
//鍫嗗灈鏈轰换鍔℃墽琛屽畬鎴�
@@ -604,7 +647,7 @@
wrkMast.setSystemMsg("");
wrkMast.setIoTime(new Date());
if (wrkMastService.updateById(wrkMast)) {
- CrnCommand resetCommand = crnThread.getResetCommand(crnProtocol.getCrnNo());
+ CrnCommand resetCommand = crnThread.getResetCommand(crnProtocol.getTaskNo(), crnProtocol.getCrnNo());
MessageQueue.offer(SlaveType.Crn, crnProtocol.getCrnNo(), new Task(2, resetCommand));
News.info("鍫嗗灈鏈轰换鍔$姸鎬佹洿鏂版垚鍔燂紝鍫嗗灈鏈哄彿={}锛屽伐浣滃彿={}", basCrnp.getCrnNo(), crnProtocol.getTaskNo());
}
@@ -779,18 +822,17 @@
if (lock != null) {
return false;
}
- redisUtil.set(RedisKeyType.CHECK_SHALLOW_LOC_STATUS_LIMIT.key + taskNo, "lock", 5);
Integer shallowRow = Utils.getShallowRowByDeepRow(Utils.getRow(locNo));
if (shallowRow == null) {
return true;
}
+ redisUtil.set(RedisKeyType.CHECK_SHALLOW_LOC_STATUS_LIMIT.key + taskNo, "lock", 5);
String shallowLocNo = Utils.getLocNo(shallowRow, Utils.getBay(locNo), Utils.getLev(locNo));
LocMast shallowLocMast = locMastService.queryByLoc(shallowLocNo);
if (shallowLocMast == null) {
- News.taskInfo(taskNo, "娴呭簱浣�:{} 鏁版嵁涓嶅瓨鍦�", shallowLocNo);
- return false;
+ return true;
}
if (shallowLocMast.getLocSts().equals("O")) {
--
Gitblit v1.9.1