From a55f2835748bd494ff46ca3e1a2d7d672153cb2f Mon Sep 17 00:00:00 2001
From: Administrator <XS@163.COM>
Date: 星期六, 25 四月 2026 13:50:38 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/core/utils/CrnOperateProcessUtils.java | 516 ++++++++++++++++++++++++++++++++++++--------------------
1 files changed, 329 insertions(+), 187 deletions(-)
diff --git a/src/main/java/com/zy/core/utils/CrnOperateProcessUtils.java b/src/main/java/com/zy/core/utils/CrnOperateProcessUtils.java
index 52ff58a..729790b 100644
--- a/src/main/java/com/zy/core/utils/CrnOperateProcessUtils.java
+++ b/src/main/java/com/zy/core/utils/CrnOperateProcessUtils.java
@@ -2,6 +2,7 @@
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson.serializer.SerializerFeature;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.core.exception.CoolException;
import com.zy.asrs.domain.enums.NotifyMsgType;
@@ -26,6 +27,8 @@
import com.zy.core.model.command.CrnCommand;
import com.zy.core.model.protocol.CrnProtocol;
import com.zy.core.model.protocol.StationProtocol;
+import com.zy.core.task.MainProcessLane;
+import com.zy.core.task.MainProcessTaskSubmitter;
import com.zy.core.thread.CrnThread;
import com.zy.core.thread.StationThread;
import org.springframework.beans.factory.annotation.Autowired;
@@ -53,6 +56,10 @@
private CommonService commonService;
@Autowired
private NotifyUtils notifyUtils;
+ @Autowired
+ private StationOperateProcessUtils stationOperateProcessUtils;
+ @Autowired
+ private MainProcessTaskSubmitter mainProcessTaskSubmitter;
public synchronized void crnIoExecute() {
Object systemConfigMapObj = redisUtil.get(RedisKeyType.SYSTEM_CONFIG_MAP.key);
@@ -66,78 +73,121 @@
}
}
+ public void crnIoExecute(BasCrnp basCrnp) {
+ if (basCrnp == null || basCrnp.getCrnNo() == null) {
+ return;
+ }
+ Object systemConfigMapObj = redisUtil.get(RedisKeyType.SYSTEM_CONFIG_MAP.key);
+ if (systemConfigMapObj != null) {
+ HashMap<String, String> systemConfigMap = (HashMap<String, String>) systemConfigMapObj;
+ if ("solver".equals(systemConfigMap.get("crnRunMethod"))) {
+ plannerExecute(basCrnp);
+ } else {
+ crnIoExecuteNormal(basCrnp);
+ }
+ } else {
+ crnIoExecuteNormal(basCrnp);
+ }
+ }
+
//鍏ュ嚭搴� ===>> 鍫嗗灈鏈哄叆鍑哄簱浣滀笟涓嬪彂
public synchronized void crnIoExecuteNormal() {
List<BasCrnp> basCrnps = basCrnpService.selectList(new EntityWrapper<>());
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("crn_no", basCrnp.getCrnNo())
- .in("wrk_sts", WrkStsType.INBOUND_RUN.sts, WrkStsType.OUTBOUND_RUN.sts)
- );
- if(!wrkMasts.isEmpty()){
- continue;
- }
-
- // 鍙湁褰撳爢鍨涙満绌洪棽 骞朵笖 鏃犱换鍔℃椂鎵嶇户缁墽琛�
- if (crnProtocol.getMode() == CrnModeType.AUTO.id
- && crnProtocol.getTaskNo() == 0
- && crnProtocol.getStatus() == CrnStatusType.IDLE.id
- && crnProtocol.getLoaded() == 0
- && crnProtocol.getForkPos() == 0
- && crnProtocol.getAlarm() == 0
- ) {
- // 濡傛灉鏈�杩戜竴娆℃槸鍏ュ簱妯″紡
- if (crnProtocol.getLastIo().equals("I")) {
- if (basCrnp.getInEnable().equals("Y")) {
- this.crnExecuteIn(basCrnp, crnThread); // 鍏ュ簱
- crnProtocol.setLastIo("O");
- } else if (basCrnp.getOutEnable().equals("Y")) {
- this.crnExecuteOut(basCrnp, crnThread); // 鍑哄簱
- crnProtocol.setLastIo("I");
- }
- }
- // 濡傛灉鏈�杩戜竴娆℃槸鍑哄簱妯″紡
- else if (crnProtocol.getLastIo().equals("O")) {
- if (basCrnp.getOutEnable().equals("Y")) {
- this.crnExecuteOut(basCrnp, crnThread); // 鍑哄簱
- crnProtocol.setLastIo("I");
- } else if (basCrnp.getInEnable().equals("Y")) {
- this.crnExecuteIn(basCrnp, crnThread); // 鍏ュ簱
- crnProtocol.setLastIo("O");
- }
- }
-
- //搴撲綅绉昏浆
- this.crnExecuteLocTransfer(basCrnp, crnThread);
- }
+ crnIoExecuteNormal(basCrnp);
}
}
- private synchronized void crnExecuteIn(BasCrnp basCrnp, CrnThread crnThread) {
+ public void crnIoExecuteNormal(BasCrnp basCrnp) {
+ if (basCrnp == null || basCrnp.getCrnNo() == null) {
+ return;
+ }
+
+ CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, basCrnp.getCrnNo());
+ if(crnThread == null){
+ return;
+ }
+
CrnProtocol crnProtocol = crnThread.getStatus();
if(crnProtocol == null){
return;
}
+ 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()){
+ return;
+ }
+
+ // 鍙湁褰撳爢鍨涙満绌洪棽 骞朵笖 鏃犱换鍔℃椂鎵嶇户缁墽琛�
+ if (crnProtocol.getMode() == CrnModeType.AUTO.id
+ && crnProtocol.getTaskNo() == 0
+ && crnProtocol.getStatus() == CrnStatusType.IDLE.id
+ && crnProtocol.getLoaded() == 0
+ && crnProtocol.getForkPos() == 0
+ && crnProtocol.getAlarm() == 0
+ ) {
+ Object clearLock = redisUtil.get(RedisKeyType.CLEAR_CRN_TASK_LIMIT.key + basCrnp.getCrnNo());
+ if (clearLock != null) {
+ return;
+ }
+
+ // 濡傛灉鏈�杩戜竴娆℃槸鍏ュ簱妯″紡
+ if (crnProtocol.getLastIo().equals("I")) {
+ if (basCrnp.getInEnable().equals("Y")) {
+ boolean result = this.crnExecuteIn(basCrnp, crnThread);// 鍏ュ簱
+ crnProtocol.setLastIo("O");
+ if (result) {
+ return;
+ }
+ } else if (basCrnp.getOutEnable().equals("Y")) {
+ boolean result = this.crnExecuteOut(basCrnp, crnThread);// 鍑哄簱
+ crnProtocol.setLastIo("I");
+ if (result) {
+ return;
+ }
+ }
+ }
+ // 濡傛灉鏈�杩戜竴娆℃槸鍑哄簱妯″紡
+ else if (crnProtocol.getLastIo().equals("O")) {
+ if (basCrnp.getOutEnable().equals("Y")) {
+ boolean result = this.crnExecuteOut(basCrnp, crnThread);// 鍑哄簱
+ crnProtocol.setLastIo("I");
+ if (result) {
+ return;
+ }
+ } else if (basCrnp.getInEnable().equals("Y")) {
+ boolean result = this.crnExecuteIn(basCrnp, crnThread);// 鍏ュ簱
+ crnProtocol.setLastIo("O");
+ if (result) {
+ return;
+ }
+ }
+ }
+
+ //搴撲綅绉昏浆
+ this.crnExecuteLocTransfer(basCrnp, crnThread);
+ }
+ }
+
+ private synchronized boolean crnExecuteIn(BasCrnp basCrnp, CrnThread crnThread) {
+ CrnProtocol crnProtocol = crnThread.getStatus();
+ if(crnProtocol == null){
+ 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();
@@ -213,25 +263,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();
@@ -239,6 +306,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) {
@@ -302,10 +370,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) {
@@ -486,10 +555,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();
@@ -534,162 +603,194 @@
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;
}
//鍫嗗灈鏈轰换鍔℃墽琛屽畬鎴�
public synchronized void crnIoExecuteFinish() {
List<BasCrnp> basCrnps = basCrnpService.selectList(new EntityWrapper<>());
for (BasCrnp basCrnp : basCrnps) {
- CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, basCrnp.getCrnNo());
- if(crnThread == null){
- continue;
+ crnIoExecuteFinish(basCrnp);
+ }
+ }
+
+ public void crnIoExecuteFinish(BasCrnp basCrnp) {
+ if (basCrnp == null || basCrnp.getCrnNo() == null) {
+ return;
+ }
+
+ CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, basCrnp.getCrnNo());
+ if(crnThread == null){
+ return;
+ }
+
+ CrnProtocol crnProtocol = crnThread.getStatus();
+ if(crnProtocol == null){
+ return;
+ }
+
+ if (crnProtocol.getMode() == CrnModeType.AUTO.id
+ && crnProtocol.getTaskNo() > 0
+ && crnProtocol.getStatus() == CrnStatusType.WAITING.id
+ ) {
+ Object lock = redisUtil.get(RedisKeyType.CRN_IO_EXECUTE_FINISH_LIMIT.key + basCrnp.getCrnNo());
+ if(lock != null){
+ return;
}
- CrnProtocol crnProtocol = crnThread.getStatus();
- if(crnProtocol == null){
- continue;
+ // 鑾峰彇寰呯‘璁ゅ伐浣滄。
+ WrkMast wrkMast = wrkMastService.selectByWorkNo(crnProtocol.getTaskNo());
+ if (wrkMast == null) {
+ News.error("鍫嗗灈鏈哄浜庣瓑寰呯‘璁や笖浠诲姟瀹屾垚鐘舵�侊紝浣嗘湭鎵惧埌宸ヤ綔妗c�傚爢鍨涙満鍙�={}锛屽伐浣滃彿={}", basCrnp.getCrnNo(), crnProtocol.getTaskNo());
+ return;
}
- if (crnProtocol.getMode() == CrnModeType.AUTO.id
- && crnProtocol.getTaskNo() > 0
- && crnProtocol.getStatus() == CrnStatusType.WAITING.id
- ) {
- Object lock = redisUtil.get(RedisKeyType.CRN_IO_EXECUTE_FINISH_LIMIT.key + basCrnp.getCrnNo());
- if(lock != null){
- continue;
+ Long updateWrkSts = null;
+ if(wrkMast.getWrkSts() == WrkStsType.INBOUND_RUN.sts){
+ updateWrkSts = WrkStsType.COMPLETE_INBOUND.sts;
+ notifyUtils.notify(String.valueOf(SlaveType.Crn), crnProtocol.getCrnNo(), String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.CRN_IN_TASK_COMPLETE, null);
+ }else if(wrkMast.getWrkSts() == WrkStsType.OUTBOUND_RUN.sts){
+ updateWrkSts = WrkStsType.OUTBOUND_RUN_COMPLETE.sts;
+ notifyUtils.notify(String.valueOf(SlaveType.Crn), crnProtocol.getCrnNo(), String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.CRN_OUT_TASK_COMPLETE, null);
+
+ List<StationObjModel> outStationList = basCrnp.getOutStationList$();
+ if(outStationList.isEmpty()){
+ News.info("鍫嗗灈鏈�:{} 鍑哄簱绔欑偣鏈缃�", basCrnp.getCrnNo());
+ return;
}
- // 鑾峰彇寰呯‘璁ゅ伐浣滄。
- WrkMast wrkMast = wrkMastService.selectByWorkNo(crnProtocol.getTaskNo());
- if (wrkMast == null) {
- News.error("鍫嗗灈鏈哄浜庣瓑寰呯‘璁や笖浠诲姟瀹屾垚鐘舵�侊紝浣嗘湭鎵惧埌宸ヤ綔妗c�傚爢鍨涙満鍙�={}锛屽伐浣滃彿={}", basCrnp.getCrnNo(), crnProtocol.getTaskNo());
- continue;
+ StationObjModel outStationObjModel = null;
+ for (StationObjModel stationObjModel : outStationList) {
+ if (stationObjModel.getStationId().equals(wrkMast.getSourceStaNo())) {
+ outStationObjModel = stationObjModel;
+ break;
+ }
}
-
- Long updateWrkSts = null;
- if(wrkMast.getWrkSts() == WrkStsType.INBOUND_RUN.sts){
- updateWrkSts = WrkStsType.COMPLETE_INBOUND.sts;
- notifyUtils.notify(String.valueOf(SlaveType.Crn), crnProtocol.getCrnNo(), String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.CRN_IN_TASK_COMPLETE, null);
- }else if(wrkMast.getWrkSts() == WrkStsType.OUTBOUND_RUN.sts){
- updateWrkSts = WrkStsType.OUTBOUND_RUN_COMPLETE.sts;
- notifyUtils.notify(String.valueOf(SlaveType.Crn), crnProtocol.getCrnNo(), String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.CRN_OUT_TASK_COMPLETE, null);
- }else if(wrkMast.getWrkSts() == WrkStsType.LOC_MOVE_RUN.sts){
- updateWrkSts = WrkStsType.COMPLETE_LOC_MOVE.sts;
- notifyUtils.notify(String.valueOf(SlaveType.Crn), crnProtocol.getCrnNo(), String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.CRN_TRANSFER_TASK_COMPLETE, null);
- }else{
- News.error("鍫嗗灈鏈哄浜庣瓑寰呯‘璁や笖浠诲姟瀹屾垚鐘舵�侊紝浣嗗伐浣滅姸鎬佸紓甯搞�傚爢鍨涙満鍙�={}锛屽伐浣滃彿={}", basCrnp.getCrnNo(), crnProtocol.getTaskNo());
- continue;
- }
-
- wrkMast.setWrkSts(updateWrkSts);
- wrkMast.setSystemMsg("");
- wrkMast.setIoTime(new Date());
- if (wrkMastService.updateById(wrkMast)) {
- CrnCommand resetCommand = crnThread.getResetCommand(crnProtocol.getCrnNo());
- MessageQueue.offer(SlaveType.Crn, crnProtocol.getCrnNo(), new Task(2, resetCommand));
- News.info("鍫嗗灈鏈轰换鍔$姸鎬佹洿鏂版垚鍔燂紝鍫嗗灈鏈哄彿={}锛屽伐浣滃彿={}", basCrnp.getCrnNo(), crnProtocol.getTaskNo());
- }
-
- redisUtil.set(RedisKeyType.CRN_IO_EXECUTE_FINISH_LIMIT.key + basCrnp.getCrnNo(), "lock",10);
+ redisUtil.set(RedisKeyType.CRN_OUT_TASK_COMPLETE_STATION_INFO.key + wrkMast.getWrkNo(), JSON.toJSONString(outStationObjModel, SerializerFeature.DisableCircularReferenceDetect), 60 * 60 * 24);
+ }else if(wrkMast.getWrkSts() == WrkStsType.LOC_MOVE_RUN.sts){
+ updateWrkSts = WrkStsType.COMPLETE_LOC_MOVE.sts;
+ notifyUtils.notify(String.valueOf(SlaveType.Crn), crnProtocol.getCrnNo(), String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.CRN_TRANSFER_TASK_COMPLETE, null);
+ }else{
+ News.error("鍫嗗灈鏈哄浜庣瓑寰呯‘璁や笖浠诲姟瀹屾垚鐘舵�侊紝浣嗗伐浣滅姸鎬佸紓甯搞�傚爢鍨涙満鍙�={}锛屽伐浣滃彿={}", basCrnp.getCrnNo(), crnProtocol.getTaskNo());
+ return;
}
+
+ wrkMast.setWrkSts(updateWrkSts);
+ wrkMast.setSystemMsg("");
+ wrkMast.setIoTime(new Date());
+ if (wrkMastService.updateById(wrkMast)) {
+ CrnCommand resetCommand = crnThread.getResetCommand(crnProtocol.getTaskNo(), crnProtocol.getCrnNo());
+ MessageQueue.offer(SlaveType.Crn, crnProtocol.getCrnNo(), new Task(2, resetCommand));
+ News.info("鍫嗗灈鏈轰换鍔$姸鎬佹洿鏂版垚鍔燂紝鍫嗗灈鏈哄彿={}锛屽伐浣滃彿={}", basCrnp.getCrnNo(), crnProtocol.getTaskNo());
+ }
+
+ redisUtil.set(RedisKeyType.CRN_IO_EXECUTE_FINISH_LIMIT.key + basCrnp.getCrnNo(), "lock",10);
}
}
public synchronized void plannerExecute() {
- int nowSec = (int) (System.currentTimeMillis() / 1000);
List<BasCrnp> basCrnps = basCrnpService.selectList(new EntityWrapper<>());
for (BasCrnp basCrnp : basCrnps) {
- String key = RedisKeyType.PLANNER_SCHEDULE.key + "CRN-" + basCrnp.getCrnNo();
- List<Object> items = redisUtil.lGet(key, 0, -1);
- if (items == null || items.isEmpty()) {
+ plannerExecute(basCrnp);
+ }
+ }
+
+ public void plannerExecute(BasCrnp basCrnp) {
+ if (basCrnp == null || basCrnp.getCrnNo() == null) {
+ return;
+ }
+
+ int nowSec = (int) (System.currentTimeMillis() / 1000);
+ String key = RedisKeyType.PLANNER_SCHEDULE.key + "CRN-" + basCrnp.getCrnNo();
+ List<Object> items = redisUtil.lGet(key, 0, -1);
+ if (items == null || items.isEmpty()) {
+ return;
+ }
+
+ CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, basCrnp.getCrnNo());
+ if (crnThread == null) {
+ return;
+ }
+ CrnProtocol crnProtocol = crnThread.getStatus();
+ if (crnProtocol == null) {
+ return;
+ }
+ List<WrkMast> running = wrkMastService.selectList(new EntityWrapper<WrkMast>()
+ .eq("crn_no", basCrnp.getCrnNo())
+ .in("wrk_sts", WrkStsType.INBOUND_RUN.sts, WrkStsType.OUTBOUND_RUN.sts, WrkStsType.LOC_MOVE_RUN.sts)
+ );
+ if (!running.isEmpty()) {
+ return;
+ }
+ if (!(crnProtocol.getMode() == CrnModeType.AUTO.id
+ && crnProtocol.getTaskNo() == 0
+ && crnProtocol.getStatus() == CrnStatusType.IDLE.id
+ && crnProtocol.getLoaded() == 0
+ && crnProtocol.getForkPos() == 0
+ && crnProtocol.getAlarm() == 0)) {
+ return;
+ }
+
+ for (Object v : items) {
+ String s = String.valueOf(v);
+ JSONObject obj = null;
+ try { obj = JSON.parseObject(s); } catch (Exception ignore) {}
+ if (obj == null) {
+ continue;
+ }
+ Integer startEpochSec = obj.getInteger("startEpochSec");
+ Integer endEpochSec = obj.getInteger("endEpochSec");
+ Integer taskId = obj.getInteger("taskId");
+ String taskType = obj.getString("taskType");
+ if (startEpochSec == null || taskId == null || taskType == null) {
+ continue;
+ }
+ int earlySlackSec = 5;
+ int lateSlackSec = 10;
+ Object systemConfigMapObj = redisUtil.get(RedisKeyType.SYSTEM_CONFIG_MAP.key);
+ if (systemConfigMapObj != null) {
+ try {
+ HashMap<String, String> systemConfigMap = (HashMap<String, String>) systemConfigMapObj;
+ String es = systemConfigMap.getOrDefault("plannerEarlySlackSec", "60");
+ String ls = systemConfigMap.getOrDefault("plannerLateSlackSec", "10");
+ earlySlackSec = Integer.parseInt(es);
+ lateSlackSec = Integer.parseInt(ls);
+ } catch (Exception ignore) {}
+ }
+ if (nowSec < startEpochSec - earlySlackSec) {
+ continue;
+ }
+ if (endEpochSec != null && nowSec > endEpochSec + lateSlackSec) {
+ redisUtil.lRemove(key, 1, s);
continue;
}
- CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, basCrnp.getCrnNo());
- if (crnThread == null) {
- continue;
- }
- CrnProtocol crnProtocol = crnThread.getStatus();
- if (crnProtocol == null) {
- continue;
- }
- List<WrkMast> running = wrkMastService.selectList(new EntityWrapper<WrkMast>()
- .eq("crn_no", basCrnp.getCrnNo())
- .in("wrk_sts", WrkStsType.INBOUND_RUN.sts, WrkStsType.OUTBOUND_RUN.sts, WrkStsType.LOC_MOVE_RUN.sts)
- );
- if (!running.isEmpty()) {
- continue;
- }
- if (!(crnProtocol.getMode() == CrnModeType.AUTO.id
- && crnProtocol.getTaskNo() == 0
- && crnProtocol.getStatus() == CrnStatusType.IDLE.id
- && crnProtocol.getLoaded() == 0
- && crnProtocol.getForkPos() == 0
- && crnProtocol.getAlarm() == 0)) {
+ WrkMast wrkMast = wrkMastService.selectByWorkNo(taskId);
+ if (wrkMast == null) {
+ redisUtil.lRemove(key, 1, s);
continue;
}
- for (Object v : items) {
- String s = String.valueOf(v);
- JSONObject obj = null;
- try { obj = JSON.parseObject(s); } catch (Exception ignore) {}
- if (obj == null) {
- continue;
- }
- Integer startEpochSec = obj.getInteger("startEpochSec");
- Integer endEpochSec = obj.getInteger("endEpochSec");
- Integer taskId = obj.getInteger("taskId");
- String taskType = obj.getString("taskType");
- if (startEpochSec == null || taskId == null || taskType == null) {
- continue;
- }
- int earlySlackSec = 5;
- int lateSlackSec = 10;
- Object systemConfigMapObj = redisUtil.get(RedisKeyType.SYSTEM_CONFIG_MAP.key);
- if (systemConfigMapObj != null) {
- try {
- HashMap<String, String> systemConfigMap = (HashMap<String, String>) systemConfigMapObj;
- String es = systemConfigMap.getOrDefault("plannerEarlySlackSec", "60");
- String ls = systemConfigMap.getOrDefault("plannerLateSlackSec", "10");
- earlySlackSec = Integer.parseInt(es);
- lateSlackSec = Integer.parseInt(ls);
- } catch (Exception ignore) {}
- }
- if (nowSec < startEpochSec - earlySlackSec) {
- continue;
- }
- if (endEpochSec != null && nowSec > endEpochSec + lateSlackSec) {
+ if ("IN".equalsIgnoreCase(taskType)) {
+ boolean result = this.crnExecuteInPlanner(basCrnp, crnThread, wrkMast);//鍏ュ簱
+ if (result) {
redisUtil.lRemove(key, 1, s);
- continue;
+ return;
}
-
- WrkMast wrkMast = wrkMastService.selectByWorkNo(taskId);
- if (wrkMast == null) {
+ } else if ("OUT".equalsIgnoreCase(taskType)) {
+ boolean result = this.crnExecuteOutPlanner(basCrnp, crnThread, wrkMast);//鍑哄簱
+ if (result) {
redisUtil.lRemove(key, 1, s);
- continue;
+ return;
}
-
- if ("IN".equalsIgnoreCase(taskType)) {
- boolean result = this.crnExecuteInPlanner(basCrnp, crnThread, wrkMast);//鍏ュ簱
- if (result) {
- redisUtil.lRemove(key, 1, s);
- break;
- }
- } else if ("OUT".equalsIgnoreCase(taskType)) {
- boolean result = this.crnExecuteOutPlanner(basCrnp, crnThread, wrkMast);//鍑哄簱
- if (result) {
- redisUtil.lRemove(key, 1, s);
- break;
- }
- } else if ("MOVE".equalsIgnoreCase(taskType)) {
- boolean result = this.crnExecuteMovePlanner(basCrnp, crnThread, wrkMast);//绉诲簱
- if (result) {
- redisUtil.lRemove(key, 1, s);
- break;
- }
+ } else if ("MOVE".equalsIgnoreCase(taskType)) {
+ boolean result = this.crnExecuteMovePlanner(basCrnp, crnThread, wrkMast);//绉诲簱
+ if (result) {
+ redisUtil.lRemove(key, 1, s);
+ return;
}
}
}
@@ -746,6 +847,48 @@
return false;
}
+ public void submitCrnIoTasks(long minIntervalMs) {
+ submitCrnIoTasks(MainProcessLane.CRN_IO, minIntervalMs);
+ }
+
+ public void submitCrnIoTasks(MainProcessLane lane, long minIntervalMs) {
+ List<BasCrnp> basCrnps = basCrnpService.selectList(new EntityWrapper<>());
+ for (BasCrnp basCrnp : basCrnps) {
+ if (basCrnp == null || basCrnp.getCrnNo() == null) {
+ continue;
+ }
+ final BasCrnp currentCrn = basCrnp;
+ mainProcessTaskSubmitter.submitKeyedSerialTask(
+ lane,
+ currentCrn.getCrnNo(),
+ "crnIoExecute",
+ minIntervalMs,
+ () -> crnIoExecute(currentCrn)
+ );
+ }
+ }
+
+ public void submitCrnIoExecuteFinishTasks(long minIntervalMs) {
+ submitCrnIoExecuteFinishTasks(MainProcessLane.CRN_IO_FINISH, minIntervalMs);
+ }
+
+ public void submitCrnIoExecuteFinishTasks(MainProcessLane lane, long minIntervalMs) {
+ List<BasCrnp> basCrnps = basCrnpService.selectList(new EntityWrapper<>());
+ for (BasCrnp basCrnp : basCrnps) {
+ if (basCrnp == null || basCrnp.getCrnNo() == null) {
+ continue;
+ }
+ final BasCrnp currentCrn = basCrnp;
+ mainProcessTaskSubmitter.submitKeyedSerialTask(
+ lane,
+ currentCrn.getCrnNo(),
+ "crnIoExecuteFinish",
+ minIntervalMs,
+ () -> crnIoExecuteFinish(currentCrn)
+ );
+ }
+ }
+
//妫�娴嬫祬搴撲綅鐘舵��
public synchronized boolean checkShallowLocStatus(String locNo, Integer taskNo) {
String checkDeepLocOutTaskBlockReport = "Y";
@@ -763,18 +906,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